Search in sources :

Example 61 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class AgentConfigInheritViewBean method populatePropertyNameTableModel.

private void populatePropertyNameTableModel(Collection propertyNames) {
    if (!submitCycle && (propertyNames != null)) {
        tblPropertyNamesModel.clearAll();
        SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
        String universalId = (String) getPageSessionAttribute(AgentProfileViewBean.UNIVERSAL_ID);
        String agentType = getAgentType();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        AgentsModel model = (AgentsModel) getModel();
        Set inheritedPropertyNames = model.getInheritedPropertyNames(curRealm, universalId);
        Map nameToSchemas = model.getAttributeSchemas(agentType, propertyNames);
        removeNonInheritable(nameToSchemas, propertyNames);
        try {
            ResourceBundle rb = AgentConfiguration.getServiceResourceBundle(model.getUserLocale());
            String groupName = model.getAgentGroup(curRealm, universalId);
            Map groupValues = model.getGroupAttributeValues(curRealm, groupName);
            ArrayList cache = new ArrayList();
            int counter = 0;
            for (Iterator i = propertyNames.iterator(); i.hasNext(); counter++) {
                if (counter > 0) {
                    tblPropertyNamesModel.appendRow();
                }
                String name = (String) i.next();
                AttributeSchema as = (AttributeSchema) nameToSchemas.get(name);
                if (as != null) {
                    String displayName = rb.getString(as.getI18NKey());
                    tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_NAME, displayName);
                    try {
                        String help = rb.getString(as.getI18NKey() + ".help");
                        tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_HELP, help);
                    } catch (MissingResourceException e) {
                        // need to clear the help value
                        tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_HELP, "");
                    }
                    Object oValue = groupValues.get(name);
                    String value = "";
                    if (oValue != null) {
                        value = oValue.toString();
                        if (value.length() >= 2) {
                            value = value.substring(1, value.length() - 1);
                        }
                    }
                    tblPropertyNamesModel.setValue(TBL_DATA_VALUE, value);
                    tblPropertyNamesModel.setSelectionVisible(counter, true);
                    tblPropertyNamesModel.setRowSelected(inheritedPropertyNames.contains(name));
                    cache.add(name);
                }
            }
            szCache.setValue(cache);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        } catch (SMSException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        } catch (SSOException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) MissingResourceException(java.util.MissingResourceException) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) SerializedField(com.sun.identity.console.components.view.html.SerializedField) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ResourceBundle(java.util.ResourceBundle) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 62 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class SmsSingletonProvider method createSchema.

@Override
protected JsonValue createSchema(Context context) {
    JsonValue result = super.createSchema(context);
    if (dynamicSchema != null) {
        Map<String, String> attributeSectionMap = getAttributeNameToSection(dynamicSchema);
        ResourceBundle console = ResourceBundle.getBundle("amConsole");
        String serviceType = dynamicSchema.getServiceType().getType();
        String sectionOrder = getConsoleString(console, "sections." + serviceName + "." + serviceType);
        List<String> sections = new ArrayList<String>();
        if (StringUtils.isNotEmpty(sectionOrder)) {
            sections.addAll(Arrays.asList(sectionOrder.split("\\s+")));
        }
        addAttributeSchema(result, "/properties/dynamic/", dynamicSchema, sections, attributeSectionMap, console, serviceType, context);
    }
    return result;
}
Also used : JsonValue(org.forgerock.json.JsonValue) ArrayList(java.util.ArrayList) ResourceBundle(java.util.ResourceBundle)

Example 63 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class UsageFormatter method formatSubcmds.

private void formatSubcmds(CommandManager mgr, StringBuffer buff) throws CLIException {
    ResourceBundle rb = mgr.getResourceBundle();
    buff.append(rb.getString("USAGE_SUBCOMMAND_TITLE"));
    buff.append("\n");
    List defObjects = mgr.getDefinitionObjects();
    Map mapCmds = new HashMap();
    Set orderCmds = new TreeSet();
    for (Iterator i = defObjects.iterator(); i.hasNext(); ) {
        IDefinition def = (IDefinition) i.next();
        for (Iterator j = def.getSubCommands().iterator(); j.hasNext(); ) {
            SubCommand cmd = (SubCommand) j.next();
            if ((cmd != null) && (!mgr.webEnabled() || cmd.webEnabled())) {
                String name = cmd.getName();
                orderCmds.add(name);
                mapCmds.put(name, cmd.getDescription());
            }
        }
    }
    StringBuilder buffCmd = new StringBuilder();
    boolean started = false;
    String webEnabledURL = mgr.getWebEnabledURL();
    for (Iterator i = orderCmds.iterator(); i.hasNext(); ) {
        String cmdName = (String) i.next();
        buffCmd.append(formAbstractCmdUsage(webEnabledURL, cmdName, (String) mapCmds.get(cmdName)));
    }
    buff.append(buffCmd.toString());
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) ResourceBundle(java.util.ResourceBundle) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 64 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class UsageFormatter method formatGlobalOptions.

private void formatGlobalOptions(CommandManager mgr, StringBuffer buff) throws CLIException {
    ResourceBundle rb = mgr.getResourceBundle();
    buff.append(rb.getString("USAGE_GLOBAL_OPTIONS_TITLE"));
    buff.append("\n");
    for (Iterator i = globalOptions.iterator(); i.hasNext(); ) {
        try {
            String option = (String) i.next();
            Field fldLong = CLIConstants.class.getField(CLIConstants.PREFIX_ARGUMENT + option);
            Field fldShort = CLIConstants.class.getField(CLIConstants.PREFIX_SHORT_ARGUMENT + option);
            Object[] params = { fldLong.get(null), fldShort.get(null), rb.getString(CLIConstants.PREFIX_ARGUMENT + option) };
            buff.append(MessageFormat.format(CLIConstants.USAGE_OPTIONAL_OPTION_FORMAT, params));
            buff.append("\n");
        } catch (Exception e) {
            throw new CLIException(e.getMessage(), ExitCodes.USAGE_FORMAT_ERROR);
        }
    }
    buff.append("\n");
}
Also used : Field(java.lang.reflect.Field) Iterator(java.util.Iterator) ResourceBundle(java.util.ResourceBundle)

Example 65 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class UsageFormatter method formatOptions.

private void formatOptions(CommandManager mgr, StringBuffer buff, SubCommand cmd) throws CLIException {
    ResourceBundle rb = mgr.getResourceBundle();
    buff.append(rb.getString("USAGE_OPTIONS_TITLE"));
    buff.append("\n");
    formatOption(cmd.getMandatoryOptions(), cmd, buff);
    formatOption(cmd.getOptionalOptions(), cmd, buff);
    buff.append("\n");
}
Also used : ResourceBundle(java.util.ResourceBundle)

Aggregations

ResourceBundle (java.util.ResourceBundle)1189 Locale (java.util.Locale)180 MissingResourceException (java.util.MissingResourceException)150 Test (org.junit.Test)100 ArrayList (java.util.ArrayList)71 HashMap (java.util.HashMap)70 IOException (java.io.IOException)67 PropertyResourceBundle (java.util.PropertyResourceBundle)56 URL (java.net.URL)48 File (java.io.File)47 Map (java.util.Map)45 InputStream (java.io.InputStream)43 Enumeration (java.util.Enumeration)34 HashSet (java.util.HashSet)30 Test (org.junit.jupiter.api.Test)30 ActionMessage (org.apache.struts.action.ActionMessage)29 MessageFormat (java.text.MessageFormat)28 ListResourceBundle (java.util.ListResourceBundle)28 Set (java.util.Set)26 Preferences (java.util.prefs.Preferences)21