public class UserImporter extends Object implements ProtectedPropertyImporter, ProtectedNodeImporter
UserImporter
implements a DefaultProtectedPropertyImporter
and DefaultProtectedNodeImporter
that is able to deal with
user/group content as defined by the default user related node types present
with jackrabbit-core.
The importer is intended to be used by applications that import user content
extracted from another repository instance and immediately persist the
imported content using Session.save()
. Omitting the
save call will lead to transient, semi-validated user content and eventually
to inconsistencies.
Note the following restrictions:
UserPerWorkspaceUserManager
.
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW
.UserManagerImpl.getUsersPath()
and UserManagerImpl.getGroupsPath()
will fail upon save as the mandatory properties will not be imported. The same may
be true in case of ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING
inserting the user/group node at some other place in the node hierarchy.UserManagerImpl
makes
sure that authorizables are never nested and are created below a hierarchy
of nt:AuthorizableFolder nodes. This isn't enforced by means of node type
constraints but only by the API. This importer currently doesn't perform such
a validation check.Session.save()
with the
following exceptions:
rep:members
: Group membershiprep:impersonators
: Impersonators of a User.PARAM_IMPORT_BEHAVIOR
configuration parameter, which can be set to
ignore
: A warning is logged.best effort
: A warning is logged
and the importer tries to fix the problem.abort
: The import is immediately
aborted with a ConstraintViolationException. (default)rep:impersonators
property referring to principals
that are created during this import AND have principalName different from the
ID will no succeed, as the validation in ImpersonationImpl
isn't able
to find the authorizable with the given principal (reason: query will only
find persisted content).Modifier and Type | Class and Description |
---|---|
static class |
UserImporter.ImportBehavior
Inner class defining the treatment of membership or impersonator
values pointing to non-existing authorizables.
|
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_IMPORT_BEHAVIOR
Parameter name for the import behavior configuration option.
|
Constructor and Description |
---|
UserImporter() |
Modifier and Type | Method and Description |
---|---|
void |
end(NodeImpl protectedParent)
Informs this importer that the tree to be imported below
protectedParent has bee completed. |
void |
end(NodeState protectedParent)
Informs this importer that the tree to be imported below
protectedParent has bee completed. |
void |
endChildInfo()
Informs this importer about the end of a child info.
|
String |
getImportBehavior() |
boolean |
handlePropInfo(NodeImpl parent,
PropInfo protectedPropInfo,
QPropertyDefinition def)
Handles a single protected property.
|
boolean |
handlePropInfo(NodeState parent,
PropInfo protectedPropInfo,
QPropertyDefinition def)
Handles a single protected property.
|
boolean |
init(JackrabbitSession session,
NamePathResolver resolver,
boolean isWorkspaceImport,
int uuidBehavior,
ReferenceChangeTracker referenceTracker) |
void |
processReferences()
Post processing protected reference properties underneath a protected
or non-protected parent node.
|
void |
setImportBehavior(String importBehaviorStr) |
boolean |
start(NodeImpl protectedParent)
Notifies this importer about the existence of a protected node that
has either been created (NEW) or has been found to be existing.
|
boolean |
start(NodeState protectedParent)
Notifies this importer about the existence of a protected node that
has either been created (NEW) or has been found to be existing.
|
void |
startChildInfo(NodeInfo childInfo,
List<PropInfo> propInfos)
Informs this importer about a new
childInfo and it's properties. |
public static final String PARAM_IMPORT_BEHAVIOR
public boolean init(JackrabbitSession session, NamePathResolver resolver, boolean isWorkspaceImport, int uuidBehavior, ReferenceChangeTracker referenceTracker)
init
in interface ProtectedItemImporter
public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws javax.jcr.RepositoryException
ProtectedPropertyImporter
handlePropInfo
in interface ProtectedPropertyImporter
parent
- The affected parent node.protectedPropInfo
- The PropInfo
to be imported.def
- The property definition determined by the importer that
calls this method.true
If the property could be successfully imported;
false
otherwise.javax.jcr.RepositoryException
- If an error occurs.ProtectedPropertyImporter.handlePropInfo(org.apache.jackrabbit.core.NodeImpl, org.apache.jackrabbit.core.xml.PropInfo, org.apache.jackrabbit.spi.QPropertyDefinition)
public boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws javax.jcr.RepositoryException
ProtectedPropertyImporter
handlePropInfo
in interface ProtectedPropertyImporter
parent
- The affected parent node.protectedPropInfo
- The PropInfo
to be imported.def
- The property definition determined by the importer that
calls this method.true
If the property could be successfully imported;
false
otherwise.javax.jcr.RepositoryException
- If an error occurs.ProtectedPropertyImporter.handlePropInfo(org.apache.jackrabbit.core.NodeImpl, org.apache.jackrabbit.core.xml.PropInfo, org.apache.jackrabbit.spi.QPropertyDefinition)
public void processReferences() throws javax.jcr.RepositoryException
ProtectedItemImporter
Importer.end()
.processReferences
in interface ProtectedItemImporter
javax.jcr.RepositoryException
- If an error occurs.ProtectedItemImporter.processReferences()
public boolean start(NodeImpl protectedParent) throws javax.jcr.RepositoryException
ProtectedNodeImporter
start
in interface ProtectedNodeImporter
protectedParent
- A protected node that has either been created
during the current XML import or that has been found to be existing
without allowing same-name siblings.true
If this importer is able to deal with the
tree that may be present below the given protected Node.javax.jcr.RepositoryException
- If an error occurs.ProtectedNodeImporter.start(org.apache.jackrabbit.core.NodeImpl)
public boolean start(NodeState protectedParent)
ProtectedNodeImporter
start
in interface ProtectedNodeImporter
protectedParent
- A protected node that has either been created
during the current XML import or that has been found to be existing
without allowing same-name siblings.true
If this importer is able to deal with the
tree that may be present below the given protected NodeState.ProtectedNodeImporter.start(org.apache.jackrabbit.core.state.NodeState)
public void startChildInfo(NodeInfo childInfo, List<PropInfo> propInfos) throws javax.jcr.RepositoryException
ProtectedNodeImporter
childInfo
and it's properties.
If the importer is able to successfully import the given information
this method returns silently. Otherwise
ConstraintViolationException
is thrown, in which case the
whole import fails.
In case this importer deals with multiple levels of nodes, it is in charge of maintaining the hierarchical structure (see also {#link endChildInfo()}.
If ProtectedNodeImporter.start(NodeImpl)
hasn't been called before, this method returns
silently.
startChildInfo
in interface ProtectedNodeImporter
javax.jcr.nodetype.ConstraintViolationException
- If the given
infos contain invalid or incomplete data and therefore cannot be properly
handled by this importer.javax.jcr.RepositoryException
- If another error occurs.ProtectedNodeImporter.start(org.apache.jackrabbit.core.NodeImpl)
public void endChildInfo() throws javax.jcr.RepositoryException
ProtectedNodeImporter
If ProtectedNodeImporter.start(NodeImpl)
hasn't been called before, this method returns
silently.
endChildInfo
in interface ProtectedNodeImporter
javax.jcr.nodetype.ConstraintViolationException
- If this method
is called before all required child information has been imported.javax.jcr.RepositoryException
- If another error occurs.ProtectedNodeImporter.endChildInfo()
public void end(NodeImpl protectedParent) throws javax.jcr.RepositoryException
ProtectedNodeImporter
protectedParent
has bee completed. This allows the importer
to be reset in order to be able to deal with another call to
ProtectedNodeImporter.start(NodeImpl)
.
If ProtectedNodeImporter.start(NodeImpl)
hasn't been called before, this method returns
silently.
end
in interface ProtectedNodeImporter
javax.jcr.nodetype.ConstraintViolationException
- If the tree
that was imported is incomplete.javax.jcr.RepositoryException
- If another error occurs.ProtectedNodeImporter.end(org.apache.jackrabbit.core.NodeImpl)
public void end(NodeState protectedParent)
ProtectedNodeImporter
protectedParent
has bee completed. This allows the importer
to be reset in order to be able to deal with another call to
ProtectedNodeImporter.start(NodeState)
.
If ProtectedNodeImporter.start(NodeState)
hasn't been called before, this method returns
silently.
end
in interface ProtectedNodeImporter
ProtectedNodeImporter.end(org.apache.jackrabbit.core.state.NodeState)
public String getImportBehavior()
importBehavior
value.public void setImportBehavior(String importBehaviorStr)
importBehaviorStr
- Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.