Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

rejecting an asset

Avatar

Level 4

I have a form that I need to be able to reject an asset. I see the code in the javascript to approve an asset. Is there a servlet that handles the rejection of an asset? If I change so that the JSON string contains "rejected" instead of "accepted", the server responds with an error that the field "accepted" does not exist. What would the URL to a servlet that would handle the rejection be?

1 Accepted Solution

Avatar

Correct answer by
Level 10

couple of quick things

1. You are using log.debug. Have you enabled the configuration to log the debug level ?? else use log.info or log.error

2. How have you created your session ?? 

View solution in original post

10 Replies

Avatar

Level 10

Can you explain a bit more of your use case ?

At what point you would need to reject an asset ? is it at the upload time, processing time and at the usage time...

Avatar

Level 4

They client creates a project that starts off a workflow. The work flow progresses along until an approval step. At that point they want to be able to reject asset(s) and return the processing to a previous step then proceed normally from there, retracing the steps between. Since there is an approval mechanism, what is the rejection mechanism? Then I'd like to see if any one of the assets associated with the project has been rejected in a GoTo step and branch back. I'm guessing I'll have to modify states of the steps that have to be retraced too.

Avatar

Level 10

So every step of a workflow, you have 'complete' to go fwd and 'Step Back' to basically use it as a reject where it goes to the previous step

Avatar

Level 4

This implementation has been heavily customized. There isn't a back option it is the fifth step of six where the reject occurs and it has to jump back to the second step and proceed from there until the reviewer accepts all of the assets.

Avatar

Level 4

I was able to add this, sort of. The problem was that the rejection didn't save unless the step was completed. Since the approve and reject are separate options, if I rejected an image, then approved, the rejected mages would be reset to "pending". I was using an ajax call to a servlet I wrote to set the value in the DAM but it wouldn't save the update in the dam even though I had a session.save() in the servlet code. What could I be missing in not being able to save the value?

Avatar

Level 10

What account did you use to open the session - did the user on which the session was based have write permissions for that part of the JCR. That is the only reason why i see not modifying the asset in the DAM. 

Avatar

Level 10

Can you share your code snippet so we can see if something missing

Avatar

Level 4

The user agent should have full access to that. I'll have to check the permissions. Shouldn't there be an error in the logs?

try { JSONArray jsonData = new JSONArray(data); for( int i = 0; i < jsonData.length(); i++){ JSONObject obj = jsonData.getJSONObject(i); String path = folder + "/" + obj.getString("id") + "/" + obj.getString("rejected"); Resource res = resourceResolver.getResource(path); Node assetMetadataNode = resourceResolver.getResource(res.getPath() + "/jcr:content/metadata").adaptTo(Node.class); assetMetadataNode.setProperty("dam:status", "rejected"); session.save(); String s = assetMetadataNode.getProperty("dam:status").getString(); log.debug(s); session.save(); } }catch(JSONException je) { je.printStackTrace(); }catch(RepositoryException re){ re.printStackTrace(); }catch (Exception e){ e.printStackTrace(); }

The value is in the session when I check it after the first save. I just added the second one just for a test. When I check the DAM in CRX, I don't see the value and I don't see any errors in the logs.

Avatar

Correct answer by
Level 10

couple of quick things

1. You are using log.debug. Have you enabled the configuration to log the debug level ?? else use log.info or log.error

2. How have you created your session ?? 

Avatar

Level 4

The log level is at debug.

The session is being created thus:

Session session = resourceResolver.adaptTo(Session.class);

This is in a servlet that overrides SlingAllMethodsServlet.