com.dotmarketing.portlets.contentlet.business
Class ContentletFactoryDBImpl

java.lang.Object
  extended by com.dotmarketing.portlets.contentlet.business.ContentletFactory
      extended by com.dotmarketing.portlets.contentlet.business.ContentletFactoryDBImpl

public class ContentletFactoryDBImpl
extends ContentletFactory

Since:
1.6
Author:
Jason Tesser

Constructor Summary
ContentletFactoryDBImpl()
           
 
Method Summary
protected  void cleanField(java.lang.String structureInode, Field field)
           
protected  void cleanHostField(java.lang.String structureInode)
           
protected  void cleanIdentifierHostField(java.lang.String structureInode)
          Set the system host in the identifier of all the contents of the specified structure.
protected  long contentletCount()
          gets the number of contentlets in the system.
protected  long contentletIdentifierCount()
          gets the number of contentlet identifiers in the system.
 Contentlet convertContentletToFatContentlet(Contentlet cont, Contentlet fatty)
          Deprecated.  
 Contentlet convertFatContentletToContentlet(Contentlet fatty)
          Deprecated.  
protected  java.util.List<java.util.Map<java.lang.String,java.io.Serializable>> DBSearch(GenericQueryFactory.Query query, java.util.List<Field> fields, java.lang.String structureInode)
           
protected  void delete(java.util.List<Contentlet> contentlets)
          deletes all passed in contentlets.
protected  int deleteOldContent(java.util.Date deleteFrom, int offset)
           
protected  Contentlet find(java.lang.String inode)
          This method gets a Contentlet object given the inode
protected  java.util.List<Contentlet> findAllCurrent()
          Use to get all contentlets live/working contentlets
protected  java.util.List<Contentlet> findAllCurrent(int offset, int limit)
          Use to get all contentlets live/working contentlets
protected  java.util.List<Contentlet> findAllUserVersions(Identifier identifier)
          Retrieves all versions for a contentlet identifier checked in by a real user meaning not the system user
protected  java.util.List<Contentlet> findAllVersions(Identifier identifier)
          Retrieves all versions for a contentlet identifier
protected  java.util.List<Contentlet> findByStructure(java.lang.String structureInode, int limit, int offset)
          Returns all Contentlets for a specific structure
protected  Contentlet findContentletByIdentifier(java.lang.String identifier, java.lang.Boolean live, java.lang.Long languageId)
          Retrieves a contentlet from the database based on its identifier
protected  Contentlet findContentletForLanguage(long languageId, Identifier contentletId)
          Returns a live Contentlet Object for a given language
protected  java.util.List<Contentlet> findContentlets(java.util.List<java.lang.String> inodes)
          Gets a list of Contentlets from a passed in list of inodes.
protected  java.util.List<Contentlet> findContentletsByIdentifier(java.lang.String identifier, java.lang.Boolean live, java.lang.Long languageId)
          Retrieves a contentlet from the database based on its identifier
protected  java.util.List<Contentlet> findContentletsWithFieldValue(java.lang.String structureInode, Field field)
          This method return all the contentlets with the specified structureInode and the specified Field cannot be null.
protected  java.util.List<Contentlet> findPageContentlets(java.lang.String HTMLPageIdentifier, java.lang.String containerIdentifier, java.lang.String orderby, boolean working, long languageId)
          Returns the contentlets on a given page.
protected  java.util.List<Contentlet> getContentletsByIdentifier(java.lang.String identifier)
          Retrieves all contentlets from the database based on its identifier (including multilingual versions)
protected  java.util.List<Contentlet> getContentletsByIdentifier(java.lang.String identifier, java.lang.Boolean live)
          Retrieves all contentlets from the database based on its identifier (including multilingual versions)
protected  java.util.List<Contentlet> getReferencingContentlet(File file, boolean live)
          Gets all contentlets referenced by this file
protected  java.util.List<File> getRelatedFiles(Contentlet contentlet)
          Gets all related files
protected  Identifier getRelatedIdentifier(Contentlet contentlet, java.lang.String relationshipType)
          Gets a file with a specific relationship type to the passed in contentlet
protected  java.util.List<Link> getRelatedLinks(Contentlet contentlet)
          Gets all related links
protected  LuceneHits indexSearch(java.lang.String luceneQuery, int limit, int offset, java.lang.String sortBy)
          The search here takes a lucene query and pulls LuceneHits for you.
protected  void lock(java.lang.String contentletInode, com.liferay.portal.model.User user)
          Usually you would use the save method to alter the contentlet from the API but in the unlock case there are concurrency issues where you can get 2 working contentlets in the DB until you checkin again.
protected  void removeUserReferences(java.lang.String userId)
          Method will remove User References of the given userId in Contentlet
protected  Contentlet save(Contentlet contentlet)
          Saves a Contentlet
protected  java.util.List<Contentlet> search(java.lang.String luceneQuery, int limit, int offset, java.lang.String sortBy)
          The search here takes a lucene query and pulls Contentlets for you.
protected  void unlock(java.lang.String contentletInode, com.liferay.portal.model.User user)
          Usually you would use the save method to alter the contentlet from the API but in the unlock case there are concurrency issues where you can get 2 working contentlets in the DB until you checkin again.
protected  void UpdateContentWithSystemHost(java.lang.String hostIdentifier)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentletFactoryDBImpl

public ContentletFactoryDBImpl()
Method Detail

findAllCurrent

protected java.util.List<Contentlet> findAllCurrent()
                                             throws DotDataException
Description copied from class: ContentletFactory
Use to get all contentlets live/working contentlets

Specified by:
findAllCurrent in class ContentletFactory
Returns:
Throws:
DotDataException

findAllCurrent

protected java.util.List<Contentlet> findAllCurrent(int offset,
                                                    int limit)
                                             throws DotDataException
Description copied from class: ContentletFactory
Use to get all contentlets live/working contentlets

Specified by:
findAllCurrent in class ContentletFactory
Returns:
Throws:
DotDataException

find

protected Contentlet find(java.lang.String inode)
                   throws DotDataException
Description copied from class: ContentletFactory
This method gets a Contentlet object given the inode

Specified by:
find in class ContentletFactory
Returns:
Throws:
DotDataException

findContentletForLanguage

protected Contentlet findContentletForLanguage(long languageId,
                                               Identifier contentletId)
                                        throws DotDataException
Returns a live Contentlet Object for a given language

Specified by:
findContentletForLanguage in class ContentletFactory
Parameters:
languageId -
inode -
Returns:
Contentlet
Throws:
DotDataException

findContentletByIdentifier

protected Contentlet findContentletByIdentifier(java.lang.String identifier,
                                                java.lang.Boolean live,
                                                java.lang.Long languageId)
                                         throws DotDataException
Description copied from class: ContentletFactory
Retrieves a contentlet from the database based on its identifier

Specified by:
findContentletByIdentifier in class ContentletFactory
live - Retrieves the live version if false retrieves the working version
Returns:
Throws:
DotDataException

findContentletsByIdentifier

protected java.util.List<Contentlet> findContentletsByIdentifier(java.lang.String identifier,
                                                                 java.lang.Boolean live,
                                                                 java.lang.Long languageId)
                                                          throws DotDataException
Description copied from class: ContentletFactory
Retrieves a contentlet from the database based on its identifier

Specified by:
findContentletsByIdentifier in class ContentletFactory
live - Retrieves the live version if false retrieves the working version
Returns:
Throws:
DotDataException

findContentlets

protected java.util.List<Contentlet> findContentlets(java.util.List<java.lang.String> inodes)
                                              throws DotDataException
Description copied from class: ContentletFactory
Gets a list of Contentlets from a passed in list of inodes.

Specified by:
findContentlets in class ContentletFactory
Returns:
Throws:
DotDataException

save

protected Contentlet save(Contentlet contentlet)
                   throws DotDataException
Description copied from class: ContentletFactory
Saves a Contentlet

Specified by:
save in class ContentletFactory
Returns:
Throws:
DotDataException

lock

protected void lock(java.lang.String contentletInode,
                    com.liferay.portal.model.User user)
             throws DotDataException
Description copied from class: ContentletFactory
Usually you would use the save method to alter the contentlet from the API but in the unlock case there are concurrency issues where you can get 2 working contentlets in the DB until you checkin again. This method will load the contentlet from the db and set the lock to true

Specified by:
lock in class ContentletFactory
Throws:
DotDataException

unlock

protected void unlock(java.lang.String contentletInode,
                      com.liferay.portal.model.User user)
               throws DotDataException
Description copied from class: ContentletFactory
Usually you would use the save method to alter the contentlet from the API but in the unlock case there are concurrency issues where you can get 2 working contentlets in the DB until you checkin again. This method will load the contentlet from the db and set the lock to false

Specified by:
unlock in class ContentletFactory
Throws:
DotDataException

search

protected java.util.List<Contentlet> search(java.lang.String luceneQuery,
                                            int limit,
                                            int offset,
                                            java.lang.String sortBy)
                                     throws ParseException,
                                            DotDataException
Description copied from class: ContentletFactory
The search here takes a lucene query and pulls Contentlets for you. You can pass sortBy as null if you do not have a field to sort by. limit should be 0 if no limit and the offset should be -1 is you are not paginating.

Specified by:
search in class ContentletFactory
Returns:
Throws:
ParseException
DotDataException

indexSearch

protected LuceneHits indexSearch(java.lang.String luceneQuery,
                                 int limit,
                                 int offset,
                                 java.lang.String sortBy)
                          throws ParseException
Description copied from class: ContentletFactory
The search here takes a lucene query and pulls LuceneHits for you. You can pass sortBy as null if you do not have a field to sort by. limit should be 0 if no limit and the offset should be -1 is you are not paginating. The returned list will be filtered with only the contentlets that the user can read(use). you can of course also pass permissions to further limit in the lucene query itself

Specified by:
indexSearch in class ContentletFactory
Returns:
Throws:
ParseException

findByStructure

protected java.util.List<Contentlet> findByStructure(java.lang.String structureInode,
                                                     int limit,
                                                     int offset)
                                              throws DotDataException
Description copied from class: ContentletFactory
Returns all Contentlets for a specific structure

Specified by:
findByStructure in class ContentletFactory
Returns:
Throws:
DotDataException

findPageContentlets

protected java.util.List<Contentlet> findPageContentlets(java.lang.String HTMLPageIdentifier,
                                                         java.lang.String containerIdentifier,
                                                         java.lang.String orderby,
                                                         boolean working,
                                                         long languageId)
                                                  throws DotDataException
Description copied from class: ContentletFactory
Returns the contentlets on a given page. You can pass -1 for languageId if you don't want to query to pull based on languages or 0 if you want to get the default language

Specified by:
findPageContentlets in class ContentletFactory
Returns:
Throws:
DotDataException

getContentletsByIdentifier

protected java.util.List<Contentlet> getContentletsByIdentifier(java.lang.String identifier,
                                                                java.lang.Boolean live)
                                                         throws DotDataException
Description copied from class: ContentletFactory
Retrieves all contentlets from the database based on its identifier (including multilingual versions)

Specified by:
getContentletsByIdentifier in class ContentletFactory
live - Retrieves the live version if false retrieves the working version
Returns:
Throws:
DotDataException

getContentletsByIdentifier

protected java.util.List<Contentlet> getContentletsByIdentifier(java.lang.String identifier)
                                                         throws DotDataException
Description copied from class: ContentletFactory
Retrieves all contentlets from the database based on its identifier (including multilingual versions)

Specified by:
getContentletsByIdentifier in class ContentletFactory
Returns:
Throws:
DotDataException

getRelatedIdentifier

protected Identifier getRelatedIdentifier(Contentlet contentlet,
                                          java.lang.String relationshipType)
                                   throws DotDataException
Description copied from class: ContentletFactory
Gets a file with a specific relationship type to the passed in contentlet

Specified by:
getRelatedIdentifier in class ContentletFactory
Returns:
Throws:
DotDataException

getRelatedFiles

protected java.util.List<File> getRelatedFiles(Contentlet contentlet)
                                        throws DotDataException
Description copied from class: ContentletFactory
Gets all related files

Specified by:
getRelatedFiles in class ContentletFactory
Returns:
Throws:
DotDataException

getRelatedLinks

protected java.util.List<Link> getRelatedLinks(Contentlet contentlet)
                                        throws DotDataException
Description copied from class: ContentletFactory
Gets all related links

Specified by:
getRelatedLinks in class ContentletFactory
Returns:
Throws:
DotDataException

getReferencingContentlet

protected java.util.List<Contentlet> getReferencingContentlet(File file,
                                                              boolean live)
                                                       throws DotDataException
Description copied from class: ContentletFactory
Gets all contentlets referenced by this file

Specified by:
getReferencingContentlet in class ContentletFactory
Parameters:
file - asset.
live - mode or not.
Returns:
Contentlets related to the given file. Null if no related files were found.
Throws:
DotDataException

delete

protected void delete(java.util.List<Contentlet> contentlets)
               throws DotDataException
Description copied from class: ContentletFactory
deletes all passed in contentlets. This is not an archive. it is permanent

Specified by:
delete in class ContentletFactory
Throws:
DotDataException

findAllUserVersions

protected java.util.List<Contentlet> findAllUserVersions(Identifier identifier)
                                                  throws DotDataException
Description copied from class: ContentletFactory
Retrieves all versions for a contentlet identifier checked in by a real user meaning not the system user

Specified by:
findAllUserVersions in class ContentletFactory
Returns:
Throws:
DotDataException

findAllVersions

protected java.util.List<Contentlet> findAllVersions(Identifier identifier)
                                              throws DotDataException
Description copied from class: ContentletFactory
Retrieves all versions for a contentlet identifier

Specified by:
findAllVersions in class ContentletFactory
Returns:
Throws:
DotDataException

convertFatContentletToContentlet

public Contentlet convertFatContentletToContentlet(Contentlet fatty)
                                            throws DotDataException
Deprecated. 

This class should not be used as it is only a temp solution until we move to JCR-170

Specified by:
convertFatContentletToContentlet in class ContentletFactory
Parameters:
fatty -
Returns:
Throws:
DotDataException

convertContentletToFatContentlet

public Contentlet convertContentletToFatContentlet(Contentlet cont,
                                                   Contentlet fatty)
                                            throws DotDataException
Deprecated. 

This class should not be used as it is only a temp solution until we move to JCR-170

Specified by:
convertContentletToFatContentlet in class ContentletFactory
Parameters:
fatty -
Returns:
Throws:
DotDataException

cleanHostField

protected void cleanHostField(java.lang.String structureInode)
                       throws DotDataException
Specified by:
cleanHostField in class ContentletFactory
Throws:
DotDataException

cleanIdentifierHostField

protected void cleanIdentifierHostField(java.lang.String structureInode)
                                 throws DotDataException
Description copied from class: ContentletFactory
Set the system host in the identifier of all the contents of the specified structure.

Specified by:
cleanIdentifierHostField in class ContentletFactory
Throws:
DotDataException

cleanField

protected void cleanField(java.lang.String structureInode,
                          Field field)
                   throws DotDataException
Specified by:
cleanField in class ContentletFactory
Throws:
DotDataException

deleteOldContent

protected int deleteOldContent(java.util.Date deleteFrom,
                               int offset)
                        throws DotDataException
Specified by:
deleteOldContent in class ContentletFactory
Returns:
Throws:
DotDataException

findContentletsWithFieldValue

protected java.util.List<Contentlet> findContentletsWithFieldValue(java.lang.String structureInode,
                                                                   Field field)
                                                            throws DotDataException
This method return all the contentlets with the specified structureInode and the specified Field cannot be null.

Specified by:
findContentletsWithFieldValue in class ContentletFactory
Parameters:
structureInode -
field -
Returns:
Throws:
DotDataException

contentletCount

protected long contentletCount()
                        throws DotDataException
Description copied from class: ContentletFactory
gets the number of contentlets in the system. This number includes all versions not distinct identifiers

Specified by:
contentletCount in class ContentletFactory
Returns:
Throws:
DotDataException

contentletIdentifierCount

protected long contentletIdentifierCount()
                                  throws DotDataException
Description copied from class: ContentletFactory
gets the number of contentlet identifiers in the system. This number includes all versions not distinct identifiers

Specified by:
contentletIdentifierCount in class ContentletFactory
Returns:
Throws:
DotDataException

DBSearch

protected java.util.List<java.util.Map<java.lang.String,java.io.Serializable>> DBSearch(GenericQueryFactory.Query query,
                                                                                        java.util.List<Field> fields,
                                                                                        java.lang.String structureInode)
                                                                                 throws ValidationException,
                                                                                        DotDataException
Specified by:
DBSearch in class ContentletFactory
Returns:
Throws:
ValidationException
DotDataException

UpdateContentWithSystemHost

protected void UpdateContentWithSystemHost(java.lang.String hostIdentifier)
                                    throws DotDataException
Specified by:
UpdateContentWithSystemHost in class ContentletFactory
Throws:
DotDataException

removeUserReferences

protected void removeUserReferences(java.lang.String userId)
                             throws DotDataException
Description copied from class: ContentletFactory
Method will remove User References of the given userId in Contentlet

Specified by:
removeUserReferences in class ContentletFactory
Throws:
DotDataException


Copyright © 2010 dotCMS Inc. All Rights Reserved.