List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:com.evolveum.midpoint.model.impl.lens.projector.policy.evaluators.ObjectModificationConstraintEvaluator.java
@Override public <F extends FocusType> EvaluatedPolicyRuleTrigger<?> evaluate( JAXBElement<ModificationPolicyConstraintType> constraint, PolicyRuleEvaluationContext<F> rctx, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { if (!(rctx instanceof ObjectPolicyRuleEvaluationContext)) { return null; }//from ww w .j av a 2 s .com ObjectPolicyRuleEvaluationContext<F> ctx = (ObjectPolicyRuleEvaluationContext<F>) rctx; if (modificationConstraintMatches(constraint, ctx, result)) { LocalizableMessage message = createMessage(constraint, rctx, result); LocalizableMessage shortMessage = createShortMessage(constraint, rctx, result); return new EvaluatedModificationTrigger(PolicyConstraintKindType.OBJECT_MODIFICATION, constraint.getValue(), message, shortMessage); } else { return null; } }
From source file:de.ingrid.interfaces.csw.domain.filter.impl.LuceneFilterParser.java
/** * Build a piece of Lucene query with the specified Comparison filter. * * @param comparisonOpsEl/*from www .j a v a2 s.c o m*/ * @return String * @throws CSWFilterException */ protected String processComparisonOperator(JAXBElement<? extends ComparisonOpsType> comparisonOpsEl) throws CSWFilterException { StringBuilder response = new StringBuilder(); ComparisonOpsType comparisonOps = comparisonOpsEl.getValue(); if (comparisonOps instanceof PropertyIsLikeType) { PropertyIsLikeType pil = (PropertyIsLikeType) comparisonOps; // get the field String propertyName = ""; String propertyNameLocal = ""; if (pil.getPropertyName() != null) { propertyName = pil.getPropertyName().getContent(); propertyNameLocal = this.removePrefix(propertyName); response.append(propertyNameLocal.toLowerCase()).append(':'); } else { throw new CSWFilterException("Missing propertyName parameter for propertyIsLike operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } // get the queryable represented by the field Queryable queryableProperty = Queryable.UNKNOWN; try { queryableProperty = Queryable.valueOf(propertyNameLocal.toUpperCase()); } catch (IllegalArgumentException ex) { throw new CSWFilterException("Unknown queryable: " + propertyName); } // get the value of the field if (pil.getLiteral() != null && pil.getLiteral() != null) { // format the value by replacing the specified special char by // the Lucene special char String value = pil.getLiteral(); if (pil.getWildCard() != null) { value = value.replace(pil.getWildCard(), "*"); } if (pil.getSingleChar() != null) { value = value.replace(pil.getSingleChar(), "?"); } if (pil.getEscapeChar() != null) { value = value.replace(pil.getEscapeChar(), "\\"); } // for a date remove the time zone if (queryableProperty.getType() instanceof Date) { value = value.replace("Z", ""); } response.append(this.maskPhrase(value)); } else { throw new CSWFilterException("Missing literal parameter for propertyIsLike operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } } else if (comparisonOps instanceof PropertyIsNullType) { PropertyIsNullType pin = (PropertyIsNullType) comparisonOps; // get the field if (pin.getPropertyName() != null) { response.append(this.removePrefix(pin.getPropertyName().getContent().toLowerCase())).append(':') .append("null"); } else { throw new CSWFilterException("Missing propertyName parameter for propertyIsNull operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } } else if (comparisonOps instanceof PropertyIsBetweenType) { // TODO PropertyIsBetweenType throw new UnsupportedOperationException("Not supported yet."); } else if (comparisonOps instanceof BinaryComparisonOpType) { BinaryComparisonOpType bc = (BinaryComparisonOpType) comparisonOps; String propertyName = bc.getPropertyName(); String propertyNameLocal = this.removePrefix(propertyName); String literal = bc.getLiteral().getStringValue(); String operator = comparisonOpsEl.getName().getLocalPart(); if (propertyName == null || literal == null) { throw new CSWFilterException( "Missing propertyName or literal parameter for binary comparison operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } else { // get the queryable represented by the field Queryable queryableProperty = Queryable.UNKNOWN; try { queryableProperty = Queryable.valueOf(propertyNameLocal.toUpperCase()); } catch (IllegalArgumentException ex) { throw new CSWFilterException("Unknown queryable: " + propertyName); } QueryableType queryableType = queryableProperty.getType(); propertyNameLocal = propertyNameLocal.toLowerCase(); // property == value -> property:"value" if (operator.equals("PropertyIsEqualTo")) { // add '*' to date fields to return also parts of the Dates AND to disable analyzing of the date field if (queryableType instanceof Date && !literal.endsWith("*")) { literal = literal.concat("*"); } response.append(propertyNameLocal).append(":").append(this.maskPhrase(literal)); } // property != value -> metafile:doc NOT property:"value" else if (operator.equals("PropertyIsNotEqualTo")) { response.append(defaultField).append(" NOT "); response.append(propertyNameLocal).append(":").append(this.maskPhrase(literal)); } // property >= value -> property:[value UPPER_BOUND] else if (operator.equals("PropertyIsGreaterThanOrEqualTo")) { if (queryableType instanceof Date) { literal = literal.replace("Z", ""); } response.append(propertyNameLocal).append(":[").append(literal).append(' ') .append(queryableType.getUpperBound()).append("]"); } // property > value -> property:{value UPPER_BOUND} else if (operator.equals("PropertyIsGreaterThan")) { if (queryableType instanceof Date) { literal = literal.replace("Z", ""); } response.append(propertyNameLocal).append(":{").append(literal).append(' ') .append(queryableType.getUpperBound()).append("}"); } // property < value -> property:{LOWER_BOUND value} else if (operator.equals("PropertyIsLessThan")) { if (queryableType instanceof Date) { literal = literal.replace("Z", ""); } response.append(propertyNameLocal).append(":{").append(queryableType.getLowerBound()) .append(' ').append(literal).append("}"); } // property <= value -> property:[LOWER_BOUND value] else if (operator.equals("PropertyIsLessThanOrEqualTo")) { if (queryableType instanceof Date) { literal = literal.replace("Z", ""); } response.append(propertyNameLocal).append(":[").append(queryableType.getLowerBound()) .append(' ').append(literal).append("]"); } else { throw new CSWFilterException("Unkwnow comparison operator: " + operator, INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } } } return response.toString(); }
From source file:be.fedict.eid.tsl.TrustService.java
public void addOIDForQCSSCDStatusAsInCert(String oid, String description) { TSPServiceInformationType tspServiceInformation = this.tspService.getServiceInformation(); ExtensionsListType extensionsList = tspServiceInformation.getServiceInformationExtensions(); if (null == extensionsList) { extensionsList = this.objectFactory.createExtensionsListType(); tspServiceInformation.setServiceInformationExtensions(extensionsList); }// ww w. j a v a2 s .c om List<ExtensionType> extensions = extensionsList.getExtension(); for (ExtensionType extension : extensions) { if (false == extension.isCritical()) { continue; } List<Object> extensionContent = extension.getContent(); for (Object extensionObject : extensionContent) { JAXBElement<?> extensionElement = (JAXBElement<?>) extensionObject; QName extensionName = extensionElement.getName(); LOG.debug("extension name: " + extensionName); if (qualifiersName.equals(extensionName)) { LOG.debug("extension found"); QualificationsType qualifications = (QualificationsType) extensionElement.getValue(); List<QualificationElementType> qualificationElements = qualifications.getQualificationElement(); for (QualificationElementType qualificationElement : qualificationElements) { QualifiersType qualifiers = qualificationElement.getQualifiers(); List<QualifierType> qualifierList = qualifiers.getQualifier(); boolean qcSscdStatusAsInCertQualifier = false; for (QualifierType qualifier : qualifierList) { if (QC_SSCD_STATUS_AS_IN_CERT_QUALIFIER_URI.equals(qualifier.getUri())) { qcSscdStatusAsInCertQualifier = true; } } if (qcSscdStatusAsInCertQualifier) { CriteriaListType criteriaList = qualificationElement.getCriteriaList(); List<PoliciesListType> policySet = criteriaList.getPolicySet(); PoliciesListType policiesList = this.eccObjectFactory.createPoliciesListType(); policySet.add(policiesList); ObjectIdentifierType objectIdentifier = this.xadesObjectFactory .createObjectIdentifierType(); IdentifierType identifier = this.xadesObjectFactory.createIdentifierType(); identifier.setValue(oid); objectIdentifier.setIdentifier(identifier); if (null != description) { objectIdentifier.setDescription(description); } policiesList.getPolicyIdentifier().add(objectIdentifier); return; } } } } } ExtensionType extension = this.objectFactory.createExtensionType(); extension.setCritical(true); extensions.add(extension); QualificationsType qualifications = this.eccObjectFactory.createQualificationsType(); extension.getContent().add(this.eccObjectFactory.createQualifications(qualifications)); List<QualificationElementType> qualificationElements = qualifications.getQualificationElement(); QualificationElementType qualificationElement = this.eccObjectFactory.createQualificationElementType(); qualificationElements.add(qualificationElement); QualifiersType qualifiers = this.eccObjectFactory.createQualifiersType(); List<QualifierType> qualifierList = qualifiers.getQualifier(); QualifierType qcSscdStatusInCertqualifier = this.eccObjectFactory.createQualifierType(); qualifierList.add(qcSscdStatusInCertqualifier); qcSscdStatusInCertqualifier.setUri(QC_SSCD_STATUS_AS_IN_CERT_QUALIFIER_URI); qualificationElement.setQualifiers(qualifiers); CriteriaListType criteriaList = this.eccObjectFactory.createCriteriaListType(); qualificationElement.setCriteriaList(criteriaList); criteriaList.setAssert("atLeastOne"); List<PoliciesListType> policySet = criteriaList.getPolicySet(); PoliciesListType policiesList = this.eccObjectFactory.createPoliciesListType(); policySet.add(policiesList); ObjectIdentifierType objectIdentifier = this.xadesObjectFactory.createObjectIdentifierType(); IdentifierType identifier = this.xadesObjectFactory.createIdentifierType(); identifier.setValue(oid); objectIdentifier.setDescription(description); objectIdentifier.setIdentifier(identifier); policiesList.getPolicyIdentifier().add(objectIdentifier); }
From source file:be.fedict.eid.tsl.TrustService.java
public void addOIDForQCForLegalPerson(String oid, boolean noRoot) { TSPServiceInformationType tspServiceInformation = this.tspService.getServiceInformation(); ExtensionsListType extensionsList = tspServiceInformation.getServiceInformationExtensions(); if (null == extensionsList) { extensionsList = this.objectFactory.createExtensionsListType(); tspServiceInformation.setServiceInformationExtensions(extensionsList); }/* w w w . ja v a 2s . c o m*/ List<ExtensionType> extensions = extensionsList.getExtension(); for (ExtensionType extension : extensions) { if (false == extension.isCritical()) { continue; } List<Object> extensionContent = extension.getContent(); for (Object extensionObject : extensionContent) { JAXBElement<?> extensionElement = (JAXBElement<?>) extensionObject; QName extensionName = extensionElement.getName(); LOG.debug("extension name: " + extensionName); if (qualifiersName.equals(extensionName)) { LOG.debug("extension found"); QualificationsType qualifications = (QualificationsType) extensionElement.getValue(); List<QualificationElementType> qualificationElements = qualifications.getQualificationElement(); for (QualificationElementType qualificationElement : qualificationElements) { QualifiersType qualifiers = qualificationElement.getQualifiers(); List<QualifierType> qualifierList = qualifiers.getQualifier(); for (QualifierType qualifier : qualifierList) { if (QC_FOR_LEGAL_PERSON_QUALIFIER_URI.equals(qualifier.getUri())) { CriteriaListType criteriaList = qualificationElement.getCriteriaList(); List<PoliciesListType> policySet = criteriaList.getPolicySet(); PoliciesListType policiesList = this.eccObjectFactory.createPoliciesListType(); policySet.add(policiesList); ObjectIdentifierType objectIdentifier = this.xadesObjectFactory .createObjectIdentifierType(); IdentifierType identifier = this.xadesObjectFactory.createIdentifierType(); identifier.setValue(oid); objectIdentifier.setIdentifier(identifier); policiesList.getPolicyIdentifier().add(objectIdentifier); return; } } } } } } ExtensionType extension = this.objectFactory.createExtensionType(); extension.setCritical(true); extensions.add(extension); QualificationsType qualifications = this.eccObjectFactory.createQualificationsType(); extension.getContent().add(this.eccObjectFactory.createQualifications(qualifications)); List<QualificationElementType> qualificationElements = qualifications.getQualificationElement(); QualificationElementType qualificationElement = this.eccObjectFactory.createQualificationElementType(); qualificationElements.add(qualificationElement); QualifiersType qualifiers = this.eccObjectFactory.createQualifiersType(); List<QualifierType> qualifierList = qualifiers.getQualifier(); QualifierType qcForLegalPersonqualifier = this.eccObjectFactory.createQualifierType(); qualifierList.add(qcForLegalPersonqualifier); qcForLegalPersonqualifier.setUri(QC_FOR_LEGAL_PERSON_QUALIFIER_URI); qualificationElement.setQualifiers(qualifiers); CriteriaListType criteriaList = this.eccObjectFactory.createCriteriaListType(); qualificationElement.setCriteriaList(criteriaList); criteriaList.setAssert("atLeastOne"); List<PoliciesListType> policySet = criteriaList.getPolicySet(); PoliciesListType policiesList = this.eccObjectFactory.createPoliciesListType(); policySet.add(policiesList); ObjectIdentifierType objectIdentifier = this.xadesObjectFactory.createObjectIdentifierType(); IdentifierType identifier = this.xadesObjectFactory.createIdentifierType(); identifier.setValue(oid); objectIdentifier.setIdentifier(identifier); policiesList.getPolicyIdentifier().add(objectIdentifier); /*if (noRoot == false) { AdditionalServiceInformationType additionalServiceInformation = this.objectFactory .createAdditionalServiceInformationType(); NonEmptyMultiLangURIType additionalServiceInformationUri = this.objectFactory .createNonEmptyMultiLangURIType(); additionalServiceInformationUri.setLang("en"); additionalServiceInformationUri .setValue("http://uri.etsi.org/TrstSvc/TrustedList/SvcInfoExt/RootCA-QC"); additionalServiceInformation .setURI(additionalServiceInformationUri); extension .getContent() .add(this.objectFactory .createAdditionalServiceInformation(additionalServiceInformation)); }*/ }
From source file:be.e_contract.dssp.client.DigitalSignatureServiceClient.java
/** * Uploads a given document to the DSS in preparation of a signing ceremony. * //from w w w. jav a 2 s .c om * @param mimetype * the mime-type of the document. * @param signatureType * the optional signature type. If none is provided, the DSS will * select the most appropriate. * @param data * the data bytes of the document. * @param useAttachments * set to <code>true</code> to use SOAP attachments. * @return a session object. Should be saved within the HTTP session for * later usage. * @throws UnsupportedDocumentTypeException * @throws UnsupportedSignatureTypeException * @throws IncorrectSignatureTypeException * @throws AuthenticationRequiredException */ public DigitalSignatureServiceSession uploadDocument(String mimetype, SignatureType signatureType, byte[] data, boolean useAttachments) throws UnsupportedDocumentTypeException, UnsupportedSignatureTypeException, IncorrectSignatureTypeException, AuthenticationRequiredException { SignRequest signRequest = this.objectFactory.createSignRequest(); signRequest.setProfile(DigitalSignatureServiceConstants.PROFILE); InputDocuments inputDocuments = this.objectFactory.createInputDocuments(); signRequest.setInputDocuments(inputDocuments); DocumentType document = addDocument(mimetype, data, useAttachments, inputDocuments); AnyType optionalInputs = this.objectFactory.createAnyType(); signRequest.setOptionalInputs(optionalInputs); optionalInputs.getAny().add( this.objectFactory.createAdditionalProfile(DigitalSignatureServiceConstants.DSS_ASYNC_PROFILE)); RequestSecurityTokenType requestSecurityToken = this.wstObjectFactory.createRequestSecurityTokenType(); optionalInputs.getAny().add(this.wstObjectFactory.createRequestSecurityToken(requestSecurityToken)); requestSecurityToken.getAny().add( this.wstObjectFactory.createTokenType(DigitalSignatureServiceConstants.WS_SEC_CONV_TOKEN_TYPE)); requestSecurityToken.getAny().add(this.wstObjectFactory .createRequestType(DigitalSignatureServiceConstants.WS_TRUST_ISSUE_REQUEST_TYPE)); EntropyType entropy = this.wstObjectFactory.createEntropyType(); BinarySecretType binarySecret = this.wstObjectFactory.createBinarySecretType(); binarySecret.setType(DigitalSignatureServiceConstants.WS_TRUST_BINARY_SECRET_NONCE_TYPE); byte[] nonce = new byte[256 / 8]; this.secureRandom.setSeed(System.currentTimeMillis()); this.secureRandom.nextBytes(nonce); binarySecret.setValue(nonce); entropy.getAny().add(this.wstObjectFactory.createBinarySecret(binarySecret)); requestSecurityToken.getAny().add(this.wstObjectFactory.createEntropy(entropy)); requestSecurityToken.getAny().add(this.wstObjectFactory.createKeySize(256L)); SignaturePlacement signaturePlacement = this.objectFactory.createSignaturePlacement(); optionalInputs.getAny().add(signaturePlacement); signaturePlacement.setCreateEnvelopedSignature(true); signaturePlacement.setWhichDocument(document); if (null != signatureType) { optionalInputs.getAny().add(this.objectFactory.createSignatureType(signatureType.getUri())); } String responseId = null; String securityTokenId = null; byte[] serverNonce = null; this.wsSecuritySOAPHandler.setCredentials(this.username, this.password); SignResponse signResponse = this.dssPort.sign(signRequest); Result result = signResponse.getResult(); String resultMajor = result.getResultMajor(); String resultMinor = result.getResultMinor(); if (false == DigitalSignatureServiceConstants.PENDING_RESULT_MAJOR.equals(resultMajor)) { if (DigitalSignatureServiceConstants.REQUESTER_ERROR_RESULT_MAJOR.equals(resultMajor)) { if (DigitalSignatureServiceConstants.UNSUPPORTED_MIME_TYPE_RESULT_MINOR.equals(resultMinor)) { throw new UnsupportedDocumentTypeException(); } else if (DigitalSignatureServiceConstants.UNSUPPORTED_SIGNATURE_TYPE_RESULT_MINOR .equals(resultMinor)) { throw new UnsupportedSignatureTypeException(); } else if (DigitalSignatureServiceConstants.INCORRECT_SIGNATURE_TYPE_RESULT_MINOR .equals(resultMinor)) { throw new IncorrectSignatureTypeException(); } else if (DigitalSignatureServiceConstants.AUTHENTICATION_REQUIRED_RESULT_MINOR .equals(resultMinor)) { throw new AuthenticationRequiredException(); } } throw new RuntimeException("not successfull: " + resultMajor + " " + resultMinor); } AnyType optionalOutputs = signResponse.getOptionalOutputs(); List<Object> optionalOutputsList = optionalOutputs.getAny(); for (Object optionalOutputsObject : optionalOutputsList) { LOG.debug("optional outputs object type: " + optionalOutputsObject.getClass().getName()); if (optionalOutputsObject instanceof JAXBElement) { JAXBElement jaxbElement = (JAXBElement) optionalOutputsObject; QName name = jaxbElement.getName(); LOG.debug("value name: " + name); if (DigitalSignatureServiceConstants.ASYNC_RESPONSEID_QNAME.equals(name)) { responseId = (String) jaxbElement.getValue(); LOG.debug("async:ResponseID = " + responseId); } else if (jaxbElement.getValue() instanceof RequestSecurityTokenResponseCollectionType) { RequestSecurityTokenResponseCollectionType requestSecurityTokenResponseCollection = (RequestSecurityTokenResponseCollectionType) jaxbElement .getValue(); List<RequestSecurityTokenResponseType> rstsList = requestSecurityTokenResponseCollection .getRequestSecurityTokenResponse(); if (rstsList.size() == 1) { RequestSecurityTokenResponseType rstr = rstsList.get(0); for (Object rstrObject : rstr.getAny()) { JAXBElement rstrElement = (JAXBElement) rstrObject; if (rstrElement.getValue() instanceof RequestedSecurityTokenType) { RequestedSecurityTokenType requestedSecurityToken = (RequestedSecurityTokenType) rstrElement .getValue(); SecurityContextTokenType securityContextToken = ((JAXBElement<SecurityContextTokenType>) requestedSecurityToken .getAny()).getValue(); securityTokenId = ((JAXBElement<String>) securityContextToken.getAny().get(0)) .getValue(); LOG.debug("security token id: " + securityTokenId); } else if (rstrElement.getValue() instanceof EntropyType) { EntropyType serverEntropy = (EntropyType) rstrElement.getValue(); BinarySecretType serverBinarySecret = ((JAXBElement<BinarySecretType>) serverEntropy .getAny().get(0)).getValue(); serverNonce = serverBinarySecret.getValue(); } } } } } } if (null == responseId) { throw new RuntimeException("missing async:ResponseID in response"); } if (null == securityTokenId) { throw new RuntimeException("missing WS-SecureConversation token identifier"); } if (null == serverNonce) { throw new RuntimeException("missing Nonce in response"); } P_SHA1 p_SHA1 = new P_SHA1(); byte[] key; try { key = p_SHA1.createKey(nonce, serverNonce, 0, 256 / 8); } catch (ConversationException e) { throw new RuntimeException("error generating P_SHA1 key"); } Element securityTokenElement = this.wsTrustSOAPHandler.getRequestedSecurityToken(); DigitalSignatureServiceSession digitalSignatureServiceSession = new DigitalSignatureServiceSession( responseId, securityTokenId, key, securityTokenElement); return digitalSignatureServiceSession; }
From source file:eu.europa.ec.markt.dss.report.Tsl2PdfExporter.java
private void printExtension(ExtensionType extension, Document document) throws DocumentException { addTitle("Extension (critical: " + extension.isCritical() + ")", title3Font, Paragraph.ALIGN_LEFT, 0, 0, document);/*from w w w . ja v a 2 s . c o m*/ List<Object> contentList = extension.getContent(); for (Object content : contentList) { LOG.debug("extension content: " + content.getClass().getName()); if (content instanceof JAXBElement<?>) { JAXBElement<?> element = (JAXBElement<?>) content; LOG.debug("QName: " + element.getName()); if (false == ADDITIONAL_SERVICE_INFORMATION_QNAME.equals(element.getName())) { continue; } addTitle("Additional service information", title4Font, Paragraph.ALIGN_LEFT, 0, 0, document); AdditionalServiceInformationType additionalServiceInformation = (AdditionalServiceInformationType) element .getValue(); LOG.debug("information value: " + additionalServiceInformation.getInformationValue()); NonEmptyMultiLangURIType multiLangUri = additionalServiceInformation.getURI(); LOG.debug("URI : " + multiLangUri.getValue() + " (language: " + multiLangUri.getLang() + ")"); document.add(new Paragraph( multiLangUri.getValue() .substring(multiLangUri.getValue().indexOf("SvcInfoExt/") + "SvcInfoExt/".length()), this.valueFont)); } else if (content instanceof Element) { addTitle("Qualifications", title4Font, Paragraph.ALIGN_LEFT, 0, 0, document); Element element = (Element) content; LOG.debug("element namespace: " + element.getNamespaceURI()); LOG.debug("element name: " + element.getLocalName()); if ("http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#" .equals(element.getNamespaceURI()) && "Qualifications".equals(element.getLocalName())) { try { QualificationsType qualifications = unmarshallQualifications(element); List<QualificationElementType> qualificationElements = qualifications .getQualificationElement(); for (QualificationElementType qualificationElement : qualificationElements) { QualifiersType qualifiers = qualificationElement.getQualifiers(); List<QualifierType> qualifierList = qualifiers.getQualifier(); for (QualifierType qualifier : qualifierList) { document.add(new Paragraph( "Qualifier: " + qualifier.getUri().substring( qualifier.getUri().indexOf("SvcInfoExt/") + "SvcInfoExt/".length()), this.valueFont)); } CriteriaListType criteriaList = qualificationElement.getCriteriaList(); String description = criteriaList.getDescription(); if (null != description) { document.add(new Paragraph("Criterial List Description", this.labelFont)); document.add(new Paragraph(description, this.valueFont)); } document.add(new Paragraph("Assert: " + criteriaList.getAssert(), this.valueFont)); List<PoliciesListType> policySet = criteriaList.getPolicySet(); for (PoliciesListType policiesList : policySet) { List<ObjectIdentifierType> oids = policiesList.getPolicyIdentifier(); for (ObjectIdentifierType oid : oids) { document.add(new Paragraph("Policy OID: " + oid.getIdentifier().getValue(), this.valueFont)); } } } } catch (JAXBException e) { LOG.error("JAXB error: " + e.getMessage(), e); } } } } }
From source file:de.ingrid.interfaces.csw.domain.filter.impl.LuceneFilterParser.java
/** * Build a piece of Lucene query with the specified Spatial filter. * * @param spatialOpsEl//w ww . jav a2s.c om * @return Filter * @throws CSWFilterException */ protected Filter processSpatialOperator(JAXBElement<? extends SpatialOpsType> spatialOpsEl) throws CSWFilterException { LuceneOGCFilter spatialfilter = null; SpatialOpsType spatialOps = spatialOpsEl.getValue(); if (spatialOps instanceof BBOXType) { BBOXType bbox = (BBOXType) spatialOps; String propertyName = bbox.getPropertyName(); String crsName = bbox.getSRS(); // make sure we DO have a valid srs // joachim@wemove.com at 21.05.2012 if (crsName == null || crsName.length() == 0) { crsName = "EPSG:4326"; } // verify that all the parameters are specified if (propertyName == null) { throw new CSWFilterException("Missing propertyName parameter for BBOX operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } else if (!propertyName.contains("BoundingBox")) { throw new CSWFilterException("The propertyName parameter for BBOX operator is not a BoundingBox.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } if (bbox.getEnvelope() == null && bbox.getEnvelopeWithTimePeriod() == null) { throw new CSWFilterException("Missing envelope parameter for BBOX operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } // transform the EnvelopeEntry in GeneralEnvelope spatialfilter = LuceneOGCFilter.wrap(FF.bbox(LuceneOGCFilter.GEOMETRY_PROPERTY, bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), crsName)); } else if (spatialOps instanceof DistanceBufferType) { DistanceBufferType dist = (DistanceBufferType) spatialOps; double distance = dist.getDistance(); String units = dist.getDistanceUnits(); JAXBElement<?> geomEl = dist.getAbstractGeometry(); String operator = spatialOpsEl.getName().getLocalPart(); // verify that all the parameters are specified if (dist.getPropertyName() == null) { throw new CSWFilterException("Missing propertyName parameter for distanceBuffer operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } if (units == null) { throw new CSWFilterException("Missing units parameter for distanceBuffer operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } if (geomEl == null || geomEl.getValue() == null) { throw new CSWFilterException("Missing geometry object for distanceBuffer operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } Object gml = geomEl.getValue(); Geometry geometry = null; String crsName = null; // transform the GML envelope into JTS polygon try { if (gml instanceof PointType) { PointType gmlPoint = (PointType) gml; crsName = gmlPoint.getSrsName(); geometry = GeometrytoJTS.toJTS(gmlPoint); } else if (gml instanceof LineStringType) { LineStringType gmlLine = (LineStringType) gml; crsName = gmlLine.getSrsName(); geometry = GeometrytoJTS.toJTS(gmlLine); } else if (gml instanceof EnvelopeType) { EnvelopeType gmlEnvelope = (EnvelopeType) gml; crsName = gmlEnvelope.getSrsName(); geometry = GeometrytoJTS.toJTS(gmlEnvelope); } if (operator.equals("DWithin")) { spatialfilter = LuceneOGCFilter.wrap( FF.dwithin(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(geometry), distance, units)); } else if (operator.equals("Beyond")) { spatialfilter = LuceneOGCFilter.wrap( FF.beyond(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(geometry), distance, units)); } else { throw new CSWFilterException("Unknow DistanceBuffer operator: " + operator, INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } } catch (NoSuchAuthorityCodeException e) { throw new CSWFilterException(UNKNOW_CRS_ERROR_MSG + crsName, INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } catch (FactoryException e) { throw new CSWFilterException(FACTORY_BBOX_ERROR_MSG + e.getMessage(), INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } catch (IllegalArgumentException e) { throw new CSWFilterException(INCORRECT_BBOX_DIM_ERROR_MSG + e.getMessage(), INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } } else if (spatialOps instanceof BinarySpatialOpType) { BinarySpatialOpType binSpatial = (BinarySpatialOpType) spatialOps; String propertyName = null; String operator = spatialOpsEl.getName().getLocalPart(); operator = operator.toUpperCase(); Object gmlGeometry = null; // the propertyName if (binSpatial.getPropertyName() != null && binSpatial.getPropertyName().getValue() != null) { PropertyNameType p = binSpatial.getPropertyName().getValue(); propertyName = p.getContent(); } // geometric object: envelope if (binSpatial.getEnvelope() != null && binSpatial.getEnvelope().getValue() != null) { gmlGeometry = binSpatial.getEnvelope().getValue(); } if (binSpatial.getAbstractGeometry() != null && binSpatial.getAbstractGeometry().getValue() != null) { AbstractGeometryType ab = binSpatial.getAbstractGeometry().getValue(); // geometric object: point if (ab instanceof PointType) { gmlGeometry = ab; } // geometric object: Line else if (ab instanceof LineStringType) { gmlGeometry = ab; } else if (ab == null) { throw new IllegalArgumentException("null value in BinarySpatialOp type"); } else { throw new IllegalArgumentException( "unknow BinarySpatialOp type: " + ab.getClass().getSimpleName()); } } if (propertyName == null && gmlGeometry == null) { throw new CSWFilterException( "Missing propertyName or geometry parameter for binary spatial operator.", INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } SpatialFilterType filterType = null; try { filterType = SpatialFilterType.valueOf(operator); } catch (IllegalArgumentException ex) { log.error("Unknow spatial filter type"); } if (filterType == null) { throw new CSWFilterException("Unknow FilterType: " + operator, INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } String crsName = "undefined CRS"; try { Geometry filterGeometry = null; if (gmlGeometry instanceof EnvelopeType) { // transform the EnvelopeEntry in GeneralEnvelope EnvelopeType gmlEnvelope = (EnvelopeType) gmlGeometry; crsName = gmlEnvelope.getSrsName(); filterGeometry = GeometrytoJTS.toJTS(gmlEnvelope); } else if (gmlGeometry instanceof PointType) { PointType gmlPoint = (PointType) gmlGeometry; crsName = gmlPoint.getSrsName(); filterGeometry = GeometrytoJTS.toJTS(gmlPoint); } else if (gmlGeometry instanceof LineStringType) { LineStringType gmlLine = (LineStringType) gmlGeometry; crsName = gmlLine.getSrsName(); filterGeometry = GeometrytoJTS.toJTS(gmlLine); } int srid = SRIDGenerator.toSRID(crsName, Version.V1); filterGeometry.setSRID(srid); switch (filterType) { case CONTAINS: spatialfilter = LuceneOGCFilter .wrap(FF.contains(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case CROSSES: spatialfilter = LuceneOGCFilter .wrap(FF.crosses(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case DISJOINT: spatialfilter = LuceneOGCFilter .wrap(FF.disjoint(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case EQUALS: spatialfilter = LuceneOGCFilter .wrap(FF.equal(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case INTERSECTS: spatialfilter = LuceneOGCFilter .wrap(FF.intersects(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case OVERLAPS: spatialfilter = LuceneOGCFilter .wrap(FF.overlaps(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case TOUCHES: spatialfilter = LuceneOGCFilter .wrap(FF.touches(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; case WITHIN: spatialfilter = LuceneOGCFilter .wrap(FF.within(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; default: log.info("using default filter within"); spatialfilter = LuceneOGCFilter .wrap(FF.within(LuceneOGCFilter.GEOMETRY_PROPERTY, FF.literal(filterGeometry))); break; } } catch (NoSuchAuthorityCodeException e) { throw new CSWFilterException(UNKNOW_CRS_ERROR_MSG + crsName, INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } catch (FactoryException e) { throw new CSWFilterException(FACTORY_BBOX_ERROR_MSG + e.getMessage(), INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } catch (IllegalArgumentException e) { throw new CSWFilterException(INCORRECT_BBOX_DIM_ERROR_MSG + e.getMessage(), INVALID_PARAMETER_CODE, QUERY_CONSTRAINT_LOCATOR); } } return spatialfilter; }
From source file:com.catify.processengine.core.nodes.NodeFactoryImpl.java
/** * Gets the TBoundaryEvents by id from subprocesses (recursively). * * @param subProcessJaxb the jaxb sub process * @param activityNodeId the activity node id * @return the TBoundaryEvents from subprocesses *///from w w w . j a v a 2 s . co m private List<TFlowNode> getTBoundaryEventByIdFromSubprocess(TSubProcess subProcessJaxb, String activityNodeId) { List<TFlowNode> boundaryEventsJaxb = new ArrayList<TFlowNode>(); for (JAXBElement<? extends TFlowElement> flowElementJaxb : subProcessJaxb.getFlowElement()) { if (flowElementJaxb.getValue() instanceof TBoundaryEvent) { TBoundaryEvent boundaryEvent = (TBoundaryEvent) flowElementJaxb.getValue(); if (boundaryEvent.getAttachedToRef().getLocalPart().equals(activityNodeId)) { LOG.debug(String.format("Found Boundary Event Node with id ", boundaryEvent.getId())); boundaryEventsJaxb.add(boundaryEvent); } } else if (flowElementJaxb.getValue() instanceof TSubProcess) { boundaryEventsJaxb.addAll(getTBoundaryEventByIdFromSubprocess( (TSubProcess) flowElementJaxb.getValue(), activityNodeId)); } } return boundaryEventsJaxb; }
From source file:com.catify.processengine.core.nodes.NodeFactoryImpl.java
/** * Gets the boundary event nodes by the id of the node connected to. The information whether an activity binds a boundary event * or not is only available at the TBoundaryEvent. The TActivity does not have this information so we have to parse the * TProcess. //from ww w . j a v a 2s. c o m * * @param processJaxb the jaxb process * @param activityNodeId the node id of the element the boundary event is connected to * @return the boundary node that is attached */ private List<TFlowNode> getTBoundaryEventById(TProcess processJaxb, String activityNodeId) { List<TFlowNode> flowNodesJaxb = new ArrayList<TFlowNode>(); for (JAXBElement<? extends TFlowElement> flowElementJaxb : processJaxb.getFlowElement()) { if (flowElementJaxb.getValue() instanceof TBoundaryEvent) { TBoundaryEvent boundaryEvent = (TBoundaryEvent) flowElementJaxb.getValue(); if (boundaryEvent.getAttachedToRef().getLocalPart().equals(activityNodeId)) { LOG.debug(String.format("Found Boundary Event Node with id ", boundaryEvent.getId())); flowNodesJaxb.add(boundaryEvent); } } else if (flowElementJaxb.getValue() instanceof TSubProcess) { flowNodesJaxb.addAll(getTBoundaryEventByIdFromSubprocess((TSubProcess) flowElementJaxb.getValue(), activityNodeId)); } } if (flowNodesJaxb.size() == 0) { LOG.debug("There are no boundary events for node id " + activityNodeId); return null; } else { return flowNodesJaxb; } }
From source file:com.qpark.eip.core.spring.PayloadLogger.java
/** * {@link Message} to string./*from w w w. j a va 2 s .c om*/ * * @param message * the {@link Message}. * @return the {@link Message} as string. */ private String getMessage(final Message<?> message) { Object logMessage = this.expression.getValue(this.evaluationContext, message); if (JAXBElement.class.isInstance(logMessage)) { final JAXBElement<?> elem = (JAXBElement<?>) logMessage; try { if (Objects.nonNull(this.jaxb2Marshaller)) { final StringResult sw = new StringResult(); this.jaxb2Marshaller.marshal(logMessage, sw); logMessage = sw.toString(); } else { final Marshaller marshaller = this.getMarshaller(); if (Objects.nonNull(marshaller)) { final StringWriter sw = new StringWriter(); marshaller.marshal(logMessage, sw); logMessage = sw.toString(); } } } catch (final Exception e) { logMessage = elem.getValue(); } } else if (logMessage instanceof Throwable) { final StringWriter stringWriter = new StringWriter(); if (logMessage instanceof AggregateMessageDeliveryException) { stringWriter.append(((Throwable) logMessage).getMessage()); for (final Exception exception : (List<? extends Exception>) ((AggregateMessageDeliveryException) logMessage) .getAggregatedExceptions()) { exception.printStackTrace(new PrintWriter(stringWriter, true)); } } else { ((Throwable) logMessage).printStackTrace(new PrintWriter(stringWriter, true)); } logMessage = stringWriter.toString(); } final StringBuffer sb = new StringBuffer(1024); sb.append(MessageHeaders.ID).append("=").append(message.getHeaders().getId()); final Object correlationId = new IntegrationMessageHeaderAccessor(message).getCorrelationId(); if (correlationId != null) { sb.append(", "); sb.append(IntegrationMessageHeaderAccessor.CORRELATION_ID).append("=").append(correlationId); } sb.append("\n"); sb.append(String.valueOf(logMessage)); return sb.toString(); }