associatedSourceContentlets = getHTMLPageMultiTree(source);
} else if (copyMode == HTMLPageAPI.CopyMode.COPY_SOURCE_CONTENT) {
associatedSourceContentlets = getHTMLPageMultiTree(source);
Contentlet contentlet;
FolderAPI folderAPI = APILocator.getFolderAPI();
Host systemHost = hostAPI.findSystemHost(user, respectFrontendRoles);
Folder systemFolder = folderAPI.findSystemFolder();
Host destinationHost = hostAPI.find(destination.getHostId(), user, respectFrontendRoles);
for (MultiTree multiTree : associatedSourceContentlets) {
contentlet = contentletAPI.findContentletByIdentifier(multiTree.getChild(), false, 0, user,
respectFrontendRoles);
Host contentletHost = null;
if(!UtilMethods.isSet(contentlet.getHost()) && !contentlet.getHost().equals(systemHost.getInode())) {
contentletHost = hostAPI.find(contentlet.getHost(), user, respectFrontendRoles);
}
Folder contentletFolder = null;
if(!UtilMethods.isSet(contentlet.getFolder()) && !contentlet.getFolder().equals(systemFolder.getInode())) {
contentletFolder = folderAPI.find(contentlet.getFolder(),user,false);
}
if (contentletFolder != null) {
Folder contentletDestFolder = folderAPI.createFolders(APILocator.getIdentifierAPI().find(contentletFolder).getPath(), destinationHost,user,false);
contentlet = contentletAPI.copyContentlet(contentlet, contentletDestFolder, user, respectFrontendRoles);
} else if (contentletHost != null) {
contentlet = contentletAPI.copyContentlet(contentlet, destinationHost, user, respectFrontendRoles);
} else {
contentlet = contentletAPI.copyContentlet(contentlet, user, respectFrontendRoles);