org.apache.jackrabbit.core.security.user
Class UserImporter

java.lang.Object
  extended by org.apache.jackrabbit.core.security.user.UserImporter
All Implemented Interfaces:
ProtectedItemImporter, ProtectedNodeImporter, ProtectedPropertyImporter

public class UserImporter
extends Object
implements ProtectedPropertyImporter, ProtectedNodeImporter

UserImporter implements a DefaultProtectedPropertyImporter 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:

Known Issue:
Importing 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).


Nested Class Summary
static class UserImporter.ImportBehavior
          Inner class defining the treatment of membership or impersonator values pointing to non-existing authorizables.
 
Field Summary
static String PARAM_IMPORT_BEHAVIOR
          Parameter name for the import behavior configuration option.
 
Constructor Summary
UserImporter()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

UserImporter

public UserImporter()
Method Detail

init

public boolean init(JackrabbitSession session,
                    NamePathResolver resolver,
                    boolean isWorkspaceImport,
                    int uuidBehavior,
                    ReferenceChangeTracker referenceTracker)
Specified by:
init in interface ProtectedItemImporter
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 interface ProtectedPropertyImporter
Parameters:
parent - The affected parent node.
protectedPropInfo - The PropInfo 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.

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 interface ProtectedPropertyImporter
Parameters:
parent - The affected parent node.
protectedPropInfo - The PropInfo 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.

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 from Importer.end().

Specified by:
processReferences in interface ProtectedItemImporter
Throws:
RepositoryException - If an error occurs.

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 interface ProtectedNodeImporter
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.

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 interface ProtectedNodeImporter
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.

startChildInfo

public void startChildInfo(NodeInfo childInfo,
                           List<PropInfo> propInfos)
                    throws RepositoryException
Description copied from interface: ProtectedNodeImporter
Informs this importer about a new 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.

Specified by:
startChildInfo in interface ProtectedNodeImporter
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.

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 interface ProtectedNodeImporter
Throws:
ConstraintViolationException - If this method is called before all required child information has been imported.
RepositoryException - If another error occurs.

end

public void end(NodeImpl protectedParent)
         throws RepositoryException
Description copied from interface: ProtectedNodeImporter
Informs this importer that the tree to be imported below 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.

Specified by:
end in interface ProtectedNodeImporter
Throws:
ConstraintViolationException - If the tree that was imported is incomplete.
RepositoryException - If another error occurs.

end

public void end(NodeState protectedParent)
Description copied from interface: ProtectedNodeImporter
Informs this importer that the tree to be imported below 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.

Specified by:
end in interface ProtectedNodeImporter

getImportBehavior

public String getImportBehavior()
Returns:
human readable representation of the importBehavior value.

setImportBehavior

public void setImportBehavior(String importBehaviorStr)
Parameters:
importBehaviorStr -


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.