List of usage examples for java.net HttpURLConnection HTTP_INTERNAL_ERROR
int HTTP_INTERNAL_ERROR
To view the source code for java.net HttpURLConnection HTTP_INTERNAL_ERROR.
Click Source Link
From source file:com.netflix.genie.server.resources.JobResource.java
/** * Remove an tag from a given job./*from w ww. ja v a 2 s .c o m*/ * * @param id The id of the job to delete the tag from. Not * null/empty/blank. * @param tag The tag to remove. Not null/empty/blank. * @return The active set of tags for the job. * @throws GenieException For any error */ @DELETE @Path("/{id}/tags/{tag}") @ApiOperation(value = "Remove a tag from a job", notes = "Remove the given tag from the job with given id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad Request"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Job for id does not exist."), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid id supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Set<String> removeTagForJob( @ApiParam(value = "Id of the job to delete from.", required = true) @PathParam("id") final String id, @ApiParam(value = "The tag to remove.", required = true) @PathParam("tag") final String tag) throws GenieException { LOG.info("Called with id " + id + " and tag " + tag); return this.jobService.removeTagForJob(id, tag); }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Get all the commands configured for a given cluster. * * @param id The id of the cluster to get the command files for. Not * NULL/empty/blank.//www . j a v a 2s. co m * @param statuses The various statuses to return commands for. * @return The active set of commands for the cluster. * @throws GenieException For any error */ @GET @Path("/{id}/commands") @ApiOperation(value = "Get the commands for a cluster", notes = "Get the commands for the cluster with the supplied id.", response = Command.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Cluster not found"), @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 List<Command> getCommandsForCluster( @ApiParam(value = "Id of the cluster to get commands for.", required = true) @PathParam("id") final String id, @ApiParam(value = "The statuses of the commands to find.", allowableValues = "ACTIVE, DEPRECATED, INACTIVE") @QueryParam("status") final Set<String> statuses) throws GenieException { LOG.info("Called with id " + id + " status " + statuses); Set<CommandStatus> enumStatuses = null; if (!statuses.isEmpty()) { enumStatuses = EnumSet.noneOf(CommandStatus.class); for (final String status : statuses) { if (StringUtils.isNotBlank(status)) { enumStatuses.add(CommandStatus.parse(status)); } } } return this.clusterConfigService.getCommandsForCluster(id, enumStatuses); }
From source file:i5.las2peer.services.gamificationQuestService.GamificationQuestService.java
/** * Get a quest data with specific ID from database * @param appId applicationId//from www.ja v a2s . co m * @param questId quest id * @return HttpResponse returned as JSON object */ @GET @Path("/{appId}/{questId}") @Produces(MediaType.APPLICATION_JSON) @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Found a quest"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal Error"), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized") }) @ApiOperation(value = "getQuestWithId", notes = "Returns quest detail with specific ID", response = QuestModel.class) public HttpResponse getQuestWithId(@ApiParam(value = "Application ID") @PathParam("appId") String appId, @ApiParam(value = "Quest ID") @PathParam("questId") String questId) { // Request log L2pLogger.logEvent(this, Event.SERVICE_CUSTOM_MESSAGE_99, "GET " + "gamification/quests/" + appId + "/" + questId); long randomLong = new Random().nextLong(); //To be able to match QuestModel quest = null; Connection conn = null; JSONObject objResponse = new JSONObject(); UserAgent userAgent = (UserAgent) getContext().getMainAgent(); String name = userAgent.getLoginName(); if (name.equals("anonymous")) { return unauthorizedMessage(); } try { conn = dbm.getConnection(); L2pLogger.logEvent(Event.SERVICE_CUSTOM_MESSAGE_16, "" + randomLong); try { if (!questAccess.isAppIdExist(conn, appId)) { objResponse.put("message", "Cannot get quest. App not found"); L2pLogger.logEvent(this, Event.SERVICE_ERROR, (String) objResponse.get("message")); return new HttpResponse(objResponse.toJSONString(), HttpURLConnection.HTTP_BAD_REQUEST); } } catch (SQLException e1) { e1.printStackTrace(); objResponse.put("message", "Cannot get quest. Cannot check whether application ID exist or not. Database error. " + e1.getMessage()); L2pLogger.logEvent(this, Event.SERVICE_ERROR, (String) objResponse.get("message")); return new HttpResponse(objResponse.toJSONString(), HttpURLConnection.HTTP_INTERNAL_ERROR); } if (!questAccess.isQuestIdExist(conn, appId, questId)) { objResponse.put("message", "Cannot get quest. Quest not found"); L2pLogger.logEvent(this, Event.SERVICE_ERROR, (String) objResponse.get("message")); return new HttpResponse(objResponse.toJSONString(), HttpURLConnection.HTTP_BAD_REQUEST); } quest = questAccess.getQuestWithId(conn, appId, questId); if (quest == null) { objResponse.put("message", "Cannot get quest. Quest Null, Cannot find quest with " + questId); L2pLogger.logEvent(this, Event.SERVICE_ERROR, (String) objResponse.get("message")); return new HttpResponse(objResponse.toJSONString(), HttpURLConnection.HTTP_INTERNAL_ERROR); } ObjectMapper objectMapper = new ObjectMapper(); //Set pretty printing of json objectMapper.enable(SerializationFeature.INDENT_OUTPUT); String questString = objectMapper.writeValueAsString(quest); L2pLogger.logEvent(Event.SERVICE_CUSTOM_MESSAGE_17, "" + randomLong); L2pLogger.logEvent(Event.SERVICE_CUSTOM_MESSAGE_26, "" + name); L2pLogger.logEvent(Event.SERVICE_CUSTOM_MESSAGE_27, "" + appId); return new HttpResponse(questString, HttpURLConnection.HTTP_OK); } catch (SQLException e) { e.printStackTrace(); objResponse.put("message", "Cannot get quest. DB Error. " + e.getMessage()); L2pLogger.logEvent(this, Event.SERVICE_ERROR, (String) objResponse.get("message")); return new HttpResponse(objResponse.toJSONString(), HttpURLConnection.HTTP_INTERNAL_ERROR); } catch (IOException e) { e.printStackTrace(); objResponse.put("message", "Cannot get quest. Problem in the quest model. " + e.getMessage()); L2pLogger.logEvent(this, Event.SERVICE_ERROR, (String) objResponse.get("message")); return new HttpResponse(objResponse.toJSONString(), HttpURLConnection.HTTP_INTERNAL_ERROR); } // always close connections finally { try { conn.close(); } catch (SQLException e) { logger.printStackTrace(e); } } }
From source file:com.netflix.genie.server.resources.CommandConfigResource.java
/** * Get all the tags for a given command. * * @param id The id of the command to get the tags for. Not * NULL/empty/blank.//from w w w . java 2 s .c om * @return The active set of tags. * @throws GenieException For any error */ @GET @Path("/{id}/tags") @ApiOperation(value = "Get the tags for a command", notes = "Get the tags for the command with the supplied id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Command not found"), @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 Set<String> getTagsForCommand( @ApiParam(value = "Id of the command to get tags for.", required = true) @PathParam("id") final String id) throws GenieException { LOG.info("Called with id " + id); return this.commandConfigService.getTagsForCommand(id); }
From source file:com.netflix.genie.server.resources.ApplicationConfigResource.java
/** * Get all the jar files for a given application. * * @param id The id of the application to get the jar files for. Not * NULL/empty/blank./*ww w .ja va2 s.co m*/ * @return The set of jar files. * @throws GenieException For any error */ @GET @Path("/{id}/jars") @ApiOperation(value = "Get the jars for an application", notes = "Get the jars for the application with the supplied id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Application not found"), @ApiResponse(code = HttpURLConnection.HTTP_PRECON_FAILED, message = "Invalid ID supplied"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Genie Server Error due to Unknown Exception") }) public Set<String> getJarsForApplication( @ApiParam(value = "Id of the application to get the jars for.", required = true) @PathParam("id") final String id) throws GenieException { LOG.info("Called with id " + id); return this.applicationConfigService.getJarsForApplication(id); }
From source file:rapture.dp.DefaultDecisionProcessExecutor.java
@Override public void executeStep(Worker worker) { WorkOrder workOrder = WorkOrderFactory.loadWorkOrder(worker); List<String> stack = worker.getStack(); worker.setStatus(WorkerExecutionState.RUNNING); saveWorker(worker);/*ww w .j av a2s . com*/ String workOrderURI = worker.getWorkOrderURI(); String workerURI = createWorkerURI(workOrderURI, worker.getId()).toString(); workOrder.setStatus(WorkOrderStatusUtil.computeStatus(workOrder, false)); WorkOrderStorage.add(new RaptureURI(workOrder.getWorkOrderURI(), Scheme.WORKORDER), workOrder, ContextFactory.getKernelUser().getUser(), "Updating status"); String stepURI = stack.get(0); // don't pop stack just yet -- we are // currently executing this log.info("Processing step: " + stepURI); CallingContext kernelUser = ContextFactory.getKernelUser(); Pair<Workflow, Step> pair = Kernel.getDecision().getTrusted().getWorkflowWithStep(kernelUser, stepURI); Workflow flow = pair.getLeft(); Step step = pair.getRight(); if (step == null) { RaptureException re = RaptureExceptionFactory.create("Step to be executed not found: " + stepURI); markAsFinished(workOrder, worker, WorkerExecutionState.ERROR, Optional.of(re)); throw re; } else { try { String transitionName = null; StepRecord stepRecord = null; RaptureException re = null; try { recordWorkerActivity(worker, "Start " + step.getName()); stepRecord = preExecuteStep(workOrder, worker, step, stepURI); recordWorkerActivity(worker, "Execute " + step.getName()); transitionName = runExecutable(step, flow, worker, workerURI, stepRecord); } catch (RaptureException e) { re = e; } catch (Throwable t) { re = RaptureExceptionFactory.create("Error while executing workorder", t); } /** * always mark step as finished if possible */ // refresh StepRecord! this may have changed during execution, e.g. by adding an activity id Optional<StepRecord> stepRecordOptional; if (stepRecord != null) { stepRecordOptional = StepRecordUtil.getRecord(worker.getWorkOrderURI(), worker.getId(), stepRecord.getStartTime()); } else { stepRecordOptional = Optional.absent(); } markStepAsFinished(worker, workOrder, stack, stepURI, step, transitionName, stepRecordOptional, Optional.fromNullable(re)); if (re == null) { // RAP-2956 - check if workflow was cancelled before we go any further if (Kernel.getDecision().wasCancelCalled(worker.getCallingContext(), workOrder.getWorkOrderURI())) { markAsFinished(workOrder, worker, WorkerExecutionState.CANCELLED, EXCEPTION_ABSENT); } else if (REPUBLISHED.equals(transitionName)) { // we don't do anything in this case -- don't want to republish } else if (ReflexValue.Internal.SUSPEND.toString().equals(transitionName)) { worker.setStatus(WorkerExecutionState.BLOCKED); saveWorker(worker); workOrder.setStatus(WorkOrderStatusUtil.computeStatus(workOrder, false)); WorkOrderStorage.add(new RaptureURI(workOrder.getWorkOrderURI(), Scheme.WORKORDER), workOrder, ContextFactory.getKernelUser().getUser(), "Updating status"); } else { log.trace("no suppress " + transitionName); transitionWorker(worker, workOrder, step, stepURI, transitionName); } } else { log.error("Step failed with error - " + re.getFormattedMessage()); markAsFinished(workOrder, worker, WorkerExecutionState.ERROR, EXCEPTION_ABSENT); } } catch (RaptureException e) { handleException(e, workOrder, worker, workerURI); } catch (Throwable t) { /** * Catch Throwable here, not just Exception. This is in case something went wrong after executing the step and while interacting with Rapture. * Catch every Throwable, not just Exception-s. Anything causing a failure here should terminate the workorder in error. It's not OK to ignore * NPEs, for example. */ String stepName = step.getName(); handleException( RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Unknown error during execution of step " + stepName, t), workOrder, worker, workerURI); } } }
From source file:com.netflix.genie.server.resources.ClusterConfigResource.java
/** * Update the commands for a given cluster. * * @param id The id of the cluster to update the configuration files for. * Not null/empty/blank. * @param commands The commands to replace existing applications with. Not * null/empty/blank./*from w w w.ja v a 2 s . c o m*/ * @return The new set of commands for the cluster. * @throws GenieException For any error */ @PUT @Path("/{id}/commands") @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Update the commands for an cluster", notes = "Replace the existing commands for cluster with given id.", response = Command.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Cluster not found"), @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 List<Command> updateCommandsForCluster( @ApiParam(value = "Id of the cluster to update commands for.", required = true) @PathParam("id") final String id, @ApiParam(value = "The commands to replace existing with. Should already be created", required = true) final List<Command> commands) throws GenieException { LOG.info("Called with id " + id + " and commands " + commands); return this.clusterConfigService.updateCommandsForCluster(id, commands); }
From source file:com.netflix.genie.server.resources.CommandConfigResource.java
/** * Update the tags for a given command.//from w w w. j a v a 2 s . com * * @param id The id of the command to update the tags for. * Not null/empty/blank. * @param tags The tags to replace existing configuration * files with. Not null/empty/blank. * @return The new set of command tags. * @throws GenieException For any error */ @PUT @Path("/{id}/tags") @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Update tags for a command", notes = "Replace the existing tags for command with given id.", response = String.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Command not found"), @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 Set<String> updateTagsForCommand( @ApiParam(value = "Id of the command to update tags for.", required = true) @PathParam("id") final String id, @ApiParam(value = "The tags to replace existing with.", required = true) final Set<String> tags) throws GenieException { LOG.info("Called with id " + id + " and tags " + tags); return this.commandConfigService.updateTagsForCommand(id, tags); }
From source file:i5.las2peer.services.servicePackage.TemplateService.java
@GET @Path("/persist/linkednodes/biojava") @Produces(MediaType.APPLICATION_JSON)// w w w. j av a 2 s. c om public HttpResponse getNewLinkedNodes() { Connection conn = null; PreparedStatement stmnt = null; Statement stmnt1 = null; ResultSet rs = null; EntityManagement em = new EntityManagement(); try { // get connection from connection pool conn = dbm.getConnection(); // prepare statement stmnt = conn.prepareStatement("SELECT sender,receiver,content FROM biojava;"); // retrieve result set rs = stmnt.executeQuery(); stmnt1 = conn.createStatement(); stmnt1.executeUpdate("create table linkednode (" + "nodeid int not null primary key," + "sender varchar(255)," + "receiver varchar(255)," + " content varchar(5000))"); em.persistNewLinkedNode(rs, conn); return new HttpResponse("Data saved in database", HttpURLConnection.HTTP_OK); } catch (Exception e) { return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } finally { // free resources if exception or not if (rs != null) { try { rs.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); // return HTTP Response on error return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } } if (stmnt != null) { try { stmnt.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); // return HTTP Response on error return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } } if (conn != null) { try { conn.close(); } catch (Exception e) { Context.logError(this, e.getMessage()); // return HTTP Response on error return new HttpResponse("Internal error: " + e.getMessage(), HttpURLConnection.HTTP_INTERNAL_ERROR); } } } }
From source file:org.projectbuendia.client.ui.OdkActivityLauncher.java
private static void handleSubmitError(VolleyError error) { SubmitXformFailedEvent.Reason reason = SubmitXformFailedEvent.Reason.UNKNOWN; if (error instanceof TimeoutError) { reason = SubmitXformFailedEvent.Reason.SERVER_TIMEOUT; } else if (error.networkResponse != null) { switch (error.networkResponse.statusCode) { case HttpURLConnection.HTTP_UNAUTHORIZED: case HttpURLConnection.HTTP_FORBIDDEN: reason = SubmitXformFailedEvent.Reason.SERVER_AUTH; break; case HttpURLConnection.HTTP_NOT_FOUND: reason = SubmitXformFailedEvent.Reason.SERVER_BAD_ENDPOINT; break; case HttpURLConnection.HTTP_INTERNAL_ERROR: if (error.networkResponse.data == null) { LOG.e("Server error, but no internal error stack trace available."); } else { LOG.e(new String(error.networkResponse.data, Charsets.UTF_8)); LOG.e("Server error. Internal error stack trace:\n"); }//from w w w . j ava 2s. co m reason = SubmitXformFailedEvent.Reason.SERVER_ERROR; break; default: reason = SubmitXformFailedEvent.Reason.SERVER_ERROR; break; } } EventBus.getDefault().post(new SubmitXformFailedEvent(reason, error)); }