/** * Adds a new generic {@link Relationship} to the artifact. * @param artifact * @param relationshipType * @param targetUUID * @return the created {@link Relationship} */ public static Relationship addGenericRelationship(BaseArtifactType artifact, String relationshipType, String targetUUID) { return addGenericRelationship(artifact, relationshipType, targetUUID, Collections.EMPTY_MAP, Collections.EMPTY_MAP); }
/** * Unsets a property on the artifact. * @param artifact * @param propName */ private void unsetProperty(BaseArtifactType artifact, String propName) { String propNameLC = propName.toLowerCase(); if (CORE_PROPERTIES.contains(propNameLC)) { setProperty(artifact, propName, null); } else { ArtificerModelUtils.unsetCustomProperty(artifact, propName); } }
Relationship genericRelationship = ArtificerModelUtils.getGenericRelationship(derivedArtifact, "relatedDocument"); if (genericRelationship == null) { ArtificerModelUtils.addGenericRelationship(derivedArtifact, "relatedDocument", primaryArtifact.getUuid());
/** * Sets a property on the artifact. * @param artifact * @param propName * @param propValue */ private void setProperty(BaseArtifactType artifact, String propName, String propValue) { String propNameLC = propName.toLowerCase(); if (CORE_PROPERTIES.contains(propNameLC)) { if (propNameLC.equals("name")) { artifact.setName(propValue); } else if (propNameLC.equals("description")) { artifact.setDescription(propValue); } else if (propNameLC.equals("version")) { artifact.setVersion(propValue); } } else { ArtificerModelUtils.setCustomProperty(artifact, propName, propValue); } }
/** * 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); } }
ArtificerModelUtils.setCustomProperty(metaData, propNameArg, propValArg); archive.updateEntry(entry, null); commandInvocation.getShell().out().println(Messages.i18n.format("UpdateEntry.MetaDataSuccessMsg"));
ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_GROUP_ID, mavenGavInfo.getGroupId()); ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_ARTIFACT_ID, mavenGavInfo.getArtifactId()); ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_VERSION, mavenGavInfo.getVersion()); ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_HASH_MD5, mavenGavInfo.getMd5()); ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_HASH_SHA1, mavenGavInfo.getSha1()); if (StringUtils.isNotBlank(mavenGavInfo.getSnapshotId())) { ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_SNAPSHOT_ID, mavenGavInfo.getSnapshotId()); } else if (mavenGavInfo.isSnapshot()) { ArtificerModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_SNAPSHOT_ID, generateSnapshotTimestamp()); ArtificerModelUtils.setCustomProperty(artifact, "maven.classifier", mavenGavInfo.getClassifier()); artifactName += '-' + mavenGavInfo.getClassifier(); ArtificerModelUtils.setCustomProperty(artifact, "maven.type", mavenGavInfo.getType()); artifactName += '.' + mavenGavInfo.getType(); BaseArtifactType pomArtifact = ArtifactType.ExtendedDocument(JavaModel.TYPE_MAVEN_POM_XML).newArtifactInstance(); pomArtifact.setName(pomName); ArtificerModelUtils.setCustomProperty(pomArtifact, JavaModel.PROP_MAVEN_TYPE, "pom"); ArtificerModelUtils.setCustomProperty(pomArtifact, JavaModel.PROP_MAVEN_HASH_MD5, DigestUtils.md5Hex(pom)); ArtificerModelUtils.setCustomProperty(pomArtifact, JavaModel.PROP_MAVEN_HASH_SHA1, DigestUtils.shaHex(pom));