List of usage examples for java.lang UnsupportedOperationException getMessage
public String getMessage()
From source file:org.alfresco.repo.version.NodeServiceImplTest.java
/** * Test getAssociationSources/*from w w w .jav a 2 s. c o m*/ */ public void testGetAssociationSources() { try { this.versionStoreNodeService.getSourceAssocs(this.dummyNodeRef, this.dummyQName); fail("This operation is not supported."); } catch (UnsupportedOperationException exception) { if (exception.getMessage() != MSG_ERR) { fail("Unexpected exception raised during method excution: " + exception.getMessage()); } } }
From source file:org.alfresco.repo.version.NodeServiceImplTest.java
/** * Test addChild/* ww w .ja v a 2 s .c o m*/ */ public void testAddChild() { try { this.versionStoreNodeService.addChild(this.dummyNodeRef, this.dummyNodeRef, this.dummyQName, this.dummyQName); fail("This operation is not supported."); } catch (UnsupportedOperationException exception) { if (exception.getMessage() != MSG_ERR) { fail("Unexpected exception raised during method excution: " + exception.getMessage()); } } }
From source file:org.phenotips.data.internal.PhenoTipsPatient.java
@Override public void updateFromJSON(JSONObject json) { try {/*from w ww . ja va 2 s . c o m*/ // TODO: Check versions and throw if versions mismatch if necessary // TODO: Separate updateFromJSON and saveToDB? Move to PatientRepository? Execution execution = ComponentManagerRegistry.getContextComponentManager() .getInstance(Execution.class); XWikiContext context = (XWikiContext) execution.getContext().getProperty("xwikicontext"); DocumentAccessBridge documentAccessBridge = ComponentManagerRegistry.getContextComponentManager() .getInstance(DocumentAccessBridge.class); XWikiDocument doc = (XWikiDocument) documentAccessBridge.getDocument(getDocument()); BaseObject data = doc.getXObject(CLASS_REFERENCE); if (data == null) { return; } updateFeaturesFromJSON(doc, data, context, json); updateDisordersFromJSON(doc, data, context, json); for (PatientDataController<?> serializer : this.serializers) { try { PatientData<?> patientData = serializer.readJSON(json); if (patientData != null) { this.extraData.put(patientData.getName(), patientData); serializer.save(this); this.logger.info("Successfully updated patient form JSON using serializer [{}]", serializer.getName()); } } catch (UnsupportedOperationException ex) { this.logger.info("Unable to update patient from JSON using serializer [{}]: not supported", serializer.getName()); } catch (Exception ex) { this.logger.warn("Failed to update patient data from JSON using serializer [{}]: {}", serializer.getName(), ex.getMessage(), ex); } } } catch (Exception ex) { this.logger.warn("Failed to update patient data from JSON [{}]: {}", ex.getMessage(), ex); } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.resourceAllocationManager.ManageLessonDA.java
public ActionForward deleteLessonInstances(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final SortedSet<NextPossibleSummaryLessonsAndDatesBean> set = new TreeSet<NextPossibleSummaryLessonsAndDatesBean>(); for (final String lessonDate : request.getParameterValues("lessonDatesToDelete")) { set.add(NextPossibleSummaryLessonsAndDatesBean.getNewInstance(lessonDate)); }//from w ww .j a v a2 s .co m try { DeleteLessonInstance.run(set); ActionErrors actionErrors = new ActionErrors(); for (final NextPossibleSummaryLessonsAndDatesBean n : set) { actionErrors.add(null, new ActionError("message.deleteLesson", n.getDate())); } saveErrors(request, actionErrors); } catch (UnsupportedOperationException unsupportedOperationException) { ActionErrors actionErrors = new ActionErrors(); for (final NextPossibleSummaryLessonsAndDatesBean n : set) { actionErrors.add(unsupportedOperationException.getMessage(), new ActionError("error.Lesson.not.instanced", n.getDate())); } saveErrors(request, actionErrors); } catch (DomainException domainException) { ActionErrors actionErrors = new ActionErrors(); actionErrors.add(domainException.getMessage(), new ActionError(domainException.getMessage())); saveErrors(request, actionErrors); } return viewAllLessonDates(mapping, form, request, response); }
From source file:de.berlios.jedi.presentation.editor.DownloadPackageAction.java
/** * Handle server requests./* w w w . j ava 2s . c o m*/ * * @param mapping * The ActionMapping used to select this instance. * @param form * The optional ActionForm bean for this request (if any). * @param request * The HTTP request we are processing. * @param response * The HTTP response we are creating. */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { JispPackagesList jispPackagesList = (JispPackagesList) request.getSession() .getAttribute(EditorKeys.JISP_PACKAGES_LIST_KEY); JispPackage jispPackage = (JispPackage) request.getSession().getAttribute(EditorKeys.JISP_PACKAGE); setJispMetadata(jispPackage, jispPackagesList); JispFile jispFile = null; try { jispFile = new EditorLogicService().getJispFileFromJispPackage(jispPackage); } catch (UnsupportedOperationException e) { LogFactory.getLog(DownloadPackageAction.class).fatal("UTF-8 encoding not supported!!!", e); return errorForward(mapping, request, new ActionMessage("utf8NotSupported"), "utf8NotSupported", Keys.ADD_STATUS_FORWARD_NAME); } catch (JispIncompletePackageException e) { LogFactory.getLog(DownloadPackageAction.class).error("Incomplete JispPackage", e); return errorForward(mapping, request, new ActionMessage("incompleteJispPackage", e.getMessage()), "incompleteJispPackage", Keys.ADD_STATUS_FORWARD_NAME); } response.setContentType("application/vnd.jisp"); // Filename should be equal to the name of the root directory of the // jisp file response.setHeader("Content-disposition", "attachment; filename=\"" + JispUtil.getDefaultRootDirectoryName(jispPackage) + ".jisp\""); ServletOutputStream out = null; try { out = response.getOutputStream(); out.write(jispFile.getData()); } catch (IOException e) { LogFactory.getLog(DownloadPackageAction.class) .error("IOException when writing the JispFile to the " + "ServlerOutputStream", e); return errorForward(mapping, request, new ActionMessage("failedJispFileWriteToOutputStream"), "failedJispFileWriteToOutputStream", Keys.ADD_STATUS_FORWARD_NAME); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } return null; }
From source file:org.mule.transport.http.HttpServerConnection.java
public synchronized void close() { try {/* w w w . ja va 2s . c o m*/ if (socket != null) { if (logger.isDebugEnabled()) { logger.debug("Closing: " + socket); } try { socket.shutdownOutput(); } catch (UnsupportedOperationException e) { //Can't shutdown in/output on SSL sockets } if (in != null) { in.close(); } if (out != null) { out.close(); } socket.close(); } } catch (IOException e) { if (logger.isDebugEnabled()) { logger.debug("(Ignored) Error closing the socket: " + e.getMessage()); } } finally { socket = null; } }
From source file:openemr.main.FhirOpenemrConn.java
/** * /*from ww w . j a v a 2s . com*/ * Start point when executing from apigee flow. * * @param messageContext * @param executionContext * @return result of type ExecutionResult to apigee flow. */ public ExecutionResult execute(MessageContext messageContext, ExecutionContext executionContext) { final ExecutionResult er = ExecutionResult.SUCCESS; int status_code = 200; String reason = "OK"; String errorMessage = ""; String result = ""; PatientList patientList = new PatientList(); final FhirOpenemrConn conn = new FhirOpenemrConn(); FhirContext context = new FhirContext(); // Get the response received from server stored in apigee variable String inputDocument = messageContext.getVariable("input_openemr_response"); String id = messageContext.getVariable("id"); inputDocument = inputDocument.trim(); StringReader stringReader = new StringReader(inputDocument); //messageContext.setVariable("inside_fun", 1); // Check and remove any BOM character present in response. if (inputDocument.charAt(0) != '<' && inputDocument.charAt(0) != '{') { int start = inputDocument.indexOf("<"); inputDocument = inputDocument.substring(start); } String output_MT = messageContext.getVariable("outputMediaType"); messageContext.setVariable("outputTypeFromCallout", output_MT); // Get the actual Content type of response and required content type. String outputMediaType = "application/json+fhir"; //messageContext.setVariable("inside_fun", 2); if (outputMediaType == "" || outputMediaType == null) { outputMediaType = "application/json+fhir"; } try { Bundle bundle; Patient patient; //messageContext.setVariable("inside_fun", 4); patientList = getPatientList(stringReader); //messageContext.setVariable("inside_fun1", patientList); IParser parser = getParser(context, FHIRMediaType.getType(outputMediaType)); parser.setPrettyPrint(true); messageContext.setVariable("inside_fun", 5); if (id == "" || id == null) { bundle = getAllPatients(patientList); result = parser.encodeResourceToString(bundle); } else { patient = getSinglePatient(patientList, 0); result = parser.encodeResourceToString(patient); } messageContext.setVariable("inside_fun", 6); } catch (UnsupportedOperationException e) { status_code = 415; reason = "Unsupported media type"; errorMessage = "Media type not supported."; } catch (Throwable e) { messageContext.setVariable("inside_fun", e); status_code = 500; reason = "Internal Server Error"; errorMessage = e.getMessage(); messageContext.setVariable("output_openemr_document", errorMessage); } finally { if (stringReader != null) IOUtils.closeQuietly(stringReader); } if (status_code == 200) { // Set result and message variables for apigee flow if response converted successfully messageContext.setVariable("inside_fun", "STATUS IS 200"); messageContext.setVariable("output_openemr_document", result); messageContext.setVariable("output_media_type", outputMediaType); } else { // Set error message variables for apigee flow if any error occur in process. messageContext.setVariable("output_openemr_status", Integer.toString(status_code)); messageContext.setVariable("output_openemr_reason", reason); if (!StringUtils.isEmpty(errorMessage)) messageContext.setVariable("output_openemr_error", errorMessage); } return er; }
From source file:org.sakaiproject.poll.tool.entityproviders.PollsEntityProvider.java
@EntityCustomAction(action = "vote-list", viewKey = EntityView.VIEW_LIST) public List<?> getVoteEntities(EntityReference ref, Search search) { String currentUserId = userDirectoryService.getCurrentUser().getId(); Restriction pollRes = search.getRestrictionByProperty("pollId"); if (pollRes == null || pollRes.getSingleValue() == null) { // throw new // IllegalArgumentException("Must include a non-null pollId in order to retreive a list of votes"); return null; }/*from w w w . ja va2 s . com*/ Long pollId = null; boolean viewVoters = false; if (developerHelperService.isUserAdmin(developerHelperService.getCurrentUserReference())) { viewVoters = true; } try { pollId = developerHelperService.convert(pollRes.getSingleValue(), Long.class); } catch (UnsupportedOperationException e) { throw new IllegalArgumentException("Invalid: pollId must be a long number: " + e.getMessage(), e); } Poll poll = pollListManager.getPollById(pollId); if (poll == null) { throw new IllegalArgumentException( "pollId (" + pollId + ") is invalid and does not match any known polls"); } List<Vote> votes = pollVoteManager.getAllVotesForPoll(poll); if (developerHelperService.isEntityRequestInternal(ref.toString())) { // ok for all internal requests } else if (!pollListManager.isAllowedViewResults(poll, currentUserId)) { // TODO - check vote location and perm? // not allowed to view throw new SecurityException("User (" + currentUserId + ") cannot view vote (" + ref + ")"); } if (viewVoters) { return votes; } else { return anonymizeVotes(votes); } }
From source file:org.sakaiproject.poll.tool.entityproviders.PollsEntityProvider.java
/** * /{pollId}/poll-options/*from ww w . jav a2 s .c o m*/ */ @EntityCustomAction(action = "poll-option-list", viewKey = EntityView.VIEW_SHOW) public List<?> getPollOptionList(EntityView view, EntityReference ref) { // get the pollId String id = ref.getId(); log.debug(id); // check siteId supplied if (StringUtils.isBlank(id)) { throw new IllegalArgumentException( "siteId must be set in order to get the polls for a site, via the URL /polls/site/siteId"); } Long pollId = null; try { pollId = Long.parseLong(id); } catch (UnsupportedOperationException e) { throw new IllegalArgumentException("Invalid: pollId must be a long number: " + e.getMessage(), e); } // get the poll Poll poll = pollListManager.getPollById(pollId); if (poll == null) { throw new IllegalArgumentException( "pollId (" + pollId + ") is invalid and does not match any known polls"); } else { boolean allowedPublic = pollListManager.isPollPublic(poll); if (!allowedPublic) { String userReference = developerHelperService.getCurrentUserReference(); if (userReference == null) { throw new EntityException("User must be logged in in order to access poll data", id, HttpServletResponse.SC_UNAUTHORIZED); } else { boolean allowedManage = false; boolean allowedVote = false; allowedManage = developerHelperService.isUserAllowedInEntityReference(userReference, PollListManager.PERMISSION_ADD, "/site/" + poll.getSiteId()); allowedVote = developerHelperService.isUserAllowedInEntityReference(userReference, PollListManager.PERMISSION_VOTE, "/site/" + poll.getSiteId()); if (!(allowedManage || allowedVote)) { throw new SecurityException( "User (" + userReference + ") not allowed to access poll data: " + id); } } } } // get the options List<Option> options = pollListManager.getOptionsForPoll(pollId); return options; }
From source file:org.restcomm.connect.http.GeolocationEndpoint.java
public Response putGeolocation(final String accountSid, final MultivaluedMap<String, String> data, GeolocationType geolocationType, final MediaType responseType) { Account account;/*from w w w . ja v a 2s. c om*/ try { account = accountsDao.getAccount(accountSid); secure(account, "RestComm:Create:Geolocation", SecuredType.SECURED_APP); } catch (final Exception exception) { return status(UNAUTHORIZED).build(); } try { validate(data, geolocationType); } catch (final NullPointerException nullPointerException) { // API compliance check regarding missing mandatory parameters return status(BAD_REQUEST).entity(nullPointerException.getMessage()).build(); } catch (final IllegalArgumentException illegalArgumentException) { // API compliance check regarding malformed parameters cause = illegalArgumentException.getMessage(); rStatus = responseStatus.Failed.toString(); } catch (final UnsupportedOperationException unsupportedOperationException) { // API compliance check regarding parameters not allowed for Immediate type of Geolocation return status(BAD_REQUEST).entity(unsupportedOperationException.getMessage()).build(); } /*********************************************/ /*** Query GMLC for Location Data, stage 1 ***/ /*********************************************/ try { String targetMSISDN = data.getFirst("DeviceIdentifier"); Configuration gmlcConf = configuration.subset("gmlc"); String gmlcURI = gmlcConf.getString("gmlc-uri"); // Authorization for further stage of the project String gmlcUser = gmlcConf.getString("gmlc-user"); String gmlcPassword = gmlcConf.getString("gmlc-password"); // Credentials credentials = new UsernamePasswordCredentials(gmlcUser, gmlcPassword); URL url = new URL(gmlcURI + targetMSISDN); HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet(String.valueOf(url)); // Authorization for further stage of the project request.addHeader("User-Agent", gmlcUser); request.addHeader("User-Password", gmlcPassword); HttpResponse response = client.execute(request); final HttpEntity entity = response.getEntity(); if (entity != null) { InputStream stream = entity.getContent(); try { BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String gmlcResponse = null; while (null != (gmlcResponse = br.readLine())) { List<String> items = Arrays.asList(gmlcResponse.split("\\s*,\\s*")); if (logger.isInfoEnabled()) { logger.info("Data retrieved from GMLC: " + items.toString()); } for (String item : items) { for (int i = 0; i < items.size(); i++) { if (item.contains("mcc")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("MobileCountryCode", token); } if (item.contains("mnc")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("MobileNetworkCode", token); } if (item.contains("lac")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("LocationAreaCode", token); } if (item.contains("cellid")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("CellId", token); } if (item.contains("aol")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("LocationAge", token); } if (item.contains("vlrNumber")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("NetworkEntityAddress", token); } if (item.contains("latitude")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("DeviceLatitude", token); } if (item.contains("longitude")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("DeviceLongitude", token); } if (item.contains("civicAddress")) { String token = item.substring(item.lastIndexOf("=") + 1); data.putSingle("FormattedAddress", token); } } } if (gmlcURI != null && gmlcResponse != null) { // For debugging/logging purposes only if (logger.isDebugEnabled()) { logger.debug("Geolocation data of " + targetMSISDN + " retrieved from GMCL at: " + gmlcURI); logger.debug( "MCC (Mobile Country Code) = " + getInteger("MobileCountryCode", data)); logger.debug("MNC (Mobile Network Code) = " + data.getFirst("MobileNetworkCode")); logger.debug("LAC (Location Area Code) = " + data.getFirst("LocationAreaCode")); logger.debug("CI (Cell ID) = " + data.getFirst("CellId")); logger.debug("AOL (Age of Location) = " + getInteger("LocationAge", data)); logger.debug("NNN (Network Node Number/Address) = " + +getLong("NetworkEntityAddress", data)); logger.debug("Devide Latitude = " + data.getFirst("DeviceLatitude")); logger.debug("Devide Longitude = " + data.getFirst("DeviceLongitude")); logger.debug("Civic Address = " + data.getFirst("FormattedAddress")); } } } } finally { stream.close(); } } } catch (Exception ex) { if (logger.isInfoEnabled()) { logger.info("Problem while trying to retrieve data from GMLC"); } return status(INTERNAL_SERVER_ERROR).entity(ex.getMessage()).build(); } Geolocation geolocation = createFrom(new Sid(accountSid), data, geolocationType); if (geolocation.getResponseStatus() != null && geolocation.getResponseStatus().equals(responseStatus.Rejected.toString())) { if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(geolocation); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(geolocation), APPLICATION_JSON).build(); } else { return null; } } else { dao.addGeolocation(geolocation); if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(geolocation); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(geolocation), APPLICATION_JSON).build(); } else { return null; } } }