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


Java WebScriptException类代码示例

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


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

示例1: getIntParameter

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
private int getIntParameter(WebScriptRequest req, String paramName, int defaultValue)
{
    String paramString = req.getParameter(paramName);

    if (paramString != null)
    {
        try
        {
            int param = Integer.valueOf(paramString);

            if (param >= 0)
            {
                return param;
            }
        }
        catch (NumberFormatException e)
        {
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
        }
    }

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

示例2: executeImpl

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();

    NodeRef nodeRef = parseRequestForNodeRef(req);
    String ratingSchemeName = parseRequestForScheme(req);
    
    Rating deletedRating = ratingService.removeRatingByCurrentUser(nodeRef, ratingSchemeName);
    if (deletedRating == null)
    {
        // There was no rating in the specified scheme to delete.
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Unable to delete non-existent rating: "
                + ratingSchemeName + " from " + nodeRef.toString());
    }
    
    model.put(NODE_REF, nodeRef.toString());
    model.put(AVERAGE_RATING, ratingService.getAverageRating(nodeRef, ratingSchemeName));
    model.put(RATINGS_TOTAL, ratingService.getTotalRating(nodeRef, ratingSchemeName));
    model.put(RATINGS_COUNT, ratingService.getRatingsCount(nodeRef, ratingSchemeName));
  
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:RatingDelete.java

示例3: parseRequestForNodeRef

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
protected NodeRef parseRequestForNodeRef(WebScriptRequest req)
{
    // get the parameters that represent the NodeRef, we know they are present
    // otherwise this webscript would not have matched
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String nodeId = templateVars.get("id");

    // create the NodeRef and ensure it is valid
    StoreRef storeRef = new StoreRef(storeType, storeId);
    NodeRef nodeRef = new NodeRef(storeRef, nodeId);

    if (!this.nodeService.exists(nodeRef))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef.toString());
    }

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

示例4: getState

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
/**
 * Gets the specified {@link WorkflowTaskState}, null if not requested
 * 
 * @param req WebScriptRequest
 * @return WorkflowTaskState
 */
private WorkflowTaskState getState(WebScriptRequest req)
{
    String stateName = req.getParameter(PARAM_STATE);
    if (stateName != null)
    {
        try
        {
            return WorkflowTaskState.valueOf(stateName.toUpperCase());
        }
        catch (IllegalArgumentException e)
        {
            String msg = "Unrecognised State parameter: " + stateName;
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
        }
    }
    
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:TaskInstancesGet.java

示例5: buildModel

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // getting task id from request parameters
    String taskId = params.get("task_instance_id");

    // searching for task in repository
    WorkflowTask workflowTask = workflowService.getTaskById(taskId);

    // task was not found -> return 404
    if (workflowTask == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow task with id: " + taskId);
    }

    Map<String, Object> model = new HashMap<String, Object>();
    // build the model for ftl
    model.put("workflowTask", modelBuilder.buildDetailed(workflowTask));

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

示例6: buildModel

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // Get the definition id from the params
    String workflowDefinitionId = params.get(PARAM_WORKFLOW_DEFINITION_ID);
    
    WorkflowDefinition workflowDefinition = workflowService.getDefinitionById(workflowDefinitionId);

    // Workflow definition is not found, 404
    if (workflowDefinition == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, 
                    "Unable to find workflow definition with id: " + workflowDefinitionId);
    }
    
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("workflowDefinition", modelBuilder.buildDetailed(workflowDefinition));
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:WorkflowDefinitionGet.java

示例7: buildModel

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // getting workflow instance id from request parameters
    String workflowInstanceId = params.get("workflow_instance_id");

    boolean includeTasks = getIncludeTasks(req);

    WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowInstanceId);

    // task was not found -> return 404
    if (workflowInstance == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow instance with id: " + workflowInstanceId);
    }

    Map<String, Object> model = new HashMap<String, Object>();
    // build the model for ftl
    model.put("workflowInstance", modelBuilder.buildDetailed(workflowInstance, includeTasks));

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

示例8: getState

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
/**
 * Gets the specified {@link WorkflowState}, null if not requested.
 * 
 * @param req The WebScript request
 * @return The workflow state or null if not requested
 */
private WorkflowState getState(WebScriptRequest req)
{
    String stateName = req.getParameter(PARAM_STATE);
    if (stateName != null)
    {
        try
        {
            return WorkflowState.valueOf(stateName.toUpperCase());
        }
        catch (IllegalArgumentException e)
        {
            String msg = "Unrecognised State parameter: " + stateName;
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
        }
    }
    
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:WorkflowInstancesGet.java

示例9: executeImpl

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
protected void executeImpl(NodeRef nodeRef, Map<String, String> templateVars, WebScriptRequest req, WebScriptResponse res, Map<String, Object> model) throws IOException
{
    // render content
       QName propertyQName = ContentModel.PROP_CONTENT;
       String contentPart = templateVars.get("property");
       if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
       {
           if (contentPart.length() < 2)
           {
               throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
           }
           String propertyName = contentPart.substring(1);
           if (propertyName.length() > 0)
           {
               propertyQName = QName.createQName(propertyName, namespaceService);
           }
       }
       
       // determine attachment
       boolean attach = Boolean.valueOf(req.getParameter("a"));
       
       // Stream the content
       streamContentLocal(req, res, nodeRef, attach, propertyQName, model);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:QuickShareContentGet.java

示例10: getClassQName

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected QName getClassQName(WebScriptRequest req)
{
    QName classQName = null;
    String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
    if (className != null && className.length() != 0)
    {            
        classQName = createClassQName(className);
        if (classQName == null)
        {
            // Error 
            throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
        }
    }
    return classQName;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:PropertiesGet.java

示例11: getAssociationQname

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected QName getAssociationQname(WebScriptRequest req)
{
    String associationName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_ASSOCIATION_SHORTNAME);
    String associationPrefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_ASSOCIATION_PREFIX);
    
    if(associationPrefix == null)
    {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter association prefix in the URL");
    }
    if(associationName == null)
    {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter association name in the URL");
    }
    
    return QName.createQName(getFullNamespaceURI(associationPrefix, associationName));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:18,代码来源:AssociationGet.java

示例12: getPropertyQname

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected QName getPropertyQname(WebScriptRequest req)
{
    String propertyName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_SHORTPROPERTY_NAME);
    String propertyPrefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PROPERTY_FREFIX);
    
    //validate the presence of property name
    if(propertyName == null)
    {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter short propertyname in the URL");
    }
    //validate the presence of property prefix
    if(propertyPrefix == null)
    {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter propertyprefix in the URL");
    }
    
    return QName.createQName(getFullNamespaceURI(propertyPrefix, propertyName));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:20,代码来源:PropertyGet.java

示例13: getIntParameter

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
/**
 * Retrieves the named parameter as an integer, if the parameter is not present the default value is returned
 * 
 * @param req The WebScript request
 * @param paramName The name of parameter to look for
 * @param defaultValue The default value that should be returned if parameter is not present in request or if it is not positive
 * @return The request parameter or default value
 */
protected int getIntParameter(WebScriptRequest req, String paramName, int defaultValue)
{
    String paramString = req.getParameter(paramName);
    
    if (paramString != null)
    {
        try
        {
            int param = Integer.valueOf(paramString);
            
            if (param >= 0)
            {
                return param;
            }
        }
        catch (NumberFormatException e) 
        {
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
        }
    }
    
    return defaultValue;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:32,代码来源:AbstractArchivedNodeWebScript.java

示例14: buildModel

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected Map<String, Object> buildModel(ReplicationModelBuilder modelBuilder, 
                                         WebScriptRequest req, Status status, Cache cache)
{
    // Which definition did they ask for?
    String replicationDefinitionName = 
       req.getServiceMatch().getTemplateVars().get("replication_definition_name");
    ReplicationDefinition replicationDefinition =
       replicationService.loadReplicationDefinition(replicationDefinitionName);
    
    // Does it exist?
    if(replicationDefinition == null) {
       throw new WebScriptException(
             Status.STATUS_NOT_FOUND, 
             "No Replication Definition found with that name"
       );
    }
   
    // Have it turned into simple models
    return modelBuilder.buildDetails(replicationDefinition);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:ReplicationDefinitionGet.java

示例15: executeImpl

import org.springframework.extensions.webscripts.WebScriptException; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req,
      Status status, Cache cache) 
{
   // Grab the site
   String siteName = 
       req.getServiceMatch().getTemplateVars().get("shortname");
   SiteInfo site = siteService.getSite(siteName);
   if (site == null)
   {
       throw new WebScriptException(
               Status.STATUS_NOT_FOUND, 
               "No Site found with that short name");
   }
   
   // Process
   return executeImpl(site, req, status, cache);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:19,代码来源:AbstractSiteWebScript.java


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