@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final String attribute = operation.require(NAME).asString(); final SensitivityClassificationResource resource = (SensitivityClassificationResource) context.readResource(PathAddress.EMPTY_ADDRESS); final AbstractSensitivity classification = resource.classification; Boolean result = null; if (attribute.equals(DEFAULT_REQUIRES_ADDRESSABLE.getName())) { result = classification.isDefaultRequiresAccessPermission(); } else if (attribute.equals(DEFAULT_REQUIRES_READ.getName())) { result = classification.isDefaultRequiresReadPermission(); } else if (attribute.equals(DEFAULT_REQUIRES_WRITE.getName())) { result = classification.isDefaultRequiresWritePermission(); } else if (attribute.equals(CONFIGURED_REQUIRES_ADDRESSABLE.getName())) { result = classification.getConfiguredRequiresAccessPermission(); } else if (attribute.equals(CONFIGURED_REQUIRES_READ.getName())) { result = classification.getConfiguredRequiresReadPermission(); } else if (attribute.equals(CONFIGURED_REQUIRES_WRITE.getName())) { result = classification.getConfiguredRequiresWritePermission(); } else { // TODO i18n throw new IllegalStateException(); } context.getResult(); if (result != null) { context.getResult().set(result); } context.stepCompleted(); }
@Override public ModelNode getModel() { ModelNode model = new ModelNode(); model .get(DEFAULT_REQUIRES_ADDRESSABLE.getName()) .set(classification.isDefaultRequiresAccessPermission()); model .get(DEFAULT_REQUIRES_READ.getName()) .set(classification.isDefaultRequiresReadPermission()); model .get(DEFAULT_REQUIRES_WRITE.getName()) .set(classification.isDefaultRequiresWritePermission()); model .get(CONFIGURED_REQUIRES_ADDRESSABLE.getName()) .set(getBoolean(classification.getConfiguredRequiresAccessPermission())); model .get(CONFIGURED_REQUIRES_READ.getName()) .set(getBoolean(classification.getConfiguredRequiresReadPermission())); model .get(CONFIGURED_REQUIRES_WRITE.getName()) .set(getBoolean(classification.getConfiguredRequiresWritePermission())); return model; }