Recently we copied our _admin folder and KDBs from other environment to our stag

Recently we copied our _admin folder and KDBs from other environment to our staging/UAT. Since then, while using the smart service "Appian document from Base64 String" we are getting below Alert

The document could not be created. Error: Attempt to write over a file that already exists [fileName = E:\\appian\\_admin\\accdocs2\\8\\10264112.pdf].

Do we need to re import our accdocs folders to fix this issue?
Also can anyone let us know the why this error is occurring?

OriginalPostID-168903

OriginalPostID-168903

  Discussion posts and replies are publicly visible

  • There's a relationship between the COLLAB engine and the ACCDOCS folder.

    COLLAB has an internal counter to determine the next internal file name when creating a document, in this example, COLLAB knows it has to create a document with the internal file name 10264112.pdf but it turns out that it already exists in the file system, therefore you get the error.

    This clearly shows that there's a mismatch between your COLLAB engine and the ACCDOCS folder. Any time you move ENGINES from one server to another you also need to copy _admin
  • Thanks for the explanation Eduardo. The issue is we have 200 GB of files to copy so we cant copy ACCDOCS folder at the same time we copied the COLLAB engine.
    I think the solution would be to go into ACCDOCS folder and find out the list of files created since the backup and delete them.
  • I think it's more complex than that:

    1. Upload the attached file via the Documents tab
    2. Search in accdocs for *.mahesh
    3. Write down the internal file name this file received
    4. That's the current value for the COLLAB counter
    5. Anything greater than that can be deleted from disk

    test.mahesh

  • Eduardo, I have a question that I think is related to what you just described about the relationship between the COLLAB engine and the ACCDOCS folder.

    I wrote a plugin for Appian whose purpose was to combine two pdf documents into one document, then put that document in the Appian file system and make it available for download.

    The plugin successfully combines the files (I can open the file and view it in Windows explorer) and puts the new file in the Appian file system with the name I gave it, "Merge_Result_Doc", and in windows explorer it also shows up as "Merge_Result_Doc".

    When I click on the document download link in the form, however, I get an error 404 web page not found error. And when I click it in the Documents tab in Appian it does not open but I get the following error message in the console:

    22:56:36,423 INFO [stdout] (http-/0.0.0.0:8080-8) 2015-09-24 22:56:36,423
    [http-/0.0.0.0:8080-8] ERROR com.appiancorp.km.actions.GetDocumentAction - The file for the Document could not be found on the server. (id=2656, path=C:/appian/_admin/accdocs3\\2050\\10001257.pdf)

    Also, I noticed that when I delete it in Appian, it does not delete from the local file system (I can still see it in Windows Explorer). One other thing I noticed is that in the Appian file system the file shows up as <1kb in size.

    Can you or anyone explain to me what causes this behavior?

    Thanks.

  • Are you explicitly overriding the physical name assigned by Appian? That's not going to work. You don't have to do that. Appian stores the display name too in such a way that when you click download the display name is preserved but internally the physical name will be 10001257.pdf. You should never change this name otherwise links in Appian to that document won't work.
  • Eduardo, thanks for your response. That's actually exactly what I did. I did it because without doing that my internal filename was null, which in turn caused my code to not work. How can I tell Appian to go ahead and set its internal filename and id and then return them to me? I figured out what I could from the public Java API, but for lack of more thorough knowledge on Appian's internal workings this is my code looks:

              String mergeResultDocName = "Merge_Result_Doc";
                        String mergeResultDocExtension = "pdf";
                        Document mergeResultDoc = new Document(folder, mergeResultDocName, mergeResultDocExtension);
                        mergeResultDoc.setSize(1);
                        mergeResultDoc.setFileSystemId(ContentConstants.ALLOCATE_FSID);
                        mergeResultDoc.setInternalFilename("C:\\\\appian\\\\_admin\\\\accdocs3\\\\2050\\\\" + mergeResultDocName + ".pdf");
                        mergeResultDoc.setState(ContentConstants.STATE_ACTIVE_PUBLISHED);
                        Long docId = cs.create(mergeResultDoc, ContentConstants.UNIQUE_FOR_TYPE);
                        mergeResultDoc.setId(docId);
                        
                        try {
                                  File destinationFile = new File(mergeResultDoc.getInternalFilename());
                                  FileOutputStream fos = new FileOutputStream(destinationFile, true);
                                  Rectangle size = RectangleFinder.getRectangleSize(inputs);
                                            
                                  PdfVeryDenseMergeTool tool = new PdfVeryDenseMergeTool(size, paddingSize, paddingSize, contentGapSize);
                                  tool.merge(fos, inputs);
                        
                        } catch (Exception e) {
                                  System.out.println("*******There has been an error creating the fileoutput stream and running the merge tool.******");
                                  System.out.println(e);
                        }
  • Thank you for posting the code, with it, I can now see where the problem is.

    Take a look at this Shared Component for an example on how to merge documents and create a new one forum.appian.com/.../summary

    In particular, you should review

    <PLUG_IN_JAR>\\src\\com\\appiancorp\\ps\\pdftools\\AbstractPDFDocumentGeneration.createDocument


  • Thank you very much Eduardo. I will take a look at that.