Package com.dotmarketing.tag.model

Examples of com.dotmarketing.tag.model.Tag


    return getTagInodeByInode(inode);
  }

  public void updateTag(String tagId, String tagName, boolean updateTagReference, String hostId) throws Exception  {

    Tag tag = getTagByTagId(tagId);
    boolean tagAlreadyExistsForNewTagStorage = false;

    //This block of code prevent saving duplicated tags when editing tag storage from host
    List<Tag> tags = getTagByName(tagName.toLowerCase());

    for(Tag t: tags){
      if(t.getHostId().equals(hostId)){
        //The tag with new tag storage already exists
        tagAlreadyExistsForNewTagStorage = true;
      }
      if(t.getTagId().equals(tagId)){
        //select tag to be updated
        tag = t;
      }
    }

    //update selected tag if it's set and if previous tag storage is different.
      if(UtilMethods.isSet(tag.getTagId())&&!tagAlreadyExistsForNewTagStorage){
        tag.setTagName(tagName);
      tag.setUserId("");
      if(updateTagReference){
        if(UtilMethods.isSet(hostId))
          tag.setHostId(hostId);
      }
      HibernateUtil.saveOrUpdate(tag);
      }

  }
View Full Code Here


     * Deletes a tag
     * @param tagName name of the tag to be deleted
     * @param userId id of the tag owner
     */
  public void deleteTag(String tagIdthrows DotHibernateException  {
    Tag tag = getTagByTagId(tagId);
    deleteTag(tag);
  }
View Full Code Here

      oldTagName = escapeSingleQuote(oldTagName);

      List tagToEdit = getTagByName(oldTagName);
      Iterator it = tagToEdit.iterator();
      for (int i = 0; it.hasNext(); i++) {
        Tag tag = (Tag)it.next();

        tag.setTagName(tagName);
        HibernateUtil.saveOrUpdate(tag);
      }
    }
    catch (Exception e) {}
  }
View Full Code Here

   */

    public TagInode addTagInode(String tagName, String inode, String hostId) throws Exception {

      //Ensure the tag exists in the tag table
      Tag existingTag = getTag(tagName, "", hostId);

      //validates the tagInode already exists
    TagInode existingTagInode = getTagInode(existingTag.getTagId(), inode);

      if (existingTagInode.getTagId() == null) {

        //the tagInode does not exists, so creates a new TagInode
        TagInode tagInode = new TagInode();
        tagInode.setTagId(existingTag.getTagId());
        /*long i = 0;
        try{
          i =Long.parseLong(inode);
        }catch (Exception e) {
        Logger.error(this, "Unable to get Long value from " + inode, e);
View Full Code Here

  public List deleteTagInode(String tagName, String inode) throws Exception {
    StringTokenizer tagNameToken = new StringTokenizer(tagName, ",");
    if (tagNameToken.hasMoreTokens()) {
        for (; tagNameToken.hasMoreTokens();) {
          String tagTokenized = tagNameToken.nextToken().trim();
          Tag tag = getTag(tagTokenized,"","");
          TagInode tagInode = getTagInode(tag.getTagId(), inode);
            if (tagInode.getTagId() != null) {
                HibernateUtil.delete(tagInode);
          }
        }
    }
View Full Code Here

    HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
      List<String> saveTagErrors = new ArrayList<String>();
      Map<String,Object> callbackData = new HashMap<String,Object>();

      Tag tag = new Tag();

      hostId=hostId.trim();
     
      StringTokenizer tagNameToken = new StringTokenizer(tagNames, ",");
      if (tagNameToken.hasMoreTokens()) {
        for (; tagNameToken.hasMoreTokens();) {
          String tagName = tagNameToken.nextToken().trim();

          try{

            tag = TagFactory.getTag(tagName, userId, hostId);
            String tagStorageForHost = "";
            Host host = APILocator.getHostAPI().find(hostId, APILocator.getUserAPI().getSystemUser(),true);

            if(host==null) {

              HttpSession session = WebContextFactory.get().getSession();
              hostId = (String) session.getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
              host = APILocator.getHostAPI().find(hostId, APILocator.getUserAPI().getSystemUser(),true);
            }
            tagAPI.addTagInode(tagName,
                APILocator.getUserProxyAPI().getUserProxy(userId, APILocator.getUserAPI().getSystemUser(), false).getInode(),
                hostId);

            if(host!=null && host.getIdentifier()!=null && host.getIdentifier().equals(Host.SYSTEM_HOST))
              tagStorageForHost = Host.SYSTEM_HOST;
            else {
              try {
                tagStorageForHost = host.getMap().get("tagStorage").toString();
              } catch(NullPointerException e) {
                tagStorageForHost = Host.SYSTEM_HOST;
              }
            }

            if (UtilMethods.isSet(tagStorageForHost)){
              if (!tag.getHostId().equals(tagStorageForHost) && tag.getHostId().equals(Host.SYSTEM_HOST)) {
                saveTagErrors.add("Global Tag Already Exists");
                SessionMessages.clear(req.getSession());
              }

            }
View Full Code Here

   * @param tagName name(s) of the tag(s)
   * @param inode inode of the object tagged
   * @return a list of all tags assigned to a user
   */
  public Map<String, List<Tag>> deleteTag(String tagNameOrId, String userId) {
    Tag tag = new Tag();
    try {
      tag = APILocator.getTagAPI().getTagByTagId(tagNameOrId);
    } catch (DotHibernateException e1) {}
    if(!UtilMethods.isSet(tag) || !UtilMethods.isSet(tag.getTagId()))
      tag = TagFactory.getTag(tagNameOrId, userId);
    String newUserId = "";
    StringTokenizer userIdToken = new StringTokenizer(tag.getUserId(), ",");
      if (userIdToken.hasMoreTokens()) {
        for (; userIdToken.hasMoreTokens();) {
          String userIds = userIdToken.nextToken().trim();
          if(!(userIds.equals(userId))){
            newUserId = userIds+","+newUserId;
          }
        }
      }
      if(!(newUserId.equals(userId))){
            try{
              TagFactory.updateTag(tag.getTagId(), newUserId);
            }catch(Exception e){
              Logger.error(this, e.getMessage());
            }
      }else{
        TagFactory.deleteTag(TagFactory.getTag(tagNameOrId, userId));
View Full Code Here

      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    final Tag other = (Tag) obj;
    if (tagName == null) {
      if (other.tagName != null)
        return false;
    } else if (!tagName.equals(other.tagName))
      return false;
View Full Code Here

    UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);

    //delete user tags
    List<TagInode> userTagsList = TagFactory.getTagInodeByInode(String.valueOf(userProxy.getInode()));
    for(TagInode tag : userTagsList){
        Tag retrievedTag = TagFactory.getTagByTagId(tag.getTagId());
      TagFactory.deleteTagInode(tag);
      TagFactory.deleteTag(retrievedTag.getTagId());
    }
   
    //deletes user proxy
    InodeFactory.deleteInode(userProxy);
    //deletes liferay user
View Full Code Here

        UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);

        //delete user tags
        List<TagInode> userTagsList = TagFactory.getTagInodeByInode(String.valueOf(userProxy.getInode()));
        for (TagInode tag : userTagsList) {
          Tag retrievedTag = TagFactory.getTagByTagId(tag.getTagId());
            TagFactory.deleteTagInode(tag);
            TagFactory.deleteTag(retrievedTag.getTagId());
        }

        if(InodeUtils.isSet(userProxy.getInode())) {
          PermissionAPI perAPI = APILocator.getPermissionAPI();
          perAPI.removePermissions(userProxy);
View Full Code Here

TOP

Related Classes of com.dotmarketing.tag.model.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.