当前位置: 首页>>代码示例>>Java>>正文


Java Status.STATUS_INTERNAL_SERVER_ERROR属性代码示例

本文整理汇总了Java中org.springframework.extensions.webscripts.Status.STATUS_INTERNAL_SERVER_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Status.STATUS_INTERNAL_SERVER_ERROR属性的具体用法?Java Status.STATUS_INTERNAL_SERVER_ERROR怎么用?Java Status.STATUS_INTERNAL_SERVER_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.extensions.webscripts.Status的用法示例。


在下文中一共展示了Status.STATUS_INTERNAL_SERVER_ERROR属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();
    
    try
    {
        req.getContent().getInputStream().close();
        model.put("result", "success");
    }
    catch (IOException e)
    {
        throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "Fail to read request content.");
    }
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:16,代码来源:LargeContentTestPut.java

示例2: createTempFile

protected File createTempFile(InputStream inputStream)
{
    try
    {
        File tempFile = TempFileProvider.createTempFile(inputStream, TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX);
        return tempFile;
    }
    catch (Exception ex)
    {
        throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "cmm.rest_api.model.import_process_zip_file_failure", ex);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:12,代码来源:CustomModelUploadPost.java

示例3: importModel

protected CustomModel importModel(M2Model m2Model)
{
    CustomModel model = null;
    try
    {
        model = customModels.createCustomModel(m2Model);
    }
    catch (Exception ex)
    {
        int statusCode;
        if (ex instanceof ConstraintViolatedException)
        {
            statusCode = Status.STATUS_CONFLICT;
        }
        else if (ex instanceof InvalidArgumentException)
        {
            statusCode = Status.STATUS_BAD_REQUEST;
        }
        else
        {
            statusCode = Status.STATUS_INTERNAL_SERVER_ERROR;
        }
        String msg = ex.getMessage();
        // remove log numbers. regEx => match 8 or more integers
        msg = (msg != null) ? msg.replaceAll("\\d{8,}", "").trim() : "cmm.rest_api.model.import_failure";

        throw new WebScriptException(statusCode, msg);
    }

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:31,代码来源:CustomModelUploadPost.java

示例4: getExtensionModule

protected String getExtensionModule(InputStream inputStream, String fileName)
{
    Element rootElement = null;
    try
    {
        final DocumentBuilder db = XMLUtil.getDocumentBuilder();
        rootElement = db.parse(inputStream).getDocumentElement();
    }
    catch (IOException io)
    {
        throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "cmm.rest_api.model.import_process_ext_module_file_failure", io);
    }
    catch (SAXException ex)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_invalid_ext_module_entry", new Object[] { fileName }, ex);
    }

    if (rootElement != null && SHARE_EXT_MODULE_ROOT_ELEMENT.equals(rootElement.getNodeName()))
    {
        StringWriter sw = new StringWriter();
        XMLUtil.print(rootElement, sw, false);

        return sw.toString();
    }

    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:CustomModelUploadPost.java

示例5: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    if (!customModelService.isModelAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, PermissionDeniedException.DEFAULT_MESSAGE_ID);
    }

    FormData formData = (FormData) req.parseContent();
    if (formData == null || !formData.getIsMultiPart())
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_not_multi_part_req");
    }

    ImportResult resultData = null;
    boolean processed = false;
    for (FormData.FormField field : formData.getFields())
    {
        if (field.getIsFile())
        {
            final String fileName = field.getFilename();
            File tempFile = createTempFile(field.getInputStream());
            try (ZipFile zipFile = new ZipFile(tempFile, StandardCharsets.UTF_8))
            {
                resultData = processUpload(zipFile, field.getFilename());
            }
            catch (ZipException ze)
            {
                throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_not_zip_format", new Object[] { fileName });
            }
            catch (IOException io)
            {
                throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "cmm.rest_api.model.import_process_zip_file_failure", io);
            }
            finally
            {
                // now the import is done, delete the temp file
                tempFile.delete();
            }
            processed = true;
            break;
        }

    }

    if (!processed)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_no_zip_file_uploaded");
    }

    // If we get here, then importing the custom model didn't throw any exceptions.
    Map<String, Object> model = new HashMap<>(2);
    model.put("importedModelName", resultData.getImportedModelName());
    model.put("shareExtXMLFragment", resultData.getShareExtXMLFragment());

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:57,代码来源:CustomModelUploadPost.java


注:本文中的org.springframework.extensions.webscripts.Status.STATUS_INTERNAL_SERVER_ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。