Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:24:43+00:00 2026-06-18T05:24:43+00:00

I am trying to copy a whole Folder . To do so I am

  • 0

I am trying to copy a whole Folder.

To do so I am creating a new folder and putting all again inside it : folders and documents.

But I am getting an Alfresco Service Exception when trying to create a Document:

Newly created object is not a document !

My code is as below :

List<Document> documentsChildren = documentFolderService.getDocuments(folderToCopy);
for (Document document:documentsChildren){
ContentFile contentFileToCopy = documentFolderService.getContent(document);
String nameFileToCopy = document.getName();

// problem there
documentFolderService.createDocument(folderCopied, nameFileToCopy, properties, contentFileToCopy);
}

What is strange is that I yet implement the copy of a simple document inside a repository by the same way and it is working good:

Document documentToCopy = (Document) documentFolderService.getNodeByIdentifier(fileToCopy.getIdentifier());
ContentFile contentFileToCopy = documentFolderService.getContent(documentToCopy);
String nameFileToCopy = fileToCopy.getName();
documentFolderService.createDocument(folderParent, nameFileToCopy, properties, contentFileToCopy);

The only thing that changes is the way to obtain the document : by taking the children documents of a folder or by getting the document with his identifier.

Update of the question :

The exact message of error is:

Caused by: org.alfresco.mobile.android.api.exceptions.AlfrescoServiceException: Newly created object is not a document! New id: workspace://SpacesStore/85753128-1ac9-4b5e-b909-91dcb7d5ff5d
at org.alfresco.mobile.android.api.services.impl.AbstractDocumentFolderServiceImpl.createDocument(AbstractDocumentFolderServiceImpl.java:482)
  • properties is en empty map :

    Map properties = new HashMap();

  • I test for .ppt documents, and as you ask the question, I also test for .docx and .jpg

  • the type of the node when the exception is raised is a folder

The quick fix that you proposed is not working.
Maybe I am doing a stupid error somewhere but I don’t manage to find it.

Complete code :

List<Folder> foldersChildren = null;
List<Document> documentsChildren = null;
try {
        ServiceRegistry serviceRegistry = Login.session.getServiceRegistry();
        DocumentFolderService documentFolderService = serviceRegistry.getDocumentFolderService();
        Folder folderParent = (Folder) documentFolderService.getNodeByIdentifier(repositoryParent.getIdentifier());

        // create the folder
        Map<String,Serializable> properties = new HashMap<String,Serializable>();   
        Folder folderToCopy = (Folder) documentFolderService.getNodeByIdentifier(repositoryToCopy.getIdentifier());
        String nameRepositoryToCopy = repositoryToCopy.getName();
        Folder folderCopied = documentFolderService.createFolder(folderParent, nameRepositoryToCopy, properties);

        foldersChildren = documentFolderService.getFolders(folderToCopy);
        documentsChildren = documentFolderService.getDocuments(folderToCopy);

        // create the files inside the folder
        ContentFile contentFileToCopy = null;
        String nameFileToCopy = null;
        for (Document document : documentsChildren){
            contentFileToCopy = documentFolderService.getContent(document);
            nameFileToCopy = document.getName();

            // this operation doesn't work
            documentFolderService.createDocument(folderCopied, nameFileToCopy, properties, contentFileToCopy);
        }
    } catch (Exception e){
        this.cancel(true);
        UIAlertDialog.runOnUIThreadOperationFailed(activity, context);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:24:44+00:00Added an answer on June 18, 2026 at 5:24 am

    As the error message explained : Newly created object is not a document !
    this error happens after the creation of the document when the method check if the current node is correctly created and have the right attributes.

    I need more informations (stacktrace, type of the node…) to know if it’s a bug on SDK side or a specific the method doesn’t cover.
    Could you provide informations

    • properties value : Is it an empty map ? the same map as the copied one ?
    • Does it happen for every document or just for some types of document ?
    • What’s the type of the node when the exception is raised ?

    But if the second method work, a quick fix could be :

    List<Document> documentsChildren = documentFolderService.getDocuments(folderToCopy);
    Document documentToCopy = null;
    ContentFile contentFileToCopy = null;
    String nameFileToCopy = null;
    for (Document document : documentsChildren){
       documentToCopy = (Document) documentFolderService.getNodeByIdentifier(document .getIdentifier());
       contentFileToCopy = documentFolderService.getContent(documentToCopy);
       nameFileToCopy = fileToCopy.getName();
       documentFolderService.createDocument(folderParent, nameFileToCopy, properties, contentFileToCopy);
    }
    

    EDIT 06.02

    Apparently there’s an issue reference with the properties object inside documentFolderService.createFolder(). The map is not empty after this method and contains informations that disturb the next part of your code.
    So to correct it (and if for you properties are not important during copy operation), please find the solution

    List<Folder> foldersChildren = null; 
    List<Document> documentsChildren = null; 
    try {
            ServiceRegistry serviceRegistry = Login.session.getServiceRegistry();
            DocumentFolderService documentFolderService = serviceRegistry.getDocumentFolderService();
            Folder folderParent = (Folder) documentFolderService.getNodeByIdentifier(repositoryParent.getIdentifier());
    
            // create the folder
            Folder folderToCopy = (Folder) documentFolderService.getNodeByIdentifier(repositoryToCopy.getIdentifier());
            String nameRepositoryToCopy = repositoryToCopy.getName();
            Folder folderCopied = documentFolderService.createFolder(folderParent, nameRepositoryToCopy, null);
    
            foldersChildren = documentFolderService.getFolders(folderToCopy);
            documentsChildren = documentFolderService.getDocuments(folderToCopy);
    
            // create the files inside the folder
            ContentFile contentFileToCopy = null;
            String nameFileToCopy = null;
            for (Document document : documentsChildren){
                contentFileToCopy = documentFolderService.getContent(document);
                nameFileToCopy = document.getName();
    
                // this operation doesn't work
                documentFolderService.createDocument(folderCopied, nameFileToCopy, null, contentFileToCopy);
            }
        } catch (Exception e){
            this.cancel(true);
            UIAlertDialog.runOnUIThreadOperationFailed(activity, context);
        }
    

    NB : Properties is an optional parameter so it can be null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy all format file (.txt,.pdf,.doc ...) file from source folder
I am trying to copy whole directory tree from server's shared folder to my
I am trying to copy folders and files which is working fine but I
I'm trying copy a single file from the Plugin directory inside of my Wordpress
I am trying to copy and paste a folder structure on file system programmatically.
I am trying to copy all the methods and attributes from a class to
I am trying to copy a 5mb database file to data folder from raw
I'm desperately trying to copy a file to the sdcard from my raw folder,
I am trying to copy my Blackberry assets folder to the SD card using
I am trying to copy over some files pulled out from a zip folder,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.