/** * Sets some meta data on the artifact model. * @param artifactMetaData * @param name * @param version * @param desc */ private void setMetaData(XsdDocument artifactMetaData, String name, String version, String desc) { artifactMetaData.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); artifactMetaData.setName(name); artifactMetaData.setVersion(version); artifactMetaData.setDescription(desc); }
/** * @return a new artifact * @throws SrampException */ private BaseArtifactType createXsdArtifact() throws SrampException { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream content = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ XsdDocument document = new XsdDocument(); document.setName(artifactFileName); document.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); BaseArtifactType artifact = persistenceManager.persistArtifact(document, content); Assert.assertNotNull(artifact); log.info("persisted PO.xsd to JCR, returned artifact uuid=" + artifact.getUuid()); //$NON-NLS-1$ return artifact; }
/** * @throws RepositoryException * @throws DerivedArtifactsCreationException */ private XsdDocument addXsdDoc() throws SrampException { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream contentStream = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ try { XsdDocument xsdDoc = new XsdDocument(); xsdDoc.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); xsdDoc.setName(artifactFileName); xsdDoc.setContentEncoding("application/xml"); //$NON-NLS-1$ // Persist the artifact BaseArtifactType artifact = persistenceManager.persistArtifact(xsdDoc, contentStream); Assert.assertNotNull(artifact); return (XsdDocument) artifact; } finally { IOUtils.closeQuietly(contentStream); } }
@Test public void testPersistArtifactPO_XSD() throws Exception { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream POXsd = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ XsdDocument document = new XsdDocument(); document.setName(artifactFileName); document.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); BaseArtifactType artifact = persistenceManager.persistArtifact(document, POXsd); Assert.assertNotNull(artifact); log.info("persisted PO.xsd to JCR, returned artifact uuid=" + artifact.getUuid()); //$NON-NLS-1$ //print out the derived node if (log.isDebugEnabled()) { persistenceManager.printArtifactGraph(artifact.getUuid(), ArtifactType.XsdDocument()); } Assert.assertEquals(XsdDocument.class, artifact.getClass()); long size = ((DocumentArtifactType) artifact).getContentSize(); Assert.assertTrue(size >= 2376L); // Not doing an equals here due to the vagaries of Windows vs *nix line endings }
testSrcArtifact.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); testSrcArtifact.setUuid(UUID.randomUUID().toString()); testSrcArtifact.setName("ws-humantask.xsd"); //$NON-NLS-1$