protected void processImportedXsds(List<XsdDocumentTarget> targetCollection, Element schema, String targetNS) throws XPathExpressionException { NodeList nodes = (NodeList) query(schema, "./xsd:import", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("namespace") && node.hasAttribute("schemaLocation")) { String namespace = node.getAttribute("namespace"); String schemaLocation = node.getAttribute("schemaLocation"); stripPath(schemaLocation); XsdDocument xsdDocumentRef = derivedArtifacts.lookupXsdDocument(namespace, schemaLocation); XsdDocumentTarget xsdDocumentTarget = new XsdDocumentTarget(); xsdDocumentTarget.setArtifactType(XsdDocumentEnum.XSD_DOCUMENT); if (xsdDocumentRef != null) { xsdDocumentTarget.setValue(xsdDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(namespace, schemaLocation, xsdDocumentTarget, targetCollection, ArtifactTypeEnum.XsdDocument.getModel(), ArtifactTypeEnum.XsdDocument.getType())); } targetCollection.add(xsdDocumentTarget); } } }
protected void processRedefinedXsds(List<XsdDocumentTarget> targetCollection, Element schema, String targetNS) throws XPathExpressionException { NodeList nodes = (NodeList) query(schema, "./xsd:redefine", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("schemaLocation")) { String schemaLocation = node.getAttribute("schemaLocation"); stripPath(schemaLocation); XsdDocument xsdDocumentRef = derivedArtifacts.lookupXsdDocument(targetNS, schemaLocation); XsdDocumentTarget xsdDocumentTarget = new XsdDocumentTarget(); xsdDocumentTarget.setArtifactType(XsdDocumentEnum.XSD_DOCUMENT); if (xsdDocumentRef != null) { xsdDocumentTarget.setValue(xsdDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(targetNS, schemaLocation, xsdDocumentTarget, targetCollection, ArtifactTypeEnum.XsdDocument.getModel(), ArtifactTypeEnum.XsdDocument.getType())); } targetCollection.add(xsdDocumentTarget); } } }
protected void processIncludedXsds(List<XsdDocumentTarget> targetCollection, Element schema, String targetNS) throws XPathExpressionException { NodeList nodes = (NodeList) query(schema, "./xsd:include", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("schemaLocation")) { String schemaLocation = node.getAttribute("schemaLocation"); stripPath(schemaLocation); XsdDocument xsdDocumentRef = derivedArtifacts.lookupXsdDocument(targetNS, schemaLocation); XsdDocumentTarget xsdDocumentTarget = new XsdDocumentTarget(); xsdDocumentTarget.setArtifactType(XsdDocumentEnum.XSD_DOCUMENT); if (xsdDocumentRef != null) { xsdDocumentTarget.setValue(xsdDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(targetNS, schemaLocation, xsdDocumentTarget, targetCollection, ArtifactTypeEnum.XsdDocument.getModel(), ArtifactTypeEnum.XsdDocument.getType())); } targetCollection.add(xsdDocumentTarget); } } }
for (BaseArtifactType derivedArtifact : derivedArtifacts) { DerivedArtifactType dat = (DerivedArtifactType) derivedArtifact; Assert.assertEquals(testSrcArtifact.getUuid(), dat.getRelatedDocument().getValue()); Assert.assertEquals(DocumentArtifactEnum.XSD_DOCUMENT, dat.getRelatedDocument().getArtifactType());
/** * Test method for {@link org.overlord.sramp.atom.archive.jar.ZipToSrampArchive.jar.JarToSrampArchive#createSrampArchive()}. */ @Test public void testMetaData() throws Exception { InputStream resourceAsStream = ZipToSrampArchiveTest.class.getResourceAsStream("sample-webservice-0.0.1.jar"); //$NON-NLS-1$ ZipToSrampArchive j2sramp = null; SrampArchive archive = null; try { j2sramp = new ZipToSrampArchive(resourceAsStream){}; archive = j2sramp.createSrampArchive(); Assert.assertNotNull(archive); SrampArchiveEntry entry = archive.getEntry("schema/teetime.xsd"); //$NON-NLS-1$ Assert.assertNotNull(entry); BaseArtifactType metaData = entry.getMetaData(); Assert.assertNotNull(metaData); Assert.assertTrue(metaData instanceof XsdDocument); XsdDocument md = (XsdDocument) metaData; Assert.assertEquals("teetime.xsd", md.getName()); //$NON-NLS-1$ Assert.assertNotNull(md.getUuid()); } finally { ZipToSrampArchive.closeQuietly(j2sramp); SrampArchive.closeQuietly(archive); } }