Workspace workspace = session.getWorkspace();
//
org.gatein.mop.api.workspace.Page srcPage;
ObjectType<Site> srcType = Utils.objectType(src.site.getType());
Site srcSite = workspace.getSite(srcType, src.site.getName());
if (srcSite == null) {
throw new PageServiceException(PageError.CLONE_NO_SRC_SITE, "Could not clone page " + src.getName()
+ "from non existing site of type " + src.site.getType() + " with id " + src.site.getName());
} else {
org.gatein.mop.api.workspace.Page root = srcSite.getRootPage();
org.gatein.mop.api.workspace.Page pages = root.getChild("pages");
srcPage = pages.getChild(src.getName());
}
//
if (srcPage == null) {
throw new PageServiceException(PageError.CLONE_NO_SRC_PAGE, "Could not clone non existing page " + src.getName()
+ " from site of type " + src.site.getType() + " with id " + src.site.getName());
}
//
ObjectType<Site> dstType = Utils.objectType(dst.getSite().getType());
Site dstSite = workspace.getSite(dstType, dst.getSite().getName());
if (dstSite == null) {
throw new PageServiceException(PageError.CLONE_NO_DST_SITE, "Could not clone page " + dst.name
+ "to non existing site of type " + dst.site.getType() + " with id " + dst.site.getName());
}
//
org.gatein.mop.api.workspace.Page dstRoot = dstSite.getRootPage();
org.gatein.mop.api.workspace.Page dstPages = dstRoot.getChild("pages");
if (dstPages.getChild(dst.getName()) != null) {
throw new PageServiceException(PageError.CLONE_DST_ALREADY_EXIST, "Could not clone page " + dst.name
+ "to existing page " + dst.site.getType() + " with id " + dst.site.getName());
}