Skip to content

Commit

Permalink
[CCUK-3559] Updated to version 0.5.0 of the view proxy components lib…
Browse files Browse the repository at this point in the history
…rary to take advantage of view server error handling fixes. [rev: ivo.miller]
  • Loading branch information
matthew-gordon-hp committed Dec 22, 2015
1 parent c7b7344 commit ca20254
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion find-idol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<dependency>
<groupId>com.hp.autonomy.frontend.view</groupId>
<artifactId>view-proxy-components-idol</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import com.hp.autonomy.frontend.view.idol.ReferenceFieldBlankException;
import com.hp.autonomy.frontend.view.idol.ViewDocumentNotFoundException;
import com.hp.autonomy.frontend.view.idol.ViewNoReferenceFieldException;
import com.hp.autonomy.frontend.view.idol.ViewServerCopyResponseProcessor;
import com.hp.autonomy.frontend.view.idol.ViewServerErrorException;
import com.hp.autonomy.frontend.view.idol.ViewServerService;
import com.hp.autonomy.idolutils.processors.CopyResponseProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void viewDocument(
) throws IOException {
response.setContentType(MediaType.TEXT_HTML_VALUE);
ViewContentSecurityPolicy.addContentSecurityPolicy(response);
viewServerService.viewDocument(reference, Collections.singletonList(index), new ViewServerCopyResponseProcessor(response.getOutputStream(), reference));
viewServerService.viewDocument(reference, Collections.singletonList(index), new CopyResponseProcessor(response.getOutputStream()));
}

@ExceptionHandler
Expand All @@ -78,7 +78,7 @@ public ModelAndView handleViewDocumentNotFoundException(

log.info(Markers.AUDIT, "TRIED TO VIEW NON EXISTENT DOCUMENT WITH REFERENCE {}", reference);

return controllerUtils.buildErrorModelAndView(request, "error.documentNotFound", "error.referenceDoesNotExist", new Object[]{reference}, HttpStatus.INTERNAL_SERVER_ERROR.value(), true);
return controllerUtils.buildErrorModelAndView(request, "error.documentNotFound", "error.referenceDoesNotExist", new Object[]{reference}, HttpStatus.NOT_FOUND.value(), true);
}

@ExceptionHandler
Expand All @@ -95,7 +95,7 @@ public ModelAndView handleViewNoReferenceFieldException(

log.info(Markers.AUDIT, "TRIED TO VIEW DOCUMENT WITH REFERENCE {} BUT THE REFERENCE FIELD {} WAS MISSING", reference, referenceField);

return controllerUtils.buildErrorModelAndView(request, "error.documentNoReferenceField", "error.documentNoReferenceFieldExtended", new Object[]{reference, referenceField}, HttpStatus.INTERNAL_SERVER_ERROR.value(), true);
return controllerUtils.buildErrorModelAndView(request, "error.documentNoReferenceField", "error.documentNoReferenceFieldExtended", new Object[]{reference, referenceField}, HttpStatus.BAD_REQUEST.value(), true);
}

@ExceptionHandler(ReferenceFieldBlankException.class)
Expand All @@ -108,10 +108,11 @@ public ModelAndView handleReferenceFieldBlankException(

log.info(Markers.AUDIT, "TRIED TO VIEW A DOCUMENT USING A BLANK REFERENCE FIELD");

return controllerUtils.buildErrorModelAndView(request, "error.referenceFieldBlankMain", "error.referenceFieldBlankSub", null, HttpStatus.INTERNAL_SERVER_ERROR.value(), true);
return controllerUtils.buildErrorModelAndView(request, "error.referenceFieldBlankMain", "error.referenceFieldBlankSub", null, HttpStatus.BAD_REQUEST.value(), true);
}

@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView handleViewServerErrorException(
final ViewServerErrorException e,
final HttpServletRequest request,
Expand All @@ -123,8 +124,6 @@ public ModelAndView handleViewServerErrorException(

log.info(Markers.AUDIT, "TRIED TO VIEW DOCUMENT WITH REFERENCE {} BUT VIEW SERVER RETURNED AN ERROR PAGE", reference);

response.setStatus(e.getStatusCode());

return controllerUtils.buildErrorModelAndView(request, "error.viewServerErrorMain", "error.viewServerErrorSub", new Object[]{reference}, HttpStatus.INTERNAL_SERVER_ERROR.value(), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package com.hp.autonomy.frontend.find.idol.view;

import com.autonomy.aci.client.services.AciServiceException;
import com.autonomy.aci.client.services.Processor;
import com.hp.autonomy.frontend.configuration.ConfigService;
import com.hp.autonomy.frontend.find.core.web.ControllerUtils;
Expand Down Expand Up @@ -82,6 +83,6 @@ public void referenceFieldBlank() {

@Test
public void viewServerError() {
assertNotNull(idolViewController.handleViewServerErrorException(new ViewServerErrorException(444, "some reference"), new MockHttpServletRequest(), new MockHttpServletResponse()));
assertNotNull(idolViewController.handleViewServerErrorException(new ViewServerErrorException("some reference", new AciServiceException("It broke")), new MockHttpServletRequest(), new MockHttpServletResponse()));
}
}

0 comments on commit ca20254

Please sign in to comment.