Example usage for javax.servlet.jsp.jstl.fmt LocaleSupport getLocalizedMessage

List of usage examples for javax.servlet.jsp.jstl.fmt LocaleSupport getLocalizedMessage

Introduction

In this page you can find the example usage for javax.servlet.jsp.jstl.fmt LocaleSupport getLocalizedMessage.

Prototype

public static String getLocalizedMessage(PageContext pageContext, String key) 

Source Link

Document

Retrieves the localized message corresponding to the given key.

Usage

From source file:com.ecyrd.jspwiki.ui.TemplateManager.java

/**
 * List all installed i18n language properties
 * //  w w w  .  j a va 2 s. com
 * @param pageContext
 * @return map of installed Languages (with help of Juan Pablo Santos Rodriguez)
 * @since 2.7.x
 */
public Map listLanguages(PageContext pageContext) {
    LinkedHashMap<String, String> resultMap = new LinkedHashMap<String, String>();

    String clientLanguage = ((HttpServletRequest) pageContext.getRequest()).getLocale().toString();
    JarInputStream jarStream = null;

    try {
        JarEntry entry;
        InputStream inputStream = pageContext.getServletContext().getResourceAsStream(I18NRESOURCE_PATH);
        jarStream = new JarInputStream(inputStream);

        while ((entry = jarStream.getNextJarEntry()) != null) {
            String name = entry.getName();

            if (!entry.isDirectory() && name.startsWith(I18NRESOURCE_PREFIX)
                    && name.endsWith(I18NRESOURCE_SUFFIX)) {
                name = name.substring(I18NRESOURCE_PREFIX.length(), name.lastIndexOf(I18NRESOURCE_SUFFIX));

                Locale locale = new Locale(name.substring(0, 2),
                        ((name.indexOf("_") == -1) ? "" : name.substring(3, 5)));

                String defaultLanguage = "";

                if (clientLanguage.startsWith(name)) {
                    defaultLanguage = LocaleSupport.getLocalizedMessage(pageContext, I18NDEFAULT_LOCALE);
                }

                resultMap.put(name, locale.getDisplayName(locale) + " " + defaultLanguage);
            }
        }
    } catch (IOException ioe) {
        if (log.isDebugEnabled())
            log.debug("Could not search jar file '" + I18NRESOURCE_PATH
                    + "'for properties files due to an IOException: \n" + ioe.getMessage());
    } finally {
        if (jarStream != null) {
            try {
                jarStream.close();
            } catch (IOException e) {
            }
        }
    }

    return resultMap;
}

From source file:com.ecyrd.jspwiki.ui.TemplateManager.java

/**
 * List all timezones, with special marker for server timezone
 * /* w  w  w  .  j  a v  a2  s.c  om*/
 * @param pageContext
 * @return map of TimeZones
 * @since 2.7.x
 */
public Map listTimeZones(PageContext pageContext) {
    LinkedHashMap<String, String> resultMap = new LinkedHashMap<String, String>();

    String[][] tzs = { { "GMT-12", "Enitwetok, Kwajalien" }, { "GMT-11", "Nome, Midway Island, Samoa" },
            { "GMT-10", "Hawaii" }, { "GMT-9", "Alaska" }, { "GMT-8", "Pacific Time" },
            { "GMT-7", "Mountain Time" }, { "GMT-6", "Central Time, Mexico City" },
            { "GMT-5", "Eastern Time, Bogota, Lima, Quito" }, { "GMT-4", "Atlantic Time, Caracas, La Paz" },
            { "GMT-3:30", "Newfoundland" }, { "GMT-3", "Brazil, Buenos Aires, Georgetown, Falkland Is." },
            { "GMT-2", "Mid-Atlantic, Ascention Is., St Helena" }, { "GMT-1", "Azores, Cape Verde Islands" },
            { "GMT", "Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia" },
            { "GMT+1", "Berlin, Brussels, Copenhagen, Madrid, Paris, Rome" },
            { "GMT+2", "Helsinki, Athens, Kaliningrad, South Africa, Warsaw" },
            { "GMT+3", "Baghdad, Riyadh, Moscow, Nairobi" }, { "GMT+3:30", "Tehran" },
            { "GMT+4", "Adu Dhabi, Baku, Muscat, Tbilisi" }, { "GMT+4:30", "Kabul" },
            { "GMT+5", "Islamabad, Karachi, Tashkent" }, { "GMT+5:30", "Bombay, Calcutta, Madras, New Delhi" },
            { "GMT+6", "Almaty, Colomba, Dhakra" }, { "GMT+7", "Bangkok, Hanoi, Jakarta" },
            { "GMT+8", "Beijing, Hong Kong, Perth, Singapore, Taipei" },
            { "GMT+9", "Osaka, Sapporo, Seoul, Tokyo, Yakutsk" }, { "GMT+9:30", "Adelaide, Darwin" },
            { "GMT+10", "Melbourne, Papua New Guinea, Sydney, Vladivostok" },
            { "GMT+11", "Magadan, New Caledonia, Solomon Islands" },
            { "GMT+12", "Auckland, Wellington, Fiji, Marshall Island" } };

    java.util.TimeZone servertz = java.util.TimeZone.getDefault();

    for (int i = 0; i < tzs.length; i++) {
        String tzID = tzs[i][0];
        java.util.TimeZone tz = java.util.TimeZone.getTimeZone(tzID);

        String serverTimeZone = "";

        if (servertz.getRawOffset() == tz.getRawOffset()) {
            serverTimeZone = LocaleSupport.getLocalizedMessage(pageContext, I18NSERVER_TIMEZONE);
            tzID = servertz.getID();
        }

        resultMap.put(tzID, "(" + tzs[i][0] + ") " + tzs[i][1] + " " + serverTimeZone);
    }

    return resultMap;
}

From source file:org.dspace.app.webui.jsptag.AccessSettingTag.java

public int doStartTag() throws JspException {
    String legend = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.legend");
    String label_name = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.label_name");
    String label_group = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.label_group");
    String label_embargo = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.label_embargo");
    String label_date = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.label_date");
    String radio0 = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.radio0");
    String radio1 = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.radio1");
    String radio_help = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.radio_help");
    String label_reason = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.label_reason");
    String button_confirm = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.button_confirm");

    String help_name = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.name_help");
    String help_reason = LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.access-setting.reason_help");

    JspWriter out = pageContext.getOut();
    StringBuffer sb = new StringBuffer();

    try {/*w ww .  j ava 2 s.com*/
        HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();
        Context context = UIUtil.obtainContext(hrq);

        // get startDate and reason of the resource policy of the target DSpaceObject
        List<ResourcePolicy> policies = null;
        if (!advanced && dso != null) {
            policies = AuthorizeManager.findPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
        } else if (rp != null) {
            policies = new ArrayList<ResourcePolicy>();
            policies.add(rp);
        }

        String name = "";
        int group_id = 0;
        String startDate = "";
        String reason = "";
        String radio0Checked = " checked=\"checked\"";
        String radio1Checked = "";
        String disabled = " disabled=\"disabled\"";
        if (policies != null && policies.size() > 0) {
            ResourcePolicy rp = policies.get(0);
            name = (rp.getRpName() == null ? "" : rp.getRpName());
            group_id = rp.getGroup().getID();
            startDate = (rp.getStartDate() != null ? DateFormatUtils.format(rp.getStartDate(), "yyyy-MM-dd")
                    : "");
            reason = (rp.getRpDescription() == null ? "" : rp.getRpDescription());
            if (!startDate.equals("")) {
                radio0Checked = "";
                radio1Checked = " checked=\"checked\"";
                disabled = "";
            }
        }

        // if advanced embargo is disabled, embargo date and reason fields are always enabled
        if (!advanced) {
            disabled = "";
        }

        if (embargo) {
            // Name
            sb.append("<div class=\"form-group\">");
            sb.append(label_name).append("\n");
            sb.append("<p class=\"help-block\">").append(help_name).append("</p>").append("\n");
            sb.append(
                    "<input class=\"form-control\" name=\"name\" id=\"policy_name\" type=\"text\" maxlength=\"30\" value=\"")
                    .append(name).append("\" />\n");
            sb.append("</div>");

            // Group
            sb.append("<div class=\"form-group\">");
            sb.append(label_group).append("\n");
            sb.append("<select class=\"form-control\" name=\"group_id\" id=\"select_group\">\n");

            Group[] groups = getGroups(context, hrq, subInfo);
            if (groups != null) {
                for (Group group : groups) {
                    sb.append("<option value=\"").append(group.getID()).append("\"");
                    if (group_id == group.getID()) {
                        sb.append(" selected=\"selected\"");
                    }
                    sb.append(">").append(group.getName()).append("</option>\n");
                }
            } else {
                sb.append("<option value=\"0\" selected=\"selected\">Anonymous</option>\n");
            }
            sb.append("</select>\n");
            sb.append("</div>");
            // Select open or embargo
            sb.append(label_embargo).append("\n");
            sb.append("<div class=\"radio\">");
            sb.append("<label><input name=\"open_access_radios\" type=\"radio\" value=\"0\"")
                    .append(radio0Checked).append(" />").append(radio0).append("</label>\n");
            sb.append("</div>");
            sb.append("<div class=\"radio\">");
            sb.append("<label><input name=\"open_access_radios\" type=\"radio\" value=\"1\"")
                    .append(radio1Checked).append(" />").append(radio1).append("</label>\n");
            sb.append("</div>");

        }

        // Embargo Date
        if (hidden) {
            sb.append(
                    "<input name=\"embargo_until_date\" id=\"embargo_until_date_hidden\" type=\"hidden\" value=\"")
                    .append(startDate).append("\" />\n");
            ;
            sb.append("<input name=\"reason\" id=\"reason_hidden\" type=\"hidden\" value=\"").append(reason)
                    .append("\" />\n");
        } else {
            sb.append("<div class=\"form-group col-md-12\">");
            sb.append("<div class=\"col-md-2\">");
            sb.append(label_date);
            sb.append("</div>");
            sb.append("<div class=\"col-md-2\">");
            sb.append(
                    "<input class=\"form-control\" name=\"embargo_until_date\" id=\"embargo_until_date\" maxlength=\"10\" size=\"10\" type=\"text\" value=\"")
                    .append(startDate).append("\"").append(disabled).append(" />\n");
            sb.append("</div>");
            sb.append("<div class=\"col-md-8\">");
            sb.append("<span class=\"help-block\">" + radio_help + "</span>");
            sb.append("</div>");
            sb.append("</div>");
            // Reason                
            sb.append("<div class=\"form-group col-md-12\">");
            sb.append("<div class=\"col-md-12\">");
            sb.append(label_reason).append("\n");
            sb.append("</div>");
            sb.append("<div class=\"col-md-12\">");
            sb.append("<p class=\"help-block\">").append(help_reason).append("</p>").append("\n");
            sb.append("</div>");
            sb.append("<div class=\"col-md-12\">");
            sb.append("<textarea class=\"form-control\" name=\"reason\" id=\"reason\" cols=\"30\" rows=\"5\"")
                    .append(disabled).append(">").append(reason).append("</textarea>\n");
            sb.append("</div>");
            sb.append("</div>");
        }

        // Add policy button
        if (addpolicy) {

            sb.append(
                    "<input class=\"btn btn-success col-md-offset-5\" name=\"submit_add_policy\" type=\"submit\" value=\"")
                    .append(button_confirm).append("\" />\n");

        }

        out.println(sb.toString());
    } catch (IOException ie) {
        throw new JspException(ie);
    } catch (SQLException e) {
        throw new JspException(e);
    }

    return SKIP_BODY;
}

From source file:org.dspace.app.webui.jsptag.BrowseListTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();

    /* just leave this out now
    boolean emphasiseDate = false;/*from  www . j a  v a2s .c o  m*/
    boolean emphasiseTitle = false;
            
    if (emphColumn != null)
    {
    emphasiseDate = emphColumn.equalsIgnoreCase("date");
    emphasiseTitle = emphColumn.equalsIgnoreCase("title");
    }
    */

    // get the elements to display
    String browseListLine = null;
    String browseWidthLine = null;

    // As different indexes / sort options may require different columns to be displayed
    // try to obtain a custom configuration based for the browse that has been performed
    if (browseInfo != null) {
        SortOption so = browseInfo.getSortOption();
        BrowseIndex bix = browseInfo.getBrowseIndex();

        // We have obtained the index that was used for this browse
        if (bix != null) {
            // First, try to get a configuration for this browse and sort option combined
            if (so != null && browseListLine == null) {
                browseListLine = ConfigurationManager.getProperty(
                        "webui.itemlist.browse." + bix.getName() + ".sort." + so.getName() + ".columns");
                browseWidthLine = ConfigurationManager.getProperty(
                        "webui.itemlist.browse." + bix.getName() + ".sort." + so.getName() + ".widths");
            }

            // We haven't got a sort option defined, so get one for the index
            // - it may be required later
            if (so == null) {
                so = bix.getSortOption();
            }
        }

        // If no config found, attempt to get one for this sort option
        if (so != null && browseListLine == null) {
            browseListLine = ConfigurationManager
                    .getProperty("webui.itemlist.sort." + so.getName() + ".columns");
            browseWidthLine = ConfigurationManager
                    .getProperty("webui.itemlist.sort." + so.getName() + ".widths");
        }

        // If no config found, attempt to get one for this browse index
        if (bix != null && browseListLine == null) {
            browseListLine = ConfigurationManager
                    .getProperty("webui.itemlist.browse." + bix.getName() + ".columns");
            browseWidthLine = ConfigurationManager
                    .getProperty("webui.itemlist.browse." + bix.getName() + ".widths");
        }

        // If no config found, attempt to get a general one, using the sort name
        if (so != null && browseListLine == null) {
            browseListLine = ConfigurationManager.getProperty("webui.itemlist." + so.getName() + ".columns");
            browseWidthLine = ConfigurationManager.getProperty("webui.itemlist." + so.getName() + ".widths");
        }

        // If no config found, attempt to get a general one, using the index name
        if (bix != null && browseListLine == null) {
            browseListLine = ConfigurationManager.getProperty("webui.itemlist." + bix.getName() + ".columns");
            browseWidthLine = ConfigurationManager.getProperty("webui.itemlist." + bix.getName() + ".widths");
        }
    }

    if (browseListLine == null) {
        browseListLine = ConfigurationManager.getProperty("webui.itemlist.columns");
        browseWidthLine = ConfigurationManager.getProperty("webui.itemlist.widths");
    }

    // Have we read a field configration from dspace.cfg?
    if (browseListLine != null) {
        // If thumbnails are disabled, strip out any thumbnail column from the configuration
        if (!showThumbs && browseListLine.contains("thumbnail")) {
            // Ensure we haven't got any nulls
            browseListLine = browseListLine == null ? "" : browseListLine;
            browseWidthLine = browseWidthLine == null ? "" : browseWidthLine;

            // Tokenize the field and width lines
            StringTokenizer bllt = new StringTokenizer(browseListLine, ",");
            StringTokenizer bwlt = new StringTokenizer(browseWidthLine, ",");

            StringBuilder newBLLine = new StringBuilder();
            StringBuilder newBWLine = new StringBuilder();
            while (bllt.hasMoreTokens() || bwlt.hasMoreTokens()) {
                String browseListTok = bllt.hasMoreTokens() ? bllt.nextToken() : null;
                String browseWidthTok = bwlt.hasMoreTokens() ? bwlt.nextToken() : null;

                // Only use the Field and Width tokens, if the field isn't 'thumbnail'
                if (browseListTok == null || !browseListTok.trim().equals("thumbnail")) {
                    if (browseListTok != null) {
                        if (newBLLine.length() > 0) {
                            newBLLine.append(",");
                        }

                        newBLLine.append(browseListTok);
                    }

                    if (browseWidthTok != null) {
                        if (newBWLine.length() > 0) {
                            newBWLine.append(",");
                        }

                        newBWLine.append(browseWidthTok);
                    }
                }
            }

            // Use the newly built configuration file
            browseListLine = newBLLine.toString();
            browseWidthLine = newBWLine.toString();
        }
    } else {
        browseListLine = DEFAULT_LIST_FIELDS;
        browseWidthLine = DEFAULT_LIST_WIDTHS;
    }

    // Arrays used to hold the information we will require when outputting each row
    String[] fieldArr = browseListLine == null ? new String[0] : browseListLine.split("\\s*,\\s*");
    String[] widthArr = browseWidthLine == null ? new String[0] : browseWidthLine.split("\\s*,\\s*");
    boolean isDate[] = new boolean[fieldArr.length];
    boolean emph[] = new boolean[fieldArr.length];
    boolean isAuthor[] = new boolean[fieldArr.length];
    boolean viewFull[] = new boolean[fieldArr.length];
    String[] browseType = new String[fieldArr.length];
    String[] cOddOrEven = new String[fieldArr.length];

    try {
        // Get the interlinking configuration too
        CrossLinks cl = new CrossLinks();

        // Get a width for the table
        String tablewidth = ConfigurationManager.getProperty("webui.itemlist.tablewidth");

        // If we have column widths, try to use a fixed layout table - faster for browsers to render
        // but not if we have to add an 'edit item' button - we can't know how big it will be
        if (widthArr.length > 0 && widthArr.length == fieldArr.length && !linkToEdit) {
            // If the table width has been specified, we can make this a fixed layout
            if (!StringUtils.isEmpty(tablewidth)) {
                out.println("<table style=\"width: " + tablewidth
                        + "; table-layout: fixed;\" align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
            } else {
                // Otherwise, don't constrain the width
                out.println(
                        "<table align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
            }

            // Output the known column widths
            out.print("<colgroup>");

            for (int w = 0; w < widthArr.length; w++) {
                out.print("<col width=\"");

                // For a thumbnail column of width '*', use the configured max width for thumbnails
                if (fieldArr[w].equals("thumbnail") && widthArr[w].equals("*")) {
                    out.print(thumbItemListMaxWidth);
                } else {
                    out.print(StringUtils.isEmpty(widthArr[w]) ? "*" : widthArr[w]);
                }

                out.print("\" />");
            }

            out.println("</colgroup>");
        } else if (!StringUtils.isEmpty(tablewidth)) {
            out.println("<table width=\"" + tablewidth
                    + "\" align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
        } else {
            out.println(
                    "<table align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
        }

        // Output the table headers
        out.println("<tr>");

        for (int colIdx = 0; colIdx < fieldArr.length; colIdx++) {
            String field = fieldArr[colIdx].toLowerCase().trim();
            cOddOrEven[colIdx] = (((colIdx + 1) % 2) == 0 ? "Odd" : "Even");

            // find out if the field is a date
            if (field.indexOf("(date)") > 0) {
                field = field.replaceAll("\\(date\\)", "");
                isDate[colIdx] = true;
            }

            // Cache any modifications to field
            fieldArr[colIdx] = field;

            // find out if this is the author column
            if (field.equals(authorField)) {
                isAuthor[colIdx] = true;
            }

            // find out if this field needs to link out to other browse views
            if (cl.hasLink(field)) {
                browseType[colIdx] = cl.getLinkType(field);
                viewFull[colIdx] = BrowseIndex.getBrowseIndex(browseType[colIdx]).isItemIndex();
            }

            // find out if we are emphasising this field
            /*
            if ((field.equals(dateField) && emphasiseDate) ||
                (field.equals(titleField) && emphasiseTitle))
            {
            emph[colIdx] = true;
            }
            */
            if (field.equals(emphColumn)) {
                emph[colIdx] = true;
            }

            // prepare the strings for the header
            String id = "t" + Integer.toString(colIdx + 1);
            String css = "oddRow" + cOddOrEven[colIdx] + "Col";
            String message = "itemlist." + field;

            // output the header
            out.print("<th id=\"" + id + "\" class=\"" + css + "\">" + (emph[colIdx] ? "<strong>" : "")
                    + LocaleSupport.getLocalizedMessage(pageContext, message)
                    + (emph[colIdx] ? "</strong>" : "") + "</th>");
        }

        if (linkToEdit) {
            String id = "t" + Integer.toString(cOddOrEven.length + 1);
            String css = "oddRow" + cOddOrEven[cOddOrEven.length - 2] + "Col";

            // output the header
            out.print("<th id=\"" + id + "\" class=\"" + css + "\">" + (emph[emph.length - 2] ? "<strong>" : "")
                    + "&nbsp;" //LocaleSupport.getLocalizedMessage(pageContext, message)
                    + (emph[emph.length - 2] ? "</strong>" : "") + "</th>");
        }

        out.print("</tr>");

        // now output each item row
        for (int i = 0; i < items.length; i++) {
            out.print("<tr>");
            // now prepare the XHTML frag for this division
            String rOddOrEven;
            if (i == highlightRow) {
                rOddOrEven = "highlight";
            } else {
                rOddOrEven = ((i & 1) == 1 ? "odd" : "even");
            }

            for (int colIdx = 0; colIdx < fieldArr.length; colIdx++) {
                String field = fieldArr[colIdx];

                // get the schema and the element qualifier pair
                // (Note, the schema is not used for anything yet)
                // (second note, I hate this bit of code.  There must be
                // a much more elegant way of doing this.  Tomcat has
                // some weird problems with variations on this code that
                // I tried, which is why it has ended up the way it is)
                StringTokenizer eq = new StringTokenizer(field, ".");

                String[] tokens = { "", "", "" };
                int k = 0;
                while (eq.hasMoreTokens()) {
                    tokens[k] = eq.nextToken().toLowerCase().trim();
                    k++;
                }
                String schema = tokens[0];
                String element = tokens[1];
                String qualifier = tokens[2];

                // first get hold of the relevant metadata for this column
                DCValue[] metadataArray;
                if (qualifier.equals("*")) {
                    metadataArray = items[i].getMetadata(schema, element, Item.ANY, Item.ANY);
                } else if (qualifier.equals("")) {
                    metadataArray = items[i].getMetadata(schema, element, null, Item.ANY);
                } else {
                    metadataArray = items[i].getMetadata(schema, element, qualifier, Item.ANY);
                }

                // save on a null check which would make the code untidy
                if (metadataArray == null) {
                    metadataArray = new DCValue[0];
                }

                // now prepare the content of the table division
                String metadata = "-";
                if (field.equals("thumbnail")) {
                    metadata = getThumbMarkup(hrq, items[i]);
                } else if (metadataArray.length > 0) {
                    // format the date field correctly
                    if (isDate[colIdx]) {
                        DCDate dd = new DCDate(metadataArray[0].value);
                        metadata = UIUtil.displayDate(dd, false, false, hrq);
                    }
                    // format the title field correctly for withdrawn items (ie. don't link)
                    else if (field.equals(titleField) && items[i].isWithdrawn()) {
                        metadata = Utils.addEntities(metadataArray[0].value);
                    }
                    // format the title field correctly (as long as the item isn't withdrawn, link to it)
                    else if (field.equals(titleField)) {
                        metadata = "<a href=\"" + hrq.getContextPath() + "/handle/" + items[i].getHandle()
                                + "\">" + Utils.addEntities(metadataArray[0].value) + "</a>";
                    }
                    // format all other fields
                    else {
                        // limit the number of records if this is the author field (if
                        // -1, then the limit is the full list)
                        boolean truncated = false;
                        int loopLimit = metadataArray.length;
                        if (isAuthor[colIdx]) {
                            int fieldMax = (authorLimit == -1 ? metadataArray.length : authorLimit);
                            loopLimit = (fieldMax > metadataArray.length ? metadataArray.length : fieldMax);
                            truncated = (fieldMax < metadataArray.length);
                            log.debug("Limiting output of field " + field + " to " + Integer.toString(loopLimit)
                                    + " from an original " + Integer.toString(metadataArray.length));
                        }

                        StringBuffer sb = new StringBuffer();
                        for (int j = 0; j < loopLimit; j++) {
                            String startLink = "";
                            String endLink = "";
                            if (!StringUtils.isEmpty(browseType[colIdx]) && !disableCrossLinks) {
                                String argument;
                                String value;
                                if (metadataArray[j].authority != null
                                        && metadataArray[j].confidence >= MetadataAuthorityManager.getManager()
                                                .getMinConfidence(metadataArray[j].schema,
                                                        metadataArray[j].element, metadataArray[j].qualifier)) {
                                    argument = "authority";
                                    value = metadataArray[j].authority;
                                } else {
                                    argument = "value";
                                    value = metadataArray[j].value;
                                }
                                if (viewFull[colIdx]) {
                                    argument = "vfocus";
                                }
                                startLink = "<a href=\"" + hrq.getContextPath() + "/browse?type="
                                        + browseType[colIdx] + "&amp;" + argument + "="
                                        + URLEncoder.encode(value, "UTF-8");

                                if (metadataArray[j].language != null) {
                                    startLink = startLink + "&amp;" + argument + "_lang="
                                            + URLEncoder.encode(metadataArray[j].language, "UTF-8");
                                }

                                if ("authority".equals(argument)) {
                                    startLink += "\" class=\"authority " + browseType[colIdx] + "\">";
                                } else {
                                    startLink = startLink + "\">";
                                }
                                endLink = "</a>";
                            }
                            sb.append(startLink);
                            sb.append(Utils.addEntities(metadataArray[j].value));
                            sb.append(endLink);
                            if (j < (loopLimit - 1)) {
                                sb.append("; ");
                            }
                        }
                        if (truncated) {
                            String etal = LocaleSupport.getLocalizedMessage(pageContext, "itemlist.et-al");
                            sb.append(", ").append(etal);
                        }
                        metadata = "<em>" + sb.toString() + "</em>";
                    }
                }

                // prepare extra special layout requirements for dates
                String extras = "";
                if (isDate[colIdx]) {
                    extras = "nowrap=\"nowrap\" align=\"right\"";
                }

                String id = "t" + Integer.toString(colIdx + 1);
                out.print("<td headers=\"" + id + "\" class=\"" + rOddOrEven + "Row" + cOddOrEven[colIdx]
                        + "Col\" " + extras + ">" + (emph[colIdx] ? "<strong>" : "") + metadata
                        + (emph[colIdx] ? "</strong>" : "") + "</td>");
            }

            // Add column for 'edit item' links
            if (linkToEdit) {
                String id = "t" + Integer.toString(cOddOrEven.length + 1);

                out.print("<td headers=\"" + id + "\" class=\"" + rOddOrEven + "Row"
                        + cOddOrEven[cOddOrEven.length - 2] + "Col\" nowrap>" + "<form method=\"get\" action=\""
                        + hrq.getContextPath() + "/tools/edit-item\">"
                        + "<input type=\"hidden\" name=\"handle\" value=\"" + items[i].getHandle() + "\" />"
                        + "<input type=\"submit\" value=\"Edit Item\" /></form>" + "</td>");
            }

            out.println("</tr>");
        }

        // close the table
        out.println("</table>");
    } catch (IOException ie) {
        throw new JspException(ie);
    } catch (SQLException e) {
        throw new JspException(e);
    } catch (BrowseException e) {
        throw new JspException(e);
    }

    return SKIP_BODY;
}

From source file:org.dspace.app.webui.jsptag.CollectionListTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {/*  w  w w.  j a v  a  2s. c om*/
        out.println("<table align=\"center\" class=\"miscTable\" title=\"Collection List\">");

        // Write column headings
        out.print("<tr><th id=\"t4\" class=\"oddRowOddCol\">" + LocaleSupport.getLocalizedMessage(pageContext,
                "org.dspace.app.webui.jsptag.CollectionListTag.collectionName") + "</th></tr>");

        // Row: toggles between Odd and Even
        String row = "even";

        for (int i = 0; i < collections.length; i++) {
            // name
            String name = collections[i].getMetadata("name");

            // first and only column is 'name'
            out.print("<tr><td headers=\"t4\" class=\"" + row + "RowEvenCol\">");
            out.print("<a href=\"");

            HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();
            out.print(hrq.getContextPath() + "/handle/");
            out.print(collections[i].getHandle());
            out.print("\">");
            out.print(name);
            out.print("</a>");

            out.println("</td></tr>");

            row = (row.equals("odd") ? "even" : "odd");
        }

        out.println("</table>");
    } catch (IOException ie) {
        throw new JspException(ie);
    }

    return SKIP_BODY;
}

From source file:org.dspace.app.webui.jsptag.CommunityListTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {/*from w  w w. j a va 2s. co m*/
        out.println("<table align=\"center\" class=\"miscTable\" title=\"Community List\">");

        // Write column headings
        out.print("<tr><th id=\"t5\" class=\"oddRowOddCol\">" + LocaleSupport.getLocalizedMessage(pageContext,
                "org.dspace.app.webui.jsptag.CommunityListTag.communityName") + "</th></tr>");

        // Row: toggles between Odd and Even
        String row = "even";

        for (int i = 0; i < communities.length; i++) {
            // name
            String name = communities[i].getMetadata("name");

            // first and only column is 'name'
            out.print("<tr><td headers=\"t5\" class=\"" + row + "RowEvenCol\">");
            out.print("<a href=\"");

            HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();
            out.print(hrq.getContextPath() + "/handle/");
            out.print(communities[i].getHandle());
            out.print("\">");
            out.print(name);
            out.print("</a>");

            out.println("</td></tr>");

            row = (row.equals("odd") ? "even" : "odd");
        }

        out.println("</table>");
    } catch (IOException ie) {
        throw new JspException(ie);
    }

    return SKIP_BODY;
}

From source file:org.dspace.app.webui.jsptag.ItemListTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();

    boolean emphasiseDate = false;
    boolean emphasiseTitle = false;

    if (emphColumn != null) {
        emphasiseDate = emphColumn.equalsIgnoreCase("date");
        emphasiseTitle = emphColumn.equalsIgnoreCase("title");
    }/*  ww  w .  java 2s  .com*/

    // get the elements to display
    String configLine = null;
    String widthLine = null;

    if (sortOption != null) {
        if (configLine == null) {
            configLine = ConfigurationManager
                    .getProperty("webui.itemlist.sort." + sortOption.getName() + ".columns");
            widthLine = ConfigurationManager
                    .getProperty("webui.itemlist.sort." + sortOption.getName() + ".widths");
        }

        if (configLine == null) {
            configLine = ConfigurationManager
                    .getProperty("webui.itemlist." + sortOption.getName() + ".columns");
            widthLine = ConfigurationManager.getProperty("webui.itemlist." + sortOption.getName() + ".widths");
        }
    }

    if (configLine == null) {
        configLine = ConfigurationManager.getProperty("webui.itemlist.columns");
        widthLine = ConfigurationManager.getProperty("webui.itemlist.widths");
    }

    // Have we read a field configration from dspace.cfg?
    if (configLine != null) {
        // If thumbnails are disabled, strip out any thumbnail column from the configuration
        if (!showThumbs && configLine.contains("thumbnail")) {
            // Ensure we haven't got any nulls
            configLine = configLine == null ? "" : configLine;
            widthLine = widthLine == null ? "" : widthLine;

            // Tokenize the field and width lines
            StringTokenizer llt = new StringTokenizer(configLine, ",");
            StringTokenizer wlt = new StringTokenizer(widthLine, ",");

            StringBuilder newLLine = new StringBuilder();
            StringBuilder newWLine = new StringBuilder();
            while (llt.hasMoreTokens() || wlt.hasMoreTokens()) {
                String listTok = llt.hasMoreTokens() ? llt.nextToken() : null;
                String widthTok = wlt.hasMoreTokens() ? wlt.nextToken() : null;

                // Only use the Field and Width tokens, if the field isn't 'thumbnail'
                if (listTok == null || !listTok.trim().equals("thumbnail")) {
                    if (listTok != null) {
                        if (newLLine.length() > 0) {
                            newLLine.append(",");
                        }

                        newLLine.append(listTok);
                    }

                    if (widthTok != null) {
                        if (newWLine.length() > 0) {
                            newWLine.append(",");
                        }

                        newWLine.append(widthTok);
                    }
                }
            }

            // Use the newly built configuration file
            configLine = newLLine.toString();
            widthLine = newWLine.toString();
        }
    } else {
        configLine = DEFAULT_LIST_FIELDS;
        widthLine = DEFAULT_LIST_WIDTHS;
    }

    // Arrays used to hold the information we will require when outputting each row
    String[] fieldArr = configLine == null ? new String[0] : configLine.split("\\s*,\\s*");
    String[] widthArr = widthLine == null ? new String[0] : widthLine.split("\\s*,\\s*");
    boolean isDate[] = new boolean[fieldArr.length];
    boolean emph[] = new boolean[fieldArr.length];
    boolean isAuthor[] = new boolean[fieldArr.length];
    boolean viewFull[] = new boolean[fieldArr.length];
    String[] browseType = new String[fieldArr.length];
    String[] cOddOrEven = new String[fieldArr.length];

    try {
        // Get the interlinking configuration too
        CrossLinks cl = new CrossLinks();

        // Get a width for the table
        String tablewidth = ConfigurationManager.getProperty("webui.itemlist.tablewidth");

        // If we have column widths, output a fixed layout table - faster for browsers to render
        // but not if we have to add an 'edit item' button - we can't know how big it will be
        if (widthArr.length > 0 && widthArr.length == fieldArr.length && !linkToEdit) {
            // If the table width has been specified, we can make this a fixed layout
            if (!StringUtils.isEmpty(tablewidth)) {
                out.println("<table style=\"width: " + tablewidth
                        + "; table-layout: fixed;\" align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
            } else {
                // Otherwise, don't constrain the width
                out.println(
                        "<table align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
            }

            // Output the known column widths
            out.print("<colgroup>");

            for (int w = 0; w < widthArr.length; w++) {
                out.print("<col width=\"");

                // For a thumbnail column of width '*', use the configured max width for thumbnails
                if (fieldArr[w].equals("thumbnail") && widthArr[w].equals("*")) {
                    out.print(thumbItemListMaxWidth);
                } else {
                    out.print(StringUtils.isEmpty(widthArr[w]) ? "*" : widthArr[w]);
                }

                out.print("\" />");
            }

            out.println("</colgroup>");
        } else if (!StringUtils.isEmpty(tablewidth)) {
            out.println("<table width=\"" + tablewidth
                    + "\" align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
        } else {
            out.println(
                    "<table align=\"center\" class=\"miscTable\" summary=\"This table browses all dspace content\">");
        }

        // Output the table headers
        out.println("<tr>");

        for (int colIdx = 0; colIdx < fieldArr.length; colIdx++) {
            String field = fieldArr[colIdx].toLowerCase().trim();
            cOddOrEven[colIdx] = (((colIdx + 1) % 2) == 0 ? "Odd" : "Even");

            // find out if the field is a date
            if (field.indexOf("(date)") > 0) {
                field = field.replaceAll("\\(date\\)", "");
                isDate[colIdx] = true;
            }

            // Cache any modifications to field
            fieldArr[colIdx] = field;

            // find out if this is the author column
            if (field.equals(authorField)) {
                isAuthor[colIdx] = true;
            }

            // find out if this field needs to link out to other browse views
            if (cl.hasLink(field)) {
                browseType[colIdx] = cl.getLinkType(field);
                viewFull[colIdx] = BrowseIndex.getBrowseIndex(browseType[colIdx]).isItemIndex();
            }

            // find out if we are emphasising this field
            if (field.equals(emphColumn)) {
                emph[colIdx] = true;
            } else if ((field.equals(dateField) && emphasiseDate)
                    || (field.equals(titleField) && emphasiseTitle)) {
                emph[colIdx] = true;
            }

            // prepare the strings for the header
            String id = "t" + Integer.toString(colIdx + 1);
            String css = "oddRow" + cOddOrEven[colIdx] + "Col";
            String message = "itemlist." + field;

            // output the header
            out.print("<th id=\"" + id + "\" class=\"" + css + "\">" + (emph[colIdx] ? "<strong>" : "")
                    + LocaleSupport.getLocalizedMessage(pageContext, message)
                    + (emph[colIdx] ? "</strong>" : "") + "</th>");
        }

        if (linkToEdit) {
            String id = "t" + Integer.toString(cOddOrEven.length + 1);
            String css = "oddRow" + cOddOrEven[cOddOrEven.length - 2] + "Col";

            // output the header
            out.print("<th id=\"" + id + "\" class=\"" + css + "\">" + (emph[emph.length - 2] ? "<strong>" : "")
                    + "&nbsp;" //LocaleSupport.getLocalizedMessage(pageContext, message)
                    + (emph[emph.length - 2] ? "</strong>" : "") + "</th>");
        }

        out.print("</tr>");

        // now output each item row
        for (int i = 0; i < items.length; i++) {
            // now prepare the XHTML frag for this division
            out.print("<tr>");
            String rOddOrEven;
            if (i == highlightRow) {
                rOddOrEven = "highlight";
            } else {
                rOddOrEven = ((i & 1) == 1 ? "odd" : "even");
            }

            for (int colIdx = 0; colIdx < fieldArr.length; colIdx++) {
                String field = fieldArr[colIdx];

                // get the schema and the element qualifier pair
                // (Note, the schema is not used for anything yet)
                // (second note, I hate this bit of code.  There must be
                // a much more elegant way of doing this.  Tomcat has
                // some weird problems with variations on this code that
                // I tried, which is why it has ended up the way it is)
                StringTokenizer eq = new StringTokenizer(field, ".");

                String[] tokens = { "", "", "" };
                int k = 0;
                while (eq.hasMoreTokens()) {
                    tokens[k] = eq.nextToken().toLowerCase().trim();
                    k++;
                }
                String schema = tokens[0];
                String element = tokens[1];
                String qualifier = tokens[2];

                // first get hold of the relevant metadata for this column
                DCValue[] metadataArray;
                if (qualifier.equals("*")) {
                    metadataArray = items[i].getMetadata(schema, element, Item.ANY, Item.ANY);
                } else if (qualifier.equals("")) {
                    metadataArray = items[i].getMetadata(schema, element, null, Item.ANY);
                } else {
                    metadataArray = items[i].getMetadata(schema, element, qualifier, Item.ANY);
                }

                // save on a null check which would make the code untidy
                if (metadataArray == null) {
                    metadataArray = new DCValue[0];
                }

                // now prepare the content of the table division
                String metadata = "-";
                if (field.equals("thumbnail")) {
                    metadata = getThumbMarkup(hrq, items[i]);
                }
                if (metadataArray.length > 0) {
                    // format the date field correctly
                    if (isDate[colIdx]) {
                        DCDate dd = new DCDate(metadataArray[0].value);
                        metadata = UIUtil.displayDate(dd, false, false, hrq);
                    }
                    // format the title field correctly for withdrawn items (ie. don't link)
                    else if (field.equals(titleField) && items[i].isWithdrawn()) {
                        metadata = Utils.addEntities(metadataArray[0].value);
                    }
                    // format the title field correctly
                    else if (field.equals(titleField)) {
                        metadata = "<a href=\"" + hrq.getContextPath() + "/handle/" + items[i].getHandle()
                                + "\">" + Utils.addEntities(metadataArray[0].value) + "</a>";
                    }
                    // format all other fields
                    else {
                        // limit the number of records if this is the author field (if
                        // -1, then the limit is the full list)
                        boolean truncated = false;
                        int loopLimit = metadataArray.length;
                        if (isAuthor[colIdx]) {
                            int fieldMax = (authorLimit > 0 ? authorLimit : metadataArray.length);
                            loopLimit = (fieldMax > metadataArray.length ? metadataArray.length : fieldMax);
                            truncated = (fieldMax < metadataArray.length);
                            log.debug("Limiting output of field " + field + " to " + Integer.toString(loopLimit)
                                    + " from an original " + Integer.toString(metadataArray.length));
                        }

                        StringBuffer sb = new StringBuffer();
                        for (int j = 0; j < loopLimit; j++) {
                            String startLink = "";
                            String endLink = "";
                            if (!StringUtils.isEmpty(browseType[colIdx]) && !disableCrossLinks) {
                                String argument;
                                String value;
                                if (metadataArray[j].authority != null
                                        && metadataArray[j].confidence >= MetadataAuthorityManager.getManager()
                                                .getMinConfidence(metadataArray[j].schema,
                                                        metadataArray[j].element, metadataArray[j].qualifier)) {
                                    argument = "authority";
                                    value = metadataArray[j].authority;
                                } else {
                                    argument = "value";
                                    value = metadataArray[j].value;
                                }
                                if (viewFull[colIdx]) {
                                    argument = "vfocus";
                                }
                                startLink = "<a href=\"" + hrq.getContextPath() + "/browse?type="
                                        + browseType[colIdx] + "&amp;" + argument + "="
                                        + URLEncoder.encode(value, "UTF-8");

                                if (metadataArray[j].language != null) {
                                    startLink = startLink + "&amp;" + argument + "_lang="
                                            + URLEncoder.encode(metadataArray[j].language, "UTF-8");
                                }

                                if ("authority".equals(argument)) {
                                    startLink += "\" class=\"authority " + browseType[colIdx] + "\">";
                                } else {
                                    startLink = startLink + "\">";
                                }
                                endLink = "</a>";
                            }
                            sb.append(startLink);
                            sb.append(Utils.addEntities(metadataArray[j].value));
                            sb.append(endLink);
                            if (j < (loopLimit - 1)) {
                                sb.append("; ");
                            }
                        }
                        if (truncated) {
                            String etal = LocaleSupport.getLocalizedMessage(pageContext, "itemlist.et-al");
                            sb.append(", ").append(etal);
                        }
                        metadata = "<em>" + sb.toString() + "</em>";
                    }
                }

                // prepare extra special layout requirements for dates
                String extras = "";
                if (isDate[colIdx]) {
                    extras = "nowrap=\"nowrap\" align=\"right\"";
                }

                String id = "t" + Integer.toString(colIdx + 1);
                out.print("<td headers=\"" + id + "\" class=\"" + rOddOrEven + "Row" + cOddOrEven[colIdx]
                        + "Col\" " + extras + ">" + (emph[colIdx] ? "<strong>" : "") + metadata
                        + (emph[colIdx] ? "</strong>" : "") + "</td>");
            }

            // Add column for 'edit item' links
            if (linkToEdit) {
                String id = "t" + Integer.toString(cOddOrEven.length + 1);

                out.print("<td headers=\"" + id + "\" class=\"" + rOddOrEven + "Row"
                        + cOddOrEven[cOddOrEven.length - 2] + "Col\" nowrap>" + "<form method=\"get\" action=\""
                        + hrq.getContextPath() + "/tools/edit-item\">"
                        + "<input type=\"hidden\" name=\"handle\" value=\"" + items[i].getHandle() + "\" />"
                        + "<input type=\"submit\" value=\"Edit Item\" /></form>" + "</td>");
            }

            out.println("</tr>");
        }

        // close the table
        out.println("</table>");
    } catch (IOException ie) {
        throw new JspException(ie);
    } catch (BrowseException e) {
        throw new JspException(e);
    }

    return SKIP_BODY;
}

From source file:org.dspace.app.webui.jsptag.ItemTag.java

/**
 * Render an item in the given style//from  w  ww .j  av a2s .  c  o  m
 */
private void render() throws IOException, SQLException, DCInputsReaderException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    Context context = UIUtil.obtainContext(request);
    Locale sessionLocale = UIUtil.getSessionLocale(request);
    String configLine = styleSelection.getConfigurationForStyle(style);

    if (configLine == null) {
        configLine = defaultFields;
    }

    out.println("<center><table class=\"itemDisplayTable\">");

    /*
     * Break down the configuration into fields and display them
     * 
     * FIXME?: it may be more efficient to do some processing once, perhaps
     * to a more efficient intermediate class, but then it would become more
     * difficult to reload the configuration "on the fly".
     */
    StringTokenizer st = new StringTokenizer(configLine, ",");

    while (st.hasMoreTokens()) {
        String field = st.nextToken().trim();
        boolean isDate = false;
        boolean isLink = false;
        boolean isResolver = false;
        boolean isNoBreakLine = false;
        boolean isDisplay = false;

        String style = null;
        Matcher fieldStyleMatcher = fieldStylePatter.matcher(field);
        if (fieldStyleMatcher.matches()) {
            style = fieldStyleMatcher.group(1);
        }

        String browseIndex;
        try {
            browseIndex = getBrowseField(field);
        } catch (BrowseException e) {
            log.error(e);
            browseIndex = null;
        }

        // Find out if the field should rendered with a particular style

        if (style != null) {
            isDate = style.contains("date");
            isLink = style.contains("link");
            isNoBreakLine = style.contains("nobreakline");
            isDisplay = style.equals("inputform");
            isResolver = style.contains("resolver") || urn2baseurl.keySet().contains(style);
            field = field.replaceAll("\\(" + style + "\\)", "");
        }

        // Get the separate schema + element + qualifier

        String[] eq = field.split("\\.");
        String schema = eq[0];
        String element = eq[1];
        String qualifier = null;
        if (eq.length > 2 && eq[2].equals("*")) {
            qualifier = Item.ANY;
        } else if (eq.length > 2) {
            qualifier = eq[2];
        }

        // check for hidden field, even if it's configured..
        if (MetadataExposure.isHidden(context, schema, element, qualifier)) {
            continue;
        }

        // FIXME: Still need to fix for metadata language?
        DCValue[] values = item.getMetadata(schema, element, qualifier, Item.ANY);

        if (values.length > 0) {
            out.print("<tr><td class=\"metadataFieldLabel\">");

            String label = null;
            try {
                label = I18nUtil.getMessage("metadata." + (style != null ? style + "." : "") + field, context);
            } catch (MissingResourceException e) {
                // if there is not a specific translation for the style we
                // use the default one
                label = LocaleSupport.getLocalizedMessage(pageContext, "metadata." + field);
            }

            out.print(label);
            out.print(":&nbsp;</td><td class=\"metadataFieldValue\">");

            //If the values are in controlled vocabulary and the display value should be shown
            if (isDisplay) {
                List<String> displayValues = new ArrayList<String>();

                displayValues = Util.getControlledVocabulariesDisplayValueLocalized(item, values, schema,
                        element, qualifier, sessionLocale);

                if (displayValues != null && !displayValues.isEmpty()) {
                    for (int d = 0; d < displayValues.size(); d++) {
                        out.print(displayValues.get(d));
                        if (d < displayValues.size() - 1)
                            out.print(" <br/>");

                    }
                }
                out.print("</td>");
                continue;
            }
            for (int j = 0; j < values.length; j++) {
                if (values[j] != null && values[j].value != null) {
                    if (j > 0) {
                        if (isNoBreakLine) {
                            String separator = ConfigurationManager
                                    .getProperty("webui.itemdisplay.nobreakline.separator");
                            if (separator == null) {
                                separator = ";&nbsp;";
                            }
                            out.print(separator);
                        } else {
                            out.print("<br />");
                        }
                    }

                    if (isLink) {
                        out.print("<a href=\"" + values[j].value + "\">" + Utils.addEntities(values[j].value)
                                + "</a>");
                    } else if (isDate) {
                        DCDate dd = new DCDate(values[j].value);

                        // Parse the date
                        out.print(UIUtil.displayDate(dd, false, false,
                                (HttpServletRequest) pageContext.getRequest()));
                    } else if (isResolver) {
                        String value = values[j].value;
                        if (value.startsWith("http://") || value.startsWith("https://")
                                || value.startsWith("ftp://") || value.startsWith("ftps://")) {
                            // Already a URL, print as if it was a regular link
                            out.print("<a href=\"" + value + "\">" + Utils.addEntities(value) + "</a>");
                        } else {
                            String foundUrn = null;
                            if (!style.equals("resolver")) {
                                foundUrn = style;
                            } else {
                                for (String checkUrn : urn2baseurl.keySet()) {
                                    if (value.startsWith(checkUrn)) {
                                        foundUrn = checkUrn;
                                    }
                                }
                            }

                            if (foundUrn != null) {

                                if (value.startsWith(foundUrn + ":")) {
                                    value = value.substring(foundUrn.length() + 1);
                                }

                                String url = urn2baseurl.get(foundUrn);
                                out.print("<a href=\"" + url + value + "\">"
                                        + Utils.addEntities(values[j].value) + "</a>");
                            } else {
                                out.print(value);
                            }
                        }

                    } else if (browseIndex != null) {
                        String argument, value;
                        if (values[j].authority != null && values[j].confidence >= MetadataAuthorityManager
                                .getManager()
                                .getMinConfidence(values[j].schema, values[j].element, values[j].qualifier)) {
                            argument = "authority";
                            value = values[j].authority;
                        } else {
                            argument = "value";
                            value = values[j].value;
                        }
                        out.print("<a class=\"" + ("authority".equals(argument) ? "authority " : "")
                                + browseIndex + "\"" + "href=\"" + request.getContextPath() + "/browse?type="
                                + browseIndex + "&amp;" + argument + "=" + URLEncoder.encode(value, "UTF-8")
                                + "\">" + Utils.addEntities(values[j].value) + "</a>");
                    } else {
                        out.print(Utils.addEntities(values[j].value));
                    }
                }
            }

            out.println("</td></tr>");
        }
    }

    listCollections();

    out.println("</table></center><br/>");

    listBitstreams();

    if (ConfigurationManager.getBooleanProperty("webui.licence_bundle.show"))

    {
        out.println("<br/><br/>");
        showLicence();
    }
}

From source file:org.dspace.app.webui.jsptag.ItemTag.java

/**
 * Render full item record//from w  w  w.j  a  v a2  s  .  co  m
 */
private void renderFull() throws IOException, SQLException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    Context context = UIUtil.obtainContext(request);

    // Get all the metadata
    DCValue[] values = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);

    out.println("<p align=\"center\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.full")
            + "</p>");

    // Three column table - DC field, value, language
    out.println("<center><table class=\"itemDisplayTable\">");
    out.println("<tr><th id=\"s1\" class=\"standard\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.dcfield")
            + "</th><th id=\"s2\" class=\"standard\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.value")
            + "</th><th id=\"s3\" class=\"standard\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.lang")
            + "</th></tr>");

    for (int i = 0; i < values.length; i++) {
        if (!MetadataExposure.isHidden(context, values[i].schema, values[i].element, values[i].qualifier)) {
            out.print("<tr><td headers=\"s1\" class=\"metadataFieldLabel\">");
            out.print(values[i].schema);
            out.print("." + values[i].element);

            if (values[i].qualifier != null) {
                out.print("." + values[i].qualifier);
            }

            out.print("</td><td headers=\"s2\" class=\"metadataFieldValue\">");
            out.print(Utils.addEntities(values[i].value));
            out.print("</td><td headers=\"s3\" class=\"metadataFieldValue\">");

            if (values[i].language == null) {
                out.print("-");
            } else {
                out.print(values[i].language);
            }

            out.println("</td></tr>");
        }
    }

    listCollections();

    out.println("</table></center><br/>");

    listBitstreams();

    if (ConfigurationManager.getBooleanProperty("webui.licence_bundle.show")) {
        out.println("<br/><br/>");
        showLicence();
    }
}

From source file:org.dspace.app.webui.jsptag.ItemTag.java

/**
 * List links to collections if information is available
 *///from w w  w  .j av a2  s .c om
private void listCollections() throws IOException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    if (collections != null) {
        out.print("<tr><td class=\"metadataFieldLabel\">");
        if (item.getHandle() == null) // assume workspace item
        {
            out.print(LocaleSupport.getLocalizedMessage(pageContext,
                    "org.dspace.app.webui.jsptag.ItemTag.submitted"));
        } else {
            out.print(LocaleSupport.getLocalizedMessage(pageContext,
                    "org.dspace.app.webui.jsptag.ItemTag.appears"));
        }
        out.print("</td><td class=\"metadataFieldValue\">");

        for (int i = 0; i < collections.length; i++) {
            out.print("<a href=\"");
            out.print(request.getContextPath());
            out.print("/handle/");
            out.print(collections[i].getHandle());
            out.print("\">");
            out.print(collections[i].getMetadata("name"));
            out.print("</a><br/>");
        }

        out.println("</td></tr>");
    }
}