org.apache.jetspeed.serializer
Class JetspeedSerializerImpl

java.lang.Object
  extended by org.apache.jetspeed.serializer.JetspeedSerializerBase
      extended by org.apache.jetspeed.serializer.JetspeedSerializerImpl
All Implemented Interfaces:
org.apache.jetspeed.serializer.JetspeedSerializer

public class JetspeedSerializerImpl
extends JetspeedSerializerBase
implements org.apache.jetspeed.serializer.JetspeedSerializer

Jetspeed Serializer

The Serializer is capable of reading and writing the current content of the Jetspeed environment to and from XML files. The component can be used from a standalone java application for seeding a new database or from a running portal as an administrative backup/restore function.

The XML file needs to indicate whether passwords used in credentials are plain text or whether they are encoded. The import algoritm can determine - prior to reading users - which encode/decode scheme was used and if or then we store plain passwords (Note that that alone requires the resulting XML to be encoded!!!!!)

Version:
$Id: $
Author:
Hajo Birthelmer

Field Summary
private  HashMap capabilityMap
           
private  HashMap capabilityMapInt
           
private  HashMap clientMap
           
private static String ENCODING_STRING
           
private  HashMap groupMap
           
private static String JETSPEED
           
private  HashMap mediaMap
           
private  HashMap mimeMap
           
private  HashMap mimeMapInt
           
private  HashMap permissionMap
           
(package private)  int refCouter
           
private  HashMap roleMap
           
private  HashMap rulesMap
           
private  HashMap userMap
           
 
Fields inherited from class org.apache.jetspeed.serializer.JetspeedSerializerBase
log
 
Fields inherited from interface org.apache.jetspeed.serializer.JetspeedSerializer
DECODING_SUPPORTED, ERROR_DECODING, INVALID_PASSWORDS, KEY_BACKUP_BEFORE_PROCESS, KEY_OVERWRITE_EXISTING, KEY_PROCESS_CAPABILITIES, KEY_PROCESS_ENTITIES, KEY_PROCESS_PERMISSIONS, KEY_PROCESS_PORTAL_PREFERENCES, KEY_PROCESS_PREFERENCES, KEY_PROCESS_PROFILER, KEY_PROCESS_USER_PREFERENCES, KEY_PROCESS_USERS, NO_DECODING, PASSTHRU_REQUIRED, TAG_SECONDARYSNAPSHOT, TAG_SNAPSHOT
 
Constructor Summary
JetspeedSerializerImpl()
           
JetspeedSerializerImpl(org.apache.jetspeed.components.ComponentManager cm)
          hand over existing component manager
JetspeedSerializerImpl(String appRoot, String[] bootConfig, String[] appConfig)
          This constructor takes the application root, the search path for the boot component configuration files and the search path for the application component configuration files.
 
Method Summary
private  void addJSUserCredentials(boolean isPublic, JSUser newUser, Object credential)
          Add the credentials to the JSUser object.
protected  int compareCurrentSecurityProvider(JSSeedData file)
          Establish whether incoming passwords are "clear" text or whether they are to be decoded.
private  JSClient createJSClient(org.apache.jetspeed.capabilities.Client c)
          create a JS CLient
private  JSGroup createJSGroup(org.apache.jetspeed.security.Group group)
          create a wrapper JSGroup object
private  JSRole createJSRole(org.apache.jetspeed.security.Role role)
          create a serializable wrapper for role
private  JSUser createJSUser(org.apache.jetspeed.security.User user)
          create a new JSUser object
private  JSProfilingRule createProfilingRule(org.apache.jetspeed.profiler.rules.ProfilingRule p, boolean standard)
          Create the Profiling Rule Wrapper
private  void exportCapabilites(org.apache.jetspeed.capabilities.Capabilities caps)
          extract the capabilities and save in snapshot file
private  void exportCapabilitiesInfrastructure()
          Extracts all capability related objects (clients, mimetypes and mediatypes) and their relationships
private  void exportClients(org.apache.jetspeed.capabilities.Capabilities caps)
          extract the current clients and save in the snapshot file
private  void exportGroups()
          extract the groups from the current environment
private  void exportMediaTypes(org.apache.jetspeed.capabilities.Capabilities caps)
          extract the media types and save in snapshot file
private  void exportMimeTypes(org.apache.jetspeed.capabilities.Capabilities caps)
          exstract the mime types anmd save in snapshot file
private  void exportRoles()
          export roles
private  void exportUsers()
          Collect all the roles, groups and users from the current environment.
private  String getEncryptionString()
           
private  Object getObjectBehindPrinicpal(Map map, org.apache.jetspeed.security.BasePrincipal _principal)
          simple lookup for principal object from a map
private  void getPermissions()
          extract all permissions from the current environment
private  void getProfilingRules()
          read the permissions and then the profiling rules.
protected  Class getSerializerDataClass()
          return the class for the serializer data , for example JSSeedData.class)
protected  String getSerializerDataTag()
          return the XML tag for the serializer data , for example "JSSnapShot")
protected  void getSnapshotData()
          On import, get the basic SnapShot data
private  Principal getUserPrincipal(org.apache.jetspeed.security.User user)
           
private  void importCapabilitiesInfrastructure()
           
private  void importProfiler()
           
private  void importUserGroupRoles()
           
private  void importUserPrincipals()
           
protected  void processExport(String name, javolution.xml.XMLBinding binding)
          The workhorse for exporting data
protected  void processImport()
          The workhorse for importing data
private  void recreateCapabilities(org.apache.jetspeed.capabilities.Capabilities caps)
           
private  void recreateClients(org.apache.jetspeed.capabilities.Capabilities caps)
           
private  void recreateMediaTypes(org.apache.jetspeed.capabilities.Capabilities caps)
           
private  void recreateMimeTypes(org.apache.jetspeed.capabilities.Capabilities caps)
           
private  void recreatePermissions()
          recreates all permissions from the current snapshot
private  void recreateProfilingRules()
           
private  void recreateRolesGroupsUsers()
          import the groups, roles and finally the users to the current environment
protected  org.apache.jetspeed.profiler.rules.ProfilingRule recreateRule(org.apache.jetspeed.profiler.Profiler profiler, org.apache.jetspeed.profiler.rules.ProfilingRule existingRule, JSProfilingRule jsp)
          recreate a profiling rule object from the deserialized wrapper and store it
protected  org.apache.jetspeed.profiler.rules.RuleCriterion recreateRuleCriterion(org.apache.jetspeed.profiler.Profiler profiler, JSRuleCriterion jsr, org.apache.jetspeed.profiler.rules.ProfilingRule rule)
          recreate a rule criterion object from the deserialized wrapper
private  void recreateUserPrincipalRules()
          called only after users have been established
protected  void resetSettings()
          reset instruction flags to default settings (all true)
protected  void setupAliases(javolution.xml.XMLBinding binding)
          Setup the binding for the different classes, mapping each extracted class to a unique tag name in the XML
 
Methods inherited from class org.apache.jetspeed.serializer.JetspeedSerializerBase
checkSettings, closeUp, createUniqueBackupFilename, doBackupOfCurrent, exportData, getCM, getDefaultIndent, getObjectBehindPath, getSetting, getSnapshot, getTokens, importData, initializeComponentManager, logMe, openWriter, readFile, recreatePassword, removeFromString, setComponentManager, setDefaultIndent, setSetting, setSnapshot, setSnapshotData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.serializer.JetspeedSerializer
, closeUp, exportData, getDefaultIndent, importData, initializeComponentManager, setComponentManager, setDefaultIndent
 

Field Detail

roleMap

private HashMap roleMap

groupMap

private HashMap groupMap

userMap

private HashMap userMap

mimeMap

private HashMap mimeMap

mimeMapInt

private HashMap mimeMapInt

mediaMap

private HashMap mediaMap

capabilityMap

private HashMap capabilityMap

capabilityMapInt

private HashMap capabilityMapInt

clientMap

private HashMap clientMap

permissionMap

private HashMap permissionMap

rulesMap

private HashMap rulesMap

refCouter

int refCouter

ENCODING_STRING

private static String ENCODING_STRING

JETSPEED

private static String JETSPEED
Constructor Detail

JetspeedSerializerImpl

public JetspeedSerializerImpl()

JetspeedSerializerImpl

public JetspeedSerializerImpl(org.apache.jetspeed.components.ComponentManager cm)
hand over existing component manager

Parameters:
cm -

JetspeedSerializerImpl

public JetspeedSerializerImpl(String appRoot,
                              String[] bootConfig,
                              String[] appConfig)
                       throws org.apache.jetspeed.serializer.SerializerException
This constructor takes the application root, the search path for the boot component configuration files and the search path for the application component configuration files.

For example: new JetspeedSerializerImpl("./", "assembly/boot/*.xml", "assembly/*.xml") will establish the current directory as the root, process all xml files in the assembly/boot directory before processing all xml files in the assembly directory itself.

Parameters:
appRoot - working directory
bootConfig - boot (primary) file or files (wildcards are allowed)
appConfig - application (secondary) file or files (wildcards are allowed)
Throws:
org.apache.jetspeed.serializer.SerializerException
Method Detail

getSerializerDataClass

protected Class getSerializerDataClass()
Description copied from class: JetspeedSerializerBase
return the class for the serializer data , for example JSSeedData.class)

Specified by:
getSerializerDataClass in class JetspeedSerializerBase
Returns:

getSerializerDataTag

protected String getSerializerDataTag()
Description copied from class: JetspeedSerializerBase
return the XML tag for the serializer data , for example "JSSnapShot")

Specified by:
getSerializerDataTag in class JetspeedSerializerBase
Returns:

resetSettings

protected void resetSettings()
reset instruction flags to default settings (all true)

Specified by:
resetSettings in class JetspeedSerializerBase

getSnapshotData

protected void getSnapshotData()
On import, get the basic SnapShot data

Overrides:
getSnapshotData in class JetspeedSerializerBase

recreateCapabilities

private void recreateCapabilities(org.apache.jetspeed.capabilities.Capabilities caps)
                           throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

recreateMimeTypes

private void recreateMimeTypes(org.apache.jetspeed.capabilities.Capabilities caps)
                        throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

recreateMediaTypes

private void recreateMediaTypes(org.apache.jetspeed.capabilities.Capabilities caps)
                         throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

recreateClients

private void recreateClients(org.apache.jetspeed.capabilities.Capabilities caps)
                      throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

importCapabilitiesInfrastructure

private void importCapabilitiesInfrastructure()
                                       throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException

recreateRolesGroupsUsers

private void recreateRolesGroupsUsers()
                               throws org.apache.jetspeed.serializer.SerializerException
import the groups, roles and finally the users to the current environment

Throws:
SerializerException

recreateUserPrincipalRules

private void recreateUserPrincipalRules()
                                 throws org.apache.jetspeed.serializer.SerializerException
called only after users have been established

Throws:
SerializerException

recreatePermissions

private void recreatePermissions()
                          throws org.apache.jetspeed.serializer.SerializerException
recreates all permissions from the current snapshot

Throws:
SerializerException

getUserPrincipal

private Principal getUserPrincipal(org.apache.jetspeed.security.User user)

importProfiler

private void importProfiler()

importUserGroupRoles

private void importUserGroupRoles()

importUserPrincipals

private void importUserPrincipals()

processImport

protected void processImport()
                      throws org.apache.jetspeed.serializer.SerializerException
The workhorse for importing data

Specified by:
processImport in class JetspeedSerializerBase
Parameters:
binding - established XML binding
Throws:
SerializerException

processExport

protected void processExport(String name,
                             javolution.xml.XMLBinding binding)
                      throws org.apache.jetspeed.serializer.SerializerException
The workhorse for exporting data

Specified by:
processExport in class JetspeedSerializerBase
Parameters:
binding - established XML binding
Throws:
SerializerException

setupAliases

protected void setupAliases(javolution.xml.XMLBinding binding)
Setup the binding for the different classes, mapping each extracted class to a unique tag name in the XML

Specified by:
setupAliases in class JetspeedSerializerBase
Parameters:
binding -

getObjectBehindPrinicpal

private Object getObjectBehindPrinicpal(Map map,
                                        org.apache.jetspeed.security.BasePrincipal _principal)
simple lookup for principal object from a map

Parameters:
map -
_fullPath -
Returns:

createJSRole

private JSRole createJSRole(org.apache.jetspeed.security.Role role)
create a serializable wrapper for role

Parameters:
role -
Returns:

exportRoles

private void exportRoles()
                  throws org.apache.jetspeed.serializer.SerializerException
export roles

Throws:
org.apache.jetspeed.serializer.SerializerException

createJSGroup

private JSGroup createJSGroup(org.apache.jetspeed.security.Group group)
create a wrapper JSGroup object


exportGroups

private void exportGroups()
                   throws org.apache.jetspeed.serializer.SerializerException
extract the groups from the current environment

Throws:
SerializerException

addJSUserCredentials

private void addJSUserCredentials(boolean isPublic,
                                  JSUser newUser,
                                  Object credential)
Add the credentials to the JSUser object.

If the credential provided is a PasswordCredential, userid and password are extracted and set explcitely

Parameters:
isPublic - public or private credential
newUser - the JS user object reference
credential - the credential object

createJSUser

private JSUser createJSUser(org.apache.jetspeed.security.User user)
create a new JSUser object

Parameters:
user -
Returns:
a new JSUser object

exportUsers

private void exportUsers()
                  throws org.apache.jetspeed.serializer.SerializerException
Collect all the roles, groups and users from the current environment. Include the current SecurityProvider to understand, whether the password collected can be used upon import

Throws:
SerializerException

exportCapabilites

private void exportCapabilites(org.apache.jetspeed.capabilities.Capabilities caps)
                        throws org.apache.jetspeed.serializer.SerializerException
extract the capabilities and save in snapshot file

Parameters:
caps - capability-container
Throws:
SerializerException

exportMimeTypes

private void exportMimeTypes(org.apache.jetspeed.capabilities.Capabilities caps)
                      throws org.apache.jetspeed.serializer.SerializerException
exstract the mime types anmd save in snapshot file

Parameters:
caps - capability container
Throws:
SerializerException

createJSClient

private JSClient createJSClient(org.apache.jetspeed.capabilities.Client c)
                         throws org.apache.jetspeed.serializer.SerializerException
create a JS CLient

Parameters:
c - the existing Client object
Returns:
Throws:
SerializerException

exportClients

private void exportClients(org.apache.jetspeed.capabilities.Capabilities caps)
                    throws org.apache.jetspeed.serializer.SerializerException
extract the current clients and save in the snapshot file

Parameters:
list -
caps -
Throws:
SerializerException

exportMediaTypes

private void exportMediaTypes(org.apache.jetspeed.capabilities.Capabilities caps)
                       throws org.apache.jetspeed.serializer.SerializerException
extract the media types and save in snapshot file

Parameters:
caps - capabilit container
Throws:
SerializerException

exportCapabilitiesInfrastructure

private void exportCapabilitiesInfrastructure()
                                       throws org.apache.jetspeed.serializer.SerializerException
Extracts all capability related objects (clients, mimetypes and mediatypes) and their relationships

Throws:
org.apache.jetspeed.serializer.SerializerException

getPermissions

private void getPermissions()
                     throws org.apache.jetspeed.serializer.SerializerException
extract all permissions from the current environment

Throws:
SerializerException

createProfilingRule

private JSProfilingRule createProfilingRule(org.apache.jetspeed.profiler.rules.ProfilingRule p,
                                            boolean standard)
Create the Profiling Rule Wrapper

Parameters:
p -
Returns:

getProfilingRules

private void getProfilingRules()
                        throws org.apache.jetspeed.serializer.SerializerException
read the permissions and then the profiling rules.

after that update the cross reference with the users

Throws:
SerializerException

compareCurrentSecurityProvider

protected int compareCurrentSecurityProvider(JSSeedData file)
Establish whether incoming passwords are "clear" text or whether they are to be decoded. That however depends on whether the passwords were encoded with the current active provider or not.

Returns:

getEncryptionString

private String getEncryptionString()

recreateRuleCriterion

protected org.apache.jetspeed.profiler.rules.RuleCriterion recreateRuleCriterion(org.apache.jetspeed.profiler.Profiler profiler,
                                                                                 JSRuleCriterion jsr,
                                                                                 org.apache.jetspeed.profiler.rules.ProfilingRule rule)
                                                                          throws org.apache.jetspeed.serializer.SerializerException,
                                                                                 ClassNotFoundException
recreate a rule criterion object from the deserialized wrapper

Parameters:
profiler - established profile manager
jsr - deserialized object
Returns:
new RuleCriterion with content set to deserialized wrapepr
Throws:
SerializerException
ClassNotFoundException

recreateRule

protected org.apache.jetspeed.profiler.rules.ProfilingRule recreateRule(org.apache.jetspeed.profiler.Profiler profiler,
                                                                        org.apache.jetspeed.profiler.rules.ProfilingRule existingRule,
                                                                        JSProfilingRule jsp)
                                                                 throws org.apache.jetspeed.serializer.SerializerException,
                                                                        ClassNotFoundException,
                                                                        org.apache.jetspeed.profiler.ProfilerException
recreate a profiling rule object from the deserialized wrapper and store it

Parameters:
profiler - established profile manager
jsp - deserialized object
Throws:
SerializerException, - ClassNotFoundException, ProfilerException
org.apache.jetspeed.serializer.SerializerException
ClassNotFoundException
org.apache.jetspeed.profiler.ProfilerException

recreateProfilingRules

private void recreateProfilingRules()
                             throws org.apache.jetspeed.serializer.SerializerException
Throws:
org.apache.jetspeed.serializer.SerializerException


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.