Content
is a piece of information, normally created directly
* by a user, that can be composed and presented in a page or menu.
*
* @author cfgi
* @author lpec
* @author pcma
*/
public abstract class Content extends Content_Base {
public Content() {
super();
setRootDomainObject(RootDomainObject.getInstance());
setOjbConcreteClass(getClass().getName());
setCreationDate(new DateTime());
setContentId(UUID.randomUUID().toString());
}
public abstract boolean isParentAccepted(Container parent);
public boolean isAnAnnouncement() {
return false;
}
public boolean isAnAnnouncementBoard() {
return false;
}
public true
if the item is available for the person hold in
* the context
*/
public boolean isAvailable(FunctionalityContext context) {
if (context == null) {
return true;
}
if (getAvailabilityPolicy() == null) {
return true;
}
try {
return getAvailabilityPolicy().isAvailable(context);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public abstract List* This delete method is a template method for all contents. First * {@link #checkDeletion()} is called. If the object is not deletable then a * subclass must throw a {@link DomainException} explaining why. If no * exception is thrown then {@link #disconnect()} is called to allow the * object to remove any specific relations. After that {@link #deleteSelf()} * is called to allow object finalization. * *
* After all this the standard relations of a functionality are removed and
* the object is marked for deletion in the database.
*
* @throws DomainException
* if the content cannot be deleted
*/
public void delete() {
checkDeletion();
disconnect();
deleteDomainObject();
}
/**
* Verifies if this content can be deleted.
*
* @return true
by default
*/
public boolean isDeletable() {
return true;
}
/**
* Checks if this content can be deleted and throws and exception if it
* can't.
*
* @throws DomainException
* if this item cannot be deleted
*/
protected void checkDeletion() {
if (!isDeletable()) {
throw new DomainException("content.delete.notAvailable");
}
}
/**
* Removes any specific relations the item has. Subclasses that override
* this method must call super to remove all relations.
*
*
* If other objects should be deleted because of this object beeing deleted,
* this is the place to do it.
*/
protected void disconnect() {
disconnectContent();
}
protected void disconnectContent() {
if (hasAvailabilityPolicy()) {
getAvailabilityPolicy().delete();
}
for (Node node : getParents()) {
node.delete();
}
for (Container container : getInitialContainer()) {
container.setInitialContent(null);
}
removeCreator();
removePortal();
removeRootDomainObject();
}
/**
* Finalizes the state of this content, that is, does the last finalization
* after beeing disconnected but before being marked for deleting from the
* persistent storage.
*/
protected void deleteSelf() {
// do nothing
}
public boolean isAvailable() {
return isAvailable(Functionality.getCurrentContext());
}
// This method is to determine if the content is publicly available in the
// contents' structure,
// i.e., whether it should be subjected to checksum verification.
public boolean isPublic() {
if (this instanceof Module) {
return false;
}
final AvailabilityPolicy availabilityPolicy = getAvailabilityPolicy();
if (availabilityPolicy == null) {
for (final Node node : getParentsSet()) {
final Content content = node.getParent();
if (content.isPublic()) {
return true;
}
}
return getParentsSet().isEmpty();
} else {
return isPublicGroup(availabilityPolicy.getTargetGroup());
}
}
private boolean isPublicGroup(final Group group) {
return group instanceof EveryoneGroup
|| (group instanceof ExpressionGroup && isPublicGroup(((ExpressionGroup) group).getGroup()));
}
public Boolean getPublicAvailable() {
return isPublic();
}
public abstract Collection