private static ArtifactSummary summary(Entry entry) { ArtifactSummary summary = new ArtifactSummary(); summary.setUuid(entry.getId().toString().replace("urn:uuid:", "")); summary.setName(entry.getTitle()); summary.setDescription(entry.getSummary()); ArtifactType artifactType = ArtificerAtomUtils.getArtifactType(entry); summary.setModel(artifactType.getModel()); summary.setType(artifactType.getType()); summary.setDerived(artifactType.isDerived()); summary.setExtensionAttributes(entry.getExtensionAttributes()); if (entry.getPublished() != null) { Calendar published = Calendar.getInstance(); published.setTime(entry.getPublished()); summary.setCreatedTimestamp(published); } if (entry.getAuthors() != null && entry.getAuthors().size() > 0) { summary.setCreatedBy(entry.getAuthors().get(0).getName()); } if (entry.getUpdated() != null) { Calendar updated = Calendar.getInstance(); updated.setTime(entry.getUpdated()); summary.setLastModifiedTimestamp(updated); } summary.setExpandedFromArchive("true".equals(entry.getExtensionAttributes().get(ArtificerConstants.ARTIFICER_EXPANDED_FROM_ARCHIVE_QNAME))); return summary; } }
@Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { ArtificerAtomApiClient client = client(commandInvocation); BaseArtifactType artifact = context(commandInvocation).getCurrentArtifact(); QueryResultSet feed = context(commandInvocation).getCurrentArtifactFeed(); if (client == null) { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status1")); } else { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status2", client.getEndpoint())); } if (artifact == null) { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status3")); } else { ArtifactType type = ArtifactType.valueOf(artifact); commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status4", artifact.getName(), type.getType())); } if (feed == null) { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status5")); } else { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status6", feed.size())); } return CommandResult.SUCCESS; }
ClientResponse<Entry> response = null; try { String type = artifactType.getType(); String atomUrl = String.format("%1$s/%2$s/%3$s", srampEndpoint, artifactType.getArtifactType().getModel(), type);
/** * 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()); }
ClientResponse<Entry> response = null; try { String type = artifactType.getType(); String atomUrl = String.format("%1$s/%2$s/%3$s", srampEndpoint, artifactType.getArtifactType().getModel(), type);
/** * Creates a new artifact in the S-RAMP repository. Use this method when creating * logical artifacts in the repository (i.e. artifacts without document content). * @param artifact */ public BaseArtifactType createArtifact(BaseArtifactType artifact) throws ArtificerClientException, ArtificerServerException { ArtifactType artifactType = ArtifactType.valueOf(artifact); if (ArtificerModelUtils.isDocumentArtifact(artifact)) { throw new ArtificerClientException(Messages.i18n.format("MISSING_ARTIFACT_CONTEN")); } assertFeatureEnabled(artifactType); ClientResponse<Entry> response = null; try { String type = artifactType.getType(); String atomUrl = String.format("%1$s/%2$s/%3$s", srampEndpoint, artifactType.getModel(), type); ClientRequest request = createClientRequest(atomUrl); request.body(MediaType.APPLICATION_ATOM_XML_ENTRY, ArtificerAtomUtils.wrapSrampArtifact(artifact)); response = request.post(Entry.class); Entry entry = response.getEntity(); return ArtificerAtomUtils.unwrapSrampArtifact(artifactType, entry); } catch (ArtificerServerException e) { throw e; } catch (Throwable e) { throw new ArtificerClientException(e); } finally { closeQuietly(response); } }
ClientResponse<Entry> response = null; try { String type = artifactType.getType(); String atomUrl = String.format("%1$s/%2$s/%3$s", srampEndpoint, artifactType.getArtifactType().getModel(), type);