How to replicate contents of a folder

We have a folder(nt:folder) containing images. We would like to replicate all the images to the publish environment. I have tried the following implementation but it only replicates the folder  without the content. Is there any way to replicate the content at the same time without iterating through each node?
Currently using CQ5.4
Thank you.
        String agentId="someAgent";
        String folderPath="/content/dam/images/someFolder";
        ReplicationOptions opts = new ReplicationOptions();
        AgentIdFilter filter = new AgentIdFilter(agentId);
        opts.setFilter(filter);
        Replicator replicator = sling.getService(Replicator.class);
        replicator.replicate(mySession, ReplicationActionType.ACTIVATE, folderPath, opts);

Hi,    
    You need to repicate notes recursively instead of just root path. Can you try something like this:
public void recursiveReplication(Session session, String path, BufferedWriter out,
            WorkItem workItem) throws IOException,Exception{ 
        doReplicate(session, path,out,workItem);           // Calling method to replicate
        Resource res = resolver.getResource(path);
        Iterator<Resource> iter = resolver.listChildren(res);
        while (iter.hasNext()) {
            Resource tempResource=iter.next();
            String temp=tempResource.getPath();
            //checking for hierarchyNode
            Node node = tempResource.adaptTo(Node.class);
                  if (!node.isNodeType("nt:hierarchyNode")){
                      continue;
                  else
                     recursiveReplication(session, temp,out,workItem);
    }// end of recursiveReplication()mthd
    public void doReplicate(Session session, String path,BufferedWriter out,
            WorkItem workItem) throws IOException,Exception{
        try {          
            //Code related to the replicate...           
        } catch (ReplicationException e) {
    }// end of doReplicate()mthd
Hope it helps..
Thanks
Siva

Similar Messages

  • Just need to know how to move contents of a folder PLEASE :)

    Hi all Need to know something?.
    I want to move the contents of a folder to another.
    I am using this code to move a file to another but how do I move the whole contents to another.
    public void moveBack() {
        try {
          selectedFileName = (String) OrdersUploadFileNameHashtable.get(
              (String) jOrdersUploadList1.getSelectedValue());
          ShortFileName = (String) jOrdersUploadList1.getSelectedValue();
          if (!jOrdersUploadList1.getSelectedValue().equals(null)) {
            File w = new File(EpodConstants.ORDERS_TO_UPLOAD_DIR, selectedFileName);
            File f = new File(EpodConstants.ORDERS_PENDING_DIR, selectedFileName);
            if (w.renameTo(f))
              System.out.println("ok");
            else {
              JOptionPane.showMessageDialog(null,
                                            "No Order Selected",
                                            "You must Select a Order to Move",
                                            JOptionPane.INFORMATION_MESSAGE);
        }

    here's my solution:
          * Copy a file. The destination file name can be different from the source file name. Rules:
         * <ul>
         * <li>If destination is an existing directory, <i>source</i> is copied to this directory
         * <li>If destination is an existing file, this file is overwritten.
         * <li>If destination is a file name with leading path, leading path is created.
         * <li>If destination is just a file name, path of <i>source</i> is used as destination.
         * <li>If destination ends with a File.separatorChar, it is created as the destination directory.
         * </ul>
          * @param source Name of file (incl. path) to copy.
          * @param destination Name of destination file to copy to.
         * @throws IOException
         * @see <a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPIOPerformance.fm.html">I/O Performance</a>
        public static void copyFile(String source, String destination) throws IOException {
            if (source != null && destination != null) {
                File sourceFile = new File(source);
                if (sourceFile.exists() && sourceFile.isFile()) { //no directory?
                    File destFile = new File(destination);
                    if (destFile.exists()) {
                        if (destFile.isDirectory()) { //1. existing destination directory
                            destFile = new File(destination + File.separatorChar + sourceFile.getName());
                        } else { //2. existing destination file
                            //ignore, overwrite existing destination file
                    } else { //destination does not exist
                        int index = destination.lastIndexOf(File.separator);
                        if (index > -1) { //3. file has leading directory path or is directory
                            if (index == (destination.length() - 1)) { //destination is directory?
                                File destDir = new File(destination);
                                destDir.mkdirs();
                                destFile = new File(destDir + sourceFile.getName());
                            } else { //destination is directory + file
                                String destDir = destination.substring(0, index + 1);
                                File destDirFile = new File(destDir);
                                if (!destDirFile.exists()) {
                                    destDirFile.mkdirs(); //create destination directory tree
                        } else { //4. file has no leading directory path
                            destFile = new File(sourceFile.getParent() + File.separatorChar + destination);
                    BufferedInputStream in = null;
                    BufferedOutputStream out = null;
                    try {
                        in = new BufferedInputStream(new FileInputStream(sourceFile));
                        out = new BufferedOutputStream(new FileOutputStream(destFile));
                        int c;
                        while ((c = in.read()) != -1) { //read next byte of data until end of stream is reached
                            out.write(c);
                        out.flush();
                    } finally {
                        if (in != null) { in.close(); }
                        if (out != null) { out.close(); }
                }//else: source file does not exist or is a directory
            }//else: no input values available
        }//copyFile()
          * Copy all files of a directory to a destination directory. If the destination file does not exist, it
         * is created. If copy of one file throws an exception, copy of remaining files continue, so that at least
         * all files without exceptions get copied.
          * @param sourceDir Source directory to copy all files from.
          * @param targetDir Destination directory to copy all files to.
         * @throws IOException
        public static void copyFiles(String sourceDir, String targetDir) throws IOException {
            IOException exception = null;
            if (sourceDir != null && targetDir != null) {
                File sourceFile = new File(sourceDir);
                if (sourceFile.exists() && sourceFile.isDirectory()) {
                    File targetFile = new File(targetDir);
                    if (!targetFile.exists()) {
                        targetFile.mkdirs();
                    //for all files of source dir do:
                    String[] filesToCopy = sourceFile.list();
                    int count = filesToCopy.length;
                    for (int i = 0; i < count; i++) { //for each source file do
                        String fileName = filesToCopy;
    File file = new File(sourceDir + File.separatorChar + fileName);
    if (file.isFile()) {
    try {
    copyFile(sourceDir + File.separatorChar + fileName, targetDir);
    } catch (IOException ioe) {
    exception = ioe;
    } else { //file is directory
    try {
    copyFiles(sourceDir + File.separatorChar + fileName, targetDir + File.separatorChar + fileName);
    } catch (IOException ioe) {
    exception = ioe;
    }//next file
    }//else: source directory does not exist
    }//else: input values not available
    if (exception != null) {
    throw exception;
    }//copyFiles()

  • How to display content with dynamic folder path

    Hi Experts,
    I have a folder with subfolders. This subfolders are named as weeknumbers. What we want is: depending on the weeknumber, the right folder with content is showing automatically. In week 1 we see the content of week 1 , in week 2 we see the content of week 2 etc.
    How to achive this, what is the best way?
    Thanks in advance,
    Joeri

    Hi Joeri,
    I would follow the below procedure...
    1. create a the KM navigation iViews for each of the folders in KM (Week1, Week2 etc).
    2. Create a JSP(PAR) or an HTML to access these iViews (as [Link1], [Link2] etc on a JSP or an HTML)
    3. Create an iView from PAR (if JSP-PAR)
        OR Create a KM Document iView for the HTML Page (Store the HTML Page in KM again)
    I hope this would help you.
    Cheers!!!
    Biroj Patro.

  • How to delete contents of sent folder

    I want to delete the contents of all sent folders on all my Apple devices. Tere are thousands so I cannot mark each item for deletion to delete them.  How can I accomplish this without deleting the account and re-creating it?  I don't see a DELETE ALL like exists in the trash, etc.
    Thanks!
    Jim in Chicago

    There just isn't a way until you get the contents into the trash and can use delete all.
    This keeps coming up and a solution has not been provided...give feedback:
    http://www.apple.com/feedback

  • How do i print a list of the contents of a folder?

    I want to be able to create a list of the contents of a folder - preferably to put it into a spreadsheet.  How cna I do this?

    Print Window is a great little app for this.   You can save file listings directly to Excel or Tab-delimited text with the advanced version ($20)

  • How do I tag all the contents of a folder?

    How do I tag all the contents of a folder?
    I'm trying to add an archive tag to a lot of files and folders, and is it possible to just tag the parent folder and all files and folders within it to adopt this tag, so that when I come to search for a document later on, and it has an archive tag, I know to dismi

    Ideally, the program you want to delete has an 'uninstaller' application and that should delete all the files. If that isn't available you could download and run this free app: http://www.freemacsoft.net/appcleaner/
    Probably not as thorough but it will do the job of ridding you mac of most of the files associated with the app you no longer want.

  • How to copy contents of folder into new folder with Automator?

    What is the simplest, fastest Automator workflow to copy the contents of a folder into a new folder? And without using 3rd party actions.
    I have a template folder structure called .ProjectFolder (to keep it invisible) so I need to copy the contents of this folder into a new folder, preferably with the ability to name the new folder on the fly. I don't want to use 3rd party actions because this is something I then need to maintain. Thanks.

    957911 wrote:
    Oracle guru,
    I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
    -Oracle 10g express
    -I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
    -Table is composed of column like id,timestamps,A,B and more.
    Thanks in advance
    PierreI will call it a very Wrong design.
    It is a wrong Table Design. You are duplicating the data in table and not complying with the Database Normalization rules.
    How about Verifying if Column A & B are NULL before inserting and inserting another row and avoiding it in Triggers?
    If you are bent to achieve this, below code might be helpful. However, I would never go with this approach. If you would care about explaining the reason for going ahead with such a data model, people could suggest better alternative that might conform with Normalization rules.
    create or replace trigger trg_test_table
    after insert on test_table
    for each row
    declare
      pragma autonomous_transaction;
    begin
      if :new.col_a is null and :new.col_b is null then
        insert into test_table
        select 2, systimestamp, col_a, col_b
          from test_table
         where pk_col = (select max(pk_col) from test_table b where b.pk_col < :new.pk_col);
      end if;
      commit;
    end trg_test_table;Read SQL and PL/SQL FAQ and post the mentioned details.
    Do not forget to mention output from
    select * from v$version;

  • How can I save the RSS feed from awebsite on the toolbar so it will show all the content in a folding menu?

    In the previous versions of FireFox I Could push the RSS sign in the addressbar and choose to have the feed on my bookmark toolbar. In that way i could push the feed name on the bar and see names of feeds i have read and them I havent read and decide whiche one to go to. today when i save a bookmark to the toolbar and then push it there, instead of showing me the different content in a folding menu like before, the whole page jumps to the website. How can I save the feed from the website like before?

    - Go to the Tools menu - select Options.
    - At the top of the Options window, click 'Applications'.
    - Scroll down to 'Web Feed' and make sure the Action is set to 'Add Live Bookmarks in Firefox'.
    - Click OK.
    - Navigate to the desired website, go to the Bookmarks Menu and select 'Subscribe to this Page'

  • How do you email contents of favorites folder without having to copy and paste each item in the folder individually?

    how do you email contents of favorites folder without having to copy and paste each item in the folder individually?

    Zip (compress) the folder before you send it.

  • How to read the contents of images folder using AS3

    Hi,
    I'd like to load the images in the folder dynamically without using XML.
    Is there a mechanism in AS3 that enables me to read directly the content of images folder directly without using XML or should I use php to do that?
    Thanks

    Yes you can do that without XML. You need to use the Loader() class to dynamically load the images. Check the documentation of the loader class.

  • How can I copy or print the contents of a folder I created in the the folder section of the inbox

    Selecting the contents of the folder and hitting Ctrl C doesn't do it

    If, by contents, you mean a list of the sender, subject, date etc., use [https://addons.mozilla.org/en-us/thunderbird/addon/importexporttools/ ImportExportTools] and right-click the folder, ImportExportTools/Export all messages in the folder/just index (csv or html).
    http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html

  • How to show no. of contents in each folder in a KM navigation iView....

    Hi everyone,
    Requirement -
    we need to display a KM Navigation iview which shows the count i.e. no. of the contents in each folder.
    Scenario -
    I have tried changing this property - in the resource renderer and have created a new layout set and a layout profile.
    However this doesnt seem to work.
    Please if anyone can help me get the count of the contents in each folder in the KM Navigation iview.
    Thanks and Regards,
    Amol Ghodekar

    Hi Amol,
    see: Number of files in folder
    Hope this helps,
    Robert

  • How to put a file lock on the contents of a folder and sub folders?

    Initally I recursively went through the children of the folder and created a file lock for each child, however after abour 2025 locks i recieved a Too many open files exception.
    Is it possible to lock a folder such that the contents of the folder cannot be changed? and would that stop the Too many open files Exception?

    Hmm.... I would have thought that this was a reasonably common problem. If no-one here can help directly, can someone point me to a forum or similar which may be able to help me?
    Cheers

  • I have an app on my Iphone4 called my folder. How can I sync the contents of the folder (pics and videos) to my new 4S?  The app is on the new device but its empty.  Thanks

    I purchased an app called my folder and after I did the sync, I lost all of the contents of this folder.  Is there a way to get the pictures and videos onto my new device?  Thank you

    Restart your iPad.

  • How can I move a mailbox folder and messages in it to a My Documents folder?

    I use meailboxes in Mail to keep project communications in while I am working on them. When the project is completed, I would like to move that mailbox and all its contents to a folder in My Documents. How do I do that?

    Hello:
    When you export a mailbox, it is exported with a .mbox suffix.  You would need to import it to read it.
    I thought about what you want to do...
    If you use Time Machine, you could simply delete the folder you are finished with....you could always retrieve the entire mailbox or specific messages.
    I do not know of a way that you can simply move the messages to someplace else on your system.
    Barry

Maybe you are looking for