public final class PortalConnectorFactory extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Datasource> |
createDatasource(Class<T> clazz,
String id)
Create a datasource instance of the given class with given id
|
static Datasource |
createDatasource(Map handleprops)
Creates a new datasource handle with the specified properties as well as
a new Datasource (with default properties).
|
static Datasource |
createDatasource(Map handleprops,
Map dsprops)
Creates a new Datasource connection with the specified properties which
should point to a Content Repository of Gentics Content.Node.
|
static Datasource |
createDatasource(String id)
Create a datasource instance for the datasource with given id
|
static Expression |
createExpression(String rule)
Parse the given expression string into an Expression.
|
static MultichannellingDatasource |
createMultichannellingDatasource(Map<String,String> handleProps,
Map<String,String> dsProps)
Create a new instance of a multichannelling datasource
|
static RuleTree |
createRuleTree(String rule)
Deprecated.
deprecated, replaced by
createExpression(String) |
static WritableMultichannellingDatasource |
createWritableMultichannellingDatasource(Map<String,String> handleProps,
Map<String,String> dsProps)
Create a new writeable multichannelling datasource instance
|
static WriteableDatasource |
createWriteableDatasource(Map handleProperties)
Creates a new datasource handle with the specified properties as well as
a new writeable datasource (with default properties).
|
static WriteableDatasource |
createWriteableDatasource(Map handleProperties,
Map datasourceProperties)
Creates a new datasource handle with the specified properties as well as
a new writeable datasource with the specified properties.
|
static void |
destroy()
Destroy the portal connector factory, close all database connections, remove the scheduler (created background threads).
|
protected static void |
destroyDatasourceFactories()
Destroy all created datasource factories, close all handles (closing database connections)
|
static List<String> |
getAvailableDatasources()
Get the list of all available datasource ids
|
static List<String> |
getAvailableDatasources(Class<? extends Datasource> datasourceClass)
Get the available datasources as list of ids
|
static Changeable |
getChangeableContentObject(String contentId,
WriteableDatasource datasource)
Returns a changeable content object with the given content id.
|
static Resolvable |
getContentObject(String contentId,
Datasource datasource)
Returns a content object with the given content id.
|
static boolean |
isAutoRepair()
Check whether the auto-repair functionality is switched on or off by
configuration.
|
static boolean |
isAutoRepair2()
Check whether the auto-repair2 functionality is switched on or off by
configuration.
|
static void |
prefillAttributes(Datasource ds,
Collection<Resolvable> objects,
List<String> prefillAttributes)
Prefill the given attributes for objects which were fetched from the given datasource
|
static void |
registerDatasource(String id,
DatasourceType type,
Map<String,String> parameters,
List<String> handles)
Register a datasource at the factory.
|
static void |
registerDatasource(String id,
DatasourceType type,
Map<String,String> parameters,
List<String> handleIds,
boolean allowOverwrite)
Register a datasource at the factory.
|
static void |
registerHandle(String id,
HandleType type,
Map<String,String> parameters)
Register a datasource handle at the factory.
|
static void |
registerHandle(String id,
HandleType type,
Map<String,String> parameters,
boolean allowOverwrite)
Register a datasource handle at the factory.
|
static void |
setAutoRepair(boolean flag)
Set the autorepair flag
|
static void |
setAutoRepair2(boolean flag)
Set the autorepair2 flag
|
protected static void |
startScheduler()
Start the scheduler
|
protected static void |
stopScheduler()
Stop the scheduler.
|
public static Datasource createDatasource(Map handleprops)
handleprops
- Handle properties used when initializing SQL handle.Datasource
,
createDatasource(Map, Map)
public static Datasource createDatasource(Map handleprops, Map dsprops)
Datasource
is NOT thread-safe.
Handle Property - Parameters:
type - Type of the datasource. (jndi or jdbc)
For JNDI:
name - The name of the defined JNDI datasource.
For JDBC:
driverClass = The name of the JDBC class to be used (e.g. com.mysql.jdbc.Driver)
url = The URL which describes the JDBC datasource. (e.g. jdbc:mysql://playground.office:3306/testdb?user=root)
Optional JDBC Pool Parameters:
maxActive = Controls the maximum number of objects that can be borrowed from the pool at one time.
maxIdle = Controls the maximum number of objects that can sit idle in the pool at any time.
for more options and more detailed documentation for JDBC Pool options
take a look at the API documentation of
GenericObjectPool
handleprops
- Handle properties used when initializing SQL handle.dsprops
- Datasource properties, may be an empty map.public static MultichannellingDatasource createMultichannellingDatasource(Map<String,String> handleProps, Map<String,String> dsProps)
handleProps
- handle propertiesdsProps
- datasource propertiespublic static Resolvable getContentObject(String contentId, Datasource datasource) throws DatasourceNotAvailableException
contentId
- The content id of the object which should be returned.
([objecttype].[object id] e.g. 10002.123)datasource
- Datasource used to load the content object.DatasourceNotAvailableException
public static Expression createExpression(String rule) throws ParserException
rule
- The Rule string to be parsed as Expression.ParserException
Datasource.createDatasourceFilter(Expression)
public static RuleTree createRuleTree(String rule) throws ParserException
createExpression(String)
rule
- The rule string which is used to initialize the RuleTreeParserException
- when rule has invalid syntax or is null.RuleTree
public static WriteableDatasource createWriteableDatasource(Map handleProperties)
handleProperties
- Handle properties used when initializing SQL
handle.public static WriteableDatasource createWriteableDatasource(Map handleProperties, Map datasourceProperties)
handleProperties
- Handle properties used when initializing SQL
handle.datasourceProperties
- Datasource properties, may be an empty map.public static WritableMultichannellingDatasource createWritableMultichannellingDatasource(Map<String,String> handleProps, Map<String,String> dsProps)
handleProps
- handle propertiesdsProps
- datasource propertiespublic static Changeable getChangeableContentObject(String contentId, WriteableDatasource datasource) throws DatasourceNotAvailableException
contentId
- The content id of the object which should be returned.
([objecttype].[object id] e.g. 10002.123)datasource
- Writeable Datasource used to load the content object.DatasourceNotAvailableException
public static void prefillAttributes(Datasource ds, Collection<Resolvable> objects, List<String> prefillAttributes) throws NodeException
ds
- datasourceobjects
- collection of objects fetched from the datasourceprefillAttributes
- list of attributes to be prefilledNodeException
protected static void startScheduler()
protected static void stopScheduler()
protected static void destroyDatasourceFactories()
public static void destroy()
public static void registerHandle(String id, HandleType type, Map<String,String> parameters) throws DuplicateIdException, NodeException
id
- id of the datasource handletype
- handle typeparameters
- handle parametersDuplicateIdException
- if a handle with that id was already registeredNodeException
- if the parameters are invalidpublic static void registerHandle(String id, HandleType type, Map<String,String> parameters, boolean allowOverwrite) throws DuplicateIdException, NodeException
id
- id of the datasource handletype
- handle typeparameters
- handle parametersallowOverwrite
- true if overwriting existing handles should be allowedDuplicateIdException
- if a handle with that id was already registered and allowOverwrite was falseNodeException
- if the parameters are invalidpublic static void registerDatasource(String id, DatasourceType type, Map<String,String> parameters, List<String> handles) throws DuplicateIdException, NodeException
id
- datasource idtype
- datasource typeparameters
- datasource parametershandles
- list of datasource handle idsDuplicateIdException
- if a datasource with that id was already registeredNodeException
public static void registerDatasource(String id, DatasourceType type, Map<String,String> parameters, List<String> handleIds, boolean allowOverwrite) throws DuplicateIdException, NodeException
id
- datasource idtype
- datasource typeparameters
- datasource parametershandleIds
- list of datasource handle idsallowOverwrite
- true if overwriting existing datasources should be allowed, false if notDuplicateIdException
- if a datasource with that id was already registered and allowOverwrite was falseNodeException
public static boolean isAutoRepair()
public static void setAutoRepair(boolean flag)
flag
- public static boolean isAutoRepair2()
public static void setAutoRepair2(boolean flag)
flag
- public static List<String> getAvailableDatasources()
public static List<String> getAvailableDatasources(Class<? extends Datasource> datasourceClass)
datasourceClass
- datasource class. If null, all available datasources will be returnedpublic static Datasource createDatasource(String id) throws NodeException
id
- datasource idNodeException
- if no datasource with given id was registeredpublic static <T extends Datasource> T createDatasource(Class<T> clazz, String id) throws NodeException
clazz
- datasource classid
- datasource idNodeException
- if no datasource with given id was registered or if the datasource does not implement the given classCopyright © 2015 Gentics Software GmbH. All Rights Reserved.