コード例 #1
0
  /*
   * Gets a specific tag tuple from the database as specified by the tags ID.
   */
  public RESTTagV1 getTagById(final int id) {
    try {
      if (entityCache.containsKeyValue(RESTTagV1.class, id)) {
        return entityCache.get(RESTTagV1.class, id);
      } else {
        /*
         * We need to expand the Categories collection in most cases so
         * expand it anyway
         */
        final ExpandDataTrunk expand = new ExpandDataTrunk();
        expand.setBranches(
            CollectionUtilities.toArrayList(
                new ExpandDataTrunk(new ExpandDataDetails("categories")),
                new ExpandDataTrunk(new ExpandDataDetails("properties"))));

        final String expandString = mapper.writeValueAsString(expand);
        // final String expandEncodedString = URLEncoder.encode(expandString, "UTF-8");

        final RESTTagV1 tag = client.getJSONTag(id, expandString);
        entityCache.add(tag);
        return tag;
      }
    } catch (Exception e) {
      log.error(ExceptionUtilities.getStackTrace(e));
    }
    return null;
  }