List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:com.persistent.cloudninja.scheduler.Scheduler.java
/** * Creates blob container 'taskscheduler' if not exists. * //from w w w .ja v a 2 s .c o m */ private void initializeTaskScheduleContainer() { try { // container for page blobs required while acquiring lease. storageUtility.initializeBlobContainer("taskscheduler"); // container to store poison messages storageUtility.initializeBlobContainer("poison-messages"); } catch (URISyntaxException e) { LOGGER.error(e.getMessage(), e); } catch (StorageException e) { LOGGER.error(e.getMessage(), e); } }
From source file:org.cerberus.servlet.publi.ExecuteNextInQueue.java
/** * Executes the next test case represented by the given * {@link TestCaseExecutionInQueue}// w ww . j ava2s. c o m * * @param lastInQueue * @param req * @param resp * @throws IOException */ private void executeNext(TestCaseExecutionInQueue lastInQueue, HttpServletRequest req, HttpServletResponse resp) throws IOException { String charset = resp.getCharacterEncoding(); String query = ""; try { ParamRequestMaker paramRequestMaker = makeParamRequestfromLastInQueue(lastInQueue); // TODO : Prefer use mkString(charset) instead of mkString(). // However the RunTestCase servlet does not decode parameters, // then we have to mkString() without using charset query = paramRequestMaker.mkString(); } catch (UnsupportedEncodingException uee) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, uee.getMessage()); return; } catch (IllegalArgumentException iae) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.getMessage()); return; } catch (IllegalStateException ise) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ise.getMessage()); return; } CloseableHttpClient httpclient = null; HttpGet httpget = null; try { httpclient = HttpClients.createDefault(); URI uri = new URIBuilder().setScheme(req.getScheme()).setHost(req.getServerName()) .setPort(req.getServerPort()).setPath(req.getContextPath() + RunTestCase.SERVLET_URL) .setCustomQuery(query).build(); httpget = new HttpGet(uri); } catch (URISyntaxException use) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, use.getMessage()); return; } CloseableHttpResponse response = null; try { response = httpclient.execute(httpget); if (response.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) { resp.sendError(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()); } } catch (ClientProtocolException cpe) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, cpe.getMessage()); } finally { if (response != null) { response.close(); } } }
From source file:com.jaspersoft.jasperserver.api.security.externalAuth.sso.SsoTicketValidatorImpl.java
protected URI constructValidationUrl(final String ticket) throws AuthenticationServiceException { final Map<String, String> urlParameters = new HashMap<String, String>(); try {//from w w w. j a v a 2 s .com logger.debug("Constructing SSO token validation URL (ticket: " + ticket + ")"); final ExternalAuthProperties externalAuthProperties = getExternalAuthProperties(); String ticketParamName = externalAuthProperties.getTicketParameterName(); urlParameters.put(ticketParamName, ticket); String serviceParameterName = externalAuthProperties.getServiceParameterName(); if (serviceParameterName != null && serviceParameterName.length() > 0) { // in case of SOAP the service does not have to match the request. in that case we will specify the service if (getService() != null && getService().length() > 0) { urlParameters.put(serviceParameterName, getService()); } else { HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder .getRequestAttributes()).getRequest(); StringBuffer requestURL = req.getRequestURL(); urlParameters.put(serviceParameterName, requestURL.toString()); } } URIBuilder uriBuilder = new URIBuilder(externalAuthProperties.getSsoServerTicketValidationUrl()); for (Map.Entry<String, String> param : urlParameters.entrySet()) { uriBuilder.setParameter(param.getKey(), param.getValue()); } return uriBuilder.build(); } catch (URISyntaxException e) { logger.error("Failed to construct the token validation URL (ticket: " + ticket + ")", e); throw new AuthenticationServiceException(e.getMessage(), e); } }
From source file:com.ebay.erl.mobius.core.mapred.ConfigurableJob.java
@Override protected synchronized void submit() { JobConf jobConf = this.getJobConf(); boolean isLocalHadoop = jobConf.get("mapred.job.tracker", "local").equals("local"); // the default partitioner is {@link com.ebay.erl.mobius.core.datajoin.DataJoinKeyPartitioner} // which is hash based. ////from www .j a va 2 s . c om // If user choose to use even partitioner, Mobius will use // {@link com.ebay.erl.mobius.core.datajoin.EvenlyPartitioner} which // is sampling based partitioner of attempting to balance the load // for each reducer. String partitioner = jobConf.get("mobius.partitioner", "default"); if (!isLocalHadoop && jobConf.getNumReduceTasks() != 0 && partitioner.equals("even")) { // this job needs reducer, perform sampling on the keys to // make load on reducers are almost evenly distributed. double freq = jobConf.getFloat("mobius.sampler.freq", 0.1F); int numSamples = jobConf.getInt("mobius.sampler.num.samples", 50000); int maxSplits = jobConf.getInt("mobius.sampler.max.slipts.sampled", 5); // log sampling parameters so that user knows. LOGGER.info("Sampling parameters { " + "mobius.sampler.freq:" + format.format(freq) + ", " + "mobius.sampler.num.samples:" + numSamples + ", " + "mobius.sampler.max.slipts.sampled:" + maxSplits + "}"); InputSampler.Sampler<?, ?> sampler = new MobiusInputSampler(freq, numSamples, maxSplits); writePartitionFile(jobConf, sampler); // add to distributed cache try { URI partitionUri = new URI(TotalOrderPartitioner.getPartitionFile(jobConf) + "#_partitions"); LOGGER.info("Adding partition uri to distributed cache:" + partitionUri.toString()); DistributedCache.addCacheFile(partitionUri, jobConf); DistributedCache.createSymlink(jobConf); jobConf.setPartitionerClass(EvenlyPartitioner.class); LOGGER.info("Using " + EvenlyPartitioner.class.getCanonicalName() + " to partiton the keys evenly among reducers."); } catch (URISyntaxException e) { LOGGER.error(e.getMessage(), e); throw new RuntimeException(e); } // adding -XX:-UseParallelOldGC, this will automatically set -XX:-UseParallelGC // according to Oracle's specification String jvmOpts = jobConf.get("mapred.child.java.opts", ""); if (jvmOpts.isEmpty()) { jvmOpts = "-XX:-UseParallelOldGC"; } else { if (jvmOpts.indexOf("-XX:-UseParallelOldGC") < 0) { // remove " jvmOpts = jvmOpts.replaceAll("\"", ""); jvmOpts = jvmOpts.concat(" -XX:-UseParallelOldGC"); } } jobConf.set("mapred.child.java.opts", jvmOpts); this.setJobConf(jobConf); } LOGGER.info("Submiting job:" + jobConf.getJobName()); super.submit(); }
From source file:com.urbancode.jenkins.plugins.ucdeploy.UCDeploySite.java
public URI getUri() throws AbortException { URI udSiteUri;//from ww w.j a va 2 s . c o m try { udSiteUri = new URI(url); } catch (URISyntaxException ex) { throw new AbortException("URL " + url + " is malformed: " + ex.getMessage()); } return udSiteUri; }
From source file:com.favalike.http.GAEClientConnection.java
@Override public void sendRequestHeader(HttpRequest request) throws HttpException, IOException { try {//from w ww .j a va2 s . co m HttpHost host = route.getTargetHost(); URI uri = new URI(host.getSchemeName() + "://" + host.getHostName() + ((host.getPort() == -1) ? "" : (":" + host.getPort())) + request.getRequestLine().getUri()); this.request = new HTTPRequest(uri.toURL(), HTTPMethod.valueOf(request.getRequestLine().getMethod()), FetchOptions.Builder.disallowTruncate().doNotFollowRedirects()); } catch (URISyntaxException ex) { throw new IOException("Malformed request URI: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw new IOException("Unsupported HTTP method: " + ex.getMessage(), ex); } for (Header h : request.getAllHeaders()) { this.request.addHeader(new HTTPHeader(h.getName(), h.getValue())); } }
From source file:com.ardnezar.lookapp.WebSocketChannelClient.java
public void connect(final String wsUrl, final String postUrl) { checkIfCalledOnValidThread();//from w ww . j av a2 s .co m if (state != WebSocketConnectionState.NEW) { Log.e(TAG, "WebSocket is already connected."); return; } wsServerUrl = wsUrl; postServerUrl = postUrl; closeEvent = false; Log.d(TAG, "Connecting WebSocket to: " + wsUrl + ". Post URL: " + postUrl); ws = new WebSocketConnection(); wsObserver = new WebSocketObserver(); try { ws.connect(new URI(wsServerUrl), wsObserver); } catch (URISyntaxException e) { reportError("URI error: " + e.getMessage()); } catch (WebSocketException e) { reportError("WebSocket connection error: " + e.getMessage()); } }
From source file:com.emental.mindraider.core.rest.resource.OutlineResource.java
/** * Get concepts URIs. We're presuming that there exists exactly one concepts * group./* w ww .j a v a 2 s . c o m*/ * * @return array of uri. */ @SuppressWarnings("unchecked") public String[] getConceptUris() { ResourcePropertyGroup[] concepts; try { concepts = resource.getData().getPropertyGroup(new URI(PROPERTY_GROUP_URI_CONCEPTS)); } catch (URISyntaxException e) { cat.debug("URISyntaxException: " + e.getMessage()); return null; } if (concepts != null) { ConceptProperty[] properties = (ConceptProperty[]) concepts[0].getProperties() .toArray(new ConceptProperty[0]); if (!ArrayUtils.isEmpty(properties)) { String[] result = new String[properties.length]; for (int i = 0; i < properties.length; i++) { result[i] = properties[i].getUri().toASCIIString(); } return result; } } return null; }
From source file:com.nridge.connector.fs.con_fs.restlet.ResourceDocView.java
/** * Returns a full representation containing the document response message * to the Restlet framework.//from www . j av a 2 s . co m * * @return A Representation - the content of a representation can be retrieved * several times if there is a stable and accessible source, like a local file * or a string. * * @throws org.restlet.resource.ResourceException Encapsulates a response status and the optional * cause as a checked exception. */ @Override protected Representation get() throws ResourceException { String msgStr; Representation replyRepresentation; RestletApplication restletApplication = (RestletApplication) getApplication(); AppMgr appMgr = restletApplication.getAppMgr(); Logger appLogger = appMgr.getLogger(this, "get"); appLogger.trace(appMgr.LOGMSG_TRACE_ENTER); Reference originalReference = getOriginalRef(); Form queryForm = originalReference.getQueryAsForm(); String docId = queryForm.getFirstValue("id"); if (StringUtils.isNotEmpty(docId)) { DataBag docBag = loadDocument(docId); if (docBag.count() == 0) { msgStr = (String) docBag.getProperty(PROPERTY_ERROR_MESSAGE); replyRepresentation = messageRepresentation(msgStr); } else { String nsdURL = docBag.getValueAsString("nsd_url"); if (StringUtils.startsWith(nsdURL, "file:")) { String mimeType = docBag.getValueAsString("nsd_mime_type"); if (StringUtils.isEmpty(mimeType)) mimeType = "application/octet-stream"; try { URI uriFile = new URI(nsdURL); File viewFile = new File(uriFile); replyRepresentation = new FileRepresentation(viewFile, MediaType.valueOf(mimeType)); } catch (URISyntaxException e) { msgStr = String.format("%s: %s", nsdURL, e.getMessage()); appLogger.error(msgStr, e); msgStr = String.format("Cannot view document - invalid URI for document id '%s'.", docId); replyRepresentation = messageRepresentation(msgStr); } } else { msgStr = String.format("Cannot view document - invalid URI for document id '%s'.", docId); replyRepresentation = messageRepresentation(msgStr); } } } else replyRepresentation = messageRepresentation("Cannot view document - missing id in request."); appLogger.trace(appMgr.LOGMSG_TRACE_DEPART); return replyRepresentation; }
From source file:fr.paris.lutece.plugins.workflow.modules.appointment.service.ICalService.java
/** * Send an appointment to a user by email. * @param strEmailAttendee Comma separated list of users that will attend * the appointment// ww w .j ava 2 s .c o m * @param strEmailOptionnal Comma separated list of users that will be * invited to the appointment, but who are not required. * @param strSubject The subject of the appointment. * @param strBodyContent The body content that describes the appointment * @param strLocation The location of the appointment * @param strSenderName The name of the sender * @param strSenderEmail The email of the sender * @param appointment The appointment * @param bCreate True to notify the creation of the appointment, false to * notify its removal */ public void sendAppointment(String strEmailAttendee, String strEmailOptionnal, String strSubject, String strBodyContent, String strLocation, String strSenderName, String strSenderEmail, Appointment appointment, boolean bCreate) { AppointmentSlot slot = AppointmentSlotHome.findByPrimaryKey(appointment.getIdSlot()); Calendar calendarStart = new GregorianCalendar(Locale.FRENCH); calendarStart.setTime(appointment.getDateAppointment()); calendarStart.add(Calendar.HOUR, slot.getStartingHour()); calendarStart.add(Calendar.MINUTE, slot.getStartingMinute()); int nAppDurationMinutes = ((slot.getEndingHour() - slot.getStartingHour()) * 60) + (slot.getEndingMinute() - slot.getStartingMinute()); int nDurationAppointmentHours = nAppDurationMinutes / 60; int nDurationAppointmentMinutes = nAppDurationMinutes % 60; int nDurationAppointmentDays = nDurationAppointmentHours / 24; nDurationAppointmentHours %= 24; // Dur duration = new Dur( nDurationAppointmentDays, nDurationAppointmentHours, nDurationAppointmentMinutes, 0 ); // TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); // TimeZone timezone = registry.getTimeZone("Europe/Paris"); DateTime beginningDateTime = new DateTime(calendarStart.getTimeInMillis()); beginningDateTime.setTimeZone(getParisZone()); Calendar endCal = new GregorianCalendar(); endCal.setTimeInMillis(calendarStart.getTimeInMillis()); endCal.add(Calendar.MINUTE, nAppDurationMinutes); DateTime endingDateTime = new DateTime(endCal.getTimeInMillis()); endingDateTime.setTimeZone(getParisZone()); VEvent event = new VEvent(beginningDateTime, endingDateTime, (strSubject != null) ? strSubject : StringUtils.EMPTY); calendarStart.add(Calendar.MINUTE, nAppDurationMinutes); // event.getProperties( ).add( new DtEnd( endingDateTime ) ); try { event.getProperties() .add(new Uid(Appointment.APPOINTMENT_RESOURCE_TYPE + appointment.getIdAppointment())); String strEmailSeparator = AppPropertiesService.getProperty(PROPERTY_MAIL_LIST_SEPARATOR, ";"); if (StringUtils.isNotEmpty(strEmailAttendee)) { StringTokenizer st = new StringTokenizer(strEmailAttendee, strEmailSeparator); while (st.hasMoreTokens()) { addAttendee(event, st.nextToken(), true); } } if (StringUtils.isNotEmpty(strEmailOptionnal)) { StringTokenizer st = new StringTokenizer(strEmailOptionnal, strEmailSeparator); while (st.hasMoreTokens()) { addAttendee(event, st.nextToken(), false); } } Organizer organizer = new Organizer(strSenderEmail); organizer.getParameters().add(new Cn(strSenderName)); event.getProperties().add(organizer); event.getProperties().add(new Location(strLocation)); event.getProperties().add(new Description(strBodyContent)); } catch (URISyntaxException e) { AppLogService.error(e.getMessage(), e); } net.fortuna.ical4j.model.Calendar iCalendar = new net.fortuna.ical4j.model.Calendar(); iCalendar.getProperties().add(bCreate ? Method.REQUEST : Method.CANCEL); iCalendar.getProperties().add(new ProdId(AppPropertiesService.getProperty(PROPERTY_ICAL_PRODID))); iCalendar.getProperties().add(Version.VERSION_2_0); iCalendar.getProperties().add(CalScale.GREGORIAN); iCalendar.getComponents().add(event); MailService.sendMailCalendar(strEmailAttendee, strEmailOptionnal, null, strSenderName, strSenderEmail, (strSubject != null) ? strSubject : StringUtils.EMPTY, strBodyContent, iCalendar.toString(), bCreate); }