private String getFileName(String pContentDisposition) { String fileName = null; if (pContentDisposition != null) { String cdl = pContentDisposition.toLowerCase(); if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // Parameter parser can handle null input Map params = parser.parse(pContentDisposition, ';'); if (params.containsKey("filename")) { fileName = (String) params.get("filename"); if (fileName != null) { fileName = fileName.trim(); } else { // Even if there is no value, the parameter is present, // so we return an empty file name rather than no file // name. fileName = ""; } } } } return fileName; }
/** * Process a Portlet action. */ @SuppressWarnings("unchecked") protected void processAction(HttpServletRequest req, HttpServletResponse res) { // see if there's an action parameter, whose value has the action to use String action = ((ParameterParser) req.getAttribute(ATTR_PARAMS)).getString(PARAM_ACTION); // if that's not present, see if there's a combination name with the action encoded in the name if (action == null) { Enumeration<String> names = req.getParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); if (name.startsWith(PARAM_ACTION_COMBO)) { action = name.substring(PARAM_ACTION_COMBO.length()); break; } } } // process the action if present if (action != null) { actionDispatch("processAction", action, req, res); } } // processAction
/** * Get a (String) parameter by name. * * @param name * The parameter name. * @return The parameter value, or null if it's not defined. */ public String getString(String name) { return get(name); }
/** * Access the parameter names. * * @return An Iterator of parameter names (String). */ public Properties getProperties() { Properties retval = new Properties(); Iterator<String> names = getNames(); while (names.hasNext()) { String name = names.next(); retval.setProperty(name,getString(name)); } return retval; }
String action = params.get(PARAM_ACTION); Iterator<String> names = params.getNames(); while (names.hasNext()) String[] actions = params.getStrings(PARAM_ACTION); if (actions != null) String panel = ((ParameterParser) req.getAttribute(ATTR_PARAMS)).getString(ActionURL.PARAM_PANEL); String newPanel = (String) getState(req).getAttribute(STATE_NEW_PANEL); getState(req).removeAttribute(STATE_NEW_PANEL);
/** * Override service, adding the setup for legacy. */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { // parse the parameters of the request, considering Unicode issues, into a ParameterParser ParameterParser parser = new ParameterParser(req); // make this available from the req as an attribute req.setAttribute(ATTR_PARAMS, parser); // Setup.setup(req, resp); super.service(req, resp); }
/** * Get an int parameter by name. * * @param name * The parameter name. * @return The parameter int value, or 0 if it's not defined or not int. */ public int getInt(String name) { return getInt(name, 0); }
String action = params.get(PARAM_ACTION); Iterator<String> names = params.getNames(); while (names.hasNext()) String[] actions = params.getStrings(PARAM_ACTION); if (actions != null) String panel = ((ParameterParser) req.getAttribute(ATTR_PARAMS)).getString(ActionURL.PARAM_PANEL); String newPanel = (String) getState(req).getAttribute(STATE_NEW_PANEL); getState(req).removeAttribute(STATE_NEW_PANEL);
/** * Access the parameter names. * * @return An Iterator of parameter names (String). */ public Properties getProperties() { Properties retval = new Properties(); Iterator<String> names = getNames(); while (names.hasNext()) { String name = names.next(); retval.setProperty(name,getString(name)); } return retval; }
/** * Override service, adding the setup for legacy. */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { // parse the parameters of the request, considering Unicode issues, into a ParameterParser ParameterParser parser = new ParameterParser(req); // make this available from the req as an attribute req.setAttribute(ATTR_PARAMS, parser); // Setup.setup(req, resp); super.service(req, resp); }
/** * Get an int parameter by name. * * @param name * The parameter name. * @return The parameter int value, or 0 if it's not defined or not int. */ public int getInt(String name) { return getInt(name, 0); }
/** * Process a Portlet action. */ @SuppressWarnings("unchecked") protected void processAction(HttpServletRequest req, HttpServletResponse res) { // see if there's an action parameter, whose value has the action to use String action = ((ParameterParser) req.getAttribute(ATTR_PARAMS)).getString(PARAM_ACTION); // if that's not present, see if there's a combination name with the action encoded in the name if (action == null) { Enumeration<String> names = req.getParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); if (name.startsWith(PARAM_ACTION_COMBO)) { action = name.substring(PARAM_ACTION_COMBO.length()); break; } } } // process the action if present if (action != null) { actionDispatch("processAction", action, req, res); } } // processAction
/** * Get a (String) parameter by name. * * @param name * The parameter name. * @return The parameter value, or null if it's not defined. */ public String getString(String name) { return get(name); }
String value = getString(name); if (value == null) return null; if (value.length() == 0) return value;
/** * Get a boolean parameter by name. * * @param name * The parameter name. * @return The parameter boolean value, or false if it's not defined. */ public boolean getBoolean(String name) { return "true".equalsIgnoreCase(get(name)); }
String value = getString(name); if (value == null) return null; if (value.length() == 0) return value;
/** * Get a boolean parameter by name. * * @param name * The parameter name. * @return The parameter boolean value, or false if it's not defined. */ public boolean getBoolean(String name) { return "true".equalsIgnoreCase(get(name)); }
/** * Handle a view indecated page request */ public void doView_page(RunData runData, Context context) { // access the portlet element id to find our state String peid = ((JetspeedRunData) runData).getJs_peid(); SessionState state = ((JetspeedRunData) runData).getPortletSessionState(peid); // set the flag to go to the next item on the next view String page = runData.getParameters().getString(FORM_PAGE_NUMBER); state.setAttribute(STATE_GOTO_PAGE, new Integer(page)); } // doView_page
/** * Get an int parameter by name, with default. * * @param name * The parameter name. * @param deflt * The default value. * @return The parameter int value, or the default if it's not defined or not int. */ public int getInt(String name, int deflt) { try { return Integer.parseInt(get(name)); } catch (Throwable t) { return deflt; } }