org.olat.ims.cp
Class CPManagerImpl

java.lang.Object
  extended by org.olat.ims.cp.CPManager
      extended by org.olat.ims.cp.CPManagerImpl

public class CPManagerImpl
extends CPManager

The CP manager implementation.

In many cases, method calls are delegated to the content package object.

Initial Date: 04.07.2008

Author:
Sergio Trentini

Method Summary
 java.lang.String addBlankPage(ContentPackage cp, java.lang.String title)
          Adds a blank new to the end of the organization
 java.lang.String addBlankPage(ContentPackage cp, java.lang.String title, java.lang.String parentNodeID)
          Adds a blank new as a child of the node with given id
 boolean addElement(ContentPackage cp, org.dom4j.tree.DefaultElement newElement)
           
 boolean addElement(ContentPackage cp, org.dom4j.tree.DefaultElement newElement, java.lang.String parentIdentifier, int position)
          Adds a new Element to the manifest.
 boolean addElementAfter(ContentPackage cp, org.dom4j.tree.DefaultElement newElement, java.lang.String identifier)
          adds a element to the manifest.
 java.lang.String copyElement(ContentPackage cp, java.lang.String sourceID)
          duplicates the element with id "sourceID" and inserts it right after the source-Element
 ContentPackage createNewCP(OLATResourceable ores, java.lang.String initalPageTitle)
          creates a new, empty ContentPackage
 org.dom4j.tree.DefaultDocument getDocument(ContentPackage cp)
          Returns the DefaultDocument of the ContentPackage cp
 org.dom4j.tree.DefaultElement getElementByIdentifier(ContentPackage cp, java.lang.String identifier)
          this is case-sensitive!
 CPOrganization getFirstOrganizationInManifest(ContentPackage cp)
          Returns the top most element (if there are more than one)
 CPPage getFirstPageToDisplay(ContentPackage cp)
          Returns the first (topmost) resource to display
 java.lang.String getItemTitle(ContentPackage cp, java.lang.String itemID)
          returns the title of an item with given id.
 java.lang.String getPageByItemId(ContentPackage cp, java.lang.String itemIdentifier)
           
 CPTreeDataModel getTreeDataModel(ContentPackage cp)
          Returns the CPTreeDataModel which is needed by the TreeController used for gui
 boolean isSingleUsedResource(CPResource res, ContentPackage cp)
          Determines if the given Resource is referenced / linked only by one item-element.
 ContentPackage load(VFSContainer directory, OLATResourceable ores)
          Generates a new Instance of ContentPackage and loads the xmlmanifest
 void moveElement(ContentPackage cp, java.lang.String nodeID, java.lang.String newParentID, int position)
          Moves a Element(with id "sourceID") in cp.
 void removeElement(ContentPackage cp, java.lang.String identifier, boolean deleteResource)
          removes a element from the manifest.
 void updatePage(ContentPackage cp, CPPage page)
          updates the according elements in the datastructure
 void writeToFile(ContentPackage cp)
          writes the ContentPackage-tree to the manifest-xml-file
 VFSLeaf writeToZip(ContentPackage cp)
          Writes the cp to a zip file.
 
Methods inherited from class org.olat.ims.cp.CPManager
getInstance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public ContentPackage load(VFSContainer directory,
                           OLATResourceable ores)
Description copied from class: CPManager
Generates a new Instance of ContentPackage and loads the xmlmanifest

Specified by:
load in class CPManager
Returns:
See Also:
org.olat.ims.cp.CPManager#load(org.olat.core.util.vfs.VFSContainer)

createNewCP

public ContentPackage createNewCP(OLATResourceable ores,
                                  java.lang.String initalPageTitle)
Description copied from class: CPManager
creates a new, empty ContentPackage

Specified by:
createNewCP in class CPManager
Returns:
the newly created CP
See Also:
org.olat.ims.cp.CPManager#createNewCP(org.olat.core.id.OLATResourceable)

isSingleUsedResource

public boolean isSingleUsedResource(CPResource res,
                                    ContentPackage cp)
Description copied from class: CPManager
Determines if the given Resource is referenced / linked only by one item-element. In other words: if the given resource is used only bye one item, this will return true

Specified by:
isSingleUsedResource in class CPManager
Returns:
if given Resource is only used by one item-element, this returns true

addBlankPage

public java.lang.String addBlankPage(ContentPackage cp,
                                     java.lang.String title)
Description copied from class: CPManager
Adds a blank new to the end of the organization

Specified by:
addBlankPage in class CPManager
Returns:

addBlankPage

public java.lang.String addBlankPage(ContentPackage cp,
                                     java.lang.String title,
                                     java.lang.String parentNodeID)
Description copied from class: CPManager
Adds a blank new as a child of the node with given id

Specified by:
addBlankPage in class CPManager
Returns:

updatePage

public void updatePage(ContentPackage cp,
                       CPPage page)
Description copied from class: CPManager
updates the according elements in the datastructure

Specified by:
updatePage in class CPManager

addElement

public boolean addElement(ContentPackage cp,
                          org.dom4j.tree.DefaultElement newElement)
Specified by:
addElement in class CPManager
Returns:
See Also:
CPManager.addElement(org.olat.ims.cp.ContentPackage, org.dom4j.tree.DefaultElement)

addElement

public boolean addElement(ContentPackage cp,
                          org.dom4j.tree.DefaultElement newElement,
                          java.lang.String parentIdentifier,
                          int position)
Description copied from class: CPManager
Adds a new Element to the manifest. the new Element is inserted as a child of the element with id "parentIdentifier" if new position is null, element is added at the end

Specified by:
addElement in class CPManager
newElement - the new Element to add
parentIdentifier - the identifier of the parent element
Returns:
true if successfully added
See Also:
org.olat.ims.cp.CPManager#addElement(org.olat.ims.cp.ContentPackage, org.dom4j.tree.DefaultElement, java.lang.String)

addElementAfter

public boolean addElementAfter(ContentPackage cp,
                               org.dom4j.tree.DefaultElement newElement,
                               java.lang.String identifier)
Description copied from class: CPManager
adds a element to the manifest. Element is inserted after the Element with id "identifier"

Specified by:
addElementAfter in class CPManager
Parameters:
cp - the contentPackage where the manipulation is performed on
newElement - the new Element to Add
identifier - the identifier of the previous element
Returns:
true if successfully added
See Also:
CPManager.addElementAfter(org.olat.ims.cp.ContentPackage, org.dom4j.tree.DefaultElement, java.lang.String)

removeElement

public void removeElement(ContentPackage cp,
                          java.lang.String identifier,
                          boolean deleteResource)
Description copied from class: CPManager
removes a element from the manifest. If deleting an , all referenced resources are removed from the manifest as well.

Specified by:
removeElement in class CPManager
See Also:
org.olat.ims.cp.CPManager#removeElement(org.olat.ims.cp.ContentPackage, java.lang.String)

moveElement

public void moveElement(ContentPackage cp,
                        java.lang.String nodeID,
                        java.lang.String newParentID,
                        int position)
Description copied from class: CPManager
Moves a Element(with id "sourceID") in cp. Inserts it into (as child) Element with id "targetID"

Specified by:
moveElement in class CPManager
See Also:
CPManager.moveElement(org.olat.ims.cp.ContentPackage, java.lang.String, java.lang.String, int)

copyElement

public java.lang.String copyElement(ContentPackage cp,
                                    java.lang.String sourceID)
Description copied from class: CPManager
duplicates the element with id "sourceID" and inserts it right after the source-Element

Specified by:
copyElement in class CPManager
Returns:
String the identifier of the newly generated element
See Also:
CPManager.copyElement(org.olat.ims.cp.ContentPackage, java.lang.String)

getDocument

public org.dom4j.tree.DefaultDocument getDocument(ContentPackage cp)
Description copied from class: CPManager
Returns the DefaultDocument of the ContentPackage cp

Specified by:
getDocument in class CPManager
Returns:
the xml Document of the cp
See Also:
CPManager.getDocument(org.olat.ims.cp.ContentPackage)

getItemTitle

public java.lang.String getItemTitle(ContentPackage cp,
                                     java.lang.String itemID)
Description copied from class: CPManager
returns the title of an item with given id. if element with id is not found or is not an , an empty String is returned

Specified by:
getItemTitle in class CPManager
Returns:
the title of the

getElementByIdentifier

public org.dom4j.tree.DefaultElement getElementByIdentifier(ContentPackage cp,
                                                            java.lang.String identifier)
Description copied from class: CPManager
this is case-sensitive!

Specified by:
getElementByIdentifier in class CPManager
Returns:
an Element by its IDENTIFIER attribute starting at the manifests root element. This will do a deep recursive search
See Also:
CPManager.getElementByIdentifier(org.olat.ims.cp.ContentPackage, java.lang.String)

getTreeDataModel

public CPTreeDataModel getTreeDataModel(ContentPackage cp)
Description copied from class: CPManager
Returns the CPTreeDataModel which is needed by the TreeController used for gui

Specified by:
getTreeDataModel in class CPManager
Returns:

getFirstOrganizationInManifest

public CPOrganization getFirstOrganizationInManifest(ContentPackage cp)
Description copied from class: CPManager
Returns the top most element (if there are more than one)

Specified by:
getFirstOrganizationInManifest in class CPManager
Returns:
See Also:
CPManager.getFirstOrganizationInManifest(org.olat.ims.cp.ContentPackage)

getFirstPageToDisplay

public CPPage getFirstPageToDisplay(ContentPackage cp)
Description copied from class: CPManager
Returns the first (topmost) resource to display

Specified by:
getFirstPageToDisplay in class CPManager
Returns:
See Also:
CPManager.getFirstPageToDisplay(org.olat.ims.cp.ContentPackage)

writeToFile

public void writeToFile(ContentPackage cp)
Description copied from class: CPManager
writes the ContentPackage-tree to the manifest-xml-file

Specified by:
writeToFile in class CPManager
See Also:
org.olat.ims.cp.CPManager#WriteToFile(org.olat.ims.cp.ContentPackage)

writeToZip

public VFSLeaf writeToZip(ContentPackage cp)
Description copied from class: CPManager
Writes the cp to a zip file.

Specified by:
writeToZip in class CPManager
Returns:
The VFS zip archive
See Also:
CPManager.writeToZip(org.olat.ims.cp.ContentPackage)

getPageByItemId

public java.lang.String getPageByItemId(ContentPackage cp,
                                        java.lang.String itemIdentifier)
Specified by:
getPageByItemId in class CPManager
Returns:
See Also:
CPManager.getPageByItemId(org.olat.ims.cp.ContentPackage, java.lang.String)