Package: DeviceKeystoreItemDeleteTargetProcessor
DeviceKeystoreItemDeleteTargetProcessor
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DeviceKeystoreItemDeleteTargetProcessor() |
|
|
|
|
|
||||||||||||||||||||
initProcessing(JobTargetWrapper) |
|
|
|
|
|
||||||||||||||||||||
lambda$processTarget$0(JobTarget, String, String, Long) |
|
|
|
|
|
||||||||||||||||||||
processTarget(JobTarget) |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.management.keystore.job;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.commons.security.KapuaSecurityUtils;
17: import org.eclipse.kapua.job.engine.commons.operation.AbstractDeviceTargetProcessor;
18: import org.eclipse.kapua.job.engine.commons.wrappers.JobTargetWrapper;
19: import org.eclipse.kapua.model.id.KapuaId;
20: import org.eclipse.kapua.service.device.management.keystore.DeviceKeystoreManagementService;
21: import org.eclipse.kapua.service.device.management.keystore.job.definition.DeviceKeystoreItemDeletePropertyKeys;
22: import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreCertificate;
23: import org.eclipse.kapua.service.job.operation.TargetProcessor;
24: import org.eclipse.kapua.service.job.targets.JobTarget;
25:
26: import javax.batch.runtime.context.JobContext;
27: import javax.batch.runtime.context.StepContext;
28: import javax.inject.Inject;
29:
30: /**
31: * {@link TargetProcessor} for {@link DeviceKeystoreManagementService#createKeystoreCertificate(KapuaId, KapuaId, DeviceKeystoreCertificate, Long)}.
32: *
33: * @since 1.0.0
34: */
35: public class DeviceKeystoreItemDeleteTargetProcessor extends AbstractDeviceTargetProcessor implements TargetProcessor {
36: private static final DeviceKeystoreManagementService KEYSTORE_MANAGEMENT_SERVICE = LOCATOR.getService(DeviceKeystoreManagementService.class);
37:
38: @Inject
39: JobContext jobContext;
40:
41: @Inject
42: StepContext stepContext;
43:
44: @Override
45: protected void initProcessing(JobTargetWrapper wrappedJobTarget) {
46: setContext(jobContext, stepContext);
47: }
48:
49: @Override
50: public void processTarget(JobTarget jobTarget) throws KapuaException {
51:
52: String keystoreId = stepContextWrapper.getStepProperty(DeviceKeystoreItemDeletePropertyKeys.KEYSTORE_ID, String.class);
53: String alias = stepContextWrapper.getStepProperty(DeviceKeystoreItemDeletePropertyKeys.ALIAS, String.class);
54: Long timeout = stepContextWrapper.getStepProperty(DeviceKeystoreItemDeletePropertyKeys.TIMEOUT, Long.class);
55:
56: KapuaSecurityUtils.doPrivileged(() -> KEYSTORE_MANAGEMENT_SERVICE.deleteKeystoreItem(jobTarget.getScopeId(), jobTarget.getJobTargetId(), keystoreId, alias, timeout));
57: }
58: }