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
UserImporterimplements aDefaultProtectedPropertyImporterandDefaultProtectedNodeImporterthat 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_EXISTINGinserting the user/group node at some other place in the node hierarchy. - While creating user/groups through the API the
UserManagerImplmakes 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_BEHAVIORconfiguration 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:impersonatorsproperty referring to principals that are created during this import AND have principalName different from the ID will no succeed, as the validation inImpersonationImplisn'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 classUserImporter.ImportBehaviorInner class defining the treatment of membership or impersonator values pointing to non-existing authorizables.
-
Field Summary
Fields Modifier and Type Field Description static StringPARAM_IMPORT_BEHAVIORParameter 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 voidend(NodeImpl protectedParent)Informs this importer that the tree to be imported belowprotectedParenthas bee completed.voidend(NodeState protectedParent)Informs this importer that the tree to be imported belowprotectedParenthas bee completed.voidendChildInfo()Informs this importer about the end of a child info.StringgetImportBehavior()booleanhandlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def)Handles a single protected property.booleanhandlePropInfo(NodeState parent, PropInfo protectedPropInfo, QPropertyDefinition def)Handles a single protected property.booleaninit(JackrabbitSession session, NamePathResolver resolver, boolean isWorkspaceImport, int uuidBehavior, ReferenceChangeTracker referenceTracker)voidprocessReferences()Post processing protected reference properties underneath a protected or non-protected parent node.voidsetImportBehavior(String importBehaviorStr)booleanstart(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.booleanstart(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.voidstartChildInfo(NodeInfo childInfo, List<PropInfo> propInfos)Informs this importer about a newchildInfoand 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:
initin interfaceProtectedItemImporter- Returns:
-
handlePropInfo
public boolean handlePropInfo(NodeImpl parent, PropInfo protectedPropInfo, QPropertyDefinition def) throws RepositoryException
Description copied from interface:ProtectedPropertyImporterHandles a single protected property.- Specified by:
handlePropInfoin interfaceProtectedPropertyImporter- Parameters:
parent- The affected parent node.protectedPropInfo- ThePropInfoto be imported.def- The property definition determined by the importer that calls this method.- Returns:
trueIf the property could be successfully imported;falseotherwise.- 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:ProtectedPropertyImporterHandles a single protected property.- Specified by:
handlePropInfoin interfaceProtectedPropertyImporter- Parameters:
parent- The affected parent node.protectedPropInfo- ThePropInfoto be imported.def- The property definition determined by the importer that calls this method.- Returns:
trueIf the property could be successfully imported;falseotherwise.- 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 RepositoryExceptionDescription copied from interface:ProtectedItemImporterPost 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:
processReferencesin interfaceProtectedItemImporter- Throws:
RepositoryException- If an error occurs.- See Also:
ProtectedItemImporter.processReferences()
-
start
public boolean start(NodeImpl protectedParent) throws RepositoryException
Description copied from interface:ProtectedNodeImporterNotifies 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:
startin 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:
trueIf 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:ProtectedNodeImporterNotifies 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:
startin 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:
trueIf 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:ProtectedNodeImporterInforms this importer about a newchildInfoand it's properties. If the importer is able to successfully import the given information this method returns silently. OtherwiseConstraintViolationExceptionis 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:
startChildInfoin 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 RepositoryExceptionDescription copied from interface:ProtectedNodeImporterInforms this importer about the end of a child info.If
ProtectedNodeImporter.start(NodeImpl)hasn't been called before, this method returns silently.- Specified by:
endChildInfoin 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:ProtectedNodeImporterInforms this importer that the tree to be imported belowprotectedParenthas 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:
endin 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:ProtectedNodeImporterInforms this importer that the tree to be imported belowprotectedParenthas 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:
endin interfaceProtectedNodeImporter- See Also:
ProtectedNodeImporter.end(org.apache.jackrabbit.core.state.NodeState)
-
getImportBehavior
public String getImportBehavior()
- Returns:
- human readable representation of the
importBehaviorvalue.
-
setImportBehavior
public void setImportBehavior(String importBehaviorStr)
- Parameters:
importBehaviorStr-
-
-