List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:org.apache.struts2.util.TokenHelper.java
/** * Sets a transaction token into the session using the provided token name. * * @param tokenName the name to store into the session with the token as the value * @return the token string// w w w . j av a2 s . c o m */ public static String setToken(String tokenName) { Map session = ActionContext.getContext().getSession(); String token = generateGUID(); try { session.put(tokenName, token); } catch (IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); } return token; }
From source file:org.artifactory.cli.rest.RestClient.java
public static byte[] delete(String uri, int expectedStatus, String expectedResultType, boolean printStream, int timeout, Credentials credentials) throws IOException { DeleteMethod method;/*from w w w . j ava2 s. c o m*/ try { method = new DeleteMethod(uri); } catch (IllegalStateException ise) { throw new RemoteCommandException("\nAn error has occurred while trying to resolve the given url: " + uri + "\n" + ise.getMessage()); } return executeMethod(uri, method, expectedStatus, expectedResultType, timeout, credentials, printStream); }
From source file:org.artifactory.cli.rest.RestClient.java
/** * Get method with full settings//from w ww . j a v a 2s .c o m * * @param uri Target URL * @param expectedStatus The expected return status * @param expectedResultType The expected media type of the returned data * @param printStream True if should print response stream to system.out * @param timeout Request timeout * @param credentials For authentication * @return byte[] - Response stream * @throws IOException * @throws RemoteCommandException */ public static byte[] get(String uri, int expectedStatus, String expectedResultType, boolean printStream, int timeout, Credentials credentials) throws IOException { GetMethod method; try { method = new GetMethod(uri); } catch (IllegalStateException ise) { throw new RemoteCommandException("\nAn error has occurred while trying to resolve the given url: " + uri + "\n" + ise.getMessage()); } return executeMethod(uri, method, expectedStatus, expectedResultType, timeout, credentials, printStream); }
From source file:com.liferay.util.portlet.PortletRequestUtil.java
private static void _mimeResponseToXML(MimeResponse mimeResponse, Element requestElement) { String namespace = mimeResponse.getNamespace(); requestElement.addElement("portlet-namespace", namespace); try {/*w w w . ja v a2 s . c o m*/ PortletURL actionURL = mimeResponse.createActionURL(); requestElement.addElement("action-url", actionURL); } catch (IllegalStateException ise) { if (_log.isWarnEnabled()) { _log.warn(ise.getMessage()); } } try { PortletURL renderURL = mimeResponse.createRenderURL(); requestElement.addElement("render-url", renderURL); try { renderURL.setWindowState(LiferayWindowState.EXCLUSIVE); requestElement.addElement("render-url-exclusive", renderURL); } catch (WindowStateException wse) { } try { renderURL.setWindowState(LiferayWindowState.MAXIMIZED); requestElement.addElement("render-url-maximized", renderURL); } catch (WindowStateException wse) { } try { renderURL.setWindowState(LiferayWindowState.MINIMIZED); requestElement.addElement("render-url-minimized", renderURL); } catch (WindowStateException wse) { } try { renderURL.setWindowState(LiferayWindowState.NORMAL); requestElement.addElement("render-url-normal", renderURL); } catch (WindowStateException wse) { } try { renderURL.setWindowState(LiferayWindowState.POP_UP); requestElement.addElement("render-url-pop-up", renderURL); } catch (WindowStateException wse) { } } catch (IllegalStateException ise) { if (_log.isWarnEnabled()) { _log.warn(ise.getMessage()); } } ResourceURL resourceURL = mimeResponse.createResourceURL(); String resourceURLString = HttpUtil.removeParameter(resourceURL.toString(), namespace + "struts_action"); resourceURLString = HttpUtil.removeParameter(resourceURLString, namespace + "redirect"); requestElement.addElement("resource-url", resourceURLString); }
From source file:com.liferay.util.portlet.PortletRequestUtil.java
public static String toXML(PortletRequest portletRequest, PortletResponse portletResponse) { Element requestElement = new Element("request"); requestElement.addElement("container-type", "portlet"); requestElement.addElement("container-type", "portlet"); requestElement.addElement("container-namespace", portletRequest.getContextPath()); requestElement.addElement("content-type", portletRequest.getResponseContentType()); requestElement.addElement("server-name", portletRequest.getServerName()); requestElement.addElement("server-port", portletRequest.getServerPort()); requestElement.addElement("secure", portletRequest.isSecure()); requestElement.addElement("auth-type", portletRequest.getAuthType()); requestElement.addElement("remote-user", portletRequest.getRemoteUser()); requestElement.addElement("context-path", portletRequest.getContextPath()); requestElement.addElement("locale", portletRequest.getLocale()); requestElement.addElement("portlet-mode", portletRequest.getPortletMode()); requestElement.addElement("portlet-session-id", portletRequest.getRequestedSessionId()); requestElement.addElement("scheme", portletRequest.getScheme()); requestElement.addElement("window-state", portletRequest.getWindowState()); if (portletRequest instanceof ActionRequest) { requestElement.addElement("lifecycle", RenderRequest.ACTION_PHASE); } else if (portletRequest instanceof RenderRequest) { requestElement.addElement("lifecycle", RenderRequest.RENDER_PHASE); } else if (portletRequest instanceof ResourceRequest) { requestElement.addElement("lifecycle", RenderRequest.RESOURCE_PHASE); }/*www . j a v a2 s . c om*/ if (portletResponse instanceof MimeResponse) { _mimeResponseToXML((MimeResponse) portletResponse, requestElement); } ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay != null) { Element themeDisplayElement = requestElement.addElement("theme-display"); _themeDisplayToXML(themeDisplay, themeDisplayElement); } Element parametersElement = requestElement.addElement("parameters"); Enumeration<String> enu = portletRequest.getParameterNames(); while (enu.hasMoreElements()) { String name = enu.nextElement(); Element parameterElement = parametersElement.addElement("parameter"); parameterElement.addElement("name", name); String[] values = portletRequest.getParameterValues(name); for (int i = 0; i < values.length; i++) { parameterElement.addElement("value", values[i]); } } Element attributesElement = requestElement.addElement("attributes"); enu = portletRequest.getAttributeNames(); while (enu.hasMoreElements()) { String name = enu.nextElement(); if (!_isValidAttributeName(name)) { continue; } Object value = portletRequest.getAttribute(name); if (!_isValidAttributeValue(value)) { continue; } Element attributeElement = attributesElement.addElement("attribute"); attributeElement.addElement("name", name); attributeElement.addElement("value", value); } Element portletSessionElement = requestElement.addElement("portlet-session"); attributesElement = portletSessionElement.addElement("portlet-attributes"); PortletSession portletSession = portletRequest.getPortletSession(); try { enu = portletSession.getAttributeNames(PortletSession.PORTLET_SCOPE); while (enu.hasMoreElements()) { String name = enu.nextElement(); if (!_isValidAttributeName(name)) { continue; } Object value = portletSession.getAttribute(name, PortletSession.PORTLET_SCOPE); if (!_isValidAttributeValue(value)) { continue; } Element attributeElement = attributesElement.addElement("attribute"); attributeElement.addElement("name", name); attributeElement.addElement("value", value); } attributesElement = portletSessionElement.addElement("application-attributes"); enu = portletSession.getAttributeNames(PortletSession.APPLICATION_SCOPE); while (enu.hasMoreElements()) { String name = enu.nextElement(); if (!_isValidAttributeName(name)) { continue; } Object value = portletSession.getAttribute(name, PortletSession.APPLICATION_SCOPE); if (!_isValidAttributeValue(value)) { continue; } Element attributeElement = attributesElement.addElement("attribute"); attributeElement.addElement("name", name); attributeElement.addElement("value", value); } } catch (IllegalStateException ise) { if (_log.isWarnEnabled()) { _log.warn(ise.getMessage()); } } return requestElement.toXMLString(); }
From source file:io.personium.common.utils.PersoniumCoreUtils.java
/** * InputStream?????String??.//ww w .j a v a 2 s . c o m * @param is InputStream * @return */ public static String readInputStreamAsString(InputStream is) { InputStreamReader isr = null; BufferedReader reader = null; String bodyString = null; try { isr = new InputStreamReader(is, "UTF-8"); reader = new BufferedReader(isr); StringBuffer sb = new StringBuffer(); int chr; while ((chr = is.read()) != -1) { sb.append((char) chr); } bodyString = sb.toString(); } catch (IllegalStateException e) { log.info(e.getMessage()); } catch (IOException e) { log.info(e.getMessage()); } finally { try { if (reader != null) { reader.close(); } if (isr != null) { isr.close(); } if (is != null) { is.close(); } } catch (IOException e) { log.info(e.getMessage()); } } return bodyString; }
From source file:org.mrgeo.resources.tms.TileMapServiceResource.java
public static void init() { try {/* w w w . j av a 2 s . c o m*/ if (props == null) { props = Configuration.getInstance().getProperties(); } } catch (final IllegalStateException e) { log.error(MrGeoConstants.MRGEO_HDFS_IMAGE + " must be specified in the MrGeo configuration file (" + e.getMessage() + ")"); } }
From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.importer.ExcelImportUtilities.java
private static String getNumericCellContentAsString(Cell cell, ProcessingLog processingLog) { // for numeric cells / dates we have to look at the cell format to tell if it's a date cell // If so, we retrieve the value as a date and convert it to ISO String notation if (HSSFDateUtil.isCellDateFormatted(cell)) { // is it a date-formatted number? then return the ISO-formatted date instead of the number Date cellDate = contentAsDate(cell); final SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); return dateformatter.format(cellDate); }/*from w w w . j a va 2 s . c o m*/ Double d = null; try { d = contentAsDouble(cell); } catch (NumberFormatException ex) { processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), ex.getMessage()); } catch (IllegalStateException e) { processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), e.getMessage()); } if (d != null) { // cut off *.0 double i = d.doubleValue() - d.intValue(); if (i == 0) { Integer j = Integer.valueOf(d.intValue()); return j.toString(); } else { return d.toString(); } } return ""; }
From source file:org.apache.eagle.alert.metadata.impl.MongoImplTest.java
@AfterClass public static void teardown() { if (mongod != null) { try {//from w w w. j av a2 s .c om mongod.stop(); } catch (IllegalStateException e) { // catch this exception for the unstable stopping mongodb // reason: the exception is usually thrown out with below message format when stop() returns null value, // but actually this should have been captured in ProcessControl.stopOrDestroyProcess() by destroying // the process ultimately if (e.getMessage() != null && e.getMessage().matches("^Couldn't kill.*process!.*")) { // if matches, do nothing, just ignore the exception } else { LOG.warn(String.format("Ignored error for stopping mongod process, see stack trace: %s", ExceptionUtils.getStackTrace(e))); } } mongodExe.stop(); } }
From source file:org.libreplan.ws.common.impl.OrderElementConverter.java
private static void addOrCriterionRequirementsEntities(ICriterionRequirable criterionRequirable, Set<CriterionRequirementDTO> criterionRequirements) { for (CriterionRequirementDTO criterionRequirementDTO : criterionRequirements) { Criterion criterion = getCriterion(criterionRequirementDTO.name, criterionRequirementDTO.type); if (criterion != null) { if (criterionRequirementDTO instanceof DirectCriterionRequirementDTO) { DirectCriterionRequirement directCriterionRequirement = getDirectCriterionRequirementByCriterion( criterionRequirable, criterion); if (directCriterionRequirement == null) { try { criterionRequirable .addCriterionRequirement(DirectCriterionRequirement.create(criterion)); } catch (IllegalStateException e) { throw new ValidationException(e.getMessage()); }/*from www .j a v a 2s . co m*/ } } else { // criterionRequirementDTO instanceof IndirectCriterionRequirementDTO IndirectCriterionRequirement indirectCriterionRequirement = getIndirectCriterionRequirementByCriterion( criterionRequirable, criterion); if (indirectCriterionRequirement != null) { indirectCriterionRequirement .setValid(((IndirectCriterionRequirementDTO) criterionRequirementDTO).valid); } } } else { if (criterionRequirementDTO.name == null || criterionRequirementDTO.type == null) { throw new ValidationException("the criterion format is incorrect"); } else { throw new ValidationException("the criterion " + criterionRequirementDTO.name + " which type is " + criterionRequirementDTO.type + " not found"); } } } }