* Such actions would result in model-errors.
*/
public void moveContent(ContentVO contentVO, Integer newParentContentId, Database db) throws ConstraintException, SystemException
{
ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
//Content content = null;
//Content newParentContent = null;
//Content oldParentContent = null;
//Validation that checks the entire object
contentVO.validate();
if(newParentContentId == null)
{
logger.warn("You must specify the new parent-content......");
throw new ConstraintException("Content.parentContentId", "3303");
}
if(contentVO.getId().intValue() == newParentContentId.intValue())
{
logger.warn("You cannot have the content as it's own parent......");
throw new ConstraintException("Content.parentContentId", "3301");
}
Content content = getMediumContentWithId(contentVO.getContentId(), db);
//oldParentContent = content.getParentContent();
//newParentContent = getContentWithId(newParentContentId, db);
if(content.getValueObject().getParentContentId() == null || content.getValueObject().getParentContentId().intValue() == newParentContentId.intValue())
{
logger.warn("You cannot specify the same folder as it originally was located in......");
throw new ConstraintException("Content.parentContentId", "3304");
}
//ContentVO tempContent = newParentContent.getParentContent();
ContentVO newParentContentVO = getContentVOWithId(newParentContentId, db);
Integer parentContentId = newParentContentVO.getParentContentId();
while(parentContentId != null)
{
ContentVO tempContent = getContentVOWithId(parentContentId, db);
if(tempContent.getId().intValue() == content.getId().intValue())
{
logger.warn("You cannot move the content to a child under it......");
throw new ConstraintException("Content.parentContentId", "3302");
}
parentContentId = tempContent.getParentContentId();
}
//oldParentContent.getChildren().remove(content);
//content.setParentContent((ContentImpl)newParentContent);
content.getValueObject().setParentContentId(newParentContentId);
changeRepositoryRecursive(content, newParentContentVO.getRepositoryId());
//content.setRepository(newParentContent.getRepository());
//newParentContent.getChildren().add(content);
//If any of the validations or setMethods reported an error, we throw them up now before create.
ceb.throwIfNotEmpty();
}