/** Add a page title and trail links. */
  public void addPageMeta(PageMeta pageMeta)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (!(dso instanceof Collection)) return;

    Collection collection = (Collection) dso;

    // Set the page title
    pageMeta.addMetadata("title").addContent(collection.getMetadata("name"));

    pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
    HandleUtil.buildHandleTrail(collection, pageMeta, contextPath);

    // Add RSS links if available
    String formats = ConfigurationManager.getProperty("webui.feed.formats");
    if (formats != null) {
      for (String format : formats.split(",")) {
        // Remove the protocol number, i.e. just list 'rss' or' atom'
        String[] parts = format.split("_");
        if (parts.length < 1) continue;

        String feedFormat = parts[0].trim() + "+xml";

        String feedURL = contextPath + "/feed/" + collection.getHandle() + "/" + format.trim();
        pageMeta.addMetadata("feed", feedFormat).addContent(feedURL);
      }
    }
  }
  /**
   * Generate the cache validity object.
   *
   * <p>The validity object will include the collection being viewed and all recently submitted
   * items. This does not include the community / collection hierarch, when this changes they will
   * not be reflected in the cache.
   */
  public SourceValidity getValidity() {
    if (this.validity == null) {
      try {
        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

        if (dso == null) return null;

        if (!(dso instanceof Collection)) return null;

        Collection collection = (Collection) dso;

        DSpaceValidity validity = new DSpaceValidity();

        // Add the actual collection;
        validity.add(collection);

        // add reciently submitted items
        for (BrowseItem item : getRecientlySubmittedIems(collection)) {
          validity.add(item);
        }

        this.validity = validity.complete();
      } catch (Exception e) {
        // Just ignore all errors and return an invalid cache.
      }
    }
    return this.validity;
  }
  public SourceValidity getValidity() {
    if (validity == null) {
      try {
        DSpaceValidity validity = new DSpaceValidity();
        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

        if (dso != null) validity.add(dso);

        BrowseInfo info = getBrowseInfo();

        // Are we browsing items, or unique metadata?
        if (isItemBrowse(info)) {
          // Add the browse items to the validity
          for (BrowseItem item : (java.util.List<BrowseItem>) info.getResults()) {
            validity.add(item);
          }
        } else {
          // Add the metadata to the validity
          for (String singleEntry : browseInfo.getStringResults()) {
            validity.add(singleEntry);
          }
        }
      } catch (Exception e) {
        // Just ignore all errors and return an invalid cache.
      }
    }

    return this.validity;
  }
  /** Add Page metadata. */
  public void addPageMeta(PageMeta pageMeta)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    BrowseInfo info = getBrowseInfo();

    // Get the name of the index
    String type = info.getBrowseIndex().getName();

    pageMeta.addMetadata("title").addContent(getTitleMessage(info));

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

    pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
    if (dso != null) HandleUtil.buildHandleTrail(dso, pageMeta, contextPath);

    pageMeta.addTrail().addContent(getTrailMessage(info));
  }
Example #5
0
  /** Add a page title and trail links. */
  public void addPageMeta(PageMeta pageMeta)
      throws SAXException, WingException, SQLException, IOException, AuthorizeException {
    Request request = ObjectModelHelper.getRequest(objectModel);
    String facetField = request.getParameter(FACET_FIELD);

    pageMeta
        .addMetadata("title")
        .addContent(message("xmlui.ArtifactBrowser.AbstractSearch.type_" + facetField + "_browse"));

    pageMeta.addTrailLink(contextPath + "/", T_dspace_home);

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if ((dso instanceof Collection) || (dso instanceof Community)) {
      HandleUtil.buildHandleTrail(dso, pageMeta, contextPath);
    }

    pageMeta
        .addTrail()
        .addContent(message("xmlui.ArtifactBrowser.AbstractSearch.type_" + facetField + "_browse"));
  }
  /**
   * Generate the unique caching key. This key must be unique inside the space of this component.
   */
  public Serializable getKey() {
    try {
      DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

      if (dso == null) return "0";

      return HashUtil.hash(dso.getHandle());
    } catch (SQLException sqle) {
      // Ignore all errors and just return that the component is not
      // cachable.
      return "0";
    }
  }
Example #7
0
  /**
   * Determine the current scope. This may be derived from the current url handle if present or the
   * scope parameter is given. If no scope is specified then null is returned.
   *
   * @return The current scope.
   */
  protected DSpaceObject getScope() throws SQLException {
    Request request = ObjectModelHelper.getRequest(objectModel);
    String scopeString = request.getParameter("scope");

    // Are we in a community or collection?
    DSpaceObject dso;
    if (scopeString == null || "".equals(scopeString)) {
      // get the search scope from the url handle
      dso = HandleUtil.obtainHandle(objectModel);
    } else {
      // Get the search scope from the location parameter
      dso = HandleManager.resolveToObject(context, scopeString);
    }

    return dso;
  }
  public Serializable getKey() {
    try {
      BrowseParams params = getUserParams();

      String key = params.getKey();

      if (key != null) {
        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
        if (dso != null) key += "-" + dso.getHandle();

        return HashUtil.hash(key);
      }
    } catch (Exception e) {
      // Ignore all errors and just don't cache.
    }

    return "0";
  }
Example #9
0
  /**
   * Add the basic navigational options:
   *
   * <p>Search - advanced search
   *
   * <p>browse - browse by Titles - browse by Authors - browse by Dates
   *
   * <p>language FIXME: add languages
   *
   * <p>context no context options are added.
   *
   * <p>action no action options are added.
   */
  public void addOptions(Options options)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    /* Create skeleton menu structure to ensure consistent order between aspects,
     * even if they are never used
     */
    List browse = options.addList("browse");
    options.addList("account");
    options.addList("context");
    options.addList("administrative");

    browse.setHead(T_head_browse);

    List browseGlobal = browse.addList("global");
    List browseContext = browse.addList("context");

    browseGlobal.setHead(T_head_all_of_dspace);

    browseGlobal.addItemXref(contextPath + "/community-list", T_communities_and_collections);

    // Add the configured browse lists for 'top level' browsing
    addBrowseOptions(browseGlobal, contextPath + "/browse");

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (dso != null) {
      if (dso instanceof Item) {
        // If we are an item change the browse scope to the parent
        // collection.
        dso = ((Item) dso).getOwningCollection();
      }

      if (dso instanceof Collection) {
        browseContext.setHead(T_head_this_collection);
      }
      if (dso instanceof Community) {
        browseContext.setHead(T_head_this_community);
      }

      // Add the configured browse lists for scoped browsing
      String handle = dso.getHandle();
      addBrowseOptions(browseContext, contextPath + "/handle/" + handle + "/browse");
    }
  }
Example #10
0
  /**
   * Generate the unique caching key. This key must be unique inside the space of this component.
   */
  public Serializable getKey() {
    try {
      Request request = ObjectModelHelper.getRequest(objectModel);
      String key =
          request.getScheme()
              + request.getServerName()
              + request.getServerPort()
              + request.getSitemapURI()
              + request.getQueryString();

      DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
      if (dso != null) {
        key += "-" + dso.getHandle();
      }

      return HashUtil.hash(key);
    } catch (SQLException sqle) {
      // Ignore all errors and just return that the component is not cachable.
      return "0";
    }
  }
Example #11
0
  /**
   * Generate the cache validity object.
   *
   * <p>The validity object will include the collection being viewed and all recently submitted
   * items. This does not include the community / collection hierarch, when this changes they will
   * not be reflected in the cache.
   */
  public SourceValidity getValidity() {
    if (this.validity == null) {

      try {
        DSpaceValidity validity = new DSpaceValidity();

        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

        if (dso != null) {
          // Add the actual collection;
          validity.add(dso);
        }

        // add recently submitted items, serialize solr query contents.
        DiscoverResult response = getQueryResponse(dso);

        validity.add("numFound:" + response.getDspaceObjects().size());

        for (DSpaceObject resultDso : response.getDspaceObjects()) {
          validity.add(resultDso);
        }

        for (String facetField : response.getFacetResults().keySet()) {
          validity.add(facetField);

          List<DiscoverResult.FacetResult> facetValues = response.getFacetResults().get(facetField);
          for (DiscoverResult.FacetResult facetValue : facetValues) {
            validity.add(facetValue.getAsFilterQuery() + facetValue.getCount());
          }
        }

        this.validity = validity.complete();
      } catch (Exception e) {
        // Just ignore all errors and return an invalid cache.
      }

      // TODO: dependent on tags as well :)
    }
    return this.validity;
  }
Example #12
0
 /**
  * Determine if the scope of the search should fixed or is changeable by the user.
  *
  * <p>The search scope when performed by url, i.e. they are at the url handle/xxxx/xx/search then
  * it is fixed. However, at the global level the search is variable.
  *
  * @return true if the scope is variable, false otherwise.
  */
 protected boolean variableScope() throws SQLException {
   return (HandleUtil.obtainHandle(objectModel) == null);
 }
  public Map act(
      Redirector redirector,
      SourceResolver resolver,
      Map objectModel,
      String source,
      Parameters parameters)
      throws Exception {
    Request request = ObjectModelHelper.getRequest(objectModel);

    String requesterName = request.getParameter("requesterName");
    String requesterEmail = request.getParameter("requesterEmail");
    String allFiles = request.getParameter("allFiles");
    String message = request.getParameter("message");
    String bitstreamId = request.getParameter("bitstreamId");

    // User email from context
    Context context = ContextUtil.obtainContext(objectModel);
    EPerson loggedin = context.getCurrentUser();
    String eperson = null;
    if (loggedin != null) {
      eperson = loggedin.getEmail();
    }

    // Check all data is there
    if (StringUtils.isEmpty(requesterName)
        || StringUtils.isEmpty(requesterEmail)
        || StringUtils.isEmpty(allFiles)
        || StringUtils.isEmpty(message)) {
      // Either the user did not fill out the form or this is the
      // first time they are visiting the page.
      Map<String, String> map = new HashMap<String, String>();
      map.put("bitstreamId", bitstreamId);

      if (StringUtils.isEmpty(requesterEmail)) {
        map.put("requesterEmail", eperson);
      } else {
        map.put("requesterEmail", requesterEmail);
      }
      map.put("requesterName", requesterName);
      map.put("allFiles", allFiles);
      map.put("message", message);
      return map;
    }
    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (!(dso instanceof Item)) {
      throw new Exception("Invalid DspaceObject at ItemRequest.");
    }

    Item item = (Item) dso;
    String title = "";
    Metadatum[] titleDC = item.getDC("title", null, Item.ANY);
    if (titleDC == null || titleDC.length == 0) {
      titleDC = item.getDC("title", Item.ANY, Item.ANY); // dc.title with qualifier term
    }
    if (titleDC != null && titleDC.length > 0) {
      title = titleDC[0].value;
    }

    RequestItemAuthor requestItemAuthor =
        new DSpace()
            .getServiceManager()
            .getServiceByName(
                RequestItemAuthorExtractor.class.getName(), RequestItemAuthorExtractor.class)
            .getRequestItemAuthor(context, item);

    RequestItem requestItem =
        new RequestItem(
            item.getID(),
            Integer.parseInt(bitstreamId),
            requesterEmail,
            requesterName,
            message,
            Boolean.getBoolean(allFiles));

    // All data is there, send the email
    Email email =
        Email.getEmail(
            I18nUtil.getEmailFilename(context.getCurrentLocale(), "request_item.author"));
    email.addRecipient(requestItemAuthor.getEmail());

    email.addArgument(requesterName);
    email.addArgument(requesterEmail);
    email.addArgument(
        allFiles.equals("true")
            ? I18nUtil.getMessage("itemRequest.all")
            : Bitstream.find(context, Integer.parseInt(bitstreamId)).getName());
    email.addArgument(HandleManager.getCanonicalForm(item.getHandle()));
    email.addArgument(title); // request item title
    email.addArgument(message); // message
    email.addArgument(getLinkTokenEmail(context, requestItem));
    email.addArgument(requestItemAuthor.getFullName()); //   corresponding author name
    email.addArgument(requestItemAuthor.getEmail()); //   corresponding author email
    email.addArgument(ConfigurationManager.getProperty("dspace.name"));
    email.addArgument(ConfigurationManager.getProperty("mail.helpdesk"));

    email.setReplyTo(requesterEmail);

    email.send();
    // Finished, allow to pass.
    return null;
  }
Example #14
0
  @Override
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {

    Request request = ObjectModelHelper.getRequest(objectModel);

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

    // Set up the major variables
    // Collection collection = (Collection) dso;

    // Build the collection viewer division.

    // Make sure we get our results
    queryResults = getQueryResponse(dso);
    if (this.queryResults != null) {

      Map<String, List<DiscoverResult.FacetResult>> facetFields =
          this.queryResults.getFacetResults();
      if (facetFields == null) {
        facetFields = new LinkedHashMap<String, List<DiscoverResult.FacetResult>>();
      }

      //            facetFields.addAll(this.queryResults.getFacetDates());

      if (facetFields.size() > 0) {
        String facetField =
            String.valueOf(facetFields.keySet().toArray(new String[facetFields.size()])[0]);
        java.util.List<DiscoverResult.FacetResult> values = facetFields.get(facetField);

        if (values != null && 0 < values.size()) {

          Division results = body.addDivision("browse-by-" + facetField + "-results", "primary");

          results.setHead(
              message(
                  "xmlui.ArtifactBrowser.AbstractSearch.type_"
                      + request.getParameter(FACET_FIELD)
                      + "_browse"));

          // Find our faceting offset
          int offSet = queryArgs.getFacetOffset();
          if (offSet == -1) {
            offSet = 0;
          }

          // Only show the nextpageurl if we have at least one result following our current results
          String nextPageUrl = null;
          if (values.size() == (DEFAULT_PAGE_SIZE + 1)) {
            nextPageUrl = getNextPageURL(request);
          }

          results.setSimplePagination(
              (int) queryResults.getDspaceObjects().size(),
              offSet + 1,
              (offSet + (values.size() - 1)),
              getPreviousPageURL(request),
              nextPageUrl);

          Table singleTable =
              results.addTable(
                  "browse-by-" + facetField + "-results",
                  (int) (queryResults.getDspaceObjects().size() + 1),
                  1);

          List<String> filterQueries = new ArrayList<String>();
          if (request.getParameterValues("fq") != null) {
            filterQueries = Arrays.asList(request.getParameterValues("fq"));
          }
          for (int i = 0; i < values.size(); i++) {
            DiscoverResult.FacetResult value = values.get(i);

            String displayedValue = value.getDisplayedValue();
            String filterQuery = value.getAsFilterQuery();

            //                        if(field.getGap() != null){
            //                            //We have a date get the year so we can display it
            //                            DateFormat simpleDateformat = new
            // SimpleDateFormat("yyyy");
            //                            displayedValue =
            // simpleDateformat.format(SolrServiceImpl.toDate(displayedValue));
            //                            filterQuery =
            // ClientUtils.escapeQueryChars(value.getFacetField().getName()) + ":" + displayedValue
            // + "*";
            //                        }

            Cell cell = singleTable.addRow().addCell();

            // No use in selecting the same filter twice
            if (filterQueries.contains(filterQuery)) {
              cell.addContent(displayedValue + " (" + value.getCount() + ")");
            } else {
              cell.addXref(
                  contextPath
                      + (dso == null ? "" : "/handle/" + dso.getHandle())
                      + "/discover?"
                      + "&fq="
                      + URLEncoder.encode(filterQuery, "UTF-8")
                      + (request.getQueryString() != null ? "&" + request.getQueryString() : ""),
                  displayedValue + " (" + value.getCount() + ")");
            }
          }
        }
      }
    }

    // DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

    /*
    if (dso != null)
    {
        if (dso instanceof Collection)
        {
            browseContext.addItem().addXref(contextPath + "/discovery/?q=search.resourcetype%3A2+AND+location%3Al" + dso.getID(), T_head_this_collection );
        }
        if (dso instanceof Community)
        {
            browseContext.addItem().addXref(contextPath + "/discovery/?q=search.resourcetype%3A2+AND+location%3Am" + dso.getID(), T_head_this_community );
        }
    }

    browseGlobal.addItem().addXref(contextPath + "/discovery/?q=search.resourcetype%3A2", T_head_all_of_dspace );
    */
  }
  /** Display a single collection */
  public void addBody(Body body)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (!(dso instanceof Collection)) return;

    // Set up the major variables
    Collection collection = (Collection) dso;

    // Build the collection viewer division.
    Division home = body.addDivision("collection-home", "primary repository collection");
    home.setHead(collection.getMetadata("name"));

    // The search / browse box.
    {
      Division search = home.addDivision("collection-search-browse", "secondary search-browse");

      // Search query
      Division query =
          search.addInteractiveDivision(
              "collection-search",
              contextPath + "/handle/" + collection.getHandle() + "/search",
              Division.METHOD_POST,
              "secondary search");

      Para para = query.addPara("search-query", null);
      para.addContent(T_full_text_search);
      para.addContent(" ");
      para.addText("query");
      para.addContent(" ");
      para.addButton("submit").setValue(T_go);

      // Browse by list
      Division browseDiv = search.addDivision("collection-browse", "secondary browse");
      List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE, "collection-browse");
      browse.setHead(T_head_browse);
      String url = contextPath + "/handle/" + collection.getHandle();
      browse.addItemXref(url + "/browse-title", T_browse_titles);
      browse.addItemXref(url + "/browse-author", T_browse_authors);
      browse.addItemXref(url + "/browse-date", T_browse_dates);
    }

    // Add the refrence
    {
      Division viewer = home.addDivision("collection-view", "secondary");
      ReferenceSet mainInclude =
          viewer.addReferenceSet("collection-view", ReferenceSet.TYPE_DETAIL_VIEW);
      mainInclude.addReference(collection);
    }

    // Reciently submitted items
    {
      java.util.List<BrowseItem> items = getRecientlySubmittedIems(collection);

      Division lastSubmittedDiv =
          home.addDivision("collection-recent-submission", "secondary recent-submission");
      lastSubmittedDiv.setHead(T_head_recent_submissions);
      ReferenceSet lastSubmitted =
          lastSubmittedDiv.addReferenceSet(
              "collection-last-submitted",
              ReferenceSet.TYPE_SUMMARY_LIST,
              null,
              "recent-submissions");
      for (BrowseItem item : items) {
        lastSubmitted.addReference(item);
      }
    }
  }
  /**
   * Get the query parameters supplied to the browse.
   *
   * @return
   * @throws SQLException
   * @throws UIException
   */
  private BrowseParams getUserParams() throws SQLException, UIException {
    if (this.userParams != null) return this.userParams;

    Context context = ContextUtil.obtainContext(objectModel);
    Request request = ObjectModelHelper.getRequest(objectModel);

    BrowseParams params = new BrowseParams();

    params.month = request.getParameter(BrowseParams.MONTH);
    params.year = request.getParameter(BrowseParams.YEAR);
    params.etAl = RequestUtils.getIntParameter(request, BrowseParams.ETAL);

    params.scope = new BrowserScope(context);

    // Are we in a community or collection?
    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (dso instanceof Community) params.scope.setCommunity((Community) dso);
    if (dso instanceof Collection) params.scope.setCollection((Collection) dso);

    try {
      String type = request.getParameter(BrowseParams.TYPE);
      int sortBy = RequestUtils.getIntParameter(request, BrowseParams.SORT_BY);

      BrowseIndex bi = BrowseIndex.getBrowseIndex(type);
      if (bi == null) {
        throw new BrowseException("There is no browse index of the type: " + type);
      }

      // If we don't have a sort column
      if (sortBy == -1) {
        // Get the default one
        SortOption so = bi.getSortOption();
        if (so != null) {
          sortBy = so.getNumber();
        }
      } else if (bi.isItemIndex() && !bi.isInternalIndex()) {
        // If a default sort option is specified by the index, but it isn't
        // the same as sort option requested, attempt to find an index that
        // is configured to use that sort by default
        // This is so that we can then highlight the correct option in the navigation
        SortOption bso = bi.getSortOption();
        SortOption so = SortOption.getSortOption(sortBy);
        if (bso != null && bso != so) {
          BrowseIndex newBi = BrowseIndex.getBrowseIndex(so);
          if (newBi != null) {
            bi = newBi;
            type = bi.getName();
          }
        }
      }

      params.scope.setBrowseIndex(bi);
      params.scope.setSortBy(sortBy);

      params.scope.setJumpToItem(RequestUtils.getIntParameter(request, BrowseParams.JUMPTO_ITEM));
      params.scope.setOrder(request.getParameter(BrowseParams.ORDER));
      params.scope.setResultsPerPage(
          RequestUtils.getIntParameter(request, BrowseParams.RESULTS_PER_PAGE));
      params.scope.setStartsWith(request.getParameter(BrowseParams.STARTS_WITH));
      params.scope.setFilterValue(request.getParameter(BrowseParams.FILTER_VALUE));
      params.scope.setJumpToValue(request.getParameter(BrowseParams.JUMPTO_VALUE));
      params.scope.setJumpToValueLang(request.getParameter(BrowseParams.JUMPTO_VALUE_LANG));
      params.scope.setFilterValueLang(request.getParameter(BrowseParams.FILTER_VALUE_LANG));

      // Filtering to a value implies this is a second level browse
      if (params.scope.getFilterValue() != null) params.scope.setBrowseLevel(1);

      // if year and perhaps month have been selected, we translate these
      // into "startsWith"
      // if startsWith has already been defined then it is overwritten
      if (params.year != null && !"".equals(params.year) && !"-1".equals(params.year)) {
        String startsWith = params.year;
        if ((params.month != null) && !"-1".equals(params.month) && !"".equals(params.month)) {
          // subtract 1 from the month, so the match works
          // appropriately
          if ("ASC".equals(params.scope.getOrder())) {
            params.month = Integer.toString((Integer.parseInt(params.month) - 1));
          }

          // They've selected a month as well
          if (params.month.length() == 1) {
            // Ensure double-digit month number
            params.month = "0" + params.month;
          }

          startsWith = params.year + "-" + params.month;
        }

        params.scope.setStartsWith(startsWith);
      }
    } catch (BrowseException bex) {
      throw new UIException("Unable to create browse parameters", bex);
    }

    this.userParams = params;
    return params;
  }
Example #17
0
  /** Insure that the context path is added to the page meta. */
  public void addPageMeta(PageMeta pageMeta)
      throws SAXException, WingException, UIException, SQLException, IOException,
          AuthorizeException {
    // FIXME: I don't think these should be set here, but there needed and I'm
    // not sure where else it could go. Perhaps the linkResolver?
    Request request = ObjectModelHelper.getRequest(objectModel);
    pageMeta.addMetadata("contextPath").addContent(contextPath);
    pageMeta.addMetadata("request", "queryString").addContent(request.getQueryString());
    pageMeta.addMetadata("request", "scheme").addContent(request.getScheme());
    pageMeta.addMetadata("request", "serverPort").addContent(request.getServerPort());
    pageMeta.addMetadata("request", "serverName").addContent(request.getServerName());
    pageMeta.addMetadata("request", "URI").addContent(request.getSitemapURI());

    String dspaceVersion = Util.getSourceVersion();
    if (dspaceVersion != null) {
      pageMeta.addMetadata("dspace", "version").addContent(dspaceVersion);
    }

    String analyticsKey = ConfigurationManager.getProperty("xmlui.google.analytics.key");
    if (analyticsKey != null && analyticsKey.length() > 0) {
      analyticsKey = analyticsKey.trim();
      pageMeta.addMetadata("google", "analytics").addContent(analyticsKey);
    }

    // add metadata for OpenSearch auto-discovery links if enabled
    if (ConfigurationManager.getBooleanProperty("websvc.opensearch.autolink")) {
      pageMeta
          .addMetadata("opensearch", "shortName")
          .addContent(ConfigurationManager.getProperty("websvc.opensearch.shortname"));
      pageMeta
          .addMetadata("opensearch", "context")
          .addContent(ConfigurationManager.getProperty("websvc.opensearch.svccontext"));
    }

    // Add metadata for quick searches:
    pageMeta.addMetadata("search", "simpleURL").addContent(contextPath + "/search");
    pageMeta.addMetadata("search", "advancedURL").addContent(contextPath + "/advanced-search");
    pageMeta.addMetadata("search", "queryField").addContent("query");

    pageMeta.addMetadata("page", "contactURL").addContent(contextPath + "/contact");
    pageMeta.addMetadata("page", "feedbackURL").addContent(contextPath + "/feedback");

    // Add the locale meta data including language dependant labels
    Locale[] locales = I18nUtil.getSupportedLocales();
    for (int i = 0; i < locales.length; i++) {
      pageMeta.addMetadata("page", "supportedLocale").addContent(locales[i].toString());
      // now add the appropriate labels
      pageMeta
          .addMetadata("supportedLocale", locales[i].toString())
          .addContent(locales[i].getDisplayName(locales[i]));
    }

    pageMeta.addMetadata("page", "currentLocale").addContent(context.getCurrentLocale().toString());

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (dso != null) {
      if (dso instanceof Item) {
        pageMeta.addMetadata("focus", "object").addContent("hdl:" + dso.getHandle());
        this.getObjectManager().manageObject(dso);
        dso = ((Item) dso).getOwningCollection();
      }

      if (dso instanceof Collection || dso instanceof Community) {
        pageMeta.addMetadata("focus", "container").addContent("hdl:" + dso.getHandle());
        this.getObjectManager().manageObject(dso);
      }
    }
  }