public static String getNodeOid(Node node) { Node oidNode = null; if ((null == node.getAttributes()) || (null == (oidNode = node.getAttributes().getNamedItem( SchemaConstants.C_OID_ATTRIBUTE.getLocalPart()))) || (StringUtils.isEmpty(oidNode.getNodeValue()))) { return null; } String oid = oidNode.getNodeValue(); return oid; }
public static ItemName fromQName(QName name) { if (name == null) { return null; } else if (name instanceof ItemName) { return (ItemName) name; } else { return new ItemName(name); } }
private boolean isAssignmentExtensionDelta(AttributeStep attributeStep, ItemName name) { if (!(attributeStep.bean instanceof RAssignment)) { return false; } if (!AssignmentType.F_EXTENSION.equals(name)) { return false; } return true; }
@NotNull @Override public List<?> getSegments() { return Collections.singletonList(new QName(getNamespaceURI(), getLocalPart(), getPrefix())); // todo eliminate QName construction while avoiding endless recursion }
private ItemName getExtensionQName() { String namespace = getName().getNamespaceURI(); return new ItemName(namespace, PrismConstants.EXTENSION_LOCAL_NAME); }
@Override public String toString() { // we don't delegate to PrismObject, because various exceptions during that process could in turn call this method StringBuilder sb = new StringBuilder(); sb.append("POV:"); if (getParent() != null) { sb.append(getParent().getElementName().getLocalPart()).append(":"); } else if (getComplexTypeDefinition() != null) { sb.append(getComplexTypeDefinition().getTypeName().getLocalPart()).append(":"); } sb.append(oid).append("("); PrismProperty nameProperty = findProperty(new ItemName(PrismConstants.NAME_LOCAL_NAME)); sb.append(nameProperty != null ? nameProperty.getRealValue() : null); sb.append(")"); return sb.toString(); }
protected ItemDeltaImpl(QName elementName, D itemDefinition, PrismContext prismContext) { //checkPrismContext(prismContext, itemDefinition); this.prismContext = prismContext; this.elementName = ItemName.fromQName(elementName); this.parentPath = ItemPath.EMPTY_PATH; this.definition = itemDefinition; }
@Test public void testGetExtensionPropertyValueParts() throws Exception { final String TEST_NAME = "testGetExtensionPropertyValueParts"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject<UserType> userJack = PrismTestUtil.parseObject(USER_JACK_FILE); // WHEN String shipExtension = f.getExtensionPropertyValue(userJack.asObjectable(), SchemaTestConstants.EXTENSION_SHIP_ELEMENT.getNamespaceURI(), SchemaTestConstants.EXTENSION_SHIP_ELEMENT.getLocalPart()); // THEN assertEquals("Wrong value for extension "+SchemaTestConstants.EXTENSION_SHIP_ELEMENT, "Black Pearl", shipExtension); }
@Override public RAssignmentReference map(Referencable input, MapperContext context) { ObjectReferenceType objectRef = buildReference(input); ObjectTypeUtil.normalizeRelation(objectRef, context.getRelationRegistry()); RAssignment owner = (RAssignment) context.getOwner(); QName name = context.getDelta().getPath().lastName().asSingleName(); RCReferenceOwner refType = null; if (MetadataType.F_CREATE_APPROVER_REF.equals(name)) { refType = RCReferenceOwner.CREATE_APPROVER; } else if (MetadataType.F_MODIFY_APPROVER_REF.equals(name)) { refType = RCReferenceOwner.MODIFY_APPROVER; } RAssignmentReference ref = new RAssignmentReference(); ref.setOwner(owner); ref.setReferenceType(refType); RObjectReference.copyFromJAXB(objectRef, ref, context.getRelationRegistry()); return ref; } }
private boolean isResourceModification(ItemDelta itemDelta) { ItemPath path = itemDelta.getPath(); ItemPath parentPath = itemDelta.getParentPath(); if (ShadowType.F_ATTRIBUTES.equivalent(parentPath)) { return true; } if (ShadowType.F_AUXILIARY_OBJECT_CLASS.equivalent(path)) { return true; } if (ShadowType.F_ASSOCIATION.equivalent(parentPath)) { return true; } if (ShadowType.F_ASSOCIATION.equivalent(path)) { return true; } if (ShadowType.F_ACTIVATION.equivalent(parentPath)) { return true; } if (ShadowType.F_ACTIVATION.equivalent(path)) { // should not occur, but for completeness... return true; } if (SchemaConstants.PATH_CREDENTIALS_PASSWORD.equivalent(parentPath)) { return true; } return false; }
@Override public String getNamespace() { return getName().getNamespaceURI(); }
/** * Finds a attribute definition by looking at the property name. * <p/> * Returns null if nothing is found. * * @param name property definition name * @return found property definition or null */ @Nullable default <X> ResourceAttributeDefinition<X> findAttributeDefinition(QName name) { return findLocalItemDefinition(ItemName.fromQName(name), ResourceAttributeDefinition.class, false); }
private ItemName getExtensionContainerElementName() { return new ItemName(getElementName().getNamespaceURI(), PrismConstants.EXTENSION_LOCAL_NAME); }
private void assertDomSchema(Element xsdElement) { assertPrefix("xsd", xsdElement); Element displayNameAnnotationElement = DOMUtil.findElementRecursive(xsdElement, PrismConstants.A_DISPLAY_NAME); assertPrefix(PrismConstants.PREFIX_NS_ANNOTATION, displayNameAnnotationElement); Element kindAnnotationElement = DOMUtil.findElementRecursive(xsdElement, MidPointConstants.RA_KIND); assertPrefix("ra", kindAnnotationElement); assertEquals(ShadowKindType.ACCOUNT.value(), kindAnnotationElement.getTextContent()); Element identifierAnnotationElement = DOMUtil.findElementRecursive(xsdElement, MidPointConstants.RA_IDENTIFIER); assertPrefix("ra", identifierAnnotationElement); QName identifier = DOMUtil.getQNameValue(identifierAnnotationElement); assertEquals("Wrong <a:identifier> value namespace", SchemaTestConstants.ICFS_UID.getNamespaceURI(), identifier.getNamespaceURI()); assertEquals("Wrong <a:identifier> value localname", SchemaTestConstants.ICFS_UID.getLocalPart(), identifier.getLocalPart()); assertEquals("Wrong <a:identifier> value prefix", "icfs", identifier.getPrefix()); Element dnaAnnotationElement = DOMUtil.findElementRecursive(xsdElement, MidPointConstants.RA_DISPLAY_NAME_ATTRIBUTE); assertPrefix("ra", dnaAnnotationElement); QName dna = DOMUtil.getQNameValue(dnaAnnotationElement); assertEquals("Wrong <a:identifier> value prefix", "tns", dna.getPrefix()); assertEquals("Wrong 'tns' prefix declaration", SCHEMA_NAMESPACE, xsdElement.lookupNamespaceURI("tns")); }
private boolean isShadowPendingOperation(RObject<?> object, ItemDelta delta) { return object instanceof RShadow && ShadowType.F_PENDING_OPERATION.equivalent(delta.getPath()); }
protected String getSchemaNamespace() { return getName().getNamespaceURI(); }
private static void shortDumpShadowIdentifiers(StringBuilder sb, PrismObject<ShadowType> shadow, Collection<ResourceAttribute<?>> identifiers) { Iterator<ResourceAttribute<?>> iterator = identifiers.iterator(); while (iterator.hasNext()) { ResourceAttribute<?> identifier = iterator.next(); sb.append(identifier.getElementName().getLocalPart()); sb.append("="); sb.append(identifier.getRealValue()); if (iterator.hasNext()) { sb.append(";"); } } }
public static ItemName stringToQName(String text) { if (StringUtils.isEmpty(text)) { return null; } int index = text.lastIndexOf(QNAME_DELIMITER); String namespace = StringUtils.left(text, index); String localPart = StringUtils.right(text, text.length() - index - 1); if (StringUtils.isEmpty(localPart)) { return null; } return new ItemName(namespace, localPart); }
@Override public void replaceDefinition(QName itemName, ItemDefinition newDefinition) { for (int i=0; i<itemDefinitions.size(); i++) { ItemDefinition itemDef = itemDefinitions.get(i); if (itemDef.getName().equals(itemName)) { if (!itemDef.getClass().isAssignableFrom(newDefinition.getClass())) { throw new IllegalArgumentException("The provided definition of class "+newDefinition.getClass().getName()+" does not match existing definition of class "+itemDef.getClass().getName()); } if (!itemDef.getName().equals(newDefinition.getName())) { newDefinition = newDefinition.clone(); ((ItemDefinitionImpl) newDefinition).setName(itemName); } // Make sure this is set, not add. set will keep correct ordering itemDefinitions.set(i, newDefinition); return; } } throw new IllegalArgumentException("The definition with name "+ itemName +" was not found in complex type "+getTypeName()); }
public void setElementName(QName elementName) { checkMutability(); this.elementName = ItemName.fromQName(elementName); this.fullPath = null; }