Skip to content

Commit

Permalink
added updateDocumentExternalId
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Nov 30, 2023
1 parent b4fd957 commit 141ff3e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ public Response updateDocument(RestfulDocumentContentV1 document) {
return res;
}

if (!currentDoc.getName().equals(document.getFileName())) {
if (document.getFileName()!=null && !currentDoc.getName().equals(document.getFileName())) {
cases.renameDocument(document.getId(), document.getFileName());
}

Expand All @@ -1257,6 +1257,10 @@ public Response updateDocument(RestfulDocumentContentV1 document) {
cases.moveDocumentsToFolder(docIds, document.getFolderId());
}

if(document.getExternalId()!=null) {
cases.updateDocumentExternalId(document.getId(), document.getExternalId());
}

ArchiveFileDocumentsBean updated = cases.getDocument(document.getId());

RestfulDocumentContentV1 doc = new RestfulDocumentContentV1();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6007,4 +6007,24 @@ public ArchiveFileDocumentsBean getDocumentByExternalId(String extId) {
return this.archiveFileDocumentsFacade.findByExternalId(extId);
}

@Override
@RolesAllowed({"writeArchiveFileRole"})
public void updateDocumentExternalId(String id, String externalId) throws Exception {

ArchiveFileDocumentsBean db = this.archiveFileDocumentsFacade.find(id);
ArchiveFileBean aFile = db.getArchiveFileKey();
SecurityUtils.checkGroupsForCase(context.getCallerPrincipal().getName(), aFile, this.securityFacade, this.getAllowedGroups(aFile));

db.setExternalId(externalId);
db.bumpVersion();
this.archiveFileDocumentsFacade.edit(db);

DocumentUpdatedEvent evt = new DocumentUpdatedEvent();
evt.setDocumentId(id);
evt.setCaseId(aFile.getId());
evt.setDocumentName(db.getName());
this.updatedDocumentEvent.fireAsync(evt);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -793,5 +793,7 @@ public interface ArchiveFileServiceLocal {

public ArchiveFileBean getCaseByExternalId(String extId);
public ArchiveFileDocumentsBean getDocumentByExternalId(String extId);

void updateDocumentExternalId(String id, String externalId) throws Exception;

}

0 comments on commit 141ff3e

Please sign in to comment.