List of usage examples for javax.xml.namespace QName equals
public final boolean equals(Object objectToTest)
Test this QName
for equality with another Object
.
If the Object
to be tested is not a QName
or is null
, then this method returns false
.
Two QName
s are considered equal if and only if both the Namespace URI and local part are equal.
From source file:com.msopentech.odatajclient.testservice.utils.XMLUtilities.java
private InputStream writeFromStartToEndElement(final StartElement element, final XMLEventReader reader, final boolean document) throws XMLStreamException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final XMLOutputFactory xof = XMLOutputFactory.newInstance(); final XMLEventWriter writer = xof.createXMLEventWriter(bos); final QName name = element.getName(); if (document) { final XMLEventFactory eventFactory = XMLEventFactory.newInstance(); writer.add(eventFactory.createStartDocument("UTF-8", "1.0")); writer.add(element);//from w w w. j a v a2 s. c o m if (element.getAttributeByName(new QName(ATOM_DATASERVICE_NS)) == null) { writer.add(eventFactory.createNamespace(ATOM_PROPERTY_PREFIX.substring(0, 1), DATASERVICES_NS)); } if (element.getAttributeByName(new QName(ATOM_METADATA_NS)) == null) { writer.add(eventFactory.createNamespace(ATOM_METADATA_PREFIX.substring(0, 1), METADATA_NS)); } } else { writer.add(element); } XMLEvent event = element; while (reader.hasNext() && !(event.isEndElement() && name.equals(event.asEndElement().getName()))) { event = reader.nextEvent(); writer.add(event); } writer.flush(); writer.close(); return new ByteArrayInputStream(bos.toByteArray()); }
From source file:com.evolveum.midpoint.prism.PrismContainerValue.java
public PrismReference findReferenceByCompositeObjectElementName(QName elementName) { if (items == null) { return null; }/*from w w w.j a v a 2 s . c om*/ for (Item item : items) { if (item instanceof PrismReference) { PrismReference ref = (PrismReference) item; PrismReferenceDefinition refDef = ref.getDefinition(); if (refDef != null) { if (elementName.equals(refDef.getCompositeObjectElementName())) { return ref; } } } } return null; }
From source file:com.evolveum.midpoint.provisioning.impl.ShadowCache.java
/** * Reapplies definition to the shadow if needed. The definition needs to be reapplied e.g. * if the shadow has auxiliary object classes, it if subclass of the object class that was originally * requested, etc. /*ww w . jav a 2 s. c o m*/ */ private ProvisioningContext reapplyDefinitions(ProvisioningContext ctx, PrismObject<ShadowType> rawResourceShadow) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException { ShadowType rawResourceShadowType = rawResourceShadow.asObjectable(); QName objectClassQName = rawResourceShadowType.getObjectClass(); List<QName> auxiliaryObjectClassQNames = rawResourceShadowType.getAuxiliaryObjectClass(); if (auxiliaryObjectClassQNames.isEmpty() && objectClassQName.equals(ctx.getObjectClassDefinition().getTypeName())) { // shortcut, no need to reapply anything return ctx; } ProvisioningContext shadowCtx = ctx.spawn(rawResourceShadow); shadowCtx.assertDefinition(); RefinedObjectClassDefinition shadowDef = shadowCtx.getObjectClassDefinition(); ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(rawResourceShadow); attributesContainer.applyDefinition(shadowDef.toResourceAttributeContainerDefinition()); return shadowCtx; }
From source file:com.trsst.client.Client.java
/** * Returns a Feed for the specified feed id, and will attempt to decrypt any * encrypted content with the specified key. * // w w w .j a v a2 s . c om * @param urn * a feed or entry urn id. * @param decryptionKey * one or more private keys used to attempt to decrypt content. * @return a Feed containing the latest entries for this feed id. */ public Feed pull(String urn, PrivateKey[] decryptionKeys) { Feed feed = pull(urn); if (feed == null) { return null; } Content content; MimeType contentType; for (Entry entry : feed.getEntries()) { content = entry.getContentElement(); if (content != null && (contentType = content.getMimeType()) != null && "application/xenc+xml".equals(contentType.toString())) { // if this message was intended for us, we will be able to // decrypt one of the elements into an AES key to decrypt the // encrypted entry itself QName publicEncryptName = new QName(Common.NS_URI, Common.ENCRYPT); QName publicSignName = new QName(Common.NS_URI, Common.SIGN); QName encryptedDataName = new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptedData"); QName cipherDataName = new QName("http://www.w3.org/2001/04/xmlenc#", "CipherData"); QName cipherValueName = new QName("http://www.w3.org/2001/04/xmlenc#", "CipherValue"); String encodedBytes; byte[] decodedBytes; Element publicKeyElement, cipherData, cipherValue, result; List<Element> encryptedElements = content.getElements(); int lastIndex = encryptedElements.size() - 1; Element element; PublicKey publicKey = null; byte[] decryptedKey = null; publicKeyElement = feed.getFirstChild(publicEncryptName); if (publicKeyElement == null) { // fall back on signing key publicKeyElement = feed.getFirstChild(publicSignName); } if (publicKeyElement != null && publicKeyElement.getText() != null) { try { publicKey = Common.toPublicKeyFromX509(publicKeyElement.getText()); } catch (GeneralSecurityException gse) { log.error("Could not parse public key: " + publicKeyElement); } } if (publicKey != null) { // TODO: if we're the author, we can start loop at // (lastIndex-1) for (int i = 0; i < encryptedElements.size(); i++) { element = encryptedElements.get(i); if (encryptedDataName.equals(element.getQName())) { cipherData = element.getFirstChild(cipherDataName); if (cipherData != null) { cipherValue = cipherData.getFirstChild(cipherValueName); if (cipherValue != null) { encodedBytes = cipherValue.getText(); if (encodedBytes != null) { decodedBytes = new Base64().decode(encodedBytes); if (i != lastIndex) { // if we're not at the last index // (the payload) so we should // attempt // to decrypt this AES key for (PrivateKey decryptionKey : decryptionKeys) { try { decryptedKey = Crypto.decryptKeyWithIES(decodedBytes, entry.getUpdated().getTime(), publicKey, decryptionKey); if (decryptedKey != null) { // success: // skip to lastIndex i = lastIndex - 1; break; } } catch (GeneralSecurityException e) { // key did not fit log.trace("Could not decrypt key: " + entry.getId(), e); } catch (Throwable t) { log.warn( "Error while decrypting key on entry: " + entry.getId(), t); } } } else if (decryptedKey != null) { // if we're at the last index // (the payload) and we have an // AES key: attempt to decrypt try { result = decryptElementAES(decodedBytes, decryptedKey); for (Element ee : encryptedElements) { ee.discard(); } content.setValueElement(result); break; } catch (SecurityException e) { log.error("Key did not decrypt element: " + entry.getId(), e); } catch (Throwable t) { log.warn("Could not decrypt element on entry: " + entry.getId(), t); } } } else { log.warn("No cipher text for entry: " + entry.getId()); } } else { log.warn("No cipher value for entry: " + entry.getId()); } } else { log.warn("No cipher data for entry: " + entry.getId()); } } } } else { log.error("No public key for feed: " + feed.getId()); } } } return feed; }
From source file:com.nortal.jroad.typegen.xmlbeans.XteeSchemaCodePrinter.java
private SchemaProperty[] getDerivedProperties(SchemaType sType) { // We have to see if this is redefined, because if it is we have // to include all properties associated to its supertypes QName name = sType.getName(); if (name != null && name.equals(sType.getBaseType().getName())) { SchemaType sType2 = sType.getBaseType(); // Walk all the redefined types and record any properties // not present in sType, because the redefined types do not // have a generated class to represent them SchemaProperty[] props = sType.getDerivedProperties(); Map<QName, SchemaProperty> propsByName = new LinkedHashMap<QName, SchemaProperty>(); for (int i = 0; i < props.length; i++) propsByName.put(props[i].getName(), props[i]); while (sType2 != null && name.equals(sType2.getName())) { props = sType2.getDerivedProperties(); for (int i = 0; i < props.length; i++) if (!propsByName.containsKey(props[i].getName())) propsByName.put(props[i].getName(), props[i]); sType2 = sType2.getBaseType(); }/*from www. j a va 2 s . c om*/ return propsByName.values().toArray(new SchemaProperty[0]); } else return sType.getDerivedProperties(); }
From source file:com.evolveum.midpoint.model.impl.controller.ModelInteractionServiceImpl.java
private <T, O extends ObjectType> boolean validateValue(PrismObject<O> object, ValuePolicyType policy, PolicyItemDefinitionType policyItemDefinition, Task task, OperationResult parentResult) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException { ValuePolicyType stringPolicy = resolveValuePolicy(policyItemDefinition, policy, task, parentResult); Object value = policyItemDefinition.getValue(); String valueToValidate = null; if (value instanceof RawType) { valueToValidate = ((RawType) value).getParsedRealValue(String.class); } else {/*from w w w . j a va 2 s .c o m*/ valueToValidate = (String) value; } List<String> valuesToValidate = new ArrayList<>(); PolicyItemTargetType target = policyItemDefinition.getTarget(); ItemPath path = null; if (target != null) { path = target.getPath().getItemPath(); } if (StringUtils.isNotEmpty(valueToValidate)) { valuesToValidate.add(valueToValidate); } else { if (target == null || target.getPath() == null) { LOGGER.error("Target item path must be defined"); parentResult.recordFatalError("Target item path must be defined"); throw new SchemaException("Target item path must be defined"); } path = target.getPath().getItemPath(); if (object == null) { LOGGER.error("Object which values should be validated is null. Nothing to validate."); parentResult .recordFatalError("Object which values should be validated is null. Nothing to validate."); throw new SchemaException("Object which values should be validated is null. Nothing to validate."); } PrismProperty<T> property = object.findProperty(path); if (property == null || property.isEmpty()) { LOGGER.error("Attribute {} has no value. Nothing to validate.", property); parentResult.recordFatalError("Attribute " + property + " has no value. Nothing to validate"); throw new SchemaException("Attribute " + property + " has no value. Nothing to validate"); } PrismPropertyDefinition<T> itemToValidateDefinition = property.getDefinition(); QName definitionName = itemToValidateDefinition.getTypeName(); if (!isSupportedType(definitionName)) { LOGGER.error( "Trying to validate string policy on the property of type {} failed. Unsupported type.", itemToValidateDefinition); parentResult.recordFatalError("Trying to validate string policy on the property of type " + itemToValidateDefinition + " failed. Unsupported type."); throw new SchemaException("Trying to validate string policy on the property of type " + itemToValidateDefinition + " failed. Unsupported type."); } if (itemToValidateDefinition.isSingleValue()) { if (definitionName.equals(PolyStringType.COMPLEX_TYPE)) { valueToValidate = ((PolyString) property.getRealValue()).getOrig(); } else if (definitionName.equals(ProtectedStringType.COMPLEX_TYPE)) { ProtectedStringType protectedString = ((ProtectedStringType) property.getRealValue()); valueToValidate = getClearValue(protectedString); } else { valueToValidate = (String) property.getRealValue(); } valuesToValidate.add(valueToValidate); } else { if (definitionName.equals(DOMUtil.XSD_STRING)) { valuesToValidate.addAll(property.getRealValues(String.class)); } else if (definitionName.equals(ProtectedStringType.COMPLEX_TYPE)) { for (ProtectedStringType protectedString : property.getRealValues(ProtectedStringType.class)) { valuesToValidate.add(getClearValue(protectedString)); } } else { for (PolyString val : property.getRealValues(PolyString.class)) { valuesToValidate.add(val.getOrig()); } } } } for (String newValue : valuesToValidate) { OperationResult result = parentResult.createSubresult(OPERATION_VALIDATE_VALUE + ".value"); if (path != null) result.addParam("path", path.toString()); result.addParam("valueToValidate", newValue); // if (stringPolicy == null) { // stringPolicy = new ValuePolicyType(); // stringPolicy.setName(PolyString.toPolyStringType(new PolyString("Default policy"))); // } ObjectValuePolicyEvaluator evaluator = new ObjectValuePolicyEvaluator(); evaluator.setValuePolicy(stringPolicy); evaluator.setValuePolicyProcessor(policyProcessor); evaluator.setProtector(protector); evaluator.setValueItemPath(path); evaluator.setOriginResolver(getOriginResolver(object)); evaluator.setTask(task); evaluator.setShortDesc(" rest validate "); if (object != null && path != null && path.isSuperPathOrEquivalent(SchemaConstants.PATH_PASSWORD)) { evaluator.setSecurityPolicy(getSecurityPolicy((PrismObject<UserType>) object, task, parentResult)); PrismContainer<PasswordType> password = object.findContainer(SchemaConstants.PATH_PASSWORD); PasswordType passwordType = null; if (password != null) { PrismContainerValue<PasswordType> passwordPcv = password.getValue(); passwordType = passwordPcv != null ? passwordPcv.asContainerable() : null; } evaluator.setOldCredentialType(passwordType); } evaluator.setNow(clock.currentTimeXMLGregorianCalendar()); LOGGER.trace("Validating value started"); OperationResult subResult = evaluator.validateStringValue(newValue); LOGGER.trace("Validating value finished"); result.addSubresult(subResult); // result.computeStatus(); // if (!policyProcessor.validateValue(newValue, stringPolicy, createOriginResolver(object, result), "validate value " + (path!= null ? "for " + path : "") + " for " + object + " value " + valueToValidate, task, result)) { // result.recordFatalError("Validation for value " + newValue + " against policy " + stringPolicy + " failed"); // LOGGER.error("Validation for value {} against policy {} failed", newValue, stringPolicy); // } } parentResult.computeStatus(); policyItemDefinition.setResult(parentResult.createOperationResultType()); return parentResult.isAcceptable(); }
From source file:com.evolveum.midpoint.prism.parser.DomSerializer.java
private void serializePrimitiveElementOrAttribute(PrimitiveXNode<?> xprim, Element parentElement, QName elementOrAttributeName, boolean asAttribute) throws SchemaException { QName typeQName = xprim.getTypeQName(); // if typeQName is not explicitly specified, we try to determine it from parsed value // TODO we should probably set typeQName when parsing the value... if (typeQName == null && xprim.isParsed()) { Object v = xprim.getValue(); if (v != null) { typeQName = XsdTypeMapper.toXsdType(v.getClass()); }/*from w w w .j a va2 s . c o m*/ } if (typeQName == null) { // this means that either xprim is unparsed or it is empty if (com.evolveum.midpoint.prism.PrismContext.isAllowSchemalessSerialization()) { // We cannot correctly serialize without a type. But this is needed // sometimes. So just default to string String stringValue = xprim.getStringValue(); if (stringValue != null) { if (asAttribute) { DOMUtil.setAttributeValue(parentElement, elementOrAttributeName.getLocalPart(), stringValue); DOMUtil.setNamespaceDeclarations(parentElement, xprim.getRelevantNamespaceDeclarations()); } else { Element element; try { element = createElement(elementOrAttributeName, parentElement); appendCommentIfPresent(element, xprim); } catch (DOMException e) { throw new DOMException(e.code, e.getMessage() + "; creating element " + elementOrAttributeName + " in element " + DOMUtil.getQName(parentElement)); } parentElement.appendChild(element); DOMUtil.setElementTextContent(element, stringValue); DOMUtil.setNamespaceDeclarations(element, xprim.getRelevantNamespaceDeclarations()); } } return; } else { throw new IllegalStateException("No type for primitive element " + elementOrAttributeName + ", cannot serialize (schemaless serialization is disabled)"); } } // typeName != null after this point if (StringUtils.isBlank(typeQName.getNamespaceURI())) { typeQName = XsdTypeMapper.determineQNameWithNs(typeQName); } Element element = null; if (typeQName.equals(ItemPath.XSD_TYPE)) { ItemPath itemPath = (ItemPath) xprim.getValue(); if (itemPath != null) { if (asAttribute) { throw new UnsupportedOperationException( "Serializing ItemPath as an attribute is not supported yet"); } XPathHolder holder = new XPathHolder(itemPath); element = holder.toElement(elementOrAttributeName, parentElement.getOwnerDocument()); parentElement.appendChild(element); } } else { // not an ItemPathType if (!asAttribute) { try { element = createElement(elementOrAttributeName, parentElement); } catch (DOMException e) { throw new DOMException(e.code, e.getMessage() + "; creating element " + elementOrAttributeName + " in element " + DOMUtil.getQName(parentElement)); } appendCommentIfPresent(element, xprim); parentElement.appendChild(element); } if (typeQName.equals(DOMUtil.XSD_QNAME)) { QName value = (QName) xprim.getParsedValueWithoutRecording(DOMUtil.XSD_QNAME); value = setQNamePrefixExplicitIfNeeded(value); if (asAttribute) { try { DOMUtil.setQNameAttribute(parentElement, elementOrAttributeName.getLocalPart(), value); } catch (DOMException e) { throw new DOMException(e.code, e.getMessage() + "; setting attribute " + elementOrAttributeName.getLocalPart() + " in element " + DOMUtil.getQName(parentElement) + " to QName value " + value); } } else { DOMUtil.setQNameValue(element, value); } } else { // not ItemType nor QName String value = xprim.getGuessedFormattedValue(); if (asAttribute) { DOMUtil.setAttributeValue(parentElement, elementOrAttributeName.getLocalPart(), value); } else { DOMUtil.setElementTextContent(element, value); } } } if (!asAttribute && xprim.isExplicitTypeDeclaration()) { DOMUtil.setXsiType(element, setQNamePrefixExplicitIfNeeded(typeQName)); } }
From source file:com.evolveum.midpoint.prism.schema.DomToSchemaProcessor.java
/** * Creates ComplexTypeDefinition object from a XSModelGroup inside XSD complexType definition. * This is a recursive method. It can create "anonymous" internal PropertyContainerDefinitions. * The definitions will be added to the ComplexTypeDefinition provided as parameter. * @param group XSD XSModelGroup//from w w w . jav a2s . c om * @param ctd ComplexTypeDefinition that will hold the definitions * @param inherited Are these properties inherited? (null means we don't know and we'll determine that from explicitContent) * @param explicitContent Explicit (i.e. non-inherited) content of the type being parsed - filled-in only for subtypes! */ private void addPropertyDefinitionListFromGroup(XSModelGroup group, ComplexTypeDefinition ctd, Boolean inherited, XSContentType explicitContent) throws SchemaException { XSParticle[] particles = group.getChildren(); for (XSParticle p : particles) { boolean particleInherited = inherited != null ? inherited : (p != explicitContent); XSTerm pterm = p.getTerm(); if (pterm.isModelGroup()) { addPropertyDefinitionListFromGroup(pterm.asModelGroup(), ctd, particleInherited, explicitContent); } // xs:element inside complex type if (pterm.isElementDecl()) { XSAnnotation annotation = selectAnnotationToUse(p.getAnnotation(), pterm.getAnnotation()); XSElementDecl elementDecl = pterm.asElementDecl(); QName elementName = new QName(elementDecl.getTargetNamespace(), elementDecl.getName()); QName typeFromAnnotation = getTypeAnnotation(p.getAnnotation()); XSType xsType = elementDecl.getType(); if (isObjectReference(xsType, annotation)) { processObjectReferenceDefinition(xsType, elementName, annotation, ctd, p, particleInherited); } else if (isObjectDefinition(xsType)) { // This is object reference. It also has its *Ref equivalent which will get parsed. // therefore it is safe to ignore } else if (xsType.getName() == null && typeFromAnnotation == null) { if (isAny(xsType)) { if (isPropertyContainer(elementDecl)) { XSAnnotation containerAnnotation = xsType.getAnnotation(); PrismContainerDefinition<?> containerDefinition = createPropertyContainerDefinition( xsType, p, null, containerAnnotation, false); containerDefinition.setInherited(particleInherited); ctd.addDefinition(containerDefinition); } else { PrismPropertyDefinition propDef = createPropertyDefinition(xsType, elementName, DOMUtil.XSD_ANY, ctd, annotation, p); propDef.setInherited(particleInherited); ctd.addDefinition(propDef); } } } else if (isPropertyContainer(elementDecl)) { // Create an inner PropertyContainer. It is assumed that this is a XSD complex type XSComplexType complexType = (XSComplexType) xsType; ComplexTypeDefinition complexTypeDefinition = null; if (typeFromAnnotation != null && complexType != null && !typeFromAnnotation.equals(getType(xsType))) { // There is a type override annotation. The type that the schema parser determined is useless // We need to locate our own complex type definition if (isMyNamespace(typeFromAnnotation)) { complexTypeDefinition = getOrProcessComplexType(typeFromAnnotation); } else { complexTypeDefinition = getPrismContext().getSchemaRegistry() .findComplexTypeDefinition(typeFromAnnotation); } if (complexTypeDefinition == null) { throw new SchemaException("Cannot find definition of complex type " + typeFromAnnotation + " as specified in type override annotation at " + elementName); } } else { complexTypeDefinition = processComplexTypeDefinition(complexType); } XSAnnotation containerAnnotation = complexType.getAnnotation(); PrismContainerDefinition<?> containerDefinition = createPropertyContainerDefinition(xsType, p, complexTypeDefinition, containerAnnotation, false); if (isAny(xsType)) { containerDefinition.setRuntimeSchema(true); containerDefinition.setDynamic(true); } containerDefinition.setInherited(particleInherited); ctd.addDefinition(containerDefinition); } else { // Create a property definition (even if this is a XSD complex type) QName typeName = new QName(xsType.getTargetNamespace(), xsType.getName()); PrismPropertyDefinition propDef = createPropertyDefinition(xsType, elementName, typeName, ctd, annotation, p); propDef.setInherited(particleInherited); ctd.add(propDef); } } } }
From source file:com.evolveum.midpoint.prism.schema.DomToSchemaPostProcessor.java
/** * Creates ComplexTypeDefinition object from a XSModelGroup inside XSD * complexType definition. This is a recursive method. It can create * "anonymous" internal PropertyContainerDefinitions. The definitions will * be added to the ComplexTypeDefinition provided as parameter. * * @param group//from ww w .j a v a2s . c om * XSD XSModelGroup * @param ctd * ComplexTypeDefinition that will hold the definitions * @param inherited * Are these properties inherited? (null means we don't know and * we'll determine that from explicitContent) * @param explicitContent * Explicit (i.e. non-inherited) content of the type being parsed * - filled-in only for subtypes! */ private void addPropertyDefinitionListFromGroup(XSModelGroup group, ComplexTypeDefinition ctd, Boolean inherited, XSContentType explicitContent) throws SchemaException { XSParticle[] particles = group.getChildren(); for (XSParticle p : particles) { boolean particleInherited = inherited != null ? inherited : (p != explicitContent); XSTerm pterm = p.getTerm(); if (pterm.isModelGroup()) { addPropertyDefinitionListFromGroup(pterm.asModelGroup(), ctd, particleInherited, explicitContent); } // xs:element inside complex type if (pterm.isElementDecl()) { XSAnnotation annotation = selectAnnotationToUse(p.getAnnotation(), pterm.getAnnotation()); XSElementDecl elementDecl = pterm.asElementDecl(); QName elementName = new QName(elementDecl.getTargetNamespace(), elementDecl.getName()); QName typeFromAnnotation = getTypeAnnotation(p.getAnnotation()); XSType xsType = elementDecl.getType(); if (isObjectReference(xsType, annotation)) { processObjectReferenceDefinition(xsType, elementName, annotation, ctd, p, particleInherited); } else if (isObjectDefinition(xsType)) { // This is object reference. It also has its *Ref equivalent // which will get parsed. // therefore it is safe to ignore } else if (xsType.getName() == null && typeFromAnnotation == null) { if (isAny(xsType)) { if (isPropertyContainer(elementDecl)) { XSAnnotation containerAnnotation = xsType.getAnnotation(); PrismContainerDefinition<?> containerDefinition = createPropertyContainerDefinition( xsType, p, null, containerAnnotation, false); ((PrismContainerDefinitionImpl) containerDefinition).setInherited(particleInherited); ((ComplexTypeDefinitionImpl) ctd).add(containerDefinition); } else { PrismPropertyDefinitionImpl propDef = createPropertyDefinition(xsType, elementName, DOMUtil.XSD_ANY, ctd, annotation, p); propDef.setInherited(particleInherited); ((ComplexTypeDefinitionImpl) ctd).add(propDef); } } } else if (isPropertyContainer(elementDecl)) { // Create an inner PropertyContainer. It is assumed that // this is a XSD complex type XSComplexType complexType = (XSComplexType) xsType; ComplexTypeDefinition complexTypeDefinition; if (typeFromAnnotation != null && !typeFromAnnotation.equals(getType(xsType))) { // There is a type override annotation. The type that // the schema parser determined is useless // We need to locate our own complex type definition if (isMyNamespace(typeFromAnnotation)) { complexTypeDefinition = getOrProcessComplexType(typeFromAnnotation); } else { complexTypeDefinition = prismContext.getSchemaRegistry() .findComplexTypeDefinition(typeFromAnnotation); } if (complexTypeDefinition == null) { throw new SchemaException("Cannot find definition of complex type " + typeFromAnnotation + " as specified in type override annotation at " + elementName); } } else { complexTypeDefinition = processComplexTypeDefinition(complexType); } XSAnnotation containerAnnotation = complexType.getAnnotation(); PrismContainerDefinition<?> containerDefinition = createPropertyContainerDefinition(xsType, p, complexTypeDefinition, containerAnnotation, false); // if (isAny(xsType)) { // ((PrismContainerDefinitionImpl) containerDefinition).setRuntimeSchema(true); // ((PrismContainerDefinitionImpl) containerDefinition).setDynamic(true); // } ((PrismContainerDefinitionImpl) containerDefinition).setInherited(particleInherited); ((ComplexTypeDefinitionImpl) ctd).add(containerDefinition); } else { // Create a property definition (even if this is a XSD // complex type) QName typeName = new QName(xsType.getTargetNamespace(), xsType.getName()); PrismPropertyDefinitionImpl propDef = createPropertyDefinition(xsType, elementName, typeName, ctd, annotation, p); propDef.setInherited(particleInherited); ((ComplexTypeDefinitionImpl) ctd).add(propDef); } } } }
From source file:com.evolveum.midpoint.provisioning.ucf.impl.ConnectorInstanceIcfImpl.java
private boolean shouldBeGenerated(List<QName> generateObjectClasses, QName objectClassXsdName) { if (generateObjectClasses == null || generateObjectClasses.isEmpty()) { return true; }/*w ww . java 2s .c om*/ for (QName objClassToGenerate : generateObjectClasses) { if (objClassToGenerate.equals(objectClassXsdName)) { return true; } } return false; }