It's all about the answers!

Ask a question

RAM- delete artifact from asset

Eric Ballance (131) | asked Feb 28 '18, 5:17 p.m.

 Is there any way to delete an artifact in the policy plugin or through OSLC?

Accepted answer

permanent link
Rahul Choudhary (662) | answered Mar 01 '18, 2:15 a.m.

 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 :

RAMFolderArtifact.removeArtifact can be used for artifact removal.

Hope it helps.

Eric Ballance selected this answer as the correct answer

Eric Ballance commented Mar 03 '18, 12:28 p.m.

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));

Eric Ballance commented Mar 03 '18, 12:50 p.m.

 Nevermind. I had to add the logic to update the asset.

RAMSession session = this.getPolicyContext()
session.putAssets(new NullProgressMonitor());

Your answer

Register or to post your answer.