1 Reply Latest reply on Nov 21, 2013 12:42 PM by garret.starke

    Authors show up as anonymous on Content tab

    garret.starke

      We have an issue with content migration regarding how document authors appear in the Content tab, and when viewing the document.  The current user is set as the author of the document, but when the documents appear on the Content tab they are shown as last modified by ANONYMOUS.  On the document page, the line "created by Administrator on <<DATE>>, last modified by on <<DATE>>" is missing the user between the second "by" and "on".

       

      Has anyone seen this issue or could someone review the code and see if there is something missing that would correct this display issue?

       

      Thanks in advance!

       

           public void save(Metadata value) {
                try {
                     // create the document
                     Document doc = documentManager.createDocument(value.getUser(),
                               documentTypeManager.getDefaultDocumentType(), null, value.getDocumentTitle(), (String) null);
                     doc.setDocumentState(DocumentState.PUBLISHED);
                     ((DbDocument) doc).setCurrentUserID(value.getUser().getID());  // ADDED THIS LINE TO FIX ISSUE
      
                     TikaInputStream tis = TikaInputStream.get(value.getFileData());
                     try {
                          // determine the mime type
                          MediaType mediaType = MimeTypes.getDefaultMimeTypes().detect(tis,
                                    new org.apache.tika.metadata.Metadata());
      
                          // set document body
                          attachmentHelper.setBinaryBody(doc, value.getFileName(), mediaType.getType(), tis);
                     } finally {
                          IOUtils.closeQuietly(tis);
                     }
      
                     // add the document to the container
                     documentManager.addDocument(value.getContainer(), doc, Collections.emptyMap());
      
                     // add the documents to the categories
                     LongList tagIDs = getTagIDsFromTagNames(value.getTags());
                     for (String category : value.getCategories()) {
                          TagSet tagSet = tagSetManager.findTagSet(value.getContainer(), category);
                          if (tagSet == null)
                               tagSet = tagSetManager.createTagSet(category, category, tagIDs, value.getContainer());
                          tagSetManager.addTagSet(tagSet, Arrays.asList(new EntityDescriptor(doc)));
                     }
      
                     // add the tags to the documents
                     TagDelegator td = doc.getTagDelegator();
                     for (String tagname : value.getTags()) {
                          td.addTag(td.createTag(tagname));
                     }
                } catch (Exception e) {
                     throw new RuntimeException(e);
                }
           }