Fix exception handling when trying to parse an edit as anonymous user
Accessing a file in a change edit (http://host:8080/#/c/3/edit/test.txt) as not signed in user failed with Internal Server Error, rather than saying that the user must sign in. Change-Id: I7f19e13e3f5663598daa0a4f63ca24a3f7eb844e Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
		 Edwin Kempin
					Edwin Kempin
				
			
				
					committed by
					
						 David Pursehouse
						David Pursehouse
					
				
			
			
				
	
			
			
			 David Pursehouse
						David Pursehouse
					
				
			
						parent
						
							1ad63efb6c
						
					
				
				
					commit
					2d142b11c1
				
			| @@ -126,7 +126,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi { | ||||
|     try { | ||||
|       return revisionApi.create( | ||||
|           revisions.parse(change, IdString.fromDecoded(id))); | ||||
|     } catch (OrmException e) { | ||||
|     } catch (OrmException | IOException e) { | ||||
|       throw new RestApiException("Cannot parse revision", e); | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -69,7 +69,8 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour | ||||
|  | ||||
|   @Override | ||||
|   public RevisionResource parse(ChangeResource change, IdString id) | ||||
|       throws ResourceNotFoundException, OrmException { | ||||
|       throws ResourceNotFoundException, AuthException, OrmException, | ||||
|       IOException { | ||||
|     if (id.equals("current")) { | ||||
|       PatchSet.Id p = change.getChange().currentPatchSetId(); | ||||
|       PatchSet ps = p != null ? dbProvider.get().patchSets().get(p) : null; | ||||
| @@ -103,7 +104,7 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour | ||||
|   } | ||||
|  | ||||
|   private List<RevisionResource> find(ChangeResource change, String id) | ||||
|       throws OrmException { | ||||
|       throws OrmException, IOException, AuthException { | ||||
|     if (id.equals("0")) { | ||||
|       return loadEdit(change, null); | ||||
|     } else if (id.length() < 6 && id.matches("^[1-9][0-9]{0,4}$")) { | ||||
| @@ -157,8 +158,7 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour | ||||
|   } | ||||
|  | ||||
|   private List<RevisionResource> loadEdit(ChangeResource change, RevId revid) | ||||
|       throws OrmException { | ||||
|     try { | ||||
|       throws AuthException, IOException { | ||||
|     Optional<ChangeEdit> edit = editUtil.byChange(change.getChange()); | ||||
|     if (edit.isPresent()) { | ||||
|       PatchSet ps = new PatchSet(new PatchSet.Id( | ||||
| @@ -170,9 +170,6 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour | ||||
|       } | ||||
|     } | ||||
|     return Collections.emptyList(); | ||||
|     } catch (AuthException | IOException e) { | ||||
|       throw new OrmException(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   private static List<RevisionResource> toResources(final ChangeResource change, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user