예제 #1
0
 // testing only
 public static void main(String[] args) /*throws JAXBException*/ {
   ExceptionHandler eh = new ExceptionHandler("1.0.0", "en-US");
   eh.addExceptionToReport(
       ExceptionCode.NOT_APPLICABLE_CODE, null, new String[] {"Line 1a.", "Line 1b."});
   eh.addExceptionToReport(
       ExceptionCode.NOT_APPLICABLE_CODE, null, new String[] {"Line 2a.", "Line 2b."});
   System.out.println(eh.getXMLExceptionReport());
 }
예제 #2
0
  /*
   * Handle GET requests.
   *
   * (non-Javadoc)
   * @see org.wholebrainproject.wbc.server.resource.DataRepositoryResource#represent(org.restlet.resource.Variant)
   */
  @Override
  public Representation represent(Variant variant) throws ResourceException {

    // if there are exceptions, send an exception report
    if (exceptionHandler != null) {
      String xmlReport = exceptionHandler.getXMLExceptionReport();
      logger.error("Exception Report returned to client: \n{}", xmlReport);
      return getExceptionRepresentation();
    }

    // look for cached file first
    File cachedResponse = new File(cacheDir, RESPONSE_FILE_NAME);
    if (cachedResponse.exists()) {
      return new FileRepresentation(cachedResponse, MediaType.APPLICATION_XML);
    }

    // prepare an ExceptionReport
    String message = "File " + RESPONSE_FILE_NAME + " not found.";
    ExceptionHandler exHandler = getExceptionHandler();
    exHandler.addExceptionToReport(ExceptionCode.NOT_APPLICABLE_CODE, null, new String[] {message});
    logger.error(message);
    return getExceptionRepresentation();
  }