title: How to add tag to document in doc library through programming in liferay?
body: <p>I am new to liferay. I am using liferay 6.0.5
  I want to add "Archive" tag to doc library document through code so latter on I can fetch the document with "Archive" tag.
  how to do this?</p>
  
  <p><strong>Here is the code being worked upon :</strong> </p>
  
  <pre class="lang-java prettyprint-override"><code>private void addArchive(List&lt;DLFileEntry&gt; fileEntryList) {       
      try
      {
          long groupId=0;
          long userId=0;
          String className=null;
          long classPK=0;
          long categoryIds[]=null;
          String tagNames[]=null;
          String newTagNames[] = new String[20];
          long entryId = 0;
          List&lt;AssetTag&gt; TNames = new ArrayList&lt;AssetTag&gt;();
          int i = 0;
          for(DLFileEntry cur:fileEntryList)
          {
              groupId=cur.getGroupId();
              userId=cur.getUserId();
              className=cur.getClass().getName();
              classPK=cur.getPrimaryKey();
              AssetEntry ae=AssetEntryLocalServiceUtil.getEntry(groupId, cur.getUuid());
              categoryIds=ae.getCategoryIds();
              entryId = ae.getEntryId();
              TNames = ae.getTags();
              System.out.println(cur.getTitle());
              i=0;
              for(AssetTag tag : TNames)
              {
                  System.out.println(tag.getName());      
                  newTagNames[i]=tag.getName().toString();
                  i++;
              }
              newTagNames[i]="NameArchive";
              AssetEntryLocalServiceUtil.updateEntry(userId, groupId, className, classPK, categoryIds, newTagNames);
              System.out.println("------------------------------------------------");
          }
          System.out.println("outside for loop"); 
      }
      catch (Exception e) {
          // TODO: handle exception
      }
  }
  </code></pre>