com.flexive.shared.interfaces
Interface ContentEngine

All Known Subinterfaces:
ContentEngineLocal

public interface ContentEngine

ContentEngine

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Method Summary
 void convertContentType(FxPK contentPK, long destinationTypeId, boolean allowLossy, boolean allVersions)
          Convert (all versions of) a given content to another content type The destinationType must either be derived from the given content's type or must be the parent of the given content's type
 FxPK createNewVersion(FxContent content)
          Create a new version for an existing content instance
 java.lang.String exportContent(FxContent content)
          Export a content instance
 FxLock extendLock(FxLock lock, long duration)
          Extend an existing lock for the given duration (duration will be added to current expire time).
 FxLock extendLock(FxPK pk, long duration)
          Extend an existing lock for the given duration (duration will be added to current expire time).
 BinaryDescriptor getBinaryDescriptor(long id)
          Load a binary descriptor (only allowed for global supervisor!).
 long getBinaryId(FxPK pk, java.lang.String xpath, FxLanguage language)
          Get the binary id for the given XPath.
 long getBinaryId(FxPK pk, java.lang.String xpath, FxLanguage language, boolean fallbackToDefault)
          Get the binary id for the given XPath.
 java.lang.String getBinaryMetaData(long id)
          Load binary meta data (only allowed for global supervisor!)
 FxContentSecurityInfo getContentSecurityInfo(FxPK pk)
          Get all security relevant information about a content instance identified by its primary key
 FxContentVersionInfo getContentVersionInfo(FxPK id)
          Get information about the versions used for a content id
 FxLock getLock(FxPK pk)
          Get the lock for a primary key.
 java.util.List<FxLock> getLocks(FxLockType lockType, long userId, long typeId, java.lang.String resource)
          Query locks
 java.util.List<FxPK> getPKsForType(long typeId, boolean onePkPerInstance)
           Returns all primary keys for the given type.
 int getReferencedContentCount(FxPK pk)
          Get the number of references that exist for the requested content
 FxContent importContent(java.lang.String xml, boolean newInstance)
          Import a content from XML
 FxContent initialize(long typeId)
          Initialize a new FxContent instance for a type with default values.
 FxContent initialize(long typeId, long mandatorId, long prefACL, long prefStep, long prefLang)
          Initialize a new FxContent instance with preferred acl, step and language
 FxContent initialize(java.lang.String typeName)
          Initialize a new FxContent instance for a type with default values.
 FxContent load(FxPK pk)
          Load a content
 FxContentContainer loadContainer(long id)
          Load a content container (all versions of a content)
 FxLock lock(FxLockType lockType, FxPK pk)
          Lock an instance
 FxLock lock(FxLockType lockType, FxPK pk, long duration)
          Lock an instance
 FxContent prepareSave(FxContent content)
          Prepare a content for a save or create operation (resolves binaries for script processing, etc.).
 void remove(FxPK pk)
          Remove a content
 int removeForType(long typeId)
          Remove all instances of the given type.
 void removeVersion(FxPK pk)
          Remove a content's version.
 FxPK save(FxContent content)
          Store an existing content or create a new one
 FxLock takeOverLock(FxLock lock)
          Take over a lock held by another user (if permitted)
 FxLock takeOverLock(FxPK pk)
          Take over a lock held by another user (if permitted)
 void unlock(FxPK pk)
          Unlock a locked instance.
 

Method Detail

initialize

FxContent initialize(long typeId,
                     long mandatorId,
                     long prefACL,
                     long prefStep,
                     long prefLang)
                     throws FxApplicationException
Initialize a new FxContent instance with preferred acl, step and language

Parameters:
typeId - type to use
mandatorId - mandator to assign this content (has to be available for the type!)
prefACL - preferred acl, if not applicable the best fit will be used
prefStep - preferred step, if not applicable the best fit will be used
prefLang - preferred language, if not applicable the best fit will be used
Returns:
FxContent
Throws:
FxApplicationException - TODO
FxLoadException - on initialization errors

initialize

FxContent initialize(long typeId)
                     throws FxApplicationException
Initialize a new FxContent instance for a type with default values. mandator, ACL, Step and Lang will be taken on a "first-useable" basis

Parameters:
typeId - type to use
Returns:
content instance
Throws:
FxApplicationException - on errors

initialize

FxContent initialize(java.lang.String typeName)
                     throws FxApplicationException
Initialize a new FxContent instance for a type with default values. mandator, ACL, Step and Lang will be taken on a "first-useable" basis

Parameters:
typeName - type to use
Returns:
content instance
Throws:
FxApplicationException - on errors

load

FxContent load(FxPK pk)
               throws FxApplicationException
Load a content

Parameters:
pk - primary key to load
Returns:
FxContent
Throws:
FxApplicationException - TODO
FxLoadException
FxNoAccessException
FxNotFoundException - if no instance for this primary key was found

loadContainer

FxContentContainer loadContainer(long id)
                                 throws FxApplicationException
Load a content container (all versions of a content)

Parameters:
id - requested content id
Returns:
container with all versions of the content
Throws:
FxApplicationException - on errors

save

FxPK save(FxContent content)
          throws FxApplicationException
Store an existing content or create a new one

Parameters:
content - the content to persist
Returns:
the primary key of the content
Throws:
FxApplicationException - TODO
FxCreateException - on errors
FxUpdateException - on errors
FxNoAccessException

prepareSave

FxContent prepareSave(FxContent content)
                      throws FxApplicationException
Prepare a content for a save or create operation (resolves binaries for script processing, etc.). This is optional and is not required to be called prior to saving, it exists to have metadata available in GUI's prior to saving.

Parameters:
content - the content to prepare
Returns:
the prepared content
Throws:
FxInvalidParameterException - on errors
FxDbException - on errors
FxApplicationException

createNewVersion

FxPK createNewVersion(FxContent content)
                      throws FxApplicationException
Create a new version for an existing content instance

Parameters:
content - the content to persist
Returns:
the primary key of the contents new version
Throws:
FxApplicationException - TODO
FxCreateException - on errors
FxUpdateException - on errors
FxNoAccessException

remove

void remove(FxPK pk)
            throws FxApplicationException
Remove a content

Parameters:
pk - primary key of the content to remove
Throws:
FxApplicationException - TODO
FxRemoveException - on errors
FxNoAccessException - on errors

removeVersion

void removeVersion(FxPK pk)
                   throws FxApplicationException
Remove a content's version. If the content consists only of this specific version the whole content is removed

Parameters:
pk - primary key of a distinct version to remove
Throws:
FxApplicationException - TODO
FxRemoveException - on errors
FxNoAccessException - on errors

removeForType

int removeForType(long typeId)
                  throws FxApplicationException
Remove all instances of the given type. Beans using this method should apply very strict security restrictions!

Parameters:
typeId - affected FxType
Returns:
number of instances removed
Throws:
FxApplicationException - TODO
FxRemoveException - on errors

getContentSecurityInfo

FxContentSecurityInfo getContentSecurityInfo(FxPK pk)
                                             throws FxApplicationException
Get all security relevant information about a content instance identified by its primary key

Parameters:
pk - primary key to query security information for
Returns:
FxContentSecurityInfo
Throws:
FxApplicationException - TODO

getContentVersionInfo

FxContentVersionInfo getContentVersionInfo(FxPK id)
                                           throws FxApplicationException
Get information about the versions used for a content id

Parameters:
id - the id to query version information for
Returns:
FxContentVersionInfo
Throws:
FxApplicationException - on errors

getReferencedContentCount

int getReferencedContentCount(FxPK pk)
                              throws FxApplicationException
Get the number of references that exist for the requested content

Parameters:
pk - primary key of the requested content
Returns:
number of references that exist for the requested content
Throws:
FxApplicationException - on errors

getPKsForType

java.util.List<FxPK> getPKsForType(long typeId,
                                   boolean onePkPerInstance)
                                   throws FxApplicationException

Returns all primary keys for the given type. Since this method does not implement security, it may only be called by the global supervisor. You can use the search engine to achieve the same, just with security enabled, with

final List<FxPK> folderPks = new SqlQueryBuilder().select("@pk").type("FOLDER").getResult().collectColumn(1);

Parameters:
typeId - the type to request the primary keys for
onePkPerInstance - return one primary key per instance (with max version) or one per actual version?
Returns:
list containing the primary keys
Throws:
FxApplicationException - on errors

getBinaryId

long getBinaryId(FxPK pk,
                 java.lang.String xpath,
                 FxLanguage language)
                 throws FxApplicationException
Get the binary id for the given XPath. The root ("/") XPath will return the contents preview binary id. An invalid XPath or no associated binary id will throw an FxNotFoundException or FxInvalidParameterException. Security will be checked and FxNoAccessException thrown if restricted.

Parameters:
pk - primary key
xpath - XPath
language - the language (if null, the user ticket language will be used)
Returns:
binary id
Throws:
FxApplicationException - on errors

getBinaryId

long getBinaryId(FxPK pk,
                 java.lang.String xpath,
                 FxLanguage language,
                 boolean fallbackToDefault)
                 throws FxApplicationException
Get the binary id for the given XPath. If no binary exists for the requested language, the default language will be tried. The root ("/") XPath will return the contents preview binary id. An invalid XPath or no associated binary id will throw an FxNotFoundException or FxInvalidParameterException. Security will be checked and FxNoAccessException thrown if restricted.

Parameters:
pk - primary key
xpath - XPath
language - the language (if null, the user ticket language will be used)
fallbackToDefault - fall back to the default language if the requested language is not null and not found?
Returns:
binary id
Throws:
FxApplicationException - on errors

getBinaryMetaData

java.lang.String getBinaryMetaData(long id)
Load binary meta data (only allowed for global supervisor!)

Parameters:
id - id of the binary
Returns:
metadata

getBinaryDescriptor

BinaryDescriptor getBinaryDescriptor(long id)
                                     throws FxApplicationException
Load a binary descriptor (only allowed for global supervisor!).

Parameters:
id - the binary ID
Returns:
the binary descriptor
Throws:
FxApplicationException - on errors
Since:
3.2.0

importContent

FxContent importContent(java.lang.String xml,
                        boolean newInstance)
                        throws FxApplicationException
Import a content from XML

Parameters:
xml - the content as XML
newInstance - modify the content to be treated like a new instance
Returns:
FxContent
Throws:
FxApplicationException - on errors

exportContent

java.lang.String exportContent(FxContent content)
                               throws FxApplicationException
Export a content instance

Parameters:
content - content instance to export
Returns:
content as XML
Throws:
FxApplicationException - on errors

lock

FxLock lock(FxLockType lockType,
            FxPK pk)
            throws FxLockException
Lock an instance

Parameters:
lockType - type of the lock
pk - primary key
Returns:
FxLock
Throws:
FxLockException - on errors

lock

FxLock lock(FxLockType lockType,
            FxPK pk,
            long duration)
            throws FxLockException
Lock an instance

Parameters:
lockType - type of the lock
pk - primary key
duration - duration in [ms] of the lock
Returns:
FxLock
Throws:
FxLockException - on errors

takeOverLock

FxLock takeOverLock(FxLock lock)
                    throws FxLockException
Take over a lock held by another user (if permitted)

Parameters:
lock - the lock to take over
Returns:
FxLock
Throws:
FxLockException - on errors

takeOverLock

FxLock takeOverLock(FxPK pk)
                    throws FxLockException
Take over a lock held by another user (if permitted)

Parameters:
pk - primary key of the instance whose lock should be taken over
Returns:
FxLock
Throws:
FxLockException - on errors

extendLock

FxLock extendLock(FxLock lock,
                  long duration)
                  throws FxLockException
Extend an existing lock for the given duration (duration will be added to current expire time). If the lock is expired, a new one will be created.

Parameters:
lock - the lock to extend
duration - duration in [ms] to extend the original expire time
Returns:
extended lock
Throws:
FxLockException - on errors

extendLock

FxLock extendLock(FxPK pk,
                  long duration)
                  throws FxLockException
Extend an existing lock for the given duration (duration will be added to current expire time). If the lock is expired, a new one will be created.

Parameters:
pk - primary key of the instance whose lock should be extended
duration - duration in [ms] to extend the original expire time
Returns:
extended lock
Throws:
FxLockException - on errors

getLock

FxLock getLock(FxPK pk)
Get the lock for a primary key. If the instance is not locked a lock with FxLockType.None is returned

Parameters:
pk - primary key
Returns:
FxLock, if not locked a lock with FxLockType.None is returned

unlock

void unlock(FxPK pk)
            throws FxLockException
Unlock a locked instance. If the instance is not locked, no exception will be thrown

Parameters:
pk - primary key
Throws:
FxLockException - on errors

getLocks

java.util.List<FxLock> getLocks(FxLockType lockType,
                                long userId,
                                long typeId,
                                java.lang.String resource)
                                throws FxLockException
Query locks

Parameters:
lockType - type of the locks to return, if null all types will be returned
userId - id of the lock owner, if < 0 locks for all users will be returned, if the calling user is not global or mandator supervisor, only locks held by the calling user will be returned
typeId - only return locks for contents of this type, if < 0 type is ignored
resource - name of the locked resources to find, will be ignored if empty or null. Queries will be pre- and postfixed by wildcards (%)
Returns:
matching locks
Throws:
FxLockException - on errors

convertContentType

void convertContentType(FxPK contentPK,
                        long destinationTypeId,
                        boolean allowLossy,
                        boolean allVersions)
                        throws FxApplicationException
Convert (all versions of) a given content to another content type The destinationType must either be derived from the given content's type or must be the parent of the given content's type

Parameters:
contentPK - the given FxPK of the content to be converted (any version of the content)
destinationTypeId - the id of the type to which the content instance should be converted
allowLossy - set to true for a "lossy" conversion, ie. fields which do not exist in the destination type will be skipped
allVersions - set to true to convert ALL versions of the given content (PK), false otherwise
Throws:
FxApplicationException - on errors
Since:
3.1