diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java index c78d61617..2af3bdd3b 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/CasesEndpointV1.java @@ -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()); } @@ -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(); diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java index 20741fc7d..7f43cda65 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileService.java @@ -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); + + } + } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileServiceLocal.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileServiceLocal.java index 00e668517..4c44996e2 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileServiceLocal.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/ArchiveFileServiceLocal.java @@ -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; }