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


Java Status.STATUS_FORBIDDEN属性代码示例

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


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

示例1: createLink

/**
 * Create link for sourceNodeRef in destinationNodeRef location
 * 
 * @param destinationNodeRef
 * @param sourceNodeRef
 * @return
 */
private NodeRef createLink(NodeRef destinationNodeRef, NodeRef sourceNodeRef)
{
    NodeRef linkNodeRef = null;
    try
    {
        linkNodeRef = documentLinkService.createDocumentLink(sourceNodeRef, destinationNodeRef);
    }
    catch (IllegalArgumentException ex)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid Arguments: " + ex.getMessage());
    }
    catch (AccessDeniedException e)
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, "You don't have permission to perform this operation");
    }
    return linkNodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:DocLinkPost.java

示例2: checkAndCancelTheInvitation

protected void checkAndCancelTheInvitation(final String invId, String siteShortName)
{
    Invitation invitation = null;
    try
    {
        invitation = invitationService.getInvitation(invId);
    }
    catch (org.alfresco.service.cmr.invitation.InvitationExceptionNotFound ienf)
    {
        throwInvitationNotFoundException(invId, siteShortName);
    }
    if (invitation == null)
    {
        throwInvitationNotFoundException(invId, siteShortName);
    }

    // check that this invitation really belongs to the specified siteShortName
    if (invitation != null && invitation.getResourceName() != null && !siteShortName.equals(invitation.getResourceName()))
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow");
    }

    invitationService.cancel(invId);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:InvitationDelete.java

示例3: validatePermission

protected void validatePermission(NodeRef nodeRef, String currentUser)
{
    if (!nodeArchiveService.hasFullAccess(nodeRef))
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, "You don't have permission to act on the node.");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:7,代码来源:AbstractArchivedNodeWebScript.java

示例4: execute

private Map<String, Object> execute(WebScriptRequest req, Status status)
{
    // initialise model to pass on for template to render
    Map<String, Object> model = new HashMap<String, Object>();
    
    // get inviteId and inviteTicket
    String inviteId = req.getServiceMatch().getTemplateVars().get("inviteId");
    String inviteTicket = req.getServiceMatch().getTemplateVars().get("inviteTicket");
    
    try 
    {
        Invitation invitation = invitationService.getInvitation(inviteId);
        
        if (invitation instanceof NominatedInvitation)
        {
            NominatedInvitation theInvitation = (NominatedInvitation)invitation;
            String ticket = theInvitation.getTicket();
            if (ticket == null || (! ticket.equals(inviteTicket)))
            {
                throw new WebScriptException(Status.STATUS_NOT_FOUND, "Ticket mismatch");
            }
            // return the invite info
            model.put("invite", toInviteInfo(theInvitation));
            return model;
        }
        else
        {
            // Not a nominated invitation
            throw new WebScriptException(Status.STATUS_FORBIDDEN, "Not a nominated invitation");
        }
    }
    catch (InvitationExceptionNotFound nfe)
    {
        throw new WebScriptException(Status.STATUS_NOT_FOUND,
        "No invite found for given id");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:37,代码来源:InviteByTicket.java

示例5: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    NodeRef destinationNodeRef = null;

    /* Parse the template vars */
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    destinationNodeRef = parseNodeRefFromTemplateArgs(templateVars);

    /* Delete links */
    DeleteLinksStatusReport report;
    try
    {
        report = documentLinkService.deleteLinksToDocument(destinationNodeRef);
    }
    catch (IllegalArgumentException ex)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid Arguments: " + ex.getMessage());
    }
    catch (AccessDeniedException e)
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, "You don't have permission to perform this operation");
    }

    /* Build response */
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("total_count", report.getTotalLinksFoundCount());
    model.put("deleted_count", report.getDeletedLinksCount());

    Map<String, String> errorDetails = new HashMap<String, String>();
    Iterator<Entry<NodeRef, Throwable>> it = report.getErrorDetails().entrySet().iterator();
    while (it.hasNext())
    {
        Map.Entry<NodeRef, Throwable> pair = it.next();

        Throwable th = pair.getValue();

        errorDetails.put(pair.getKey().toString(), th.getMessage());
    }

    model.put("error_details", errorDetails);
    

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

示例6: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{

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

    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    final String siteShortName = templateVars.get("shortname");
    final String invitationId = templateVars.get("invitationId");
    validateParameters(siteShortName, invitationId);

    try
    {
        // MNT-9905 Pending Invites created by one site manager aren't visible to other site managers
        String currentUser = AuthenticationUtil.getRunAsUser();

        if (siteShortName != null && (SiteModel.SITE_MANAGER).equals(siteService.getMembersRole(siteShortName, currentUser)))
        {

            RunAsWork<Void> runAsSystem = new RunAsWork<Void>()
            {
                @Override
                public Void doWork() throws Exception
                {
                    checkAndCancelTheInvitation(invitationId, siteShortName);
                    return null;
                }
            };

            AuthenticationUtil.runAs(runAsSystem, AuthenticationUtil.getSystemUserName());
        }
        else
        {
            checkAndCancelTheInvitation(invitationId, siteShortName);
        }
    }
    catch (InvitationExceptionForbidden fe)
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow", fe);
    }
    catch (AccessDeniedException ade)
    {
        throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow", ade);
    }

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

示例7: 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_FORBIDDEN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。