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);
// update content context
fromContentFragmentImpl.removeFragmentById(fragmentId);
toContentFragmentImpl.getFragments().add(contentFragmentImpl);