Examples of CreateResponse


Examples of com.linkedin.restli.server.CreateResponse

  @Override
  public CreateResponse create(final Greeting greeting)
  {
    // just echo back the provided id (for testing only, this would not a be correct implementation of POST)
    return new CreateResponse(new CustomLong(greeting.getId()));
  }
View Full Code Here

Examples of com.linkedin.restli.server.CreateResponse

  {
    List<CreateResponse> results = new ArrayList<CreateResponse>();
    for (Greeting greeting: entities.getInput())
    {
      // just echo back the provided ids (for testing only, this would not a be correct implementation of POST)
      results.add(new CreateResponse(new CustomLong(greeting.getId()), HttpStatus.S_204_NO_CONTENT));
    }
    return new BatchCreateResult<CustomLong, Greeting>(results);
  }
View Full Code Here

Examples of com.rallydev.rest.response.CreateResponse

        JsonObject newDefect = new JsonObject();
        newDefect.addProperty("Name", "Foo");
        CreateRequest request = new CreateRequest("defect", newDefect);

        doReturn(new Gson().toJson(response)).when(api.client).doPost(request.toUrl(), request.getBody());
        CreateResponse createResponse = api.create(request);

        verify(api.client).doPost(request.toUrl(), request.getBody());
        Assert.assertTrue(createResponse.wasSuccessful());
        JsonObject createdObj = createResponse.getObject();
        assertEquals(createdObj.get("_ref").getAsString(), "/defect/1234");
    }
View Full Code Here

Examples of com.rallydev.rest.response.CreateResponse

     * @param request the {@link CreateRequest} specifying the object to be created.
     * @return the resulting {@link CreateResponse}
     * @throws IOException if an error occurs during the creation.
     */
    public CreateResponse create(CreateRequest request) throws IOException {
        return new CreateResponse(client.doPost(request.toUrl(), request.getBody()));
    }
View Full Code Here

Examples of com.rallydev.rest.response.CreateResponse

            //Create a defect
            System.out.println("Creating defect...");
            JsonObject newDefect = new JsonObject();
            newDefect.addProperty("Name", "Test Defect");
            CreateRequest createRequest = new CreateRequest("defect", newDefect);
            CreateResponse createResponse = restApi.create(createRequest);
            System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));

            //Read defect
            String ref = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
            System.out.println(String.format("\nReading defect %s...", ref));
            GetRequest getRequest = new GetRequest(ref);
            GetResponse getResponse = restApi.get(getRequest);
            JsonObject obj = getResponse.getObject();
            System.out.println(String.format("Read defect. Name = %s, State = %s",
View Full Code Here

Examples of de.metalcon.server.tomcat.NSSP.create.CreateResponse

    // store response item for the server response creation
    final TomcatClientResponder responder = new TomcatClientResponder(
        response);
    response.setHeader("Access-Control-Allow-Origin",
        this.config.getHeaderAccessControl());
    CreateResponse createResponse = new CreateResponse();
    FormItemList formItemList = null;
    try {
      formItemList = FormItemList.extractFormItems(request, FACTORY);
    } catch (final FileUploadException e) {
      responder.error(500,
          "errors encountered while processing the request");
      return;
    }

    if (formItemList != null) {
      final CreateRequest createRequest = CreateRequest.checkRequest(
          formItemList, createResponse);

      boolean commandStacked = false;
      if (createRequest != null) {
        switch (createRequest.getType()) {

        // create a user
        case USER:
          final CreateUserResponse createUserResponse = new CreateUserResponse();
          final CreateUserRequest createUserRequest = CreateUserRequest
              .checkRequest(formItemList, createRequest,
                  createUserResponse);
          createResponse = createUserResponse;

          if (createUserRequest != null) {
            // create user
            final CreateUser createUserCommand = new CreateUser(
                this, createUserResponse, createUserRequest);
            this.commandQueue.add(createUserCommand);

            commandStacked = true;
          }
          break;

        // create a follow edge
        case FOLLOW:
          final CreateFollowResponse createFollowResponse = new CreateFollowResponse();
          final CreateFollowRequest createFollowRequest = CreateFollowRequest
              .checkRequest(formItemList, createRequest,
                  createFollowResponse);
          createResponse = createFollowResponse;

          if (createFollowRequest != null) {
            // create follow edge
            final CreateFollow createFollowCommand = new CreateFollow(
                this, createFollowResponse, createFollowRequest);
            this.commandQueue.add(createFollowCommand);

            commandStacked = true;
          }
          break;

        // create a status update
        default:
          final CreateStatusUpdateResponse createStatusUpdateResponse = new CreateStatusUpdateResponse();
          final CreateStatusUpdateRequest createStatusUpdateRequest = CreateStatusUpdateRequest
              .checkRequest(formItemList, createRequest,
                  createStatusUpdateResponse);
          createResponse = createStatusUpdateResponse;

          if (createStatusUpdateRequest != null) {
            try {
              this.writeFiles(createStatusUpdateRequest
                  .getStatusUpdateTemplate(), formItemList);

              // create a new status update of the type specified
              final StatusUpdate statusUpdate = StatusUpdateManager
                  .instantiateStatusUpdate(
                      createStatusUpdateRequest
                          .getStatusUpdateTemplate()
                          .getName(), formItemList);
              statusUpdate.setId(createStatusUpdateRequest
                  .getStatusUpdateId());
              createStatusUpdateRequest
                  .setStatusUpdate(statusUpdate);

              // create status update
              final CreateStatusUpdate createStatusUpdateCommand = new CreateStatusUpdate(
                  this, createStatusUpdateResponse,
                  createStatusUpdateRequest);
              this.commandQueue.add(createStatusUpdateCommand);

              commandStacked = true;
            } catch (final StatusUpdateInstantiationFailedException e) {
              // remove the files
              FormFile fileItem;
              File file;
              for (String fileIdentifier : formItemList
                  .getFileIdentifiers()) {
                fileItem = formItemList.getFile(fileIdentifier);
                file = fileItem.getFile();

                if (file != null) {
                  file.delete();
                }
              }

              createStatusUpdateResponse
                  .statusUpdateInstantiationFailed(e
                      .getMessage());
            } catch (final Exception e) {
              responder.error(500,
                  "errors encountered while writing files");
            }
          }
          break;

        }

        if (commandStacked) {
          try {
            this.workingQueue.take();
          } catch (final InterruptedException e) {
            System.err
                .println("request status queue failed due to create request");
            e.printStackTrace();
          }
        }
      }
    } else {
      createResponse.noMultipartRequest();
    }

    responder.addLine(createResponse.toString());
    responder.finish();
  }
View Full Code Here

Examples of org.apache.zookeeper.proto.CreateResponse

                                } else {
                                    cb.processResult(rc, path, p.ctx, null);
                                }
                            } else if (p.response instanceof CreateResponse) {
                                StringCallback cb = (StringCallback) p.cb;
                                CreateResponse rsp = (CreateResponse) p.response;
                                if (rc == 0) {
                                    cb.processResult(rc, path, p.ctx, rsp
                                            .getPath());
                                } else {
                                    cb.processResult(rc, path, p.ctx, null);
                                }
                            } else if (p.cb instanceof VoidCallback) {
View Full Code Here

Examples of org.apache.zookeeper.proto.CreateResponse

        throws KeeperException, InterruptedException
    {
        RequestHeader h = new RequestHeader();
        h.setType(ZooDefs.OpCode.create);
        CreateRequest request = new CreateRequest();
        CreateResponse response = new CreateResponse();
        request.setData(data);
        request.setFlags(createMode.toFlag());
        request.setPath(path);
        if (acl != null && acl.size() == 0) {
            throw new KeeperException.InvalidACLException();
        }
        request.setAcl(acl);
        ReplyHeader r = cnxn.submitRequest(h, request, response, null);
        if (r.getErr() != 0) {
            throw KeeperException.create(r.getErr(), path);
        }
        return response.getPath();
    }
View Full Code Here

Examples of org.apache.zookeeper.proto.CreateResponse

            CreateMode createMode,  StringCallback cb, Object ctx)
    {
        RequestHeader h = new RequestHeader();
        h.setType(ZooDefs.OpCode.create);
        CreateRequest request = new CreateRequest();
        CreateResponse response = new CreateResponse();
        ReplyHeader r = new ReplyHeader();
        request.setData(data);
        request.setFlags(createMode.toFlag());
        request.setPath(path);
        request.setAcl(acl);
View Full Code Here

Examples of org.apache.zookeeper.proto.CreateResponse

                return;
            case OpCode.createSession:
                request.cnxn.finishSessionInit(true);
                return;
            case OpCode.create:
                rsp = new CreateResponse(rc.path);
                err = Code.get(rc.err);
                break;
            case OpCode.delete:
                err = Code.get(rc.err);
                break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.