List of usage examples for javax.servlet ServletException getMessage
public String getMessage()
From source file:org.openbravo.materialmgmt.ReservationUtils.java
public static OBError reserveStockAuto(Reservation reservation) throws OBException { OBDal.getInstance().flush();//from www .j ava2 s . c o m CSResponse cs = null; try { cs = ReservationUtilsData.reserveStockAuto(OBDal.getInstance().getConnection(false), new DalConnectionProvider(false), reservation.getId(), (String) DalUtil.getId(OBContext.getOBContext().getUser())); } catch (ServletException e) { String message = OBMessageUtils.translateError(e.getMessage()).getMessage(); throw new OBException(message, e); } String message = ""; if (cs != null && cs.returnValue != null) { message = cs.returnValue; } OBError obmessage = new OBError(); obmessage.setType("SUCCESS"); obmessage.setMessage(message); return obmessage; }
From source file:org.openbravo.materialmgmt.ReservationUtils.java
/** * Function to reserve in allocated or not allocated given stock or purchase order line. Available * OBObject are:<br>/*from w w w .j a v a 2 s.c o m*/ * - StorageDetail: reserves stock in the warehouse.<br> * - OrderLine: reserves stock pending to receipt purchase order line. */ public static ReservationStock reserveStockManual(Reservation reservation, BaseOBObject obObject, BigDecimal quantity, String allocated) throws OBException { String strType = ""; if (obObject instanceof OrderLine) { strType = "PO"; } else if (obObject instanceof StorageDetail) { strType = "SD"; } else { throw new OBException("notValidReservationType"); } OBDal.getInstance().flush(); CSResponse cs = null; try { cs = ReservationUtilsData.reserveStockManual(OBDal.getInstance().getConnection(false), new DalConnectionProvider(false), reservation.getId(), strType, obObject.getId().toString(), quantity.toString(), (String) DalUtil.getId(OBContext.getOBContext().getUser()), allocated); } catch (ServletException e) { String message = OBMessageUtils.translateError(e.getMessage()).getMessage(); throw new OBException(message, e); } if (cs != null && cs.returnValue != null) { return OBDal.getInstance().get(ReservationStock.class, cs.returnValue); } return null; }
From source file:org.openbravo.materialmgmt.ReservationUtils.java
/** * Function to reallocate given reservation stock on given attributes and storage bin. *///from w w w.java 2 s .co m public static OBError reallocateStock(Reservation reservation, Locator storageBin, AttributeSetInstance asi, BigDecimal quantity) throws OBException { OBDal.getInstance().flush(); CSResponse cs = null; try { cs = ReservationUtilsData.reallocateStock(OBDal.getInstance().getConnection(false), new DalConnectionProvider(false), reservation.getId(), storageBin.getId(), asi.getId(), quantity.toPlainString(), (String) DalUtil.getId(OBContext.getOBContext().getUser())); } catch (ServletException e) { String message = OBMessageUtils.translateError(e.getMessage()).getMessage(); throw new OBException(message, e); } OBError result = new OBError(); if (cs == null || StringUtils.isEmpty(cs.returnValue)) { throw new OBException(OBMessageUtils.messageBD("Error", false)); } result.setType("Success"); result.setMessage(OBMessageUtils.messageBD("Success", false)); if (cs.returnValue == "0") { result.setType("Error"); } else if (cs.returnValue == "2") { result.setType("Warning"); } if (StringUtils.isNotEmpty(cs.returnValueMsg)) { result.setMessage(OBMessageUtils.parseTranslation(cs.returnValueMsg)); } return result; }
From source file:com.aurel.track.GeneralSettings.java
/** * Loads the filter names from property file * @return//from w ww . j a v a2s .co m */ public static void loadGeneralConfigs() { try { configMap = HandleHome.getProperties(HandleHome.GENERAL_SETTINGS_FILE, ApplicationBean.getInstance().getServletContext()); } catch (ServletException e) { LOGGER.error("ServletException by getting the " + HandleHome.GENERAL_SETTINGS_FILE + " from war " + e.getMessage()); } }
From source file:com.aurel.track.admin.customize.category.filter.MenuitemFilterBL.java
/** * Loads the filter names from property file * @return//from w w w. j a v a 2 s . c o m */ private static List<String> loadFilterNamesToSubscribe() { List<String> filterNames = new LinkedList<String>(); String ON = "on"; String OFF = "off"; PropertiesConfiguration propertiesConfiguration = null; try { propertiesConfiguration = HandleHome.getProperties(HandleHome.FILTER_SUBSCRIPTIONS_FILE, ApplicationBean.getInstance().getServletContext()); } catch (ServletException e) { LOGGER.error( "ServletException by getting the FilterSubscriptions.properties from war " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (propertiesConfiguration != null) { Iterator<String> keys = propertiesConfiguration.getKeys(); while (keys.hasNext()) { String key = keys.next(); String[] keyParts = key.split("\\."); if (keyParts != null && keyParts.length > 1) { String repository = keyParts[0]; if (repository != null && !"".equals(repository)) { String filterName = key.substring(repository.length() + 1); String value = propertiesConfiguration.getString(key); if (value != null && !"".equals(value)) { if (ON.equals(value)) { filterNames.add(filterName); } else { if (!OFF.equals(value)) { try { Boolean boolValue = Boolean.valueOf(value); if (boolValue != null && boolValue.booleanValue()) { filterNames.add(filterName); } } catch (Exception e) { LOGGER.info("The value " + value + " for key " + key + " can't be converted to a boolean " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } } } } } } return filterNames; }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Forward a request that was received by this servlet on to another JSP * page or servlet to continue handling the request. * /*from w w w.ja va 2 s . c o m*/ * @param request * to be forwarded * @param response * that can be used for writing output to the client * @param destination * the context-relative URL to which the request is forwarded * @param params the request parameters. these will be added to the request */ public static void forwardRequest(HttpServletRequest request, HttpServletResponse response, String destinationUrl, Hashtable<String, String[]> params) throws MetacatUtilException { destinationUrl += "?" + paramsToQuery(params); logMetacat.debug("Forwarding request to " + destinationUrl); ServletContext servletContext = request.getSession().getServletContext(); try { servletContext.getRequestDispatcher(destinationUrl).forward(request, response); } catch (IOException ioe) { throw new MetacatUtilException("RequestUtil.forwardRequest - I/O error when forwarding to " + destinationUrl + " : " + ioe.getMessage()); } catch (ServletException se) { throw new MetacatUtilException("RequestUtil.forwardRequest - Servlet error when forwarding to " + destinationUrl + " : " + se.getMessage()); } }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Forward a request that was received by this servlet on to another JSP * page or servlet to continue handling the request. In this case, the page * must be referenced in a paramter named "forwardto". If the qformat is * provided, the file will be retrieved from that skin. Otherwise, the file * will be retrieved from the system default skin. * /*from ww w. j a va 2 s .c om*/ * For more specific file location, use: forwardRequest(request,response, destinationUrl, params) * * @param request * to be forwarded * @param response * that can be used for writing output to the client * @param params * the request parameters. these will be added to the request. */ public static void forwardRequest(HttpServletRequest request, HttpServletResponse response, Hashtable<String, String[]> params) throws MetacatUtilException { String forwardTos[] = params.get("forwardto"); if (forwardTos == null || forwardTos[0].equals("")) { throw new MetacatUtilException( "RequestUtil.forwardRequest - forwardto must be set in parameters when forwarding."); } String forwardTo = forwardTos[0]; String qformat = null; String qformats[] = params.get("qformat"); if (qformats == null || qformats.length == 0) { try { qformat = PropertyService.getProperty("application.default-style"); } catch (PropertyNotFoundException pnfe) { qformat = "default"; logMetacat.warn("RequestUtil.forwardRequest - could not get property " + "'application.default-style'. Using 'default'"); } } else { qformat = qformats[0]; } String destinationUrl = "/style/skins/" + qformat + "/" + forwardTo; destinationUrl += "?" + paramsToQuery(params); logMetacat.debug("RequestUtil.forwardRequest - Forwarding request to " + destinationUrl); ServletContext servletContext = request.getSession().getServletContext(); try { servletContext.getRequestDispatcher(destinationUrl).forward(request, response); } catch (IOException ioe) { throw new MetacatUtilException("RequestUtil.forwardRequest - I/O error when forwarding to " + destinationUrl + " : " + ioe.getMessage()); } catch (ServletException se) { throw new MetacatUtilException("RequestUtil.forwardRequest - Servlet error when forwarding to " + destinationUrl + " : " + se.getMessage()); } }
From source file:org.sakaiproject.entitybroker.util.request.RequestUtils.java
/** * Handles the redirect to a URL from the current location, * the URL should be relative for a forward, otherwise it will be a redirect <br/> * NOTE: You should perform no actions after call this method, * you should simply pass control back to the handler * @param redirectURL the URL to redirect to (relative or absolute) * @param forward if false, use redirect (this should be the default), * if true use forward, note that we can only forward from your webapp back to your servlets and * a check will be performed to see if this is the case, if it is not * (anything with a "http", a non-matching prefix, and anything with a query string) will be switched to redirect automatically * @param req the current request/* ww w . ja v a2 s . c om*/ * @param res the current response * @throws IllegalArgumentException is the params are invalid */ public static void handleURLRedirect(String redirectURL, boolean forward, HttpServletRequest req, HttpServletResponse res) { if (redirectURL == null || "".equals(redirectURL)) { throw new IllegalArgumentException("The redirect URL must be set and cannot be null"); } if (req == null || res == null) { throw new IllegalArgumentException("The request and response must be set and cannot be null"); } if (redirectURL.startsWith("http:") || redirectURL.startsWith("https:") || RequestUtils.containsQueryString(redirectURL)) { forward = false; } else { // we allow forwarding ONLY if the current webapp path matches the redirect path String webapp = req.getContextPath(); if (webapp != null && webapp.length() > 0) { if (redirectURL.startsWith(webapp + "/")) { redirectURL = redirectURL.substring(webapp.length()); forward = true; } else if (redirectURL.length() > 1 && redirectURL.startsWith(webapp.substring(1) + "/")) { redirectURL = redirectURL.substring(webapp.length() - 1); forward = true; } else { forward = false; } } } if (forward) { // check for infinite forwarding String curRedirect = DIVIDER + redirectURL + DIVIDER; if (req.getAttribute(ENTITY_REDIRECT_CHECK) != null) { String redirectCheck = (String) req.getAttribute(ENTITY_REDIRECT_CHECK); if (redirectCheck.contains(curRedirect)) { throw new IllegalStateException("Infinite forwarding loop detected with attempted redirect to (" + redirectURL + "), path to failure: " + redirectCheck.replace(DIVIDER + DIVIDER, " => ").replace(DIVIDER, "") + " => " + redirectURL); } redirectCheck += curRedirect; req.setAttribute(ENTITY_REDIRECT_CHECK, redirectCheck); } else { req.setAttribute(ENTITY_REDIRECT_CHECK, curRedirect); } RequestDispatcher rd = req.getRequestDispatcher(redirectURL); try { rd.forward(req, res); } catch (ServletException e) { throw new RuntimeException( "Failure with servlet while forwarding to '" + redirectURL + "': " + e.getMessage(), e); } catch (IOException e) { throw new RuntimeException( "Failure with encoding while forwarding to '" + redirectURL + "': " + e.getMessage(), e); } } else { res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); try { res.sendRedirect(redirectURL); } catch (IOException e) { throw new RuntimeException( "Failure with encoding while redirecting to '" + redirectURL + "': " + e.getMessage(), e); } } }
From source file:org.kuali.kfs.kns.util.WebUtils.java
public static void getMultipartParameters(HttpServletRequest request, ActionServletWrapper servletWrapper, ActionForm form, ActionMapping mapping) { // Get the ActionServletWrapper from the form bean // ActionServletWrapper servletWrapper = getServletWrapper(); try {/* w ww .j ava 2 s . c o m*/ CommonsMultipartRequestHandler multipartHandler = new CommonsMultipartRequestHandler(); if (multipartHandler != null) { // Set servlet and mapping info if (servletWrapper != null) { // from pojoformbase // servlet only affects tempdir on local disk servletWrapper.setServletFor(multipartHandler); } multipartHandler.setMapping((ActionMapping) request.getAttribute(Globals.MAPPING_KEY)); // Initialize multipart request class handler multipartHandler.handleRequest(request); Collection<FormFile> files = multipartHandler.getFileElements().values(); Enumeration keys = multipartHandler.getFileElements().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); FormFile file = (FormFile) multipartHandler.getFileElements().get(key); long maxSize = WebUtils.getMaxUploadSize(form); if (LOG.isDebugEnabled()) { LOG.debug(file.getFileSize()); } if (maxSize > 0 && Long.parseLong(file.getFileSize() + "") > maxSize) { GlobalVariables.getMessageMap().putError(key.toString(), RiceKeyConstants.ERROR_UPLOADFILE_SIZE, new String[] { file.getFileName(), Long.toString(maxSize) }); } } // get file elements for kualirequestprocessor if (servletWrapper == null) { request.setAttribute(KRADConstants.UPLOADED_FILE_REQUEST_ATTRIBUTE_KEY, getFileParametersForMultipartRequest(request, multipartHandler)); } } } catch (ServletException e) { throw new ValidationException("unable to handle multipart request " + e.getMessage(), e); } }
From source file:org.kuali.rice.kns.util.WebUtils.java
public static void getMultipartParameters(HttpServletRequest request, ActionServletWrapper servletWrapper, ActionForm form, ActionMapping mapping) { Map params = new HashMap(); // Get the ActionServletWrapper from the form bean // ActionServletWrapper servletWrapper = getServletWrapper(); try {//from www . j a v a 2 s. c om CommonsMultipartRequestHandler multipartHandler = new CommonsMultipartRequestHandler(); if (multipartHandler != null) { // Set servlet and mapping info if (servletWrapper != null) { // from pojoformbase // servlet only affects tempdir on local disk servletWrapper.setServletFor(multipartHandler); } multipartHandler.setMapping((ActionMapping) request.getAttribute(Globals.MAPPING_KEY)); // Initialize multipart request class handler multipartHandler.handleRequest(request); Collection<FormFile> files = multipartHandler.getFileElements().values(); Enumeration keys = multipartHandler.getFileElements().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); FormFile file = (FormFile) multipartHandler.getFileElements().get(key); long maxSize = WebUtils.getMaxUploadSize(form); if (LOG.isDebugEnabled()) { LOG.debug(file.getFileSize()); } if (maxSize > 0 && Long.parseLong(file.getFileSize() + "") > maxSize) { GlobalVariables.getMessageMap().putError(key.toString(), RiceKeyConstants.ERROR_UPLOADFILE_SIZE, new String[] { file.getFileName(), Long.toString(maxSize) }); } } // get file elements for kualirequestprocessor if (servletWrapper == null) { request.setAttribute(KRADConstants.UPLOADED_FILE_REQUEST_ATTRIBUTE_KEY, getFileParametersForMultipartRequest(request, multipartHandler)); } } } catch (ServletException e) { throw new ValidationException("unable to handle multipart request " + e.getMessage(), e); } }