throw new IllegalArgumentException("Cannot use move fragment operation between pages");
}
boolean contentFragmentIsReference = (contentFragmentImpl.getReference() != null);
// retrieve current page or template and fragments from page manager
BaseFragmentsElement pageOrTemplate = getPageOrTemplate(contentPageImpl.getPageOrTemplate().getPath());
BaseFragmentElement fromFragmentElement = pageOrTemplate.getFragmentById(fromContentFragmentImpl.getFragment().getId());
if (!(fromFragmentElement instanceof Fragment))
{
throw new IllegalArgumentException("Move from fragmentId and page not consistent");
}
Fragment fromFragment = (Fragment)fromFragmentElement;
String pageFragmentId = (contentFragmentIsReference ? contentFragmentImpl.getReference().getId() : contentFragmentImpl.getFragment().getId());
BaseFragmentElement fragment = fromFragment.getFragmentById(pageFragmentId);
if (fragment == null)
{
throw new IllegalArgumentException("Move fragmentId and page not consistent");
}
BaseFragmentElement toFragmentElement = pageOrTemplate.getFragmentById(toContentFragmentImpl.getFragment().getId());
if (!(toFragmentElement instanceof Fragment))
{
throw new IllegalArgumentException("Move to fragmentId and page not consistent");
}
Fragment toFragment = (Fragment)toFragmentElement;
// check for edit permission
pageOrTemplate.checkAccess(JetspeedActions.EDIT);
// move page fragment and update page in page manager
fragment = fromFragment.removeFragmentById(fragment.getId());
toFragment.getFragments().add(fragment);
updatePage(pageOrTemplate);