Skip to content

Commit

Permalink
Add error message to file resource get
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Mar 29, 2022
1 parent af0ed77 commit 239511f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {

sourceCompatibility = 1.8
targetCompatibility = 1.8
def libraryVersion = '1.5.9'
def libraryVersion = '1.6.0'
// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you
// are looking at a tagged version of the example and not "master"!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void getResource(GetResourceRequest request, StreamObserver<Resource> res
*/
private void getResource(String resourceUuid, String resourceName, StreamObserver<Resource> responseObserver) throws Exception {
if(!AttachmentUtil.getInstance().isValidForClient(Env.getAD_Client_ID(Env.getCtx()))) {
responseObserver.onCompleted();
responseObserver.onError(new AdempiereException("@NotFound@"));
return;
}
// Validate by name
Expand All @@ -682,20 +682,20 @@ private void getResource(String resourceUuid, String resourceName, StreamObserve
.first();
if(reference == null
|| reference.getAD_AttachmentReference_ID() <= 0) {
responseObserver.onCompleted();
responseObserver.onError(new AdempiereException("@NotFound@"));
return;
}
resourceUuid = reference.getUUID();
} else if(Util.isEmpty(resourceUuid)) {
responseObserver.onCompleted();
responseObserver.onError(new AdempiereException("@NotFound@"));
return;
}
byte[] data = AttachmentUtil.getInstance()
.withClientId(Env.getAD_Client_ID(Env.getCtx()))
.withAttachmentReferenceId(RecordUtil.getIdFromUuid(I_AD_AttachmentReference.Table_Name, resourceUuid, null))
.getAttachment();
if(data == null) {
responseObserver.onCompleted();
responseObserver.onError(new AdempiereException("@NotFound@"));
return;
}
// For all
Expand Down

0 comments on commit 239511f

Please sign in to comment.