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


Java PutRequest类代码示例

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


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

示例1: testUpdateThumbnail

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
public void testUpdateThumbnail() throws Exception
{
    // Do a image transformation
    String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
    JSONObject tn = new JSONObject();
    tn.put("thumbnailName", "doclib");
    Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
    System.out.println(response.getContentAsString());
    
    // Check getAll whilst we are here 
    Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
    JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
    assertNotNull(getArr);
    assertEquals(1, getArr.length());
    assertEquals("doclib", getArr.getJSONObject(0).get("thumbnailName"));
    //Now we know that thumbnail was created
    
    
    sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/incorrectname"), 404);
    //Request for update of thumbnail, that is absent
    sendRequest(new PutRequest(getThumbnailsURL(jpgNode) + "/incorrectname", "", "application/json"), 404);
    //Request for update of correct thumbnail
    sendRequest(new PutRequest(getThumbnailsURL(jpgNode) + "/doclib", "", "application/json"), 200);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:ThumbnailServiceTest.java

示例2: testLargeContentRequest

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
public void testLargeContentRequest() throws Exception
{
    authenticationComponent.setCurrentUser(USER_ONE);
    
    // create the 5 mb size buffer of zero bytes
    byte[] content = new byte[5 * 1024 * 1024];
    Arrays.fill(content, (byte)0);
    
    // chek that we can upload file larger than 4 mb
    Response response = sendRequest(new PutRequest("/test/largecontenttest", content, "text/plain"), STATUS_OK);
    assertEquals(SUCCESS, response.getContentAsString());
    
    // trigger the webscript temp folder cleaner job
    CronTriggerBean webscriptsTempFileCleanerJobTrigger = (CronTriggerBean) getServer().getApplicationContext().getBean("webscripts.tempFileCleanerTrigger");
    
    webscriptsTempFileCleanerJobTrigger.getScheduler().triggerJobWithVolatileTrigger(
            webscriptsTempFileCleanerJobTrigger.getJobDetail().getName(),
            webscriptsTempFileCleanerJobTrigger.getJobDetail().getGroup(),
            webscriptsTempFileCleanerJobTrigger.getJobDetail().getJobDataMap());
    
    // check that we still can upload file larger than 4 mb, i.e. ensure that cleaner has not deleted temp folder
    response = sendRequest(new PutRequest("/test/largecontenttest", content, "text/plain"), STATUS_OK);
    assertEquals(SUCCESS, response.getContentAsString());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:RepositoryContainerTest.java

示例3: updateComment

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
private JSONObject updateComment(String 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(getCommentUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);

    if (expectedStatus != 200)
    {
        return null;
    }

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

示例4: createRequest

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
private Request createRequest(String method, String url) throws Exception
{
    switch (method)
    {
    case "DELETE":
        return new DeleteRequest(url);
    case "GET":
        return new GetRequest(url);
    case "PUT":
        return new PutRequest(url, "{}", "application/json");
    case "POST":
        return new PostRequest(url, "{}", "application/json");
    default:
        throw new InvalidArgumentException("HTTP method not supported");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:XssVulnerabilityTest.java

示例5: testUpdateRule

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
public void testUpdateRule() throws Exception
{
    JSONObject jsonRule = createRule(testNodeRef);

    String ruleId = jsonRule.getJSONObject("data").getString("id");

    Response getResponse = sendRequest(new GetRequest(formateRuleUrl(testNodeRef, ruleId)), 200);

    JSONObject before = new JSONObject(getResponse.getContentAsString());

    // do some changes
    before.put("description", "this is modified description for test_rule");

    // do some changes for action object
    JSONObject beforeAction = before.getJSONObject("action");
    // no changes for actions list  
    beforeAction.remove("actions");
    // clear conditions
    beforeAction.put("conditions", new JSONArray());

    Response putResponse = sendRequest(new PutRequest(formateRuleUrl(testNodeRef, ruleId), before.toString(), "application/json"), 200);

    JSONObject after = new JSONObject(putResponse.getContentAsString());

    // sent and retrieved objects should be the same (except ids and urls)
    // this means that all changes was saved
    checkUpdatedRule(before, after);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:29,代码来源:RuleServiceTest.java

示例6: updatePerson

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
private JSONObject updatePerson(String userName, String title, String firstName, String lastName, 
        String organisation, String jobTitle, String email, String bio, String avatarUrl, int expectedStatus)
throws Exception
{
    // switch to admin user to create a person
    String currentUser = this.authenticationComponent.getCurrentUserName();
    String adminUser = this.authenticationComponent.getSystemUserName();
    this.authenticationComponent.setCurrentUser(adminUser);
    
    JSONObject person = new JSONObject();
    person.put("userName", userName);
    person.put("title", title);
    person.put("firstName", firstName);
    person.put("lastName", lastName);
    person.put("organisation", organisation);
    person.put("jobtitle", jobTitle);
    person.put("email", email);
    
    Response response = sendRequest(new PutRequest(URL_PEOPLE + "/" + userName, person.toString(), "application/json"), expectedStatus); 
    
    // switch back to non-admin user
    this.authenticationComponent.setCurrentUser(currentUser);
    
    return new JSONObject(response.getContentAsString());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:26,代码来源:PersonServiceTest.java

示例7: doUpdatePost

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
private JSONObject doUpdatePost(String url, String title, String content, 
      int expectedStatus) throws Exception
{
   JSONObject post = new JSONObject();
   post.put("title", title);
   post.put("content", content);
   Response response = sendRequest(new PutRequest(url, post.toString(), "application/json"), expectedStatus);

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

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

示例8: updateComment

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
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,代码行数:18,代码来源:DiscussionRestApiTest.java

示例9: testUpdateSite

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
public void testUpdateSite() throws Exception
{
    // Create a site
    String shortName  = GUID.generate();
    JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
    
    // Update the site
    result.put("title", "abs123abc");
    result.put("description", "123abc123");
    result.put("visibility", SiteVisibility.PRIVATE.toString());
    Response response = sendRequest(new PutRequest(URL_SITES + "/" + shortName, result.toString(), "application/json"), 200);
    result = new JSONObject(response.getContentAsString());
    assertEquals("abs123abc", result.get("title"));
    assertEquals("123abc123", result.get("description"));
    assertFalse(result.getBoolean("isPublic"));
    assertEquals(SiteVisibility.PRIVATE.toString(), result.get("visibility"));
    
    // Try and get the site and double check it's changed
    response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
    result = new JSONObject(response.getContentAsString());
    assertEquals("abs123abc", result.get("title"));
    assertEquals("123abc123", result.get("description"));
    assertFalse(result.getBoolean("isPublic"));
    assertEquals(SiteVisibility.PRIVATE.toString(), result.get("visibility"));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:SiteServiceTest.java

示例10: testChannelPut

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
public void testChannelPut() throws Exception
{
    Channel channel1 = testHelper.createChannel(publishAnyType);
    Channel channel2 = testHelper.createChannel(publishAnyType);
    
    String name1 = channel1.getName();
    String name2 = channel2.getName();
    
    String newName = name1 + "Foo";
    JSONObject json = new JSONObject();
    json.put(NAME, newName);
    
    String jsonStr = json.toString();
    
    String channel1Url = MessageFormat.format(CHANNEL_URL, URLEncoder.encode(channel1.getId()));
    // Post JSON content.
    sendRequest(new PutRequest(channel1Url, jsonStr, JSON), 200);
    
    Channel renamedCH1 = channelService.getChannelById(channel1.getId());
    assertEquals("Channel1 was not renamed correctly!", newName, renamedCH1.getName());
    
    Channel renamedCH2 = channelService.getChannelById(channel2.getId());
    assertEquals("Channel2 name should not have changed!", name2, renamedCH2.getName());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:PublishingRestApiTest.java

示例11: putCustomPropDefinition

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
private void putCustomPropDefinition(String label, String id) throws JSONException, IOException,
            UnsupportedEncodingException
    {
        String jsonString = new JSONStringer().object()
            .key("label").value(label)
        .endObject()
        .toString();

        String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + id;
        Response rsp = sendRequest(new PutRequest(propDefnUrl,
                                 jsonString, APPLICATION_JSON), 200);

        String rspContent = rsp.getContentAsString();
//        System.out.println(rspContent);

        JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent));
        String urlOfNewPropDef = jsonRsp.getString("url");
        assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef);
    }
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:20,代码来源:RmRestApiTest.java

示例12: testRestoreDeletedItems

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
/**
 * This test method restores some deleted nodes from the archive store.
 */
public void testRestoreDeletedItems() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    JSONObject archivedNodesJson = getArchivedNodes();
    JSONObject dataJsonObj = archivedNodesJson.getJSONObject("data");
    JSONArray archivedNodesArray = dataJsonObj.getJSONArray(AbstractArchivedNodeWebScript.DELETED_NODES);
    
    int archivedNodesLength = archivedNodesArray.length();
    assertTrue("Insufficient archived nodes for test to run.", archivedNodesLength > 1);
    
    // Take a specific archived node and restore it.
    JSONObject firstArchivedNode = archivedNodesArray.getJSONObject(0);
    
    // So we have identified a specific Node in the archive that we want to restore.
    String nodeRefString = firstArchivedNode.getString(AbstractArchivedNodeWebScript.NODEREF);
    assertTrue("nodeRef string is invalid", NodeRef.isNodeRef(nodeRefString));
    NodeRef nodeRef = new NodeRef(nodeRefString);
    
    // This is not the StoreRef where the node originally lived e.g. workspace://SpacesStore
    // This is its current StoreRef i.e. archive://SpacesStore
    final StoreRef currentStoreRef = nodeRef.getStoreRef();
    
    String restoreUrl = getArchiveUrl(currentStoreRef) + "/" + nodeRef.getId();
    
    
    int archivedNodesCountBeforeRestore = getArchivedNodesCount();

    // Send the PUT REST call.
    String jsonString = new JSONStringer().object()
        .key("restoreLocation").value("")
        .endObject()
    .toString();
    Response rsp = sendRequest(new PutRequest(restoreUrl, jsonString, "application/json"), 200);
    
    assertEquals("Expected archive to shrink by one", archivedNodesCountBeforeRestore - 1, getArchivedNodesCount());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:41,代码来源:NodeArchiveServiceRestApiTest.java

示例13: testRestoreDeletedItemsAsNonAdminUser

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
/**
 * This test method restores some deleted nodes from the archive store for the current user.
 */
public void testRestoreDeletedItemsAsNonAdminUser() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);

    String restoreUrl = getArchiveUrl(user2_DeletedTestNode.getStoreRef()) + "/" + user2_DeletedTestNode.getId();

    String jsonString = new JSONStringer().object().key("restoreLocation").value("").endObject().toString();
    
    // User_One has the nodeRef of the node deleted by User_Two. User_One is
    // not an Admin, so he must not be allowed to restore a node which he doesn’t own.
    Response rsp = sendRequest(new PutRequest(restoreUrl, jsonString, "application/json"), 403);
    assertEquals(403, rsp.getStatus());
    
    // Now User_One gets his own archived node and tries to restore it
    JSONObject jsonRsp = getArchivedNodes();
    JSONObject dataObj = (JSONObject) jsonRsp.get(DATA);
    JSONArray deletedNodesArray = (JSONArray) dataObj.get(AbstractArchivedNodeWebScript.DELETED_NODES);

    // User_One deleted only 1 node and he doesn't have permission to see other users' archived data.
    assertEquals("Unexpectedly found more than 1 item in the archive store.", 1, deletedNodesArray.length());
    JSONObject archivedNode = (JSONObject) deletedNodesArray.get(0);

    // So we have identified a specific Node in the archive that we want to restore.
    String nodeRefString = archivedNode.getString(AbstractArchivedNodeWebScript.NODEREF);
    assertTrue("nodeRef string is invalid", NodeRef.isNodeRef(nodeRefString));

    NodeRef nodeRef = new NodeRef(nodeRefString);

    // This is its current StoreRef i.e. archive://SpacesStore
    restoreUrl = getArchiveUrl(nodeRef.getStoreRef()) + "/" + nodeRef.getId();
    
    int archivedNodesCountBeforeRestore = getArchivedNodesCount();

    // Send the PUT REST call.
    jsonString = new JSONStringer().object().key("restoreLocation").value("").endObject().toString();
    rsp = sendRequest(new PutRequest(restoreUrl, jsonString, "application/json"), 200);
    
    assertEquals("Expected archive to shrink by one", archivedNodesCountBeforeRestore - 1, getArchivedNodesCount());        
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:43,代码来源:NodeArchiveServiceRestApiTest.java

示例14: updatePost

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
private JSONObject updatePost(String name, String title, String content, String[] tags, boolean isDraft, int expectedStatus)
throws Exception
{
    JSONObject post = getRequestObject(title, content, tags, isDraft);
    Response response = sendRequest(new PutRequest(URL_BLOG_POST + name, post.toString(), "application/json"), expectedStatus);
    
    if (expectedStatus != 200)
    {
        return null;
    }

    JSONObject result = new JSONObject(response.getContentAsString());
    return result.getJSONObject("item");
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:15,代码来源:BlogServiceTest.java

示例15: setSubscriptionListPrivate

import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; //导入依赖的package包/类
protected void setSubscriptionListPrivate(String user, boolean setPrivate) throws Exception
{
    JSONObject privateObject = new JSONObject();
    privateObject.put("private", setPrivate);

    String url = getUrl(URL_PRIVATE, user);
    Response response = sendRequest(new PutRequest(url, privateObject.toString(), "application/json"),
            Status.STATUS_OK);

    JSONObject resultObject = new JSONObject(response.getContentAsString());
    assertTrue(resultObject.has("private"));
    assertEquals(setPrivate, resultObject.getBoolean("private"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:14,代码来源:SubscriptionServiceRestApiTest.java


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