Class UserImporter
- java.lang.Object
-
- org.apache.jackrabbit.core.security.user.UserImporter
-
- All Implemented Interfaces:
ProtectedItemImporter
,ProtectedNodeImporter
,ProtectedPropertyImporter
public class UserImporter extends Object implements ProtectedPropertyImporter, ProtectedNodeImporter
UserImporter
implements aDefaultProtectedPropertyImporter
andDefaultProtectedNodeImporter
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:
- The importer will only be initialized if the user manager is an instance
of
UserPerWorkspaceUserManager
. - The importer will only be initialized if the editing session starting this import is the same as the UserManager's Session instance.
- The jcr:uuid property of user and groups is defined to represent the
hashed authorizable id as calculated by the UserManager. This importer
is therefore not able to handle imports with
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW
. - Importing user/group nodes outside of the hierarchy defined by
UserManagerImpl.getUsersPath()
andUserManagerImpl.getGroupsPath()
will fail upon save as the mandatory properties will not be imported. The same may be true in case ofImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING
inserting the user/group node at some other place in the node hierarchy. - While creating user/groups through the API the
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. - Any attempt to import conflicting data will cause the import to fail
either immediately or upon calling
Session.save()
with the following exceptions:rep:members
: Group membershiprep:impersonators
: Impersonators of a User.
PARAM_IMPORT_BEHAVIOR
configuration parameter, which can be set toignore
: 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)
Importingrep:impersonators
property referring to principals that are created during this import AND have principalName different from the ID will no succeed, as the validation inImpersonationImpl
isn't able to find the authorizable with the given principal (reason: query will only find persisted content).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UserImporter.ImportBehavior
Inner class defining the treatment of membership or impersonator values pointing to non-existing authorizables.
-
Field Summary
Fields Modifier and Type Field Description static String
PARAM_IMPORT_BEHAVIOR
Parameter name for the import behavior configuration option.
-
Constructor Summary
Constructors Constructor Description UserImporter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
end(NodeImpl protectedParent)
Informs this importer that the tree to be imported belowprotectedParent
has bee completed.void
end(NodeState protectedParent)
Informs this importer that the tree to be imported belowprotectedParent
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 newchildInfo
and it's properties.
-
-
-
Field Detail
-
PARAM_IMPORT_BEHAVIOR
public static final String PARAM_IMPORT_BEHAVIOR
Parameter name for the import behavior configuration option.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public boolean init(JackrabbitSession session, NamePathResolver resolver, boolean isWorkspaceImport, int uuidBehavior, ReferenceChangeTracker referenceTracker)
- Specified by:
init
in interfaceProtectedItemImporter
- Returns:
-
handlePropInfo
public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws RepositoryException
Description copied from interface:ProtectedPropertyImporter
Handles a single protected property.- Specified by:
handlePropInfo
in interfaceProtectedPropertyImporter
- Parameters:
parent
- The affected parent node.protectedPropInfo
- ThePropInfo
to be imported.def
- The property definition determined by the importer that calls this method.- Returns:
true
If the property could be successfully imported;false
otherwise.- Throws:
RepositoryException
- If an error occurs.- See Also:
ProtectedPropertyImporter.handlePropInfo(org.apache.jackrabbit.core.NodeImpl, org.apache.jackrabbit.core.xml.PropInfo, org.apache.jackrabbit.spi.QPropertyDefinition)
-
handlePropInfo
public boolean handlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws RepositoryException
Description copied from interface:ProtectedPropertyImporter
Handles a single protected property.- Specified by:
handlePropInfo
in interfaceProtectedPropertyImporter
- Parameters:
parent
- The affected parent node.protectedPropInfo
- ThePropInfo
to be imported.def
- The property definition determined by the importer that calls this method.- Returns:
true
If the property could be successfully imported;false
otherwise.- Throws:
RepositoryException
- If an error occurs.- See Also:
ProtectedPropertyImporter.handlePropInfo(org.apache.jackrabbit.core.NodeImpl, org.apache.jackrabbit.core.xml.PropInfo, org.apache.jackrabbit.spi.QPropertyDefinition)
-
processReferences
public void processReferences() throws RepositoryException
Description copied from interface:ProtectedItemImporter
Post processing protected reference properties underneath a protected or non-protected parent node. If the parent is protected it has been handled by this importer already. This method is called fromImporter.end()
.- Specified by:
processReferences
in interfaceProtectedItemImporter
- Throws:
RepositoryException
- If an error occurs.- See Also:
ProtectedItemImporter.processReferences()
-
start
public boolean start(NodeImpl protectedParent) throws RepositoryException
Description copied from interface:ProtectedNodeImporter
Notifies this importer about the existence of a protected node that has either been created (NEW) or has been found to be existing. This importer implementation is in charge of evaluating the nature of that protected node in order to determine, if it is able to handle subsequent protected or non-protected child nodes in the tree below that parent.- Specified by:
start
in interfaceProtectedNodeImporter
- Parameters:
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.- Returns:
true
If this importer is able to deal with the tree that may be present below the given protected Node.- Throws:
RepositoryException
- If an error occurs.- See Also:
ProtectedNodeImporter.start(org.apache.jackrabbit.core.NodeImpl)
-
start
public boolean start(NodeState protectedParent)
Description copied from interface:ProtectedNodeImporter
Notifies this importer about the existence of a protected node that has either been created (NEW) or has been found to be existing. This importer implementation is in charge of evaluating the nature of that protected node in order to determine, if it is able to handle subsequent protected or non-protected child nodes in the tree below that parent.- Specified by:
start
in interfaceProtectedNodeImporter
- Parameters:
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.- Returns:
true
If this importer is able to deal with the tree that may be present below the given protected NodeState.- See Also:
ProtectedNodeImporter.start(org.apache.jackrabbit.core.state.NodeState)
-
startChildInfo
public void startChildInfo(NodeInfo childInfo, List<PropInfo> propInfos) throws RepositoryException
Description copied from interface:ProtectedNodeImporter
Informs this importer about a newchildInfo
and it's properties. If the importer is able to successfully import the given information this method returns silently. OtherwiseConstraintViolationException
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.- Specified by:
startChildInfo
in interfaceProtectedNodeImporter
- Throws:
ConstraintViolationException
- If the given infos contain invalid or incomplete data and therefore cannot be properly handled by this importer.RepositoryException
- If another error occurs.- See Also:
ProtectedNodeImporter.start(org.apache.jackrabbit.core.NodeImpl)
-
endChildInfo
public void endChildInfo() throws RepositoryException
Description copied from interface:ProtectedNodeImporter
Informs this importer about the end of a child info.If
ProtectedNodeImporter.start(NodeImpl)
hasn't been called before, this method returns silently.- Specified by:
endChildInfo
in interfaceProtectedNodeImporter
- Throws:
ConstraintViolationException
- If this method is called before all required child information has been imported.RepositoryException
- If another error occurs.- See Also:
ProtectedNodeImporter.endChildInfo()
-
end
public void end(NodeImpl protectedParent) throws RepositoryException
Description copied from interface:ProtectedNodeImporter
Informs this importer that the tree to be imported belowprotectedParent
has bee completed. This allows the importer to be reset in order to be able to deal with another call toProtectedNodeImporter.start(NodeImpl)
.If
ProtectedNodeImporter.start(NodeImpl)
hasn't been called before, this method returns silently.- Specified by:
end
in interfaceProtectedNodeImporter
- Throws:
ConstraintViolationException
- If the tree that was imported is incomplete.RepositoryException
- If another error occurs.- See Also:
ProtectedNodeImporter.end(org.apache.jackrabbit.core.NodeImpl)
-
end
public void end(NodeState protectedParent)
Description copied from interface:ProtectedNodeImporter
Informs this importer that the tree to be imported belowprotectedParent
has bee completed. This allows the importer to be reset in order to be able to deal with another call toProtectedNodeImporter.start(NodeState)
.If
ProtectedNodeImporter.start(NodeState)
hasn't been called before, this method returns silently.- Specified by:
end
in interfaceProtectedNodeImporter
- See Also:
ProtectedNodeImporter.end(org.apache.jackrabbit.core.state.NodeState)
-
getImportBehavior
public String getImportBehavior()
- Returns:
- human readable representation of the
importBehavior
value.
-
setImportBehavior
public void setImportBehavior(String importBehaviorStr)
- Parameters:
importBehaviorStr
-
-
-