List of usage examples for java.net HttpURLConnection HTTP_CONFLICT
int HTTP_CONFLICT
To view the source code for java.net HttpURLConnection HTTP_CONFLICT.
Click Source Link
From source file:i5.las2peer.services.userManagement.UserManagement.java
/** * //from w ww .j av a 2 s. c o m * createUser * * * @return HttpResponse * */ @POST @Path("/create") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.TEXT_PLAIN) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "userExists"), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "authorizationNeeded"), @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "userCreated"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "internal"), @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "malformedRequest") }) @ApiOperation(value = "createUser", notes = "") public HttpResponse createUser() { // userExists boolean userExists_condition = true; if (userExists_condition) { String error = "Some String"; HttpResponse userExists = new HttpResponse(error, HttpURLConnection.HTTP_CONFLICT); return userExists; } // authorizationNeeded boolean authorizationNeeded_condition = true; if (authorizationNeeded_condition) { String error = "Some String"; HttpResponse authorizationNeeded = new HttpResponse(error, HttpURLConnection.HTTP_UNAUTHORIZED); return authorizationNeeded; } // userCreated boolean userCreated_condition = true; if (userCreated_condition) { JSONObject User = new JSONObject(); HttpResponse userCreated = new HttpResponse(User.toJSONString(), HttpURLConnection.HTTP_CREATED); return userCreated; } // internal boolean internal_condition = true; if (internal_condition) { String error = "Some String"; HttpResponse internal = new HttpResponse(error, HttpURLConnection.HTTP_INTERNAL_ERROR); return internal; } // malformedRequest boolean malformedRequest_condition = true; if (malformedRequest_condition) { String malformation = "Some String"; HttpResponse malformedRequest = new HttpResponse(malformation, HttpURLConnection.HTTP_BAD_REQUEST); return malformedRequest; } return null; }
From source file:com.netflix.genie.server.resources.CommandConfigResource.java
/** * Create a Command configuration./*from w ww .j av a 2 s. c om*/ * * @param command The command configuration to create * @return The command created * @throws GenieException For any error */ @POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Create a command", notes = "Create a command from the supplied information.", response = Command.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Created", response = Command.class), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "A command with the supplied id already exists"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Response createCommand( @ApiParam(value = "The command to create.", required = true) final Command command) throws GenieException { LOG.info("called to create new command configuration " + command.toString()); final Command createdCommand = this.commandConfigService.createCommand(command); return Response.created(this.uriInfo.getAbsolutePathBuilder().path(createdCommand.getId()).build()) .entity(createdCommand).build(); }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Create cluster configuration./*from ww w . java 2s . c o m*/ * * @param cluster contains the cluster information to create * @return The created cluster * @throws GenieException For any error */ @POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Create a cluster", notes = "Create a cluster from the supplied information.", response = Cluster.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Created", response = Cluster.class), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "A cluster with the supplied id already exists"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid required parameter supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Response createCluster( @ApiParam(value = "The cluster to create.", required = true) final Cluster cluster) throws GenieException { LOG.info("Called to create new cluster " + cluster); final Cluster createdCluster = this.clusterConfigService.createCluster(cluster); return Response.created(this.uriInfo.getAbsolutePathBuilder().path(createdCluster.getId()).build()) .entity(createdCluster).build(); }
From source file:com.mobile.godot.core.controller.CoreController.java
public synchronized void register(UserBean user) { String servlet = "AddUser"; List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); params.add(new BasicNameValuePair("firstname", user.getFirstname())); params.add(new BasicNameValuePair("lastname", user.getLastname())); params.add(new BasicNameValuePair("mail", user.getMail())); params.add(new BasicNameValuePair("username", user.getUsername())); params.add(new BasicNameValuePair("password", user.getPassword())); SparseIntArray mMessageMap = new SparseIntArray(); mMessageMap.append(HttpURLConnection.HTTP_OK, GodotMessage.Session.REGISTERED); mMessageMap.append(HttpURLConnection.HTTP_CONFLICT, GodotMessage.Error.CONFLICT); mMessageMap.append(HttpURLConnection.HTTP_NOT_ACCEPTABLE, GodotMessage.Error.UNACCEPTABLE); GodotAction action = new GodotAction(servlet, params, mMessageMap, mHandler); Thread tAction = new Thread(action); tAction.start();/*from w w w .j a va 2 s .c om*/ }
From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java
/** * Create an Application.// w ww.j a v a2s. c om * * @param app The application to create * @return The created application configuration * @throws GenieException For any error */ @POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Create an application", notes = "Create an application from the supplied information.", response = Application.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Application created successfully.", response = Application.class), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "An application with the supplied id already exists"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "A precondition failed"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Response createApplication( @ApiParam(value = "The application to create.", required = true) final Application app) throws GenieException { LOG.info("Called to create new application"); final Application createdApp = this.applicationConfigService.createApplication(app); return Response.created(this.uriInfo.getAbsolutePathBuilder().path(createdApp.getId()).build()) .entity(createdApp).build(); }
From source file:com.netflix.genie.server.resources.JobResource.java
/** * Submit a new job./*w ww . ja v a2s . c o m*/ * * @param job request object containing job info element for new job * @return The submitted job * @throws GenieException For any error */ @POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Submit a job", notes = "Submit a new job to run to genie", response = Job.class) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Created", response = Job.class), @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad Request"), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "Job with ID already exists."), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Precondition Failed"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Response submitJob(@ApiParam(value = "Job object to run.", required = true) final Job job) throws GenieException { if (job == null) { throw new GenieException(HttpURLConnection.HTTP_PRECON_FAILED, "No job entered. Unable to submit."); } LOG.info("Called to submit job: " + job); // get client's host from the context String clientHost = this.httpServletRequest.getHeader(FORWARDED_FOR_HEADER); if (clientHost != null) { clientHost = clientHost.split(",")[0]; } else { clientHost = this.httpServletRequest.getRemoteAddr(); } // set the clientHost, if it is not overridden already if (StringUtils.isNotBlank(clientHost)) { LOG.debug("called from: " + clientHost); job.setClientHost(clientHost); } final Job createdJob = this.executionService.submitJob(job); return Response.created(this.uriInfo.getAbsolutePathBuilder().path(createdJob.getId()).build()) .entity(createdJob).build(); }
From source file:org.opendaylight.lispflowmapping.neutron.LispNeutronSubnetHandler.java
/** * Method to check whether new Subnet can be created by LISP implementation * of Neutron service API. Since we store the Cidr part of the subnet as the * main key to the Lisp mapping service, we do not support updates to * subnets that change it's cidr.//w w w.ja v a2 s . c o m */ @Override public int canUpdateSubnet(NeutronSubnet delta, NeutronSubnet original) { if (delta == null || original == null) { LOG.error("Neutron canUpdateSubnet rejected: subnet objects were null"); return HttpURLConnection.HTTP_BAD_REQUEST; } LOG.info("Neutron canUpdateSubnet : Subnet name: " + original.getName() + " Subnet Cidr: " + original.getCidr()); LOG.debug("Lisp Neutron Subnet update: original : " + original.toString() + " delta : " + delta.toString()); // We do not accept a Subnet update that changes the cidr. If cider or // network UUID is changed, return error. if (!(original.getCidr().equals(delta.getCidr()))) { LOG.error("Neutron canUpdateSubnet rejected: Subnet name: " + original.getName() + " Subnet Cidr: " + original.getCidr()); return HttpURLConnection.HTTP_CONFLICT; } return HttpURLConnection.HTTP_OK; }
From source file:com.mobile.godot.core.controller.CoreController.java
public synchronized void addCar(CarBean car) { String servlet = "AddCar"; List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); params.add(new BasicNameValuePair("carName", car.getName())); params.add(new BasicNameValuePair("username", car.getOwnerUsername())); SparseIntArray mMessageMap = new SparseIntArray(); mMessageMap.append(HttpURLConnection.HTTP_OK, GodotMessage.Entity.CAR_CREATED); mMessageMap.append(HttpURLConnection.HTTP_CONFLICT, GodotMessage.Error.CONFLICT); mMessageMap.append(HttpURLConnection.HTTP_NOT_ACCEPTABLE, GodotMessage.Error.UNACCEPTABLE); GodotAction action = new GodotAction(servlet, params, mMessageMap, mHandler); Thread tAction = new Thread(action); tAction.start();/*from ww w .j a v a2 s. co m*/ }
From source file:nz.skytv.example.SwaggerApplication.java
@ApiOperation(value = "Update a book", notes = "Update a book.", response = Book.class, tags = { "book", "updates" }) @ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Book updated successfully"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found"), @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = "Transient Entity") }) @RequestMapping(value = { "/rest/book" }, method = RequestMethod.PATCH) void updateBook(@ApiParam(value = "Book entity", required = true) @RequestBody @Valid final Book book) { LOG.debug("update {}", book); }