private static String determinePropName(PrismPropertyValue<?> value) { Itemable item = value.getParent(); return item != null && item.getElementName() != null ? item.getElementName().getLocalPart() : ""; }
protected ItemDefinition getDefinition() { Itemable parent = getParent(); if (parent == null) { return null; } return parent.getDefinition(); }
@NotNull @Override public ItemPath getPath() { Itemable parent = getParent(); if (parent == null) { throw new IllegalStateException("No parent, cannot create value path for "+this); } return parent.getPath(); }
info.itemDefinition = itemDefinition = value.getParent().getDefinition(); if (info.itemDefinition == null) { info.itemDefinition = schemaRegistry.findItemDefinitionByElementName(value.getParent().getElementName()); info.itemName = value.getParent().getElementName();
@Override public PrismContext getPrismContext() { if (prismContext != null) { return prismContext; } if (parent != null) { prismContext = parent.getPrismContext(); return prismContext; } return null; }
public RAnyValue convertToRValue(PrismValue value, boolean assignment, RObjectExtensionType ownerType) throws SchemaException { RAnyValue rValue; ItemDefinition definition = value.getParent().getDefinition(); if (!isIndexed(definition, value.getParent().getElementName(), areDynamicsOfThisKindIndexed(ownerType), prismContext)) { return null; } if (value instanceof PrismPropertyValue) { PrismPropertyValue propertyValue = (PrismPropertyValue) value; rValue = extractAndCreateValue(definition, propertyValue, assignment); } else if (value instanceof PrismReferenceValue) { if (assignment) { PrismReferenceValue referenceValue = (PrismReferenceValue) value; rValue = RAExtReference.createReference(referenceValue); } else { PrismReferenceValue referenceValue = (PrismReferenceValue) value; rValue = ROExtReference.createReference(referenceValue); } } else { // shouldn't get here because if isIndexed test above throw new AssertionError("Wrong value type: " + value); } rValue.setItemId(extItemDictionary.createOrFindItemDefinition(definition).getId()); return rValue; }
return; ItemDefinition itemDef = item.getDefinition(); if (itemDef == null) { return; QName propName = item.getElementName(); @SuppressWarnings("unchecked") PrismPropertyValue<ProtectedStringType> psPval = (PrismPropertyValue<ProtectedStringType>)pval;
/** * Returns JAXBElement corresponding to the this value. * Name of the element is the name of parent property; its value is the real value of the property. * * @return Created JAXBElement. */ public JAXBElement<T> toJaxbElement() { Itemable parent = getParent(); if (parent == null) { throw new IllegalStateException("Couldn't represent parent-less property value as a JAXBElement"); } Object realValue = getValue(); return new JAXBElement<T>(parent.getElementName(), (Class) realValue.getClass(), (T) realValue); }
@NotNull private <T> T extractValue(PrismPropertyValue value, Class<T> returnType) throws SchemaException { ItemDefinition definition = value.getParent().getDefinition(); //todo raw types Object object = value.getValue(); if (object instanceof Element) { object = getRealRepoValue(definition, (Element) object, prismContext); } else if (object instanceof RawType) { RawType raw = (RawType) object; object = raw.getParsedRealValue(returnType); // todo this can return null! } else { object = getAggregatedRepoObject(object); } if (returnType.isAssignableFrom(object.getClass())) { return (T) object; } throw new IllegalStateException("Can't extract value for saving from prism property value " + value + " expected return type " + returnType + ", actual type " + (object == null ? null : object.getClass())); }
@NotNull public ItemPath getPath() { Itemable parent = getParent(); @NotNull ItemPath parentPath = ItemPath.EMPTY_PATH; if (parent != null) { parentPath = parent.getPath(); } if (getId() != null) { return parentPath.append(getId()); } else { return parentPath; } }
return; ItemDefinition itemDef = item.getDefinition(); if (itemDef == null) { return; QName propName = item.getElementName(); @SuppressWarnings("unchecked") PrismPropertyValue<ProtectedStringType> psPval = (PrismPropertyValue<ProtectedStringType>) pval;
/** * @param targetType * @param allowEmptyNamespace This is an ugly hack. See comment in DOMUtil.validateNonEmptyQName. */ public void setTargetType(QName targetType, boolean allowEmptyNamespace) { checkMutability(); // Null value is OK if (targetType != null) { // But non-empty is not .. Itemable item = getParent(); DOMUtil.validateNonEmptyQName(targetType, " in target type in reference "+ (item == null ? "(unknown)" : item.getElementName()), allowEmptyNamespace); } this.targetType = targetType; }
@Override public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) { if (!scope.isThorough()) { return; } ItemPath myPath = getPath(); if (StringUtils.isBlank(oid) && object == null && filter == null) { boolean mayBeEmpty = false; if (getParent() != null && getParent().getDefinition() != null) { ItemDefinition itemDefinition = getParent().getDefinition(); if (itemDefinition instanceof PrismReferenceDefinition) { PrismReferenceDefinition prismReferenceDefinition = (PrismReferenceDefinition) itemDefinition; mayBeEmpty = prismReferenceDefinition.isComposite(); } } if (!mayBeEmpty) { throw new IllegalStateException("Neither OID, object nor filter specified in reference value "+this+" ("+myPath+" in "+rootItem+")"); } } if (object != null) { try { object.checkConsistence(); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(e.getMessage()+" in reference "+myPath+" in "+rootItem, e); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in reference "+myPath+" in "+rootItem, e); } } }
pathComponent = ((Itemable) v).getPath(); } else { throw new IllegalStateException("Expected Item or PrismValue but got " + v.getClass());
throw new IllegalStateException("Couldn't convert parent-less prism value to xsd:any: " + value); QName elementName = parent.getElementName(); if (value instanceof PrismPropertyValue) { PrismPropertyValue<Object> pval = (PrismPropertyValue)value; if (pval.isRaw() && parent.getDefinition() == null) { XNodeImpl rawElement = (XNodeImpl) pval.getRawElement(); if (rawElement instanceof MapXNodeImpl) {
@NotNull @Override public T serialize(@NotNull PrismValue value) throws SchemaException { QName nameToUse; if (itemName != null) { nameToUse = itemName; } else if (itemDefinition != null) { nameToUse = itemDefinition.getName(); } else if (value.getParent() != null) { nameToUse = value.getParent().getElementName(); } else { nameToUse = null; } // else { // // TODO derive from the value type itself? Not worth the effort. // throw new IllegalArgumentException("Item name nor definition is not known for " + value); // } RootXNodeImpl xroot = getMarshaller().marshalPrismValueAsRoot(value, nameToUse, itemDefinition, context); checkPostconditions(xroot); // TODO find better way return target.write(xroot, context); }
ItemDefinition def = null; Itemable parent = getParent(); if (parent != null && parent.getDefinition() != null) { def = getParent().getDefinition();
PrismContext prismContext, String contextDesc, boolean throwExceptionOnFailure, OperationResult parentResult) { String refName = refVal.getParent() != null ? refVal.getParent().getElementName().toString() : "(unnamed)"; PrismReferenceDefinition definition = (PrismReferenceDefinition) refVal.getParent().getDefinition(); if (definition != null) { typeQName = definition.getTargetTypeName();
return ConnIdUtil.toGuardedString(ps, pval.getParent().getElementName().getLocalPart(), protector); } else { throw new ConfigurationException( "Expected protected string as value of configuration property " + pval.getParent().getElementName().getLocalPart() + " but got " + midPointRealValue.getClass());
public <O extends ObjectType> PrismObject<O> resolve(PrismReferenceValue refVal, String string, GetOperationOptions options, Task task, OperationResult result) throws ObjectNotFoundException { String oid = refVal.getOid(); Class<?> typeClass = ObjectType.class; QName typeQName = refVal.getTargetType(); if (typeQName == null && refVal.getParent() != null && refVal.getParent().getDefinition() != null) { PrismReferenceDefinition refDef = (PrismReferenceDefinition) refVal.getParent().getDefinition(); typeQName = refDef.getTargetTypeName(); } if (typeQName != null) { typeClass = prismContext.getSchemaRegistry().determineCompileTimeClass(typeQName); } return (PrismObject<O>) (getObjectSimple((Class<O>)typeClass, oid, options, task, result)).asPrismObject(); }