List of usage examples for org.apache.commons.httpclient HttpStatus SC_INTERNAL_SERVER_ERROR
int SC_INTERNAL_SERVER_ERROR
To view the source code for org.apache.commons.httpclient HttpStatus SC_INTERNAL_SERVER_ERROR.
Click Source Link
From source file:org.wso2.carbon.mdm.services.android.OperationManager.java
@GET @Path("{id}") public List<Operation> getPendingOperations(@PathParam("id") String id) throws AndroidAgentException { List<Operation> operations; String msg;/*from w ww .j a va 2 s . c o m*/ DeviceManagementService dmService; try { dmService = AndroidAPIUtils.getDeviceManagementService(); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); operations = dmService.getPendingOperations(deviceIdentifier); Response.status(HttpStatus.SC_OK); return operations; } catch (OperationManagementException e) { msg = "Error occurred while fetching the operation list for the device."; log.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } }
From source file:org.wso2.carbon.mdm.services.android.OperationManager.java
@PUT public Message updateOperation() throws AndroidAgentException { String msg;//from w w w . j a v a 2s.c o m DeviceManagementService dmService; Message responseMsg = new Message(); try { dmService = AndroidAPIUtils.getDeviceManagementService(); //TODO: need to complete updateOperation logic boolean result = dmService.addOperation(null, null); if (result) { Response.status(HttpStatus.SC_OK); responseMsg.setResponseMessage("Device has already enrolled"); } else { Response.status(HttpStatus.SC_NOT_FOUND); responseMsg.setResponseMessage("Operation not found"); } return responseMsg; } catch (OperationManagementException e) { msg = "Error occurred while updating the operation status for the device."; log.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } }
From source file:org.wso2.cdmserver.mobileservices.android.Operation.java
@GET @Path("{id}") public List<org.wso2.carbon.device.mgt.common.Operation> getAllOperations(@PathParam("id") String id) throws AndroidAgentException { List<org.wso2.carbon.device.mgt.common.Operation> operations; String msg;//from w w w. ja v a2 s . c om DeviceManagementService dmService; try { dmService = AndroidAPIUtils.getDeviceManagementService(); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); operations = dmService .getOperationManager(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID) .getOperations(deviceIdentifier); Response.status(HttpStatus.SC_OK); return operations; } catch (DeviceManagementServiceException deviceMgtServiceEx) { msg = "Device management service error"; log.error(msg, deviceMgtServiceEx); throw new AndroidAgentException(msg, deviceMgtServiceEx); } catch (DeviceManagementException e) { msg = "Error occurred while fetching the operation manager for the device type."; log.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } catch (OperationManagementException e) { msg = "Error occurred while fetching the operation list for the device."; log.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } }
From source file:org.wso2.cdmserver.mobileservices.android.Operation.java
@PUT public Message updateOperation() throws AndroidAgentException { String msg;/*from ww w. j a va 2s .c om*/ DeviceManagementService dmService; Message responseMsg = new Message(); try { dmService = AndroidAPIUtils.getDeviceManagementService(); boolean result = dmService.getOperationManager("").addOperation(null, null); if (result) { Response.status(HttpStatus.SC_OK); responseMsg.setResponseMessage("Device has already enrolled"); } else { Response.status(HttpStatus.SC_NOT_FOUND); responseMsg.setResponseMessage("Operation not found"); } return responseMsg; } catch (DeviceManagementServiceException deviceMgtServiceEx) { msg = "Device management service error"; log.error(msg, deviceMgtServiceEx); throw new AndroidAgentException(msg, deviceMgtServiceEx); } catch (DeviceManagementException e) { msg = "Error occurred while fetching the operation manager for the device type."; log.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } catch (OperationManagementException e) { msg = "Error occurred while updating the operation status for the device."; log.error(msg, e); Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR); throw new AndroidAgentException(msg, e); } }
From source file:org.wso2.deployment.monitor.scheduling.service.ManageServerServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ScheduleManager scheduleManager;/*from w w w . j a va 2 s . c o m*/ boolean isSuccess = false; String responseMsg = null; String action = CharacterEncoder.getSafeText(req.getParameter("action")); String taskName = CharacterEncoder.getSafeText(req.getParameter("task")); String serverName = CharacterEncoder.getSafeText(req.getParameter("server")); //Checking the mandatory parameters if (action == null) { logger.warn("Action has not been specified."); responseMsg = "Action name is not specified. " + "Please specify a action { schedule | unschedule | pause | resume }"; resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); resp.getWriter().println(responseMsg); return; } if (serverName == null) { logger.warn("Server name has not been specified"); responseMsg = "Please specify the server"; resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); resp.getWriter().println(responseMsg); return; } logger.info("Action : " + action + ", Task : " + taskName + ", Server : " + serverName); try { scheduleManager = ScheduleManager.getInstance(); //by task and server both if (taskName != null) { switch (action) { case "schedule": isSuccess = scheduleManager.scheduleTaskForServer(taskName, serverName); break; case "unschedule": isSuccess = scheduleManager.unScheduleTaskForServer(taskName, serverName); break; case "pause": isSuccess = scheduleManager.pauseTaskForServer(taskName, serverName); break; case "resume": isSuccess = scheduleManager.resumeTaskForServer(taskName, serverName); break; default: logger.warn("Incorrect Action has been specified"); responseMsg = "Incorrect Action has been specified. " + "Please specify a action { schedule | unschedule | pause | resume }"; break; } //only by server } else { switch (action) { case "schedule": isSuccess = scheduleManager.scheduleTasksOfServer(serverName); break; case "unschedule": isSuccess = scheduleManager.unScheduleTasksOfServer(serverName); break; case "pause": isSuccess = scheduleManager.pauseTasksOfServer(serverName); break; case "resume": isSuccess = scheduleManager.resumeTasksOfServer(serverName); break; default: logger.warn("Incorrect Action has been specified"); responseMsg = "Incorrect Action has been specified." + " Please specify a action { schedule | unschedule | pause | resume }"; break; } } } catch (SchedulerException e) { logger.error("Error occurred while running the Scheduling Service {}", e); responseMsg = "Error occurred while running the Scheduling Service"; } if (isSuccess) { resp.setStatus(HttpStatus.SC_OK); } else { resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); resp.getWriter().println(responseMsg); } }
From source file:org.wso2.ei.businessprocess.integration.common.clients.bpmn.ActivitiRestClient.java
/** * This Method is used to deploy BPMN packages to the BPMN Server * * @param fileName The name of the Package to be deployed * @param filePath The location of the BPMN package to be deployed * @throws java.io.IOException/*from w ww . j ava 2 s .c o m*/ * @throws org.json.JSONException * @returns String array with status, deploymentID and Name */ public String[] deployBPMNPackage(String filePath, String fileName) throws RestClientException, IOException, JSONException { String url = serviceURL + "repository/deployments"; DefaultHttpClient httpClient = getHttpClient(); HttpPost httpPost = new HttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", new File(filePath), ContentType.MULTIPART_FORM_DATA, fileName); HttpEntity multipart = builder.build(); httpPost.setEntity(multipart); HttpResponse response = httpClient.execute(httpPost); String status = response.getStatusLine().toString(); String responseData = EntityUtils.toString(response.getEntity()); JSONObject jsonResponseObject = new JSONObject(responseData); if (status.contains(Integer.toString(HttpStatus.SC_CREATED)) || status.contains(Integer.toString(HttpStatus.SC_OK))) { String deploymentID = jsonResponseObject.getString(ID); String name = jsonResponseObject.getString(NAME); return new String[] { status, deploymentID, name }; } else if (status.contains(Integer.toString(HttpStatus.SC_INTERNAL_SERVER_ERROR))) { String errorMessage = jsonResponseObject.getString("errorMessage"); throw new RestClientException(errorMessage); } else { throw new RestClientException("Failed to deploy package " + fileName); } }
From source file:org.wso2.iot.integration.operation.OperationManagement.java
@Test(dependsOnMethods = { "testInstallApps" }, description = "Test get device apps with wrong Device ID") public void testGetDeviceAppsWithWrongDeviceID() throws Exception { IOTResponse response = client.get(Constants.OperationManagement.GET_DEVICE_APPS_ENDPOINT + Constants.NUMBER_NOT_EQUAL_TO_DEVICE_ID + Constants.OperationManagement.PATH_APPS); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); }
From source file:org.wso2.iot.integration.operation.OperationManagement.java
@Test(dependsOnMethods = { "testInstallApps" }, description = "Test get operations for device with wrong Device ID") public void testGetDeviceOperationsWithWrongDeviceID() throws Exception { IOTResponse response = client//from w ww .j a v a 2s.co m .get(Constants.OperationManagement.GET_DEVICE_OPERATIONS_ENDPOINT + Constants.DEVICE_IMEI); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); }
From source file:org.wso2.mdm.integration.operation.OperationManagement.java
@Test(dependsOnMethods = { "testInstallApps" }, description = "Test get device apps with wrong Device ID") public void testGetDeviceAppsWithWrongDeviceID() throws Exception { MDMResponse response = client.get(Constants.OperationManagement.GET_DEVICE_APPS_ENDPOINT + Constants.NUMBER_NOT_EQUAL_TO_DEVICE_ID + Constants.OperationManagement.PATH_APPS); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); }
From source file:org.wso2.mdm.integration.operation.OperationManagement.java
@Test(dependsOnMethods = { "testInstallApps" }, description = "Test get operations for device with wrong Device ID") public void testGetDeviceOperationsWithWrongDeviceID() throws Exception { MDMResponse response = client//from ww w . j a va2s . c om .get(Constants.OperationManagement.GET_DEVICE_OPERATIONS_ENDPOINT + Constants.DEVICE_IMEI); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); }