RAM- delete artifact from asset
Accepted answer
Hi Eric,
You can modify an asset( add/delete artifacts) by using the JAVA API or even the REST API's. Please find below the references for the same.
Rest API :
JAVA API:
RAMFolderArtifact.removeArtifact can be used for artifact removal.
Hope it helps.
Comments
Thank you for responding. I have a .doc file attached to an asset and am using the code below. It does not remove the .doc file from the asset. Any ideas what is wrong?
for (Artifact artifact : srcArtifacts) {
RAMArtifact ramArtifact = (RAMArtifact) artifact;
String nm = ramArtifact.getName();
if (nm.endsWith(".doc") || nm.endsWith(".docx")) {
status.addDetail(new ResultDetail(ResultDetail.INFO,
"processing artifact : " + nm));
boolean removed = root.removeArtifact(artifact);
status.addDetail(new ResultDetail(ResultDetail.INFO, "removed : " + removed));
}
Nevermind. I had to add the logic to update the asset.
RAMSession session = this.getPolicyContext()
.getRAMSession();
session.queueAssetForPut(currentAsset);
session.putAssets(new NullProgressMonitor());