if (artifact.getCreatedTimestamp() != null) entry.setPublished(artifact.getCreatedTimestamp().toGregorianCalendar().getTime()); if (artifact.getCreatedBy() != null) entry.getAuthors().add(new Person(artifact.getCreatedBy())); if (artifact.getDescription() != null) entry.setSummary(artifact.getDescription());
@Test public void testCreatedBy() throws Exception { BaseArtifactType artifact = createArtifact(null); Assert.assertEquals(Document.class, artifact.getClass()); Assert.assertEquals("junituser", artifact.getCreatedBy()); //$NON-NLS-1$ }
if (artifact.getCreatedTimestamp() != null) entry.setPublished(artifact.getCreatedTimestamp().toGregorianCalendar().getTime()); if (artifact.getCreatedBy() != null) entry.getAuthors().add(new Person(artifact.getCreatedBy())); if (artifact.getDescription() != null) entry.setSummary(artifact.getDescription());
/** * Updates the basic s-ramp meta data. * @param srampArtifact * @throws Exception */ private void updateArtifactMetaData(BaseArtifactType srampArtifact) throws Exception { artificerArtifact.setUuid(srampArtifact.getUuid()); artificerArtifact.setModel(artifactType.getModel()); // may have already been set... if (StringUtils.isBlank(artificerArtifact.getType())) { artificerArtifact.setType(artifactType.getType()); } ArtificerUser createdBy = HibernateEntityFactory.user(srampArtifact.getCreatedBy(), srampArtifact.getCreatedTimestamp()); artificerArtifact.setCreatedBy(createdBy); ArtificerUser modifiedBy = HibernateEntityFactory.user(srampArtifact.getLastModifiedBy(), srampArtifact.getLastModifiedTimestamp()); artificerArtifact.setModifiedBy(modifiedBy); if (srampArtifact.getName() != null) artificerArtifact.setName(srampArtifact.getName()); else artificerArtifact.setName(srampArtifact.getClass().getSimpleName()); artificerArtifact.setDescription(srampArtifact.getDescription()); artificerArtifact.setVersion(srampArtifact.getVersion()); }
printProperty(Messages.i18n.format("PrintArtifact.ExpandedFromArchive"), archiveUuid); printProperty(Messages.i18n.format("PrintArtifact.CreatedBy"), artifact.getCreatedBy()); if (artifact.getCreatedTimestamp() != null) printProperty(Messages.i18n.format("PrintArtifact.CreatedOn"), artifact.getCreatedTimestamp().toXMLFormat());
@Test public void testLastModifiedBy() throws Exception { BaseArtifactType artifact = createArtifact(null); // Now update the artifact as a different user. MockSecurityContext.currentUser = "junituser2"; //$NON-NLS-1$ artifact.setDescription("New description of the artifact."); //$NON-NLS-1$ persistenceManager.updateArtifact(artifact, ArtifactType.Document()); MockSecurityContext.currentUser = "junituser"; //$NON-NLS-1$ artifact = persistenceManager.getArtifact(artifact.getUuid(), ArtifactType.Document()); Assert.assertEquals("junituser", artifact.getCreatedBy()); //$NON-NLS-1$ Assert.assertEquals("junituser2", artifact.getLastModifiedBy()); //$NON-NLS-1$ }
@Test public void testGetArtifact_XSD() throws Exception { String artifactFileName = "PO.xsd"; //$NON-NLS-1$ InputStream POXsd = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); //$NON-NLS-1$ Document document = new Document(); 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$ 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 BaseArtifactType artifact2 = persistenceManager.getArtifact(artifact.getUuid(), ArtifactType.XsdDocument()); Assert.assertEquals(artifact.getUuid(), artifact2.getUuid()); Assert.assertEquals(artifact.getCreatedBy(), artifact2.getCreatedBy()); Assert.assertEquals(artifact.getDescription(), artifact2.getDescription()); Assert.assertEquals(artifact.getLastModifiedBy(), artifact2.getLastModifiedBy()); Assert.assertEquals(artifact.getName(), artifact2.getName()); Assert.assertEquals(artifact.getVersion(), artifact2.getVersion()); Assert.assertEquals(artifact.getLastModifiedTimestamp(), artifact2.getLastModifiedTimestamp()); }