예제 #1
0
  /** @return list of application links */
  public Map<String, List<Link>> getApplicationLinks() throws DataStoreException {
    List<LinkGroup> categories = linkGroupService.list();
    if (categories != null) {
      Map<String, List<Link>> applicationLinks = new HashMap<>(categories.size());
      List<Link> firstlevelLinks;
      for (LinkGroup group : categories) {
        firstlevelLinks = linkGroupService.getFirstLevelLinks(group.getName());
        if (firstlevelLinks != null) {
          for (Link link : firstlevelLinks) {
            link.setChildren(listChildren(link.getName()));
          }
          applicationLinks.put(group.getName(), firstlevelLinks);
        }
      }

      Map<String, LinkProvider> beansMap = applicationContext.getBeansOfType(LinkProvider.class);

      for (Map.Entry<String, LinkProvider> entry : beansMap.entrySet()) {
        applicationLinks.put(entry.getKey(), entry.getValue().getLinks());
      }
      return applicationLinks;
    }

    return null;
  }
예제 #2
0
 /**
  * Delete a Link with given String
  *
  * @param linkName String to be delete
  * @return status of the Delete operation
  */
 public Boolean delete(String linkName) throws DataStoreException {
   LOGGER.info("Deleting Link {}", linkName);
   List<Link> children = listChildren(linkName);
   if (children != null) {
     for (Link child : children) {
       delete(child.getName());
     }
   }
   return dataStore.delete(Link.class, linkName);
 }
예제 #3
0
 /**
  * Update a Link with given Url
  *
  * @param linkName name of the Link
  * @param url URL to be linked
  * @return status of the Update
  */
 public Link linkUrl(String linkName, String url) throws DataStoreException {
   Link updated = null;
   if (linkName != null) {
     LOGGER.info("Updating Link with url {}", linkName);
     Link link = read(linkName);
     link.setTargetUrl(url);
     updated = update(link);
   }
   return updated;
 }
예제 #4
0
 /**
  * Update a Link with given Object
  *
  * @param link Object to be update
  * @return status of the Update operation
  */
 public Link update(Link link) throws DataStoreException {
   Link updated = null;
   if (link != null) {
     LOGGER.info("Updating Link {}", link);
     updated = dataStore.update(link, link.getName());
   }
   return updated;
 }
예제 #5
0
  /**
   * Creates a new Link with given Object
   *
   * @param link Object to be Create
   * @return created Link object
   */
  public Link create(Link link) throws DataStoreException {
    Link createdLink = null;
    if (link != null) {

      createdLink = dataStore.create(link);
      LOGGER.info("Created Link {}", createdLink.getName());

      if (link.getTargetUrl() == null || link.getTargetUrl().trim().length() == 0) {
        LOGGER.info("Setting Default Link URL {}", createdLink.getName());
        createdLink.setTargetUrl("/create_page/" + createdLink.getName());
        update(createdLink);
      }
    }
    return createdLink;
  }