List of usage examples for java.io UnsupportedEncodingException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.opencms.ui.CmsVaadinUtils.java
/** * Reads the content of an input stream into a string (using UTF-8 encoding), performs a function on the string, and returns the result * again as an input stream.<p>//from w w w.ja va 2s .c o m * * @param stream the stream producing the input data * @param transformation the function to apply to the input * * @return the stream producing the transformed input data */ public static InputStream filterUtf8ResourceStream(InputStream stream, Function<String, String> transformation) { try { byte[] streamData = CmsFileUtil.readFully(stream); String dataAsString = new String(streamData, "UTF-8"); byte[] transformedData = transformation.apply(dataAsString).getBytes("UTF-8"); return new ByteArrayInputStream(transformedData); } catch (UnsupportedEncodingException e) { LOG.error(e.getLocalizedMessage(), e); return null; } catch (IOException e) { LOG.error(e.getLocalizedMessage(), e); throw new RuntimeException(e); } }
From source file:org.opencms.ui.actions.CmsEditCodeDialogAction.java
/** * @see org.opencms.ui.actions.I_CmsWorkplaceAction#executeAction(org.opencms.ui.I_CmsDialogContext) */// w w w . j a v a2 s . co m public void executeAction(I_CmsDialogContext context) { String backLink; try { backLink = URLEncoder.encode(UI.getCurrent().getPage().getLocation().toString(), "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error(e.getLocalizedMessage(), e); backLink = UI.getCurrent().getPage().getLocation().toString(); } CmsAppWorkplaceUi.get().showApp(OpenCms.getWorkplaceAppManager().getAppConfiguration("editor"), CmsEditor.getEditState(context.getResources().get(0).getStructureId(), true, backLink)); }
From source file:org.opencms.ui.actions.CmsEditDialogAction.java
/** * @see org.opencms.ui.actions.I_CmsWorkplaceAction#executeAction(org.opencms.ui.I_CmsDialogContext) */// w w w. j a v a2 s . com public void executeAction(I_CmsDialogContext context) { String backLink; try { String currentLocation = UI.getCurrent().getPage().getLocation().toString(); backLink = URLEncoder.encode(currentLocation, "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error(e.getLocalizedMessage(), e); backLink = UI.getCurrent().getPage().getLocation().toString(); } View view = CmsAppWorkplaceUi.get().getCurrentView(); if (view instanceof CmsAppView) { ((CmsAppView) view).setCacheStatus(CacheStatus.cacheOnce); } CmsAppWorkplaceUi.get().showApp(OpenCms.getWorkplaceAppManager().getAppConfiguration("editor"), CmsEditor.getEditState(context.getResources().get(0).getStructureId(), false, backLink)); }
From source file:org.dd4t.core.providers.BaseBrokerProvider.java
/** * Encodes the given URL parameter to Base64 format * * @param url String representing the message to encode * @return String the Base64 encoded string *//*from ww w . java 2 s. c o m*/ protected String encodeUrl(final String url) { if (url == null) { return ""; } String encoded = null; try { encoded = URL_CODER.encodeAsString(url.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { LOG.error(e.getLocalizedMessage(), e); } if (encoded == null) { return ""; } return encoded.trim(); }
From source file:org.geowebcache.storage.blobstore.memory.NullBlobStore.java
@Override public synchronized void putLayerMetadata(String layerName, String key, String value) { // Check if the property is present Properties props = metadataMap.get(layerName); if (props != null) { try {// www .ja v a2 s .co m // If present adds the new property props.setProperty(key, URLEncoder.encode(value, "UTF-8")); } catch (UnsupportedEncodingException e) { LOGGER.error(e.getLocalizedMessage(), e); } } else { // Else creates a new Property object and them adds the new property props = new Properties(); try { props.setProperty(key, URLEncoder.encode(value, "UTF-8")); } catch (UnsupportedEncodingException e) { LOGGER.error(e.getLocalizedMessage(), e); } metadataMap.put(layerName, props); } }
From source file:org.geomajas.plugin.deskmanager.domain.types.XmlSerialisationType.java
private Object fromXmlString(String xmlString) { if (xmlString == null) { return null; }//from w ww . ja v a 2s. c o m try { ByteArrayInputStream is = new ByteArrayInputStream(xmlString.getBytes(ENCODING)); XMLDecoder decoder = new XMLDecoder(is); return decoder.readObject(); } catch (UnsupportedEncodingException e) { LOG.warn(e.getLocalizedMessage()); IllegalArgumentException ex = new IllegalArgumentException("cannot disassemble the object"); ex.setStackTrace(e.getStackTrace()); throw ex; } }
From source file:org.dd4t.providers.BaseBrokerProvider.java
/** * Encodes the given URL parameter to Base64 format * * @param url String representing the message to encode * @return String the Base64 encoded string *///from ww w . j a v a 2 s . c o m protected String encodeUrl(final String url) { if (url == null) { return ""; } String encoded = null; try { encoded = URL_CODER.encodeAsString(url.getBytes(CharEncoding.UTF_8)); } catch (UnsupportedEncodingException e) { LOG.error(e.getLocalizedMessage(), e); } if (encoded == null) { return ""; } return encoded.trim(); }
From source file:com.infullmobile.jenkins.plugin.restrictedregister.mail.Mail.java
public void send() throws MailException { MimeMessage msg = null;/*from w w w . j a va2s .c o m*/ try { msg = createMessage(); } catch (UnsupportedEncodingException e) { fail("Failed to encode e-mail message, " + e.getLocalizedMessage()); } catch (MessagingException e) { fail(""); } if (msg == null) { throw new NullPointerException("Message must not be null"); } try { Transport.send(msg); } catch (MessagingException e) { fail("Failed to send e-mail message"); } }
From source file:org.opencms.ui.dialogs.history.diff.CmsValueDiff.java
/** * Decodes the given data with the given encoding, falling back to the system encoding if necessary.<p> * * @param data the data to decode/*w w w . j a v a 2 s . c o m*/ * @param encoding the encoding to use * * @return if something goes wrong */ private String decode(byte[] data, String encoding) { try { return new String(data, encoding); } catch (UnsupportedEncodingException e) { LOG.warn(e.getLocalizedMessage(), e); return new String(data); } }
From source file:pt.webdetails.cns.notifications.sparkl.SparklEndpointEventHandler.java
private Map<String, String> toKtrParamMap(INotificationEvent e, String commaSeparatedRecipientList, String eventSubType) {/*from w ww . java 2 s . c om*/ Map<String, String> map = new HashMap<String, String>(); if (e != null && !StringUtils.isEmpty(commaSeparatedRecipientList)) { try { map.put(SPARKL_PARAM_PREFIX + "rcpts", URLEncoder.encode(commaSeparatedRecipientList, ENCODING)); if (e.getRecipientType() != null) { String type = e.getRecipientType().toString(); if (!StringUtils.isEmpty(eventSubType)) { type += " (" + eventSubType + ")"; } map.put(SPARKL_PARAM_PREFIX + "eventtype", URLEncoder.encode(type, ENCODING)); } if (!StringUtils.isEmpty(e.getSender())) { map.put(SPARKL_PARAM_PREFIX + "author", URLEncoder.encode(e.getSender(), ENCODING)); } if (!StringUtils.isEmpty(e.getTitle())) { map.put(SPARKL_PARAM_PREFIX + "title", URLEncoder.encode(e.getTitle(), ENCODING)); } if (!StringUtils.isEmpty(e.getMessage())) { map.put(SPARKL_PARAM_PREFIX + "message", URLEncoder.encode(e.getMessage(), ENCODING)); } if (!StringUtils.isEmpty(e.getLink())) { map.put(SPARKL_PARAM_PREFIX + "link", URLEncoder.encode(e.getLink(), ENCODING)); } if (!StringUtils.isEmpty(e.getNotificationType())) { map.put(SPARKL_PARAM_PREFIX + "style", URLEncoder.encode(e.getNotificationType(), ENCODING)); } } catch (UnsupportedEncodingException ex) { logger.error(ex.getLocalizedMessage(), ex); } } return map; }