It's all about the answers!

Ask a question

RAM- delete artifact from asset


Eric Ballance (134) | 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 :

JAVA API:
RAMFolderArtifact.removeArtifact can be used for artifact removal.

Hope it helps.

Eric Ballance selected this answer as the correct answer

Comments
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()
.getRAMSession();
session.queueAssetForPut(currentAsset);
session.putAssets(new NullProgressMonitor());

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.