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; }
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(";"); } } }
@NotNull @Override public List<?> getSegments() { return Collections.singletonList(new QName(getNamespaceURI(), getLocalPart(), getPrefix())); // todo eliminate QName construction while avoiding endless recursion }
private Path[] buildOrderByPaths(String orderBy, Root<RLookupTableRow> root) { if (!LookupTableRowType.F_LABEL.getLocalPart().equals(orderBy)) { return new Path[]{root.get(orderBy)}; } Path label = root.get(orderBy); return new Path[]{label.get("norm"), label.get("orig")}; }
public static PrismContainerDefinition<ReportConfigurationType> findReportConfigurationDefinition(PrismSchema schema) { if (schema == null) { return null; } QName configContainerQName = new QName(schema.getNamespace(), ReportType.F_CONFIGURATION.getLocalPart()); return schema.findContainerDefinitionByElementName(configContainerQName); }
public static PrismContainerDefinition<ConnectorConfigurationType> findConfigurationContainerDefinition(ConnectorType connectorType, PrismSchema connectorSchema) { QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); return connectorSchema.findContainerDefinitionByElementName(configContainerQName); }
private static boolean isMetadata(ItemPathType itemPath) { boolean retMeta = false; for (Object ips : itemPath.getItemPath().getSegments()) { if (ItemPath.isName(ips) && ObjectType.F_METADATA.getLocalPart().equals(ItemPath.toName(ips).getLocalPart())) { return true; } } return retMeta; }
private PrismContainerDefinition<?> getConfigurationContainerDefinition() throws SchemaException { QName configContainerQName = new QName(connectorType.getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); PrismContainerDefinition<?> configContainerDef = connectorSchema .findContainerDefinitionByElementName(configContainerQName); if (configContainerDef == null) { throw new SchemaException("No definition of container " + configContainerQName + " in configuration schema for connector " + this); } return configContainerDef; }
@Test public void testCanonicalizationMultiNoNs() { ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT.getLocalPart(), 1234, AssignmentType.F_ACTIVATION.getLocalPart(), ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()); assertCanonical(path, null, "\\#assignment", "\\#assignment\\#activation", "\\#assignment\\#activation\\#administrativeStatus"); assertCanonical(path, UserType.class, "\\" + COMMON + "#assignment", "\\" + COMMON + "#assignment\\" + ZERO + "#activation", "\\" + COMMON + "#assignment\\" + ZERO + "#activation\\" + ZERO + "#administrativeStatus"); }
private static String determinePropName(PrismPropertyValue<?> value) { Itemable item = value.getParent(); return item != null && item.getElementName() != null ? item.getElementName().getLocalPart() : ""; }
protected PrismContainerDefinition<?> getConfigurationContainerDefinition() throws SchemaException { QName configContainerQName = new QName(getConnectorObject().getNamespace(), ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart()); PrismContainerDefinition<?> configContainerDef = getConnectorConfigurationSchema() .findContainerDefinitionByElementName(configContainerQName); if (configContainerDef == null) { throw new SchemaException("No definition of container " + configContainerQName + " in configuration schema for connector " + this); } return configContainerDef; }
private String formatPath(ItemDelta itemDelta) { if (itemDelta.getDefinition() != null && itemDelta.getDefinition().getDisplayName() != null) { return itemDelta.getDefinition().getDisplayName(); } StringBuilder sb = new StringBuilder(); for (Object segment : itemDelta.getPath().getSegments()) { if (ItemPath.isName(segment)) { if (sb.length() > 0) { sb.append("/"); } sb.append(ItemPath.toName(segment).getLocalPart()); } } return sb.toString(); }
public <T> T getResourceIcfConfigurationPropertyValue(ResourceType resource, String propertyLocalPart) throws SchemaException { if (propertyLocalPart == null) { return null; } PrismContainer<?> configurationProperties = getIcfConfigurationProperties(resource); if (configurationProperties == null) { return null; } for (PrismProperty<?> property : configurationProperties.getValue().getProperties()) { if (propertyLocalPart.equals(property.getElementName().getLocalPart())) { return (T) property.getAnyRealValue(); } } return null; }
private <T> PrismProperty<T> findProp(List<Item<?, ?>> items, String local) { for (Item<?, ?> item: items) { if (local.equals(item.getElementName().getLocalPart())) { return (PrismProperty<T>) item; } } fail("No item "+local); return null; // not reached }
@Test public void testCanonicalizationSimpleNoNs() { ItemPath path = ItemPath.create(UserType.F_NAME.getLocalPart()); assertCanonical(path, null, "\\#name"); assertCanonical(path, UserType.class, "\\" + COMMON + "#name"); }
private String getItemLabel(Item item) { return item.getDefinition().getDisplayName() != null ? resolve(item.getDefinition().getDisplayName()) : item.getElementName().getLocalPart(); }
private NameImpl createSceneItemName(Item<?,?> item) { NameImpl name = new NameImpl(item.getElementName().getLocalPart()); ItemDefinition<?> def = item.getDefinition(); if (def != null) { name.setDisplayName(def.getDisplayName()); name.setDescription(def.getDocumentation()); } name.setId(name.getSimpleName()); // todo reconsider name.setNamesAreResourceKeys(true); return name; }
@Override protected <T> void assertConfigurationProperty(PrismProperty<T> confProp) { T val = confProp.getRealValue(); switch (confProp.getElementName().getLocalPart()) { case "instanceId": assertEquals("Wrong value for "+confProp, "", val); break; case "uselessString": assertEquals("Wrong value for "+confProp, "Shiver me timbers!", val); assertExpression(confProp, "value"); break; default: break; } }
@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); }
@Test public void testPasswordPolyString() throws Exception { // WHEN PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = evaluator.evaluateMappingDynamicReplace( "mapping-script-system-variables-password.xml", "testPasswordPolyString", UserType.F_ADDITIONAL_NAME.getLocalPart(), // target ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), // changed property evaluator.createProtectedString("weighAnch0r")); // changed values // THEN PrismAsserts.assertTripleNoZero(outputTriple); PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("weighAnch0r")); PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("d3adM3nT3llN0Tal3s")); }