use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class TaskQuartzImpl method setExtensionPropertyValue.
// use this method to avoid cloning the value
@Override
public <T> void setExtensionPropertyValue(QName propertyName, T value) throws SchemaException {
PrismPropertyDefinition propertyDef = getPrismContext().getSchemaRegistry().findPropertyDefinitionByElementName(propertyName);
if (propertyDef == null) {
throw new SchemaException("Unknown property " + propertyName);
}
ArrayList<PrismPropertyValue<T>> values = new ArrayList(1);
if (value != null) {
values.add(new PrismPropertyValue<T>(value));
}
processModificationBatched(setExtensionPropertyAndPrepareDelta(propertyName, propertyDef, values));
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class MidPointQueryExecutor method getParameters.
protected Map<QName, Object> getParameters() {
JRParameter[] params = dataset.getParameters();
Map<QName, Object> expressionParameters = new HashMap<QName, Object>();
for (JRParameter param : params) {
if (param.isSystemDefined()) {
continue;
}
//LOGGER.trace(((JRBaseParameter)param).getName());
Object v = getParameterValue(param.getName());
try {
expressionParameters.put(new QName(param.getName()), new PrismPropertyValue(v));
} catch (Exception e) {
//just skip properties that are not important for midpoint
}
LOGGER.trace("p.val: {}", v);
}
return expressionParameters;
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class ReportUtils method getItemRealValue.
public static Object getItemRealValue(PrismContainerValue containerValue, String itemName) {
Item item = containerValue.findItem(new QName(itemName));
if (item == null || item.size() == 0) {
return null;
}
if (item.size() > 1) {
throw new IllegalStateException("More than one value in item " + item);
}
PrismValue value = item.getValue(0);
if (value == null) {
return null;
}
if (value instanceof PrismPropertyValue) {
return ((PrismPropertyValue) value).getValue();
} else if (value instanceof PrismReferenceValue) {
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue((PrismReferenceValue) value);
return ort;
} else if (value instanceof PrismContainerValue) {
// questionable
return ((PrismContainerValue) value).asContainerable();
} else {
throw new IllegalStateException("Unknown PrismValue: " + value);
}
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class WebComponentUtil method encryptCredentials.
public static void encryptCredentials(ObjectDelta delta, boolean encrypt, MidPointApplication app) {
if (delta == null || delta.isEmpty()) {
return;
}
PropertyDelta propertyDelta = delta.findPropertyDelta(new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE));
if (propertyDelta == null) {
return;
}
Collection<PrismPropertyValue<ProtectedStringType>> values = propertyDelta.getValues(ProtectedStringType.class);
for (PrismPropertyValue<ProtectedStringType> value : values) {
ProtectedStringType string = value.getValue();
encryptProtectedString(string, encrypt, app);
}
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class ValueOperation method interpret.
@Override
public <T> Filter interpret(ObjectFilter objectFilter, ConnIdNameMapper icfNameMapper) throws SchemaException {
OperationResult parentResult = new OperationResult("interpret");
ValueFilter valueFilter = (ValueFilter) objectFilter;
if (valueFilter.getParentPath().isEmpty()) {
throw new UnsupportedOperationException("Empty path is not supported (filter: " + objectFilter + ")");
}
if (valueFilter.getParentPath().equivalent(new ItemPath(ShadowType.F_ATTRIBUTES))) {
try {
QName propName = valueFilter.getDefinition().getName();
String icfName = icfNameMapper.convertAttributeNameToIcf(propName, getInterpreter().getObjectClassDefinition(), "(attribute in the filter)");
if (objectFilter instanceof EqualFilter) {
EqualFilter<T> eq = (EqualFilter<T>) objectFilter;
Collection<Object> convertedValues = convertValues(propName, eq.getValues());
if (convertedValues == null || convertedValues.isEmpty()) {
// See MID-1460
throw new UnsupportedOperationException("Equals filter with a null value is NOT supported by ICF");
} else {
Attribute attr = AttributeBuilder.build(icfName, convertedValues);
if (valueFilter.getDefinition().isSingleValue()) {
return FilterBuilder.equalTo(attr);
} else {
return FilterBuilder.containsAllValues(attr);
}
}
} else if (objectFilter instanceof SubstringFilter) {
SubstringFilter substring = (SubstringFilter) objectFilter;
Collection<Object> convertedValues = convertValues(propName, substring.getValues());
if (convertedValues.isEmpty()) {
throw new IllegalArgumentException("Substring filter with null value makes no sense");
} else {
if (convertedValues.size() != 1) {
throw new IllegalArgumentException("Substring filter with multiple values makes no sense");
//maybe it does, through OR clauses
}
return FilterBuilder.contains(AttributeBuilder.build(icfName, convertedValues.iterator().next()));
}
} else {
throw new UnsupportedOperationException("Unsupported filter type: " + objectFilter);
}
} catch (SchemaException ex) {
throw ex;
}
} else if (valueFilter.getParentPath().equivalent(new ItemPath(ShadowType.F_ACTIVATION))) {
if (objectFilter instanceof EqualFilter) {
QName propName = valueFilter.getDefinition().getName();
EqualFilter<T> eq = (EqualFilter<T>) objectFilter;
List<PrismPropertyValue<T>> values = eq.getValues();
if (values.size() != 1) {
throw new SchemaException("Unexpected number of values in filter " + objectFilter);
}
PrismPropertyValue<T> pval = values.get(0);
String icfName;
Object convertedValue;
if (propName.equals(ActivationType.F_ADMINISTRATIVE_STATUS)) {
icfName = OperationalAttributes.ENABLE_NAME;
convertedValue = pval.getValue() == ActivationStatusType.ENABLED;
} else if (propName.equals(ActivationType.F_LOCKOUT_STATUS)) {
icfName = OperationalAttributes.LOCK_OUT_NAME;
convertedValue = pval.getValue() == LockoutStatusType.LOCKED;
} else {
throw new UnsupportedOperationException("Unsupported activation property " + propName + " in filter: " + objectFilter);
}
Attribute attr = AttributeBuilder.build(icfName, convertedValue);
if (valueFilter.getDefinition().isSingleValue()) {
return FilterBuilder.equalTo(attr);
} else {
return FilterBuilder.containsAllValues(attr);
}
} else {
throw new UnsupportedOperationException("Unsupported filter type in filter: " + objectFilter);
}
} else {
throw new UnsupportedOperationException("Unsupported parent path " + valueFilter.getParentPath() + " in filter: " + objectFilter);
}
}
Aggregations