@@ -185,25 +185,19 @@ public Resource authorize(ContainerRequestContext request, Resource agent, Resou
185185
186186 docTypesResult .close ();
187187 docTypesResult = loadResultSet (getApplication ().getService (), getDocumentTypeQuery (), thisQsm );
188- try
189- {
190- Set <Resource > parentTypes = new HashSet <>();
191- docTypesResult .forEachRemaining (qs -> parentTypes .add (qs .getResource ("Type" )));
192188
193- // only root and containers allow child documents. This needs to be checked before checking ownership
194- if (Collections .disjoint (parentTypes , Set .of (Default .Root , DH .Container ))) return null ;
195- docTypesResult .reset (); // rewind result set to the beginning - it's used again later on
196-
197- // special case where the agent is the owner of the requested document - automatically grant acl:Read/acl:Append/acl:Write access
198- if (agent != null && isOwner (accessTo , agent ))
199- {
200- log .debug ("Agent <{}> is the owner of <{}>, granting acl:Read/acl:Append/acl:Write access" , agent , accessTo );
201- return createOwnerAuthorization (accessTo , agent );
202- }
203- }
204- finally
189+ Set <Resource > parentTypes = new HashSet <>();
190+ docTypesResult .forEachRemaining (qs -> parentTypes .add (qs .getResource ("Type" )));
191+
192+ // only root and containers allow child documents. This needs to be checked before checking ownership
193+ if (Collections .disjoint (parentTypes , Set .of (Default .Root , DH .Container ))) return null ;
194+ docTypesResult .reset (); // rewind result set to the beginning - it's used again later on
195+
196+ // special case where the agent is the owner of the requested document - automatically grant acl:Read/acl:Append/acl:Write access
197+ if (agent != null && isOwner (accessTo , agent ))
205198 {
206- docTypesResult .close ();
199+ log .debug ("Agent <{}> is the owner of <{}>, granting acl:Read/acl:Append/acl:Write access" , agent , accessTo );
200+ return createOwnerAuthorization (accessTo , agent );
207201 }
208202 }
209203 else return null ;
0 commit comments