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.error.reporting;
 
 
 import  javax.ws.rs.Consumes;
 import  javax.ws.rs.PUT;
 import  javax.ws.rs.Path;
 import  javax.ws.rs.Produces;
 
 import  org.codehaus.enunciate.contract.jaxrs.ResourceMethodSignature;
 import  org.restlet.Context;
 import  org.restlet.data.Request;
 import  org.restlet.data.Response;
 import  org.restlet.data.Status;
 import  org.restlet.resource.ResourceException;
 
 @Component( role = PlexusResource.class, hint = "ErrorReportingPlexusResource" )
 @Produces( { "application/xml""application/json" } )
 @Consumes( { "application/xml""application/json" } )
 {
     public static final String RESOURCE_URI = "/error_reporting";
 
     public ErrorReportingPlexusResource()
     {
         setModifiabletrue );
         setReadablefalse );
     }
 
     @Override
     public Object getPayloadInstance()
     {
         return new ErrorReportRequest();
     }
 
     @Override
     {
         return new PathProtectionDescriptor"/error_reporting""authcBasic,perms[nexus:settings]" );
     }
 
     @Override
     public String getResourceUri()
     {
         return ;
     }

    
Generate a new error report, will return a url that can be used to access the error ticket.
 
     @Override
     @PUT
     @ResourceMethodSignature( input = ErrorReportRequest.class, output = ErrorReportResponse.class )
     public Object put( Context context, Request request, Response responseObject payload )
         throws ResourceException
     {
         ErrorReportRequestDTO dto = ( (ErrorReportRequestpayload ).getData();
 
         if ( StringUtils.isBlankdto.getTitle() ) )
         {
             throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "A Title for the report is required." );
         }
 
         ErrorReportingManager manager =
             (ErrorReportingManagercontext.getAttributes().get( ErrorReportingManager.class.getName() );
 
         if ( manager == null )
         {
             throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to retrieve error reporting manager." );
         }
 
         ErrorReportingSettings settings = dto.getErrorReportingSettings();
        if ( dto.isSaveErrorReportingSettings() )
        {
            if ( settings == null )
            {
                throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST,
                                             "Jira settings must be provided when set to save as default." );
            }
            manager.setJIRAUsernamesettings.getJiraUsername() );
            manager.setJIRAPasswordgetActualPasswordsettings.getJiraPassword(), manager.getJIRAPassword() ) );
            try
            {
                getNexusConfiguration().saveConfiguration();
            }
            catch ( IOException e )
            {
                getLogger().warn"Got IO Exception during update of Nexus configuration."e );
                throw new ResourceException( Status.SERVER_ERROR_INTERNAL, e );
            }
        }
            new org.sonatype.nexus.error.reporting.ErrorReportRequest();
        genReq.setTitledto.getTitle() );
        genReq.setDescriptiondto.getDescription() );
        genReq.getContext().putAllcontext.getAttributes() );
        genReq.setManualtrue );
        try
        {
            ErrorReportResponse dtoResponse = new ErrorReportResponse();
            dtoResponse.setDatanew ErrorReportResponseDTO() );
            org.sonatype.nexus.error.reporting.ErrorReportResponse genRes;
            if ( settings != null && !dto.isSaveErrorReportingSettings()
                && !StringUtils.isEmptysettings.getJiraUsername() ) )
            {
                genRes =
                    manager.handleErrorgenReqsettings.getJiraUsername(), settings.getJiraPassword()
                    );
            }
            else
            {
                genRes = manager.handleErrorgenReq );
            }
            if ( !genRes.isSuccess() )
            {
                getLogger().debug"Unable to submit jira ticket." );
                throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "Unable to submit jira ticket." );
            }
            dtoResponse.getData().setJiraUrlgenRes.getJiraUrl() );
            return dtoResponse;
        }
        catch ( IssueSubmissionException e )
        {
            if ( getLogger().isDebugEnabled() )
            {
                getLogger().error"Unable to submit jira ticket."e );
            }
            else
            {
                getLogger().error"Unable to submit jira ticket: " + e.getMessage() );
            }
            throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Unable to submit jira ticket:" + e.getMessage(), e );
        }
    }
New to GrepCode? Check out our FAQ X