Beispiel #1
0
  private void setTitle(HttpServletRequest request, Portal portal, String titleName)
      throws Exception {
    Resource resource = RequestUtils.getResource(request);
    ResourceGroup group = RequestUtils.getResourceGroupIfExists(request);
    ResourceType type;
    if (resource != null) {
      // resource alert definition
      type = resource.getResourceType();
    } else if (group != null) {
      // group alert definition
      type = group.getResourceType();
    } else {
      // template alert definition
      type = RequestUtils.getResourceType(request);
    }

    ResourceCategory category = type.getCategory();

    titleName = StringUtil.replace(titleName, "platform", category.toString().toLowerCase());

    portal.setName(titleName);

    // if there's an alert definition available, set our second
    // title parameter to its name
    try {
      AlertDefinition alertDef = AlertDefUtil.getAlertDefinition(request);
      request.setAttribute(Constants.TITLE_PARAM2_ATTR, alertDef.getName());
    } catch (ParameterNotFoundException e) {
      // it's okay
      log.trace("couldn't find alert definition: " + e.getMessage());
    }
  }
Beispiel #2
0
  /**
   * This sets the return path for a ResourceAction by appending the type and resource id to the
   * forward url.
   *
   * @param request The current controller's request.
   * @param mapping The current controller's mapping that contains the input.
   * @exception ParameterNotFoundException if the type or id are not found
   * @exception ServletException If there is not input defined for this form
   */
  @Override
  protected void setReturnPath(HttpServletRequest request, ActionMapping mapping) throws Exception {
    HashMap parms = new HashMap();

    int resourceId = RequestUtils.getResourceId(request);
    parms.put(Constants.RESOURCE_ID_PARAM, resourceId);

    try {
      parms.put(
          Constants.ALERT_DEFINITION_PARAM,
          RequestUtils.getIntParameter(request, Constants.ALERT_DEFINITION_PARAM));
      parms.put(Constants.CHILD_RESOURCE_TYPE_ID_PARAM, WebUtility.getChildResourceTypeId(request));
    } catch (ParameterNotFoundException pnfe) {
      // that's ok!
      log.trace("couldn't find parameter: " + pnfe.getMessage());
    }

    // sets the returnPath to match the mode we're in.
    String mode = request.getParameter(Constants.MODE_PARAM);
    parms.put(Constants.MODE_PARAM, mode);

    String returnPath = ActionUtils.findReturnPath(mapping, parms);
    SessionUtils.setReturnPath(request.getSession(), returnPath);
  }