Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Sonatype Nexus (TM) Open Source Version Copyright (c) 2007-2012 Sonatype, Inc. All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the Eclipse Foundation. All other trademarks are the property of their respective owners.
 
 package org.sonatype.nexus.rest;
 
 
 import  org.restlet.Context;
 import  org.restlet.data.Request;
 import  org.restlet.data.Response;
 import  org.restlet.data.Status;
 import  org.restlet.resource.Representation;
 import  org.restlet.resource.ResourceException;
 import  org.restlet.resource.Variant;
 
 public class NexusRestletResource
     extends RestletResource {
 
     public NexusRestletResource( Context context, Request request, Response responsePlexusResource delegate ) {
         supercontextrequestresponsedelegate );
     }
 
     @Override
     public Representation represent( Variant variant )
         throws ResourceException {
         try {
             return super.representvariant );
         } catch ( ResourceException e ) {
             // NEXUS-4238, NEXUS-4290
             // if it's server error based on HTTP Code, but NOT when Nexus throws a known 503 
             // (see org.sonatype.nexus.rest.AbstractResourceStoreContentPlexusResource.handleException(Request, Response, Exception))
             final Status status = e.getStatus();
             if ( status == null ) {
                 handleErrore );
             } else {
                 final int code = status.getCode();
                 if ( Status.isServerError( code ) && Status.SERVER_ERROR_SERVICE_UNAVAILABLE.getCode() != code ) {
                     handleErrore );
                 }
             }
 
             throw e;
         } catch ( RuntimeException e ) {
             handleErrore );
 
             throw e;
         }
     }
 
     @Override
     public void acceptRepresentation( Representation representation )
         throws ResourceException {
         try {
             super.acceptRepresentationrepresentation );
         } catch ( ResourceException e ) {
             if ( Status.isServerError( e.getStatus().getCode() ) ) {
                 handleErrore );
             }
 
             throw e;
         } catch ( RuntimeException e ) {
             handleErrore );
 
             throw e;
         }
     }
 
     @Override
     public void storeRepresentation( Representation representation )
         throws ResourceException {
         try {
             super.storeRepresentationrepresentation );
         } catch ( ResourceException e ) {
             if ( Status.isServerError( e.getStatus().getCode() ) ) {
                 handleErrore );
             }
 
             throw e;
         } catch ( RuntimeException e ) {
             handleErrore );
 
             throw e;
        }
    }
    @Override
    public void removeRepresentations()
        throws ResourceException {
        try {
            super.removeRepresentations();
        } catch ( ResourceException e ) {
            if ( Status.isServerError( e.getStatus().getCode() ) ) {
                handleErrore );
            }
            throw e;
        } catch ( RuntimeException e ) {
            handleErrore );
            throw e;
        }
    }
    protected void handleErrorThrowable throwable ) {
        Context c = getContext();
        ConcurrentMap<StringObjectattrs = c.getAttributes();
        ErrorReportingManager manager =
            ( ErrorReportingManager ) attrs.getErrorReportingManager.class.getName() );
        if ( manager != null ) {
            ErrorReportRequest request = new ErrorReportRequest();
            request.getContext().putAllgetContext().getAttributes() );
            request.setThrowablethrowable );
            try {
                manager.handleErrorrequest );
            } catch ( IssueSubmissionException e ) {
                getLogger().log( ."Unable to submit error report to jira"e );
	    }
        }
    }
New to GrepCode? Check out our FAQ X