List of usage examples for javax.xml.datatype DatatypeFactory newInstance
public static DatatypeFactory newInstance() throws DatatypeConfigurationException
From source file:org.orcid.persistence.adapter.impl.Jpa2JaxbAdapterImpl.java
public Jpa2JaxbAdapterImpl() { try {//from w ww . j a v a2s . c o m datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { // We're in serious trouble and can't carry on throw new IllegalStateException("Cannot create new DatatypeFactory"); } }
From source file:org.orcid.pojo.ajaxForm.WorkForm.java
public WorkForm() { try {//ww w. j a va 2 s.co m datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { // We're in serious trouble and can't carry on throw new IllegalStateException("Cannot create new DatatypeFactory"); } }
From source file:org.orcid.utils.DateUtils.java
private static DatatypeFactory createDataTypeFactory() { DatatypeFactory dataTypeFactory; try {/* w w w. j av a 2s . co m*/ dataTypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException("Couldn't create org.orcid.test.data type factory", e); } return dataTypeFactory; }
From source file:org.oscarehr.phr.model.PHRDocument.java
protected static XMLGregorianCalendar dateToXmlGregorianCalendar(Date date) throws DatatypeConfigurationException { DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTime(date);//from w ww . j av a 2 s.c o m return datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); }
From source file:org.oscarehr.web.OcanReportUIBean.java
public static int sendSubmissionToIAR(OCANv2SubmissionFileDocument submissionDoc) { if (submissionDoc.getOCANv2SubmissionFile().getOCANv2SubmissionRecordArray().length == 0) { logger.info("No records to send"); return 0; }//from ww w.j ava 2 s. c o m if (submissionDoc.getOCANv2SubmissionFile().getOCANv2SubmissionRecordArray().length > 500) { logger.warn("over 500 to send..will probably fail"); } //serialize the data ByteArrayOutputStream sos = new ByteArrayOutputStream(); try { XmlOptions options = new XmlOptions(); options.setUseDefaultNamespace(); //options.setSavePrettyPrint(); options.setCharacterEncoding("UTF-8"); Map<String, String> implicitNamespaces = new HashMap<String, String>(); implicitNamespaces.put("", "http://oscarehr.org/ocan"); options.setSaveImplicitNamespaces(implicitNamespaces); submissionDoc.save(sos, options); } catch (IOException e) { logger.error("Error:", e); return 0; } //generate the envelope IARSubmission is = new IARSubmission(); is.setVersion("2.0"); Application application = new Application(); application.setId("1"); application.setName("OSCAR"); application.setVendor("CAISI"); application.setVersion("10.06"); Organization org = new Organization(); //String orgId = OscarProperties.getInstance().getProperty("ocan.iar.org.id"); String orgId = LoggedInInfo.loggedInInfo.get().currentFacility.getOcanServiceOrgNumber(); org.setId(orgId); org.setName(LoggedInInfo.loggedInInfo.get().currentFacility.getName()); XMLGregorianCalendar cal = null; try { GregorianCalendar gc = new GregorianCalendar(); DatatypeFactory dtf = DatatypeFactory.newInstance(); cal = dtf.newXMLGregorianCalendar(gc); } catch (Exception e) { logger.error("Error:", e); } TransmissionHeaderType th = new TransmissionHeaderType(); th.setApplication(application); th.setAssessmentType("OCAN"); th.setExportTimestamp(cal); th.setOrganization(org); th.setSubmissionId("1"); is.setTransmissionHeader(th); Text t = new Text(); t.setValue(sos.toString()); Record r = new Record(); r.setRecordType("Assessment"); r.setMimeType("text/xml"); r.setText(t); r.setVersion("2.0.6"); Record consent = new Record(); consent.setVersion("1.0"); consent.setMimeType("text/xml"); consent.setRecordType("Consent"); ConsentSubmission cs = ConsentSubmission.Factory.newInstance(); //cs.getDomNode().getAttributes(). OCANv2SubmissionRecord[] submissionRecords = submissionDoc.getOCANv2SubmissionFile() .getOCANv2SubmissionRecordArray(); for (OCANv2SubmissionRecord submissionRecord : submissionRecords) { String assessmentId = submissionRecord.getAssessmentID(); String assessmentId_noPrefix = assessmentId; String idPrefix = OscarProperties.getInstance().getProperty("ocan.iar.idPrefix"); if (!StringUtils.isBlank(idPrefix)) { assessmentId_noPrefix = assessmentId.replace(idPrefix, ""); } OcanStaffForm staffForm = ocanStaffFormDao.findLatestByAssessmentId( LoggedInInfo.loggedInInfo.get().currentFacility.getId(), Integer.parseInt(assessmentId_noPrefix)); ConsentDirective cd = cs.addNewConsentDirective(); cd.setId(assessmentId); cd.setType(CdConsentDirectiveType.ASSESSMENT); PersonIdentification pi = PersonIdentification.Factory.newInstance(); SourceSystem ss = pi.addNewSourceSystem(); ss.setId(application.getId()); ss.setType(SourceSystem.Type.APPLICATION_ID); PersonIdentificationDocument.PersonIdentification.Organization o = pi.addNewOrganization(); o.setId(orgId); o.setName(LoggedInInfo.loggedInInfo.get().currentFacility.getName()); pi.setPersonId(submissionRecord.getClientRecord().getClientID().getOrgClientID()); cd.setPersonIdentification(pi); ApplyTo at = ApplyTo.Factory.newInstance(); ApplyToDocument.ApplyTo.Assessment a = at.addNewAssessment(); a.setAssessmentId(assessmentId); a.setAssessmentType(AssessmentType.OCAN); at.setAssessment(a); cd.setApplyTo(at); CdConsentActionType actionType = CdConsentActionType.Factory.newInstance(); String c = staffForm.getConsent(); if (c.equals("GRANT")) { actionType.setAccessLevel(CdConsentActionType.AccessLevel.GRANT); } else if (c.equals("DENY")) { actionType.setAccessLevel(CdConsentActionType.AccessLevel.DENY); } else if (c.equals("NOT_SPECIFIED")) { actionType.setAccessLevel(CdConsentActionType.AccessLevel.UNSUPPORTED); } else { actionType.setAccessLevel(CdConsentActionType.AccessLevel.GRANT); } cd.setDirective(actionType); RecordedByInfo rbi = RecordedByInfo.Factory.newInstance(); rbi.setNameOrUserID(staffForm.getProviderName()); Calendar cal2 = Calendar.getInstance(); cal2.setTime(staffForm.getCreated()); rbi.setTimeRecorded(cal2); cd.setRecordedByInfo(rbi); } Text t2 = new Text(); String cs1 = cs.toString().replace("<xml-fragment xmlns:ccim=\"http://www.ehealthontario.ca/CCIM\">", ""); String cs2 = cs1.replace("</xml-fragment>", ""); String cs3 = cs2.replaceAll("ccim:", ""); t2.setValue( "<ConsentSubmission xsi:schemaLocation=\"http://www.ehealthontario.ca/CCIMConsentSubmission-1.0.xsd\" xmlns=\"http://www.ehealthontario.ca/CCIM\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + cs3 + "</ConsentSubmission>"); consent.setText(t2); SubmissionContent sc = new SubmissionContent(); sc.getRecord().add(r); sc.getRecord().add(consent); is.setSubmissionContent(sc); //create the log entry and get the submission id OcanSubmissionLog log = new OcanSubmissionLog(); log.setSubmitDateTime(new Date()); logDao.persist(log); if (log.getId() == null) { logger.info("log has no id!"); return 0; } is.getTransmissionHeader().setSubmissionId(String.valueOf(log.getId())); logger.info("the submissionId is " + log.getId()); try { String user = OscarProperties.getInstance().getProperty("ocan.iar.user"); String url = OscarProperties.getInstance().getProperty("ocan.iar.url"); if (url == null || url.length() == 0) { //validation environment url = "https://iarvt.ccim.on.ca/iarws-2.0/services/SubmissionService"; } SubmissionService service = new SubmissionService(); SubmissionPortType port = service.getSubmissionPort(); ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); CxfClientUtils.configureClientConnection(port); CxfClientUtils.configureWSSecurity(port, user, new OcanReportUIBean()); CxfClientUtils.configureLogging(port); SubmissionResultType result = port.submitAssessment(is); Result res = result.getResult(); logger.info("result message:" + result.getDetailMessage()); logger.info("error code:" + result.getErrorCode()); logger.info("result:" + res.isValue()); logger.info("transactionId=" + res.getTransactionId()); log.setResult(String.valueOf(res.isValue())); log.setTransactionId(res.getTransactionId()); log.setResultMessage(result.getDetailMessage()); } catch (Exception e) { logger.error("Error:", e); return 0; } logDao.merge(log); if (log.getResult() != null && log.getResult().equals("true")) { for (int x = 0; x < submissionDoc.getOCANv2SubmissionFile() .getOCANv2SubmissionRecordArray().length; x++) { OCANv2SubmissionRecord subRec = submissionDoc.getOCANv2SubmissionFile() .getOCANv2SubmissionRecordArray()[x]; String id = subRec.getAssessmentID(); //OcanStaffForm staffForm = ocanStaffFormDao.find(Integer.parseInt(id)); // assessment ID is not form ID. String assessmentId_noPrefix = id; String idPrefix = OscarProperties.getInstance().getProperty("ocan.iar.idPrefix"); if (!StringUtils.isBlank(idPrefix)) { assessmentId_noPrefix = id.replace(idPrefix, ""); } OcanStaffForm staffForm = ocanStaffFormDao.findLatestByAssessmentId( LoggedInInfo.loggedInInfo.get().currentFacility.getId(), Integer.valueOf(assessmentId_noPrefix)); staffForm.setSubmissionId(log.getId()); ocanStaffFormDao.merge(staffForm); } } return log.getId(); }
From source file:org.oscarehr.web.OcanReportUIBean.java
public static void writeExportIar_forOneOcanType(OutputStream out, String ocanType) { OCANv2SubmissionFileDocument submissionDoc = generateOCANSubmission(ocanType); if (submissionDoc.getOCANv2SubmissionFile().getOCANv2SubmissionRecordArray().length == 0) { logger.info("No records to send"); return;//from w ww . j a v a2 s . co m } if (submissionDoc.getOCANv2SubmissionFile().getOCANv2SubmissionRecordArray().length > 500) { logger.warn("over 500 to send..will probably fail"); } //serialize the data ByteArrayOutputStream sos = new ByteArrayOutputStream(); try { XmlOptions options = new XmlOptions(); options.setUseDefaultNamespace(); //options.setSavePrettyPrint(); options.setCharacterEncoding("UTF-8"); Map<String, String> implicitNamespaces = new HashMap<String, String>(); implicitNamespaces.put("", "http://oscarehr.org/ocan"); options.setSaveImplicitNamespaces(implicitNamespaces); submissionDoc.save(sos, options); } catch (IOException e) { logger.error("Error:", e); return; } //generate the envelope IARSubmission is = new IARSubmission(); is.setVersion("1.1"); Application application = new Application(); application.setId("1"); application.setName("OSCAR"); application.setVendor("CAISI"); application.setVersion("10.06"); Organization org = new Organization(); //String orgId = OscarProperties.getInstance().getProperty("ocan.iar.org.id"); String orgId = LoggedInInfo.loggedInInfo.get().currentFacility.getOcanServiceOrgNumber(); org.setId(orgId); org.setName(LoggedInInfo.loggedInInfo.get().currentFacility.getName()); XMLGregorianCalendar cal = null; try { GregorianCalendar gc = new GregorianCalendar(); DatatypeFactory dtf = DatatypeFactory.newInstance(); cal = dtf.newXMLGregorianCalendar(gc); } catch (Exception e) { logger.error("Error:", e); } TransmissionHeaderType th = new TransmissionHeaderType(); th.setApplication(application); th.setAssessmentType("OCAN"); th.setExportTimestamp(cal); th.setOrganization(org); th.setSubmissionId("1"); is.setTransmissionHeader(th); Text t = new Text(); t.setValue(sos.toString()); Record r = new Record(); r.setRecordType("Assessment"); r.setMimeType("text/xml"); r.setText(t); SubmissionContent sc = new SubmissionContent(); sc.getRecord().add(r); is.setSubmissionContent(sc); //create the log entry and get the submission id OcanSubmissionLog log = new OcanSubmissionLog(); log.setSubmitDateTime(new Date()); logDao.persist(log); if (log.getId() == null) { logger.info("log has no id!"); return; } is.getTransmissionHeader().setSubmissionId(String.valueOf(log.getId())); logger.info("the submissionId is " + log.getId()); try { JAXBContext context = JAXBContext.newInstance(IARSubmission.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixmapperImpl()); marshaller.marshal(is, out); log.setResult("true"); log.setResultMessage("Manual Export"); log.setTransactionId(""); } catch (Exception e) { logger.error("Error", e); } logDao.merge(log); if (log.getResult() != null && log.getResult().equals("true")) { for (int x = 0; x < submissionDoc.getOCANv2SubmissionFile() .getOCANv2SubmissionRecordArray().length; x++) { OCANv2SubmissionRecord subRec = submissionDoc.getOCANv2SubmissionFile() .getOCANv2SubmissionRecordArray()[x]; String id = subRec.getAssessmentID(); //OcanStaffForm staffForm = ocanStaffFormDao.find(Integer.parseInt(id)); // attention: assessment ID is not form ID. String assessmentId_noPrefix = id; String idPrefix = OscarProperties.getInstance().getProperty("ocan.iar.idPrefix"); if (!StringUtils.isBlank(idPrefix)) { assessmentId_noPrefix = id.replace(idPrefix, ""); } OcanStaffForm staffForm = ocanStaffFormDao.findLatestByAssessmentId( LoggedInInfo.loggedInInfo.get().currentFacility.getId(), Integer.valueOf(assessmentId_noPrefix)); staffForm.setSubmissionId(log.getId()); ocanStaffFormDao.merge(staffForm); } } }
From source file:org.overlord.dtgov.taskapi.TaskApi.java
/** * Fetches a single task by its unique ID. * @param httpRequest/*w w w. j a v a 2 s . co m*/ * @param taskId * @throws Exception */ @GET @Path("get/{taskId}") @Produces(MediaType.APPLICATION_XML) public TaskType getTask(@Context HttpServletRequest httpRequest, @PathParam("taskId") long taskId) throws Exception { assertCurrentUser(httpRequest); Task task = taskService.getTaskById(taskId); TaskType rval = new TaskType(); List<I18NText> descriptions = task.getDescriptions(); if (descriptions != null && !descriptions.isEmpty()) { rval.setDescription(descriptions.iterator().next().getText()); } List<I18NText> names = task.getNames(); if (names != null && !names.isEmpty()) { rval.setName(names.iterator().next().getText()); } rval.setPriority(task.getPriority()); rval.setId(String.valueOf(task.getId())); rval.setType(task.getTaskType()); TaskData taskData = task.getTaskData(); if (taskData != null) { User owner = taskData.getActualOwner(); if (owner != null) { rval.setOwner(owner.getId()); } Date expTime = taskData.getExpirationTime(); if (expTime != null) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(expTime); DatatypeFactory dtFactory = DatatypeFactory.newInstance(); rval.setDueDate(dtFactory.newXMLGregorianCalendar(cal)); } rval.setStatus(StatusType.fromValue(taskData.getStatus().toString())); } long docId = taskService.getTaskById(taskId).getTaskData().getDocumentContentId(); if (docId > 0) { //Set the input params Content content = taskService.getContentById(docId); @SuppressWarnings("unchecked") Map<String, Object> inputParams = (Map<String, Object>) ContentMarshallerHelper .unmarshall(content.getContent(), null); if (inputParams != null && inputParams.size() > 0) { if (rval.getTaskData() == null) rval.setTaskData(new TaskDataType()); for (String key : inputParams.keySet()) { Entry entry = new Entry(); entry.setKey(key); entry.setValue(String.valueOf(inputParams.get(key))); rval.getTaskData().getEntry().add(entry); } } } return rval; }
From source file:org.overlord.dtgov.ui.server.services.tasks.DtGovTaskApiClient.java
/** * @throws DatatypeConfigurationException *///from ww w .j a v a 2s . com protected DatatypeFactory getXmlFactory() { try { return DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } }
From source file:org.overlord.dtgov.ui.server.services.WorkflowQueryService.java
@Override public String save(WorkflowQueryBean workflowQuery) throws DtgovUiException { List<ValidationError> errors = _queryValidator.validate(workflowQuery, PAGE_SIZE); if (errors.size() == 0) { String uuid = ""; //$NON-NLS-1$ ExtendedArtifactType toSave = new ExtendedArtifactType(); toSave.setArtifactType(BaseArtifactEnum.EXTENDED_ARTIFACT_TYPE); toSave.setExtendedType("DtgovWorkflowQuery"); //$NON-NLS-1$ toSave.setName(workflowQuery.getName()); toSave.setDescription(workflowQuery.getDescription()); SrampModelUtils.setCustomProperty(toSave, "query", workflowQuery.getQuery()); //$NON-NLS-1$ SrampModelUtils.setCustomProperty(toSave, "workflow", workflowQuery.getWorkflow()); //$NON-NLS-1$ GregorianCalendar gcal = new GregorianCalendar(); gcal.setTime(new Date()); try {/*w w w . j a v a 2s .c om*/ XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal); toSave.setCreatedTimestamp(xmlCal); } catch (DatatypeConfigurationException ee) { throw new RuntimeException(ee); } for (WorkflowQueryProperty property : workflowQuery.getProperties()) { SrampModelUtils.setCustomProperty(toSave, "prop." + property.getKey(), property.getValue()); //$NON-NLS-1$ } SrampAtomApiClient client = _srampClientAccessor.getClient(); if (StringUtils.isBlank(workflowQuery.getUuid())) { try { BaseArtifactType art = client.createArtifact(toSave); uuid = art.getUuid(); } catch (Exception exc) { throw new DtgovUiException( Messages.i18n.format("WorkflowQueryService.ArtifactCreateFailed", exc)); //$NON-NLS-1$ } } else { uuid = workflowQuery.getUuid(); toSave.setUuid(workflowQuery.getUuid()); try { client.updateArtifactMetaData(toSave); } catch (SrampClientException e) { throw new DtgovUiException(e.getMessage()); } catch (SrampAtomException e) { throw new DtgovUiException(e.getMessage()); } } return uuid; } else { throw new DtgovFormValidationException(errors); } }
From source file:org.overlord.sramp.common.artifactbuilder.WsdlDocumentArtifactBuilderTest.java
@Test public void testDeriverWsdl() throws Exception { DatatypeFactory dtFactory = DatatypeFactory.newInstance(); WsdlDocumentArtifactBuilder builder = new WsdlDocumentArtifactBuilder(); WsdlDocument testSrcArtifact = new WsdlDocument(); testSrcArtifact.setArtifactType(BaseArtifactEnum.WSDL_DOCUMENT); testSrcArtifact.setUuid(UUID.randomUUID().toString()); testSrcArtifact.setName("sample.wsdl"); //$NON-NLS-1$ testSrcArtifact.setVersion("2012/09"); //$NON-NLS-1$ testSrcArtifact.setContentEncoding("UTF-8"); //$NON-NLS-1$ testSrcArtifact.setContentType("application/xml"); //$NON-NLS-1$ testSrcArtifact.setContentSize(92779L); testSrcArtifact.setCreatedBy("anonymous"); //$NON-NLS-1$ XMLGregorianCalendar xmlGC = dtFactory.newXMLGregorianCalendar(new GregorianCalendar()); testSrcArtifact.setCreatedTimestamp(xmlGC); testSrcArtifact.setDescription("Sample WSDL."); //$NON-NLS-1$ testSrcArtifact.setLastModifiedBy("anonymous"); //$NON-NLS-1$ testSrcArtifact.setLastModifiedTimestamp(xmlGC); InputStream testSrcContent = null; try {// w w w. j a va 2s . com testSrcContent = getClass().getResourceAsStream("/sample-files/wsdl/deriver.wsdl"); //$NON-NLS-1$ Collection<BaseArtifactType> derivedArtifacts = builder .buildArtifacts(testSrcArtifact, new ArtifactContent("deriver.wsdl", testSrcContent)) .getDerivedArtifacts(); Assert.assertNotNull(derivedArtifacts); Assert.assertEquals(35, derivedArtifacts.size()); // Index the results by artifact type and name Map<QName, DerivedArtifactType> index = new HashMap<QName, DerivedArtifactType>(); for (BaseArtifactType da : derivedArtifacts) { DerivedArtifactType artifact = (DerivedArtifactType) da; if (artifact instanceof NamedWsdlDerivedArtifactType) { NamedWsdlDerivedArtifactType arty = (NamedWsdlDerivedArtifactType) artifact; if (arty.getNCName() != null) index.put(new QName(arty.getArtifactType().toString(), arty.getNCName()), artifact); } else if (artifact instanceof WsdlExtension) { WsdlExtension arty = (WsdlExtension) artifact; index.put(new QName(arty.getArtifactType().toString(), arty.getNCName()), arty); } else if (artifact instanceof ElementDeclaration) { ElementDeclaration arty = (ElementDeclaration) artifact; index.put(new QName(arty.getArtifactType().toString(), arty.getNCName()), artifact); } else if (artifact instanceof AttributeDeclaration) { AttributeDeclaration arty = (AttributeDeclaration) artifact; index.put(new QName(arty.getArtifactType().toString(), arty.getNCName()), artifact); } else if (artifact instanceof SimpleTypeDeclaration) { SimpleTypeDeclaration arty = (SimpleTypeDeclaration) artifact; index.put(new QName(arty.getArtifactType().toString(), arty.getNCName()), artifact); } else if (artifact instanceof ComplexTypeDeclaration) { ComplexTypeDeclaration arty = (ComplexTypeDeclaration) artifact; index.put(new QName(arty.getArtifactType().toString(), arty.getNCName()), artifact); } } // Do some specific assertions //////////////////////////////////////////// // Find the message named 'findRequest' DerivedArtifactType artifact = index.get(new QName(BaseArtifactEnum.MESSAGE.toString(), "findRequest")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("findRequest", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("findRequest", ((Message) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", //$NON-NLS-1$ ((Message) artifact).getNamespace()); Message message = (Message) artifact; Assert.assertEquals(1, message.getPart().size()); // Find the element decl named 'findResponse' artifact = index.get(new QName(BaseArtifactEnum.ELEMENT_DECLARATION.toString(), "findResponse")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("findResponse", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("findResponse", ((ElementDeclaration) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl/types", //$NON-NLS-1$ ((ElementDeclaration) artifact).getNamespace()); // Find the simple type named 'keywordType' artifact = index.get(new QName(BaseArtifactEnum.SIMPLE_TYPE_DECLARATION.toString(), "keywordType")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("keywordType", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("keywordType", ((SimpleTypeDeclaration) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl/types", //$NON-NLS-1$ ((SimpleTypeDeclaration) artifact).getNamespace()); String typeUuid = artifact.getUuid(); // Find the part named 'keyword' artifact = index.get(new QName(BaseArtifactEnum.PART.toString(), "keyword")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("keyword", artifact.getName()); //$NON-NLS-1$ Part part = (Part) artifact; Assert.assertEquals("keyword", part.getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", part.getNamespace()); //$NON-NLS-1$ Assert.assertNotNull(part.getType()); Assert.assertEquals(typeUuid, part.getType().getValue()); // Find the port type named 'SamplePortType' artifact = index.get(new QName(BaseArtifactEnum.PORT_TYPE.toString(), "SamplePortType")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("SamplePortType", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("SamplePortType", ((PortType) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", //$NON-NLS-1$ ((PortType) artifact).getNamespace()); PortType portType = (PortType) artifact; Assert.assertEquals(2, portType.getOperation().size()); // Find the operation named 'find' artifact = index.get(new QName(BaseArtifactEnum.OPERATION.toString(), "find")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("find", artifact.getName()); //$NON-NLS-1$ Operation operation = (Operation) artifact; Assert.assertEquals("find", operation.getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", //$NON-NLS-1$ operation.getNamespace()); Assert.assertNotNull(operation.getInput()); Assert.assertNotNull(operation.getOutput()); Assert.assertNotNull(operation.getFault()); Assert.assertEquals(2, operation.getFault().size()); // Find the operation input named 'findRequest' artifact = index.get(new QName(BaseArtifactEnum.OPERATION_INPUT.toString(), "findRequest")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("findRequest", artifact.getName()); //$NON-NLS-1$ OperationInput operationInput = (OperationInput) artifact; Assert.assertEquals("findRequest", operationInput.getNCName()); //$NON-NLS-1$ Assert.assertNotNull(operationInput.getMessage()); Assert.assertNotNull(operationInput.getMessage().getValue()); Assert.assertEquals(index.get(new QName(BaseArtifactEnum.MESSAGE.toString(), "findRequest")).getUuid(), //$NON-NLS-1$ operationInput.getMessage().getValue()); // Find the operation output named 'findResponse' artifact = index.get(new QName(BaseArtifactEnum.OPERATION_OUTPUT.toString(), "findResponse")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("findResponse", artifact.getName()); //$NON-NLS-1$ OperationOutput operationOutput = (OperationOutput) artifact; Assert.assertEquals("findResponse", operationOutput.getNCName()); //$NON-NLS-1$ Assert.assertNotNull(operationOutput.getMessage()); Assert.assertNotNull(operationOutput.getMessage().getValue()); Assert.assertEquals(index.get(new QName(BaseArtifactEnum.MESSAGE.toString(), "findResponse")).getUuid(), //$NON-NLS-1$ operationOutput.getMessage().getValue()); // Find the binding named 'SampleBinding' artifact = index.get(new QName(BaseArtifactEnum.BINDING.toString(), "SampleBinding")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("SampleBinding", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("SampleBinding", ((Binding) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", //$NON-NLS-1$ ((Binding) artifact).getNamespace()); Binding binding = (Binding) artifact; Assert.assertEquals(2, binding.getBindingOperation().size()); Assert.assertEquals(1, binding.getExtension().size()); // Find the document style soap:binding artifact = index.get(new QName(BaseArtifactEnum.SOAP_BINDING.toString(), "binding")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("soap:binding", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("binding", ((SoapBinding) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/soap/", ((SoapBinding) artifact).getNamespace()); //$NON-NLS-1$ SoapBinding soapBinding = (SoapBinding) artifact; Assert.assertEquals("document", soapBinding.getStyle()); //$NON-NLS-1$ Assert.assertEquals("http://schemas.xmlsoap.org/soap/http", soapBinding.getTransport()); //$NON-NLS-1$ Assert.assertEquals(binding.getExtension().get(0).getValue(), soapBinding.getUuid()); // Find the binding operation named 'find' artifact = index.get(new QName(BaseArtifactEnum.BINDING_OPERATION.toString(), "find")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("find", artifact.getName()); //$NON-NLS-1$ BindingOperation bindingOperation = (BindingOperation) artifact; Assert.assertEquals("find", bindingOperation.getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", //$NON-NLS-1$ bindingOperation.getNamespace()); Assert.assertNotNull(bindingOperation.getInput()); Assert.assertNotNull(bindingOperation.getOutput()); Assert.assertNotNull(bindingOperation.getFault()); Assert.assertEquals(2, bindingOperation.getFault().size()); Assert.assertNotNull(bindingOperation.getOperation()); Assert.assertEquals(operation.getUuid(), bindingOperation.getOperation().getValue()); // Find the binding operation input named 'findRequest' artifact = index.get(new QName(BaseArtifactEnum.BINDING_OPERATION_INPUT.toString(), "findRequest")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("findRequest", artifact.getName()); //$NON-NLS-1$ BindingOperationInput bindingOperationInput = (BindingOperationInput) artifact; Assert.assertEquals("findRequest", bindingOperationInput.getNCName()); //$NON-NLS-1$ Assert.assertEquals(bindingOperation.getInput().getValue(), bindingOperationInput.getUuid()); // Find the binding operation output named 'findResponse' artifact = index.get(new QName(BaseArtifactEnum.BINDING_OPERATION_OUTPUT.toString(), "findResponse")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("findResponse", artifact.getName()); //$NON-NLS-1$ BindingOperationOutput bindingOperationOutput = (BindingOperationOutput) artifact; Assert.assertEquals("findResponse", bindingOperationOutput.getNCName()); //$NON-NLS-1$ Assert.assertEquals(bindingOperation.getOutput().getValue(), bindingOperationOutput.getUuid()); // Find the service named 'SampleService' artifact = index.get(new QName(BaseArtifactEnum.WSDL_SERVICE.toString(), "SampleService")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("SampleService", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("SampleService", ((WsdlService) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://ewittman.redhat.com/sample/2012/09/wsdl/sample.wsdl", //$NON-NLS-1$ ((WsdlService) artifact).getNamespace()); WsdlService service = (WsdlService) artifact; Assert.assertEquals(1, service.getPort().size()); // Find the port named 'SamplePort' artifact = index.get(new QName(BaseArtifactEnum.PORT.toString(), "SamplePort")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("SamplePort", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("SamplePort", ((Port) artifact).getNCName()); //$NON-NLS-1$ Port port = (Port) artifact; Assert.assertNotNull(port.getBinding()); Assert.assertEquals(port.getBinding().getValue(), binding.getUuid()); Assert.assertEquals(1, port.getExtension().size()); // Find the soap:address artifact = index.get(new QName(BaseArtifactEnum.SOAP_ADDRESS.toString(), "address")); //$NON-NLS-1$ Assert.assertNotNull(artifact); Assert.assertEquals("soap:address", artifact.getName()); //$NON-NLS-1$ Assert.assertEquals("address", ((SoapAddress) artifact).getNCName()); //$NON-NLS-1$ Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/soap/", ((SoapAddress) artifact).getNamespace()); //$NON-NLS-1$ SoapAddress soapAddress = (SoapAddress) artifact; Assert.assertEquals("http://localhost:8080/sample/sampleEP", soapAddress.getSoapLocation()); //$NON-NLS-1$ Assert.assertEquals(port.getExtension().get(0).getValue(), soapAddress.getUuid()); } finally { IOUtils.closeQuietly(testSrcContent); } }