Hi All,
Requirement: I have enabled "Delete" action in the Action Menu. I want to restrict the "Delete" if the document status is approved. Otherwise, it should be possible to delete the document.
What I have done So far:
1. I achieved this requirement using request filter service "/p8/deleteItem". I moved the changes to UAT and PROD. All looks good.
Issue:
1. The java project has other navigator customizations including this requirement. There is a bug in another customization.
2. To fix that issue, I opened the java project. It is showing compilation issue in the request filter service "/p8/deleteItem". But there was no error in this filter service before. In fact, the filter service is working fine in DEV, UAT and PROD.
3. Below is the requester filter service code. Highlighted the compilation code in Bold. Can you guys try this code(at least the line which is showing compilation error) and let me know if it shows the compilation error.
public JSONObject filter(PluginServiceCallbacks callbacks, HttpServletRequest request, JSONArtifact jsonRequest) throws Exception {
JSONObject loReturnJSONObject = null;
if(moObjectStore==null) {
moObjectStore = callbacks.getP8ObjectStore(callbacks.getRepositoryId());
}
String lsLoggedInUserName = request.getUserPrincipal() == null ? null : request.getUserPrincipal().getName();
ContentEngineUtil loContentEngineUtil = new ContentEngineUtil(moConfigReader);
BankAccountValueObject loBankAccountValueObject;
for(Map.Entry<String,String[]> loLineMapEntry: request.getParameterMap().entrySet()) {//Compilation error is "Type mismatch: cannot convert from element type Object to Map.Entry<String,String[]>"
String lsKeyName = loLineMapEntry.getKey();
if(lsKeyName.equalsIgnoreCase(PluginConstants.DOCID)) {
for(int i=0;i<loLineMapEntry.getValue().length;i++) {
String[] loSplitValues = loLineMapEntry.getValue()[i].split(",");
String lsDocID = loSplitValues[2];
// 1.Checks if the document status is Approved.
Document loDocument = loContentEngineUtil.doFetchDocument(moObjectStore, new Id(lsDocID));
loBankAccountValueObject = loContentEngineUtil.doFetchDocumentProperties(loDocument);
if(loContentEngineUtil.isDocumentStatusApproved(new Id(lsDocID), loBankAccountValueObject.getEvidenceStatus())) {
// 1.1.If yes, deletion will not happen
loReturnJSONObject = new JSONObject();
}
// 1.2.If no, deletion will happen. Audit record will be inserted in to table
else {
DatabaseUtil loDatabaseUtil = new DatabaseUtil(moConfigReader);
Connection loConnection = loDatabaseUtil.getDatabaseConnection();
loBankAccountValueObject.setEvidence_Deleted_By(lsLoggedInUserName);
loBankAccountValueObject.setEvidence_DeletedDate(new Date());
loDatabaseUtil.doInsertDocumentAudit(loBankAccountValueObject, loConnection);
loDatabaseUtil.closeDataBaseConnection(loConnection);
}
}
}
}
return loReturnJSONObject;
}
------------------------------
RAVI KUMAR
------------------------------