Example usage for org.apache.commons.httpclient HttpStatus SC_NOT_ACCEPTABLE

List of usage examples for org.apache.commons.httpclient HttpStatus SC_NOT_ACCEPTABLE

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_NOT_ACCEPTABLE.

Prototype

int SC_NOT_ACCEPTABLE

To view the source code for org.apache.commons.httpclient HttpStatus SC_NOT_ACCEPTABLE.

Click Source Link

Document

<tt>406 Not Acceptable</tt> (HTTP/1.1 - RFC 2616)

Usage

From source file:com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult.java

public void notAcceptable(Localizable message) {
    this.message = message;
    httpCode = HttpStatus.SC_NOT_ACCEPTABLE;
}

From source file:com.sun.faban.harness.util.DeployTask.java

/**
 * Executes the Faban deployment task./*from   www  .ja  v  a 2s.  c om*/
 * @throws BuildException If there is an
 */
public void execute() throws BuildException {
    try {
        // First check the jar file and name
        if (jarFile == null)
            throw new BuildException("jar attribute missing for target deploy.");
        if (!jarFile.isFile())
            throw new BuildException("jar file not found.");
        String jarName = jarFile.getName();
        if (!jarName.endsWith(".jar"))
            throw new BuildException("Jar file name must end with \".jar\"");
        jarName = jarName.substring(0, jarName.length() - 4);
        if (jarName.indexOf('.') > -1)
            throw new BuildException("Jar file name must not have any " + "dots except ending with \".jar\"");

        // Prepare the parts for the request.
        ArrayList<Part> params = new ArrayList<Part>(4);
        if (user != null)
            params.add(new StringPart("user", user));
        if (password != null)
            params.add(new StringPart("password", password));
        if (clearConfig)
            params.add(new StringPart("clearconfig", "true"));
        params.add(new FilePart("jarfile", jarFile));
        Part[] parts = new Part[params.size()];
        parts = params.toArray(parts);

        // Prepare the post method.
        PostMethod post = new PostMethod(target + "/deploy");

        // Ensure text/plain is the only accept header.
        post.removeRequestHeader("Accept");
        post.setRequestHeader("Accept", "text/plain");
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));

        // Execute the multi-part post method.
        HttpClient client = new HttpClient();
        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
        int status = client.executeMethod(post);
        StringBuilder b = new StringBuilder();
        InputStream respBody = post.getResponseBodyAsStream();
        byte[] readBuffer = new byte[8192];
        for (;;) {
            int size = respBody.read(readBuffer);
            if (size == -1)
                break;
            b.append(new String(readBuffer, 0, size));
        }
        String response = b.toString();

        // Check status.
        if (status == HttpStatus.SC_CONFLICT) {
            handleErrorFlush(response);
            throw new BuildException(
                    "Benchmark to deploy is currently " + "run or queued to be run. Please clear run queue "
                            + "of this benchmark before deployment");
        } else if (status == HttpStatus.SC_NOT_ACCEPTABLE) {
            handleErrorFlush(response);
            throw new BuildException(
                    "Benchmark deploy name or deploy " + "file invalid. Deploy file may contain errors. Name "
                            + "must have no '.' and file must have the " + "'.jar' extensions.");
        } else if (status != HttpStatus.SC_CREATED) {
            handleOutput(response);
            throw new BuildException(
                    "Faban responded with status code " + status + ". Status code 201 (SC_CREATED) expected.");
        }
    } catch (FileNotFoundException e) {
        throw new BuildException(e);
    } catch (HttpException e) {
        throw new BuildException(e);
    } catch (IOException e) {
        throw new BuildException(e);
    }
}

From source file:com.microfocus.application.automation.tools.octane.actions.Webhooks.java

@RequirePOST
public void doNotify(StaplerRequest req, StaplerResponse res) throws IOException {
    logger.info("Received POST from " + req.getRemoteHost());
    // legal user, handle request
    JSONObject inputNotification = (JSONObject) JSONValue.parse(req.getInputStream());
    Object properties = inputNotification.get("properties");
    // without build context, could not send octane relevant data
    if (!req.getHeader(PROJECT_KEY_HEADER).isEmpty() && properties instanceof Map) {
        // get relevant parameters
        Map sonarAttachedProperties = (Map) properties;
        // filter notifications from sonar projects, who haven't configured listener parameters
        if (sonarAttachedProperties.containsKey(BUILD_NUMBER_PARAM_NAME)
                && sonarAttachedProperties.containsKey(JOB_NAME_PARAM_NAME)) {
            String buildId = (String) (sonarAttachedProperties.get(BUILD_NUMBER_PARAM_NAME));
            String jobName = (String) sonarAttachedProperties.get(JOB_NAME_PARAM_NAME);
            // get sonar details from job configuration
            TopLevelItem jenkinsJob = Jenkins.getInstance().getItem(jobName);
            if (isValidJenkinsJob(jenkinsJob)) {
                AbstractProject jenkinsProject = ((AbstractProject) jenkinsJob);
                Integer buildNumber = Integer.valueOf(buildId, 10);
                if (isValidJenkinsBuildNumber(jenkinsProject, buildNumber)) {
                    AbstractBuild build = getBuild(jenkinsProject, buildNumber);
                    if (build != null && isBuildExpectingToGetWebhookCall(build)
                            && !isBuildAlreadyGotWebhookCall(build)) {
                        WebhookExpectationAction action = build.getAction(WebhookExpectationAction.class);
                        ExtensionList<GlobalConfiguration> allConfigurations = GlobalConfiguration.all();
                        GlobalConfiguration sonarConfiguration = allConfigurations
                                .getDynamic(SonarHelper.SONAR_GLOBAL_CONFIG);
                        if (sonarConfiguration != null) {
                            String sonarToken = SonarHelper.getSonarInstallationTokenByUrl(sonarConfiguration,
                                    action.getServerUrl());
                            HashMap project = (HashMap) inputNotification.get(PROJECT);
                            String sonarProjectKey = (String) project.get(SONAR_PROJECT_KEY_NAME);

                            // use SDK to fetch and push data
                            OctaneSDK.getClients()
                                    .forEach(octaneClient -> octaneClient.getSonarService()
                                            .enqueueFetchAndPushSonarCoverage(jobName, buildId, sonarProjectKey,
                                                    action.getServerUrl(), sonarToken));
                            markBuildAsRecievedWebhookCall(build);
                            res.setStatus(HttpStatus.SC_OK); // sonar should get positive feedback for webhook
                        }//  ww  w  .  j  a va2 s.  c om
                    } else {
                        logger.warn("Got request from sonarqube webhook listener for build ," + buildId
                                + " which is not expecting to get sonarqube data");
                        res.setStatus(HttpStatus.SC_EXPECTATION_FAILED);
                    }
                } else {
                    logger.warn("Got request from sonarqube webhook listener, but build " + buildId
                            + " context could not be resolved");
                    res.setStatus(HttpStatus.SC_NOT_ACCEPTABLE);
                }
            }
        }
    }
}

From source file:com.sun.faban.harness.webclient.RunUploader.java

/**
 * Client call to upload the run back to the originating server.
 * This method does nothing if the run is local.
 * @param runId The id of the run//from w w  w.ja  v  a  2s . co m
 * @throws IOException If the upload fails
 */
public static void uploadIfOrigin(String runId) throws IOException {

    // 1. Check origin
    File originFile = new File(
            Config.OUT_DIR + File.separator + runId + File.separator + "META-INF" + File.separator + "origin");

    if (!originFile.isFile())
        return; // Is local run, do nothing.

    String originSpec = readStringFromFile(originFile);
    int idx = originSpec.lastIndexOf('.');
    if (idx == -1) { // This is wrong, we do not accept this.
        logger.severe("Bad origin spec.");
        return;
    }
    idx = originSpec.lastIndexOf('.', idx - 1);
    if (idx == -1) {
        logger.severe("Bad origin spec.");
        return;
    }

    String host = originSpec.substring(0, idx);
    String key = null;
    URL target = null;
    String proxyHost = null;
    int proxyPort = -1;

    // Search the poll hosts for this origin.
    for (int i = 0; i < Config.pollHosts.length; i++) {
        Config.HostInfo pollHost = Config.pollHosts[i];
        if (host.equals(pollHost.name)) {
            key = pollHost.key;
            target = new URL(pollHost.url, "upload");
            proxyHost = pollHost.proxyHost;
            proxyPort = pollHost.proxyPort;
            break;
        }
    }

    if (key == null) {
        logger.severe("Origin host/url/key not found!");
        return;
    }

    // 2. Jar up the run
    String[] files = new File(Config.OUT_DIR, runId).list();
    File jarFile = new File(Config.TMP_DIR, runId + ".jar");
    jar(Config.OUT_DIR + runId, files, jarFile.getAbsolutePath());

    // 3. Upload the run
    ArrayList<Part> params = new ArrayList<Part>();
    //MultipartPostMethod post = new MultipartPostMethod(target.toString());
    params.add(new StringPart("host", Config.FABAN_HOST));
    params.add(new StringPart("key", key));
    params.add(new StringPart("origin", "true"));
    params.add(new FilePart("jarfile", jarFile));
    Part[] parts = new Part[params.size()];
    parts = params.toArray(parts);
    PostMethod post = new PostMethod(target.toString());
    post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
    HttpClient client = new HttpClient();
    if (proxyHost != null)
        client.getHostConfiguration().setProxy(proxyHost, proxyPort);
    client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
    int status = client.executeMethod(post);
    if (status == HttpStatus.SC_FORBIDDEN)
        logger.severe("Server " + host + " denied permission to upload run " + runId + '!');
    else if (status == HttpStatus.SC_NOT_ACCEPTABLE)
        logger.severe("Run " + runId + " origin error!");
    else if (status != HttpStatus.SC_CREATED)
        logger.severe(
                "Server responded with status code " + status + ". Status code 201 (SC_CREATED) expected.");
    jarFile.delete();
}

From source file:com.sun.faban.harness.webclient.ResultAction.java

/**
 * This method is responsible for uploading the runs to repository.
 * @param uploadSet//from   w  w w . j  a  v  a  2 s.c  om
 * @param replaceSet
 * @return HashSet
 * @throws java.io.IOException
 */
public static HashSet<String> uploadRuns(String[] runIds, HashSet<File> uploadSet, HashSet<String> replaceSet)
        throws IOException {
    // 3. Upload the run
    HashSet<String> duplicates = new HashSet<String>();

    // Prepare run id set for cross checking.
    HashSet<String> runIdSet = new HashSet<String>(runIds.length);
    for (String runId : runIds) {
        runIdSet.add(runId);
    }

    // Prepare the parts for the request.
    ArrayList<Part> params = new ArrayList<Part>();
    params.add(new StringPart("host", Config.FABAN_HOST));
    for (String replaceId : replaceSet) {
        params.add(new StringPart("replace", replaceId));
    }
    for (File jarFile : uploadSet) {
        params.add(new FilePart("jarfile", jarFile));
    }
    Part[] parts = new Part[params.size()];
    parts = params.toArray(parts);

    // Send the request for each reposotory.
    for (URL repository : Config.repositoryURLs) {
        URL repos = new URL(repository, "/controller/uploader/upload_runs");
        PostMethod post = new PostMethod(repos.toString());
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));

        HttpClient client = new HttpClient();
        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
        int status = client.executeMethod(post);

        if (status == HttpStatus.SC_FORBIDDEN)
            logger.warning("Server denied permission to upload run !");
        else if (status == HttpStatus.SC_NOT_ACCEPTABLE)
            logger.warning("Run origin error!");
        else if (status != HttpStatus.SC_CREATED)
            logger.warning(
                    "Server responded with status code " + status + ". Status code 201 (SC_CREATED) expected.");
        for (File jarFile : uploadSet) {
            jarFile.delete();
        }

        String response = post.getResponseBodyAsString();

        if (status == HttpStatus.SC_CREATED) {

            StringTokenizer t = new StringTokenizer(response.trim(), "\n");
            while (t.hasMoreTokens()) {
                String duplicateRun = t.nextToken().trim();
                if (duplicateRun.length() > 0)
                    duplicates.add(duplicateRun.trim());
            }

            for (Iterator<String> iter = duplicates.iterator(); iter.hasNext();) {
                String runId = iter.next();
                if (!runIdSet.contains(runId)) {
                    logger.warning("Unexpected archive response from " + repos + ": " + runId);
                    iter.remove();
                }
            }
        } else {
            logger.warning("Message from repository: " + response);
        }
    }
    return duplicates;
}

From source file:davmail.exchange.dav.DavExchangeSession.java

/**
 * Create message in specified folder./* w w w.j  a v a2s.  c o  m*/
 * Will overwrite an existing message with same messageName in the same folder
 *
 * @param folderPath  Exchange folder path
 * @param messageName message name
 * @param properties  message properties (flags)
 * @param mimeMessage MIME message
 * @throws IOException when unable to create message
 */
@Override
public void createMessage(String folderPath, String messageName, HashMap<String, String> properties,
        MimeMessage mimeMessage) throws IOException {
    String messageUrl = URIUtil.encodePathQuery(getFolderPath(folderPath) + '/' + messageName);
    PropPatchMethod patchMethod;
    List<PropEntry> davProperties = buildProperties(properties);

    if (properties != null && properties.containsKey("draft")) {
        // note: draft is readonly after create, create the message first with requested messageFlags
        davProperties.add(Field.createDavProperty("messageFlags", properties.get("draft")));
    }
    if (properties != null && properties.containsKey("mailOverrideFormat")) {
        davProperties.add(Field.createDavProperty("mailOverrideFormat", properties.get("mailOverrideFormat")));
    }
    if (properties != null && properties.containsKey("messageFormat")) {
        davProperties.add(Field.createDavProperty("messageFormat", properties.get("messageFormat")));
    }
    if (!davProperties.isEmpty()) {
        patchMethod = new PropPatchMethod(messageUrl, davProperties);
        try {
            // update message with blind carbon copy and other flags
            int statusCode = httpClient.executeMethod(patchMethod);
            if (statusCode != HttpStatus.SC_MULTI_STATUS) {
                throw new DavMailException("EXCEPTION_UNABLE_TO_CREATE_MESSAGE", messageUrl, statusCode, ' ',
                        patchMethod.getStatusLine());
            }

        } finally {
            patchMethod.releaseConnection();
        }
    }

    // update message body
    PutMethod putmethod = new PutMethod(messageUrl);
    putmethod.setRequestHeader("Translate", "f");
    putmethod.setRequestHeader("Content-Type", "message/rfc822");

    try {
        // use same encoding as client socket reader
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        mimeMessage.writeTo(baos);
        baos.close();
        putmethod.setRequestEntity(new ByteArrayRequestEntity(baos.toByteArray()));
        int code = httpClient.executeMethod(putmethod);

        // workaround for misconfigured Exchange server
        if (code == HttpStatus.SC_NOT_ACCEPTABLE) {
            LOGGER.warn(
                    "Draft message creation failed, failover to property update. Note: attachments are lost");

            ArrayList<PropEntry> propertyList = new ArrayList<PropEntry>();
            propertyList.add(Field.createDavProperty("to", mimeMessage.getHeader("to", ",")));
            propertyList.add(Field.createDavProperty("cc", mimeMessage.getHeader("cc", ",")));
            propertyList.add(Field.createDavProperty("message-id", mimeMessage.getHeader("message-id", ",")));

            MimePart mimePart = mimeMessage;
            if (mimeMessage.getContent() instanceof MimeMultipart) {
                MimeMultipart multiPart = (MimeMultipart) mimeMessage.getContent();
                for (int i = 0; i < multiPart.getCount(); i++) {
                    String contentType = multiPart.getBodyPart(i).getContentType();
                    if (contentType.startsWith("text/")) {
                        mimePart = (MimePart) multiPart.getBodyPart(i);
                        break;
                    }
                }
            }

            String contentType = mimePart.getContentType();

            if (contentType.startsWith("text/plain")) {
                propertyList.add(Field.createDavProperty("description", (String) mimePart.getContent()));
            } else if (contentType.startsWith("text/html")) {
                propertyList.add(Field.createDavProperty("htmldescription", (String) mimePart.getContent()));
            } else {
                LOGGER.warn("Unsupported content type: " + contentType + " message body will be empty");
            }

            propertyList.add(Field.createDavProperty("subject", mimeMessage.getHeader("subject", ",")));
            PropPatchMethod propPatchMethod = new PropPatchMethod(messageUrl, propertyList);
            try {
                int patchStatus = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propPatchMethod);
                if (patchStatus == HttpStatus.SC_MULTI_STATUS) {
                    code = HttpStatus.SC_OK;
                }
            } finally {
                propPatchMethod.releaseConnection();
            }
        }

        if (code != HttpStatus.SC_OK && code != HttpStatus.SC_CREATED) {

            // first delete draft message
            if (!davProperties.isEmpty()) {
                try {
                    DavGatewayHttpClientFacade.executeDeleteMethod(httpClient, messageUrl);
                } catch (IOException e) {
                    LOGGER.warn("Unable to delete draft message");
                }
            }
            if (code == HttpStatus.SC_INSUFFICIENT_STORAGE) {
                throw new InsufficientStorageException(putmethod.getStatusText());
            } else {
                throw new DavMailException("EXCEPTION_UNABLE_TO_CREATE_MESSAGE", messageUrl, code, ' ',
                        putmethod.getStatusLine());
            }
        }
    } catch (MessagingException e) {
        throw new IOException(e.getMessage());
    } finally {
        putmethod.releaseConnection();
    }

    try {
        // need to update bcc after put
        if (mimeMessage.getHeader("Bcc") != null) {
            davProperties = new ArrayList<PropEntry>();
            davProperties.add(Field.createDavProperty("bcc", mimeMessage.getHeader("Bcc", ",")));
            patchMethod = new PropPatchMethod(messageUrl, davProperties);
            try {
                // update message with blind carbon copy
                int statusCode = httpClient.executeMethod(patchMethod);
                if (statusCode != HttpStatus.SC_MULTI_STATUS) {
                    throw new DavMailException("EXCEPTION_UNABLE_TO_CREATE_MESSAGE", messageUrl, statusCode,
                            ' ', patchMethod.getStatusLine());
                }

            } finally {
                patchMethod.releaseConnection();
            }
        }
    } catch (MessagingException e) {
        throw new IOException(e.getMessage());
    }

}

From source file:org.ala.client.appender.RestfulAppender.java

private int sendRestRequest(LoggingEvent event) {
    PostMethod post = null;/*  w w  w. j  a  v a2  s .  c o  m*/
    int statusCode = 0;
    String message = null;
    LogEventVO vo = null;

    try {
        Object object = event.getMessage();
        if (object instanceof LogEventVO) {
            //convert to JSON
            message = serMapper.writeValueAsString(object);
        } else if (event.getMessage() instanceof String) {
            message = (String) object;
            if (message.startsWith("Discarded")) {
                //NQ:2014-02-13 - This is a special type of message that was sent from the AsynAppender to let us know that 
                //some messages were discarded
                return 0;
            }
            //validate json string
            vo = deserMapper.readValue(message, LogEventVO.class);
        }

        if (restfulClient == null) {
            restfulClient = new RestfulClient(timeout);
        }

        LogLog.debug("Posting log event to URL [" + urlTemplate + "]");
        Object[] array = restfulClient.restPost(urlTemplate, message, constructHttpHeaders(event));
        if (array != null && array.length > 0) {
            statusCode = (Integer) array[0];
        }
    } catch (Exception e) {
        statusCode = HttpStatus.SC_NOT_ACCEPTABLE;
        LogLog.error(
                "Could not send message from RestfulAppender [" + name + "],\nMessage: " + event.getMessage(),
                e);
    } finally {
        vo = null; //waiting for gc.
        if (post != null) {
            post.releaseConnection();
        }
    }
    return statusCode;
}

From source file:org.alfresco.integrations.google.docs.webscripts.DiscardContent.java

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    getGoogleDocsServiceSubsystem();// w ww  .ja  va  2s.  c o m

    Map<String, Object> model = new HashMap<String, Object>();

    Map<String, Serializable> map = parseContent(req);
    final NodeRef nodeRef = (NodeRef) map.get(JSON_KEY_NODEREF);

    if (nodeService.hasAspect(nodeRef, GoogleDocsModel.ASPECT_EDITING_IN_GOOGLE)) {
        try {
            boolean deleted = false;

            if (!Boolean.valueOf(map.get(JSON_KEY_OVERRIDE).toString())) {
                SiteInfo siteInfo = siteService.getSite(nodeRef);
                if (siteInfo == null
                        || siteService.isMember(siteInfo.getShortName(), AuthenticationUtil.getRunAsUser())) {

                    if (googledocsService.hasConcurrentEditors(nodeRef)) {
                        throw new WebScriptException(HttpStatus.SC_CONFLICT,
                                "Node: " + nodeRef.toString() + " has concurrent editors.");
                    }
                } else {
                    throw new AccessDeniedException(
                            "Access Denied.  You do not have the appropriate permissions to perform this operation.");
                }
            }

            deleted = delete(nodeRef);

            model.put(MODEL_SUCCESS, deleted);

        } catch (InvalidNodeRefException ine) {
            throw new WebScriptException(HttpStatus.SC_NOT_FOUND, ine.getMessage());
        } catch (IOException ioe) {
            throw new WebScriptException(HttpStatus.SC_INTERNAL_SERVER_ERROR, ioe.getMessage());
        } catch (GoogleDocsAuthenticationException gdae) {
            throw new WebScriptException(HttpStatus.SC_BAD_GATEWAY, gdae.getMessage());
        } catch (GoogleDocsRefreshTokenException gdrte) {
            throw new WebScriptException(HttpStatus.SC_BAD_GATEWAY, gdrte.getMessage());
        } catch (GoogleDocsServiceException gdse) {
            if (gdse.getPassedStatusCode() > -1) {
                throw new WebScriptException(gdse.getPassedStatusCode(), gdse.getMessage());
            } else {
                throw new WebScriptException(gdse.getMessage());
            }
        } catch (AccessDeniedException ade) {
            // This code will make changes after the rollback has occurred to clean up the node: remove the lock and the Google
            // Docs aspect. If it has the temporary aspect it will also remove the node from Alfresco
            AlfrescoTransactionSupport.bindListener(new TransactionListenerAdapter() {
                public void afterRollback() {
                    transactionService.getRetryingTransactionHelper()
                            .doInTransaction(new RetryingTransactionCallback<Object>() {
                                public Object execute() throws Throwable {
                                    DriveFile driveFile = googledocsService.getDriveFile(nodeRef);
                                    googledocsService.unlockNode(nodeRef);
                                    boolean deleted = googledocsService.deleteContent(nodeRef, driveFile);

                                    if (deleted) {
                                        AuthenticationUtil
                                                .runAsSystem(new AuthenticationUtil.RunAsWork<Object>() {
                                                    public Object doWork() throws Exception {
                                                        if (nodeService.hasAspect(nodeRef,
                                                                ContentModel.ASPECT_TEMPORARY)) {
                                                            nodeService.deleteNode(nodeRef);
                                                        }

                                                        return null;
                                                    }
                                                });
                                    }

                                    return null;
                                }
                            }, false, true);
                }
            });

            throw new WebScriptException(HttpStatus.SC_FORBIDDEN, ade.getMessage(), ade);
        } catch (Exception e) {
            throw new WebScriptException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage(), e);
        }
    } else {
        throw new WebScriptException(HttpStatus.SC_NOT_ACCEPTABLE,
                "Missing Google Docs Aspect on " + nodeRef.toString());
    }

    return model;
}

From source file:org.alfresco.integrations.google.docs.webscripts.Exportable.java

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    getGoogleDocsServiceSubsystem();//from  w ww  .  j a v  a 2s  .c o  m

    Map<String, Object> model = new HashMap<String, Object>();

    try {
        if (googledocsService.isExportable(req.getParameter(PARAM_MIMETYPE))) {
            model.put(MODEL_EXPORT_ACION, ACTION_DEFAULT);
        } else {
            throw new WebScriptException(HttpStatus.SC_NOT_ACCEPTABLE, "Content not exportable");
        }
    } catch (MustUpgradeFormatException mufe) {
        model.put(MODEL_EXPORT_ACION, ACTION_UPGRADE);
    } catch (MustDowngradeFormatException mdfe) {
        model.put(MODEL_EXPORT_ACION, ACTION_DOWNGRADE);
    }

    log.debug("Mimetype: " + req.getParameter(PARAM_MIMETYPE) + "; export action: "
            + model.get(MODEL_EXPORT_ACION));

    return model;
}

From source file:org.opens.tanaguru.util.http.HttpRequestHandler.java

private int computeStatus(int status) {
    switch (status) {
    case HttpStatus.SC_FORBIDDEN:
    case HttpStatus.SC_METHOD_NOT_ALLOWED:
    case HttpStatus.SC_BAD_REQUEST:
    case HttpStatus.SC_UNAUTHORIZED:
    case HttpStatus.SC_PAYMENT_REQUIRED:
    case HttpStatus.SC_NOT_FOUND:
    case HttpStatus.SC_NOT_ACCEPTABLE:
    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
    case HttpStatus.SC_REQUEST_TIMEOUT:
    case HttpStatus.SC_CONFLICT:
    case HttpStatus.SC_GONE:
    case HttpStatus.SC_LENGTH_REQUIRED:
    case HttpStatus.SC_PRECONDITION_FAILED:
    case HttpStatus.SC_REQUEST_TOO_LONG:
    case HttpStatus.SC_REQUEST_URI_TOO_LONG:
    case HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE:
    case HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE:
    case HttpStatus.SC_EXPECTATION_FAILED:
    case HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE:
    case HttpStatus.SC_METHOD_FAILURE:
    case HttpStatus.SC_UNPROCESSABLE_ENTITY:
    case HttpStatus.SC_LOCKED:
    case HttpStatus.SC_FAILED_DEPENDENCY:
    case HttpStatus.SC_INTERNAL_SERVER_ERROR:
    case HttpStatus.SC_NOT_IMPLEMENTED:
    case HttpStatus.SC_BAD_GATEWAY:
    case HttpStatus.SC_SERVICE_UNAVAILABLE:
    case HttpStatus.SC_GATEWAY_TIMEOUT:
    case HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED:
    case HttpStatus.SC_INSUFFICIENT_STORAGE:
        return 0;
    case HttpStatus.SC_CONTINUE:
    case HttpStatus.SC_SWITCHING_PROTOCOLS:
    case HttpStatus.SC_PROCESSING:
    case HttpStatus.SC_OK:
    case HttpStatus.SC_CREATED:
    case HttpStatus.SC_ACCEPTED:
    case HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION:
    case HttpStatus.SC_NO_CONTENT:
    case HttpStatus.SC_RESET_CONTENT:
    case HttpStatus.SC_PARTIAL_CONTENT:
    case HttpStatus.SC_MULTI_STATUS:
    case HttpStatus.SC_MULTIPLE_CHOICES:
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_MOVED_TEMPORARILY:
    case HttpStatus.SC_SEE_OTHER:
    case HttpStatus.SC_NOT_MODIFIED:
    case HttpStatus.SC_USE_PROXY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        return 1;
    default:/*w  w  w  .ja  v a  2  s. c  o m*/
        return 1;
    }
}