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


Java Status.STATUS_OK属性代码示例

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


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

示例1: processUpload

protected void processUpload(InputStream input, String filename, List<Map<QName,String>> users)
{
    try
    {
        if (filename != null && filename.length() > 0)
        {
            if (filename.endsWith(".csv"))
            {
                processCSVUpload(input, users);
                return;
            }
            if (filename.endsWith(".xls"))
            {
                processXLSUpload(input, users);
                return;
            }
            if (filename.endsWith(".xlsx"))
            {
                processXLSXUpload(input, users);
                return;
            }
        }
        
        // If in doubt, assume it's probably a .csv
        processCSVUpload(input, users);
    } 
    catch (IOException e)
    {
        // Return the error as a 200 so the user gets a friendly
        //  display of the error message in share
        throw new ResourceBundleWebScriptException(
                Status.STATUS_OK, getResources(),
                ERROR_CORRUPT_FILE, e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:35,代码来源:UserCSVUploadPost.java

示例2: updateComment

private JSONObject updateComment(NodeRef nodeRef, String title, String content, 
      int expectedStatus) throws Exception
{
   JSONObject comment = new JSONObject();
   comment.put("title", title);
   comment.put("content", content);
   Response response = sendRequest(new PutRequest(getPostUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);

   if (expectedStatus != Status.STATUS_OK)
   {
      return null;
   }

   //logger.debug("Comment updated: " + response.getContentAsString());
   JSONObject result = new JSONObject(response.getContentAsString());
   return result.getJSONObject("item");
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:DiscussionRestApiTest.java

示例3: getLink

private JSONObject getLink(String name, int expectedStatus) throws Exception
{
   Response response = sendRequest(new GetRequest(URL_LINKS_FETCH + name), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = new JSONObject(response.getContentAsString());
      if (result.has("item"))
      {
         return result.getJSONObject("item");
      }
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:LinksRestApiTest.java

示例4: deleteLinks

/**
 * Deletes the links
 */
private JSONObject deleteLinks(List<String> names, int expectedStatus) throws Exception
{
   JSONArray items = new JSONArray();
   for (String name : names)
   {
      items.put(name);
   }
   
   JSONObject json = new JSONObject();
   json.put("items", items);
   
   Response response = sendRequest(new PostRequest(URL_LINKS_DELETE, json.toString(), "application/json"), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = new JSONObject(response.getContentAsString());
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:LinksRestApiTest.java

示例5: getEntry

private JSONObject getEntry(String name, int expectedStatus) throws Exception
{
   Response response = sendRequest(new GetRequest(URL_EVENT_BASE + name), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = validateAndParseJSON(response.getContentAsString());
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:CalendarRestApiTest.java

示例6: createEntry

/**
 * Creates an event, with the date properties manually set
 */
private JSONObject createEntry(String name, String where, String description, 
      JSONObject datesJSON, int expectedStatus) throws Exception
{
   JSONObject json = new JSONObject();
   
   json.put("site", SITE_SHORT_NAME_CALENDAR);
   json.put("what", name);
   json.put("where", where);
   json.put("desc", description);
   json.put("tags", "");
   json.put("docfolder", "");
   json.put("page", "calendar");
   
   // Copy in the date properties
   for (String key : getKeys(datesJSON, false))
   {
      json.put(key, datesJSON.get(key));
   }
   
   Response response = sendRequest(new PostRequest(URL_EVENT_CREATE, json.toString(), "application/json"), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = validateAndParseJSON(response.getContentAsString());
      if (result.has("event"))
      {
         return result.getJSONObject("event");
      }
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:37,代码来源:CalendarRestApiTest.java

示例7: testAddHeader

@Test
public void testAddHeader() throws Exception
{
    WithResponse callBack = new WithResponse(Status.STATUS_OK,ResponseWriter.DEFAULT_JSON_CONTENT, ResponseWriter.CACHE_NEVER);
    callBack.addHeader("king", "can");
    callBack.addHeader("king", "kong");
    assertTrue(callBack.getHeaders().size() == 1);
    List<String> vals = callBack.getHeaders().get("king");
    assertTrue(vals.size() == 2);
    assertEquals(vals, Arrays.asList("can", "kong"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:11,代码来源:WithResponseTest.java

示例8: updateLink

/**
 * Updates the link with the new details
 */
private JSONObject updateLink(String name, String title, String description, String url,
      boolean internal, int expectedStatus) throws Exception
{
   JSONObject json = new JSONObject();
   json.put("site", SITE_SHORT_NAME_LINKS);
   json.put("title", title);
   json.put("description", description);
   json.put("url", url);
   json.put("tags", "");
   json.put("internal", Boolean.toString(internal).toLowerCase());
   json.put("page", "links-view"); // TODO Is this really needed?
   
   Response response = sendRequest(new PutRequest(URL_LINKS_UPDATE + name, json.toString(), "application/json"), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = new JSONObject(response.getContentAsString());
      if (result.has("links"))
      {
         return result.getJSONObject("links");
      }
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:LinksRestApiTest.java

示例9: deleteLink

/**
 * Deletes the link
 */
private JSONObject deleteLink(String name, int expectedStatus) throws Exception
{
   Response response = sendRequest(new DeleteRequest(URL_LINKS_FETCH+name), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = new JSONObject(response.getContentAsString());
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:16,代码来源:LinksRestApiTest.java

示例10: testDefaults

@Test
public void testDefaults() throws Exception
{
    WithResponse callBack = new WithResponse(Status.STATUS_OK, ResponseWriter.DEFAULT_JSON_CONTENT, ResponseWriter.CACHE_NEVER);
    assertEquals(Status.STATUS_OK, callBack.getStatus());
    assertEquals(ResponseWriter.DEFAULT_JSON_CONTENT, callBack.getContentInfo());
    assertEquals(ResponseWriter.CACHE_NEVER, callBack.getCache());
    assertTrue(callBack.getHeaders().isEmpty());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:9,代码来源:WithResponseTest.java

示例11: doGetPost

private JSONObject doGetPost(String url, int expectedStatus) throws Exception
{
   Response response = sendRequest(new GetRequest(url), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = new JSONObject(response.getContentAsString());
      return result.getJSONObject("item");
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:DiscussionRestApiTest.java

示例12: doGetReplies

private JSONObject doGetReplies(String url, int expectedStatus) throws Exception
{
   Response response = sendRequest(new GetRequest(url), expectedStatus);
   if (expectedStatus == Status.STATUS_OK)
   {
      JSONObject result = new JSONObject(response.getContentAsString());
      return result;
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:DiscussionRestApiTest.java

示例13: testSetters

@Test
public void testSetters() throws Exception
{
    WithResponse callBack = new WithResponse(Status.STATUS_OK, ResponseWriter.DEFAULT_JSON_CONTENT, ResponseWriter.CACHE_NEVER);
    callBack.setStatus(Status.STATUS_GONE);
    Cache myCache = new Cache(new Description.RequiredCache()
    {
        @Override
        public boolean getNeverCache()
        {
            return false;
        }

        @Override
        public boolean getIsPublic()
        {
            return true;
        }

        @Override
        public boolean getMustRevalidate()
        {
            return true;
        }
    });
    callBack.setCache(myCache);
    ContentInfo myContent = new ContentInfoImpl(Format.HTML.mimetype(),"UTF-16", 12, Locale.FRENCH);
    callBack.setContentInfo(myContent);

    assertEquals(Status.STATUS_GONE, callBack.getStatus());
    assertEquals(myCache, callBack.getCache());
    assertEquals(myContent, callBack.getContentInfo());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:33,代码来源:WithResponseTest.java

示例14: doDeletePost

private JSONObject doDeletePost(String url, int expectedStatus) throws Exception
{
   Response response = sendRequest(new DeleteRequest(url), Status.STATUS_OK);
   if (expectedStatus == Status.STATUS_OK)
   {
      return new JSONObject(response.getContentAsString());
   }
   else
   {
      return null;
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:12,代码来源:DiscussionRestApiTest.java

示例15: evaluate

@Override
public boolean evaluate(JSONObject jsonObject) {
   try
   {
      String username = getUserId();
      JSONObject modifier =(JSONObject) getProperty(jsonObject,"cm:modifier");
      
      if (username.equalsIgnoreCase((String)modifier.get("userName")))
      {
          return true;
      }
      
      
      
      String siteName = getSiteId(jsonObject);
      
      if (siteName == null)
      {
         // It's not a site, so we have no opinion on access
         return true;
      }

      // Fetch the membership information for the site
      RequestContext rc = ThreadLocalRequestContext.getRequestContext();
      Connector conn = rc.getServiceRegistry().getConnectorService().getConnector(
            "alfresco", username, ServletUtil.getSession());
      Response response = conn.call("/api/sites/"+siteName+"/memberships/"+username);
      
      if (response.getStatus().getCode() == Status.STATUS_OK)
      {
         // Convert the response text to jsonobject
         JSONObject responsetext = (JSONObject)new JSONParser().parse(response.getResponse());
         
         // Get the user role and compare with required role
         return requiredRole.equalsIgnoreCase(this.getUserRole(responsetext));         
      }
      else if (response.getStatus().getCode() == Status.STATUS_NOT_FOUND)
      {
         // Not a member of the site / site not found / etc
         // Shouldn't be showing in this case
         return false;
      }
      else
      {
         logger.warn("Invalid response fetching memberships for " + username + " in " + siteName + " - " + response);
         return false;
      }
   }
   catch (Exception err)
   {
      throw new AlfrescoRuntimeException("Failed to run UI evaluator: " + err.getMessage());
   }
 }
 
开发者ID:muralidharand,项目名称:alfresco-disable-enable-download-action,代码行数:53,代码来源:DownloadActionEvaluator.java


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