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

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

Introduction

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

Prototype

int SC_INSUFFICIENT_STORAGE

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

Click Source Link

Document

507 Insufficient Storage (WebDAV - RFC 2518)

Usage

From source file:com.owncloud.android.operations.RemoteOperationResult.java

private RemoteOperationResult(boolean success, int httpCode) {
    mSuccess = success;//from   w  w  w  .  j a  va2s. c om
    mHttpCode = httpCode;

    if (success) {
        mCode = ResultCode.OK;

    } else if (httpCode > 0) {
        switch (httpCode) {
        case HttpStatus.SC_UNAUTHORIZED:
            mCode = ResultCode.UNAUTHORIZED;
            break;
        case HttpStatus.SC_NOT_FOUND:
            mCode = ResultCode.FILE_NOT_FOUND;
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
            break;
        case HttpStatus.SC_CONFLICT:
            mCode = ResultCode.CONFLICT;
            break;
        case HttpStatus.SC_INSUFFICIENT_STORAGE:
            mCode = ResultCode.QUOTA_EXCEEDED;
            break;
        default:
            mCode = ResultCode.UNHANDLED_HTTP_CODE;
            Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
        }
    }
}

From source file:com.owncloud.android.oc_framework.operations.RemoteOperationResult.java

private RemoteOperationResult(boolean success, int httpCode) {
    mSuccess = success;/* www. jav a  2s.c o m*/
    mHttpCode = httpCode;

    if (success) {
        mCode = ResultCode.OK;

    } else if (httpCode > 0) {
        switch (httpCode) {
        case HttpStatus.SC_UNAUTHORIZED:
            mCode = ResultCode.UNAUTHORIZED;
            break;
        case HttpStatus.SC_NOT_FOUND:
            mCode = ResultCode.FILE_NOT_FOUND;
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
            break;
        case HttpStatus.SC_CONFLICT:
            mCode = ResultCode.CONFLICT;
            break;
        case HttpStatus.SC_INSUFFICIENT_STORAGE:
            mCode = ResultCode.QUOTA_EXCEEDED;
            break;
        default:
            mCode = ResultCode.UNHANDLED_HTTP_CODE;
            Log.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
        }
    }
}

From source file:com.cerema.cloud2.lib.common.operations.RemoteOperationResult.java

private RemoteOperationResult(boolean success, int httpCode) {
    mSuccess = success;//www .  j  a va  2 s . c  o  m
    mHttpCode = httpCode;

    if (success) {
        mCode = ResultCode.OK;

    } else if (httpCode > 0) {
        switch (httpCode) {
        case HttpStatus.SC_UNAUTHORIZED:
            mCode = ResultCode.UNAUTHORIZED;
            break;
        case HttpStatus.SC_NOT_FOUND:
            mCode = ResultCode.FILE_NOT_FOUND;
            break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
            mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
            break;
        case HttpStatus.SC_CONFLICT:
            mCode = ResultCode.CONFLICT;
            break;
        case HttpStatus.SC_INSUFFICIENT_STORAGE:
            mCode = ResultCode.QUOTA_EXCEEDED;
            break;
        case HttpStatus.SC_FORBIDDEN:
            mCode = ResultCode.FORBIDDEN;
            break;
        default:
            mCode = ResultCode.UNHANDLED_HTTP_CODE;
            Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
        }
    }
}

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

/**
 * Create message in specified folder.//  w  w  w . jav  a  2 s.  co  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.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 om
        return 1;
    }
}