Package org.apache.struts.util

Examples of org.apache.struts.util.MessageResources


        ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig("", context);
        return (MessageResources) context.getAttribute(key + moduleConfig.getPrefix());
    }
   
    public static String getMessage(HttpSession session, String bundle, String key) {
      MessageResources resources = getMessageResources(session, bundle);
      Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
      if (null != resources) {
          return resources.getMessage(locale, key);
      } else {
          return null;
      }
    }
View Full Code Here


   
    protected String getLocalisedLabel(LabelValueBean lvb) {
        if(valueKeyPrefix != null) {
            Locale locale = (Locale)pageContext.getSession().getAttribute(Globals.LOCALE_KEY);
            if(locale != null) {
                MessageResources mr = CoreUtil.getMessageResources(pageContext.getSession(), getBundle());
                if(mr != null) {
                    String locLabel = mr.getMessage(locale, valueKeyPrefix + ".value." + lvb.getValue());
                    if(locLabel != null) {
                        return locLabel;
                    }
                }
            }
View Full Code Here

            xml.append(bar.getValue());
            xml.append("</progressBarValue>");
            xml.append("<progressBarNote>");
            if(bar.getNote() != null) {
                BundleActionMessage bam = bar.getNote();
                MessageResources mr = CoreUtil.getMessageResources(request.getSession(), bam.getBundle());
                Locale l = (Locale)request.getSession().getAttribute(Globals.LOCALE_KEY);
                xml.append(Utils.htmlescape(mr.getMessage(l, bar.getNote().getKey(),
                    bam.getArg0(), bam.getArg1(), bam.getArg2(), bam.getArg3())));
            }
            else {
                xml.append("No note");
            }
View Full Code Here

                int j = 0;
                for (Iterator i = permissionsList.iterator(); i.hasNext();) {
                    j++;
                    AccessRight permission = (AccessRight) i.next();

                    MessageResources mrPermission = CoreUtil.getMessageResources(session.getHttpSession(), permission
                                    .getPermission().getBundle());
                    String permissionName = mrPermission.getMessage("permission." + permission.getPermission().getId() + ".title");

                    MessageResources mrResourceType = CoreUtil.getMessageResources(session.getHttpSession(), permission
                                    .getResourceType().getBundle());
                    String resourceTypeName = mrResourceType.getMessage("resourceType."
                                    + permission.getResourceType().getResourceTypeId() + ".title");

                    coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_PERMISSION + Integer.toString(j), permissionName
                                    + " " + resourceTypeName);
                }
View Full Code Here

    CoreEvent addAccessRightsAttributes(CoreEvent evt, AccessRights resource) {
        return evt;
    }

    private static String getAccessRightType(SessionInfo session, String permissionClass) {
        MessageResources messageResources = CoreUtil.getMessageResources(session.getHttpSession(), "policyframework");
        String accessRightType = messageResources.getMessage("permission.type." + permissionClass);
        return accessRightType;
    }
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    // Get all of the options from the resource bundle
    List options = new ArrayList();
    MessageResources resources = null;

    String bundle = request.getParameter("bundle");
    String propertyPrefix = request.getParameter("propertyPrefix");
    String type = request.getParameter("type");
    if (type == null) {
      type = "message";
    }
    String arg0 = request.getParameter("arg0");
    boolean decorated = true;
    String align = "center";
       
        Locale locale = (Locale)request.getSession().getAttribute(Globals.LOCALE_KEY);

    // parameter
    // ="administration,deletePropertyProfile,yes=/updatePropertyProfile.do?action=delete,no="
    if (mapping.getParameter() != null
        && !mapping.getParameter().equals("")) {
      StringTokenizer t = new StringTokenizer(mapping.getParameter(), ",");
      if (t.hasMoreTokens()) {
        type = t.nextToken();
      }

      // TODO this is a hack to get the extension store agreement aligning
      // left, sort it out properly!
      if (type.startsWith("align=")) {
        int idx = type.indexOf('=');
        align = type.substring(idx + 1);
        type = t.nextToken();
      }

      if (t.hasMoreTokens()) {
        decorated = t.nextToken().equalsIgnoreCase("true");
      }
      if (t.hasMoreTokens()) {
        bundle = t.nextToken();
      }
      if (t.hasMoreTokens()) {
        propertyPrefix = t.nextToken();
      }
      resources = getResources(request, bundle);
      if (resources == null) {
        throw new Exception("Could not find resource bundle " + bundle);
      }
      while (t.hasMoreTokens()) {
        String option = t.nextToken();
        options.add(getOption(locale, option, propertyPrefix, request,
            resources));
      }
    } else {
      resources = getResources(request, bundle);
      if (resources == null) {
        throw new Exception("Could not find resource bundle " + bundle);
      }
      String[] optionValues = request.getParameterValues("option");
      if (options != null) {
        for (int i = 0; i < optionValues.length; i++) {
          options.add(getOption(locale, optionValues[i], propertyPrefix,
              request, resources));
        }

      }
    }

    // Get the title text and the description
    String title = resources.getMessage(locale, propertyPrefix + ".title");
    String subtitle = resources.getMessage(locale, propertyPrefix + ".subtitle");
    String message = resources
        .getMessage(locale, propertyPrefix + ".message", arg0);

    // Initialise the form
    ConfirmForm confirmForm = (ConfirmForm) form;
    confirmForm.initialize(type, title, subtitle, message, options,
        decorated, align, arg0);

    // If this confirmation is the result on an exception then build up the
    // exception text
    Throwable exception = type.equals(ConfirmForm.TYPE_EXCEPTION) ? (Throwable) request
        .getSession().getAttribute(Constants.EXCEPTION)
        : null;
    request.getSession().removeAttribute(Constants.EXCEPTION);
    if (exception != null) {
      StringBuffer mesgBuf = new StringBuffer();
      StringBuffer traceBuf = new StringBuffer();
      Throwable ex = exception;
      while (ex != null) {
        String mesg = ex.getMessage();
        if (mesg != null) {
          mesg = mesg.trim();
          if (!mesg.endsWith(".")) {
            mesg += ".";
          }
          if (mesgBuf.length() == 0) {
            mesgBuf.append('\n');
          }
          mesgBuf.append(mesg);
        }
        StringWriter sw = new StringWriter();
        ex.printStackTrace(new PrintWriter(sw));
        if (traceBuf.length() == 0) {
          traceBuf.append("\n");
        }
        traceBuf.append(sw.toString());
        ex = ex.getCause();
      }

      // If this is a code exception we can get the localised messages
      if (exception instanceof CoreException) {
        CoreException ce = (CoreException) exception;
        MessageResources mr = CoreUtil.getMessageResources(request
            .getSession(), ce.getBundle());
        if (mr != null) {
          mesgBuf.append(" ");
          mesgBuf.append(mr.getMessage((Locale) request
              .getSession().getAttribute(Globals.LOCALE_KEY), ce
              .getBundleActionMessage().getKey(), ce
              .getBundleActionMessage().getArg0(), ce
              .getBundleActionMessage().getArg1(), ce
              .getBundleActionMessage().getArg2(), ce
View Full Code Here

  public ExtensionException(int code, String arg0, String arg1, String arg2, Throwable cause) {
    super(code, ERROR_CATEGORY, DEFAULT_BUNDLE, cause, arg0, arg1, arg2, null);
  }

  protected MessageResources getMessageResources(String bundleName) {
    MessageResources mr = (MessageResources) CoreServlet.getServlet().getServletContext().getAttribute(getBundle());
    if(mr == null) {
      MessageResourcesFactory fact = new ExceptionMessageResourcesFactory();
      mr = fact.createResources("com.adito.errors.ApplicationResources");
    }
    return mr;
View Full Code Here

                }
               
                if (buf.length() != 0) {
                    buf.append(")");
                }
                MessageResources mr = CoreUtil.getMessageResources(session.getHttpSession(), def.getMessageResourcesKey());
                l
                                .add(new LabelValueBean(
                                                mr == null ? ("!unknown bundle " + def.getMessageResourcesKey() + " in module definition")
                                                                : mr.getMessage("authenticationModule." + def.getName() + ".name")
                                                                                + buf.toString(), def.getName()));
            }
        }
        return l;
    }
View Full Code Here

     *      javax.servlet.http.HttpServletResponse)
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {

        MessageResources resources = CoreUtil.getMessageResources(request.getSession(), "agent");

        // Get the pending VPN session ticket
        String ticket = request.getParameter("ticket");
       
        if (log.isDebugEnabled())
            log.debug("Registering agent synchronization " + ticket);

        if(DefaultAgentManager.getInstance().getSessionByAgentId(ticket)!=null) {
          SessionInfo session = DefaultAgentManager.getInstance().getSessionByAgentId(ticket);
          session.setSession(request.getSession());       
         
          int timeout = Property.getPropertyInt(new ProfilePropertyKey(
            CoreUtil.getCurrentPropertyProfileId(request.getSession()),
            session.getUser().getPrincipalName(), "client.registration.synchronization.timeout", session.getUser().getRealm().getResourceId()));
 
          if (log.isDebugEnabled())
              log.debug("Waiting for agent registration (timeout " + timeout + ")");
         
          if (DefaultAgentManager.getInstance().waitForRegistrationAndSynchronization(ticket, timeout)) {
              if (log.isDebugEnabled())
                  log.debug("Successfull agent registration");   
        LogonControllerFactory.getInstance().removeAuthorizationTicket(ticket);
              Element root = new Element("success");
              Document doc = new Document(root);
              root.setText(resources.getMessage((Locale) request.getSession().getAttribute(Globals.LOCALE_KEY),
                  "registerSync.message.ok"));
              sendDocument(doc, response);
             
              // Were complete
              return null;
          }
          else {
            log.error("Registration of agent did not occur when the specified timeout of " + timeout + "ms");
        LogonControllerFactory.getInstance().removeAuthorizationTicket(ticket);
          }
        }
       
        if (log.isDebugEnabled())
                log.debug("Failed agent registration");
       
        sendError(resources.getMessage((Locale) request.getSession().getAttribute(Globals.LOCALE_KEY),
                "registerSync.message.failed"), response);

        return null;
    }
View Full Code Here

     * @throws Exception on any error
     */
    public ActionForward attributeInformation(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                                    HttpServletResponse response) throws Exception {
      AttributeDefinition def = (AttributeDefinition) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE);
        MessageResources mr = null;
        if(def.getMessageResourcesKey() != null) {
            mr = CoreUtil.getMessageResources(request.getSession(), def.getMessageResourcesKey());
        }
        Locale locale = (Locale)request.getSession().getAttribute(Globals.LOCALE_KEY);
        ((AttributeDefinitionInformationForm) form).initialise(mr, def, locale);
View Full Code Here

TOP

Related Classes of org.apache.struts.util.MessageResources

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.