org.sakaiproject.component.legacy.archive
Class BasicArchiveService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.archive.BasicArchiveService
All Implemented Interfaces:
ArchiveService

public class BasicArchiveService
extends Object
implements ArchiveService

...

Version:
$Revision: 6248 $
Author:
University of Michigan, Sakai Software Development Team

Field Summary
 String[] CT_roles
           
 String[] CT_tools_toImport
           
protected  EntityManager m_entityManager
          Dependency: EntityManager.
protected  Logger m_logger
          Dependency: logging service
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  String m_storagePath
          A full path and file name to the storage file.
 String[] SAKAI_roles
           
 String[] SakaiServicesToImport
           
 HashMap tool_draft_flag
           
protected static HashMap userIdTrans
          A tag for the input system.
protected  HashSet UsersListAllowImport
           
 String[] WT_roles
           
 String[] WT_tools_toImport
           
 
Fields inherited from interface org.sakaiproject.service.legacy.archive.ArchiveService
FROM_CT, FROM_SAKAI, FROM_WT, SAKAI_assign_draft_import, SAKAI_msg_draft_import, SAKAI_rsc_draft_import, SAKAI_schedule_draft_import, SERVICE_NAME
 
Constructor Summary
BasicArchiveService()
           
 
Method Summary
 String archive(String siteId)
          Create an archive for the resources of a site.
protected static String archiveSite(Site site, Document doc, Stack stack)
          Archive the site definition.
protected static String archiveUsers(Site site, Document doc, Stack stack)
          Archive the users defined in this site (internal users only).
 boolean checkSakaiRole(String siteId, String userId)
          When Sakai is importing an item archived by Sakai, check the creator's role first.
protected  boolean checkSakaiService(String serviceName)
           
protected  boolean checkSystemRole(String system, String roleId)
          When Sakai is importing a role in site.xml, check if it is a qualified role.
 void destroy()
          Final cleanup.
 void init()
          Final initialization, once all dependencies are set.
 String merge(String fileName, String siteId, String creatorId)
          Process a merge for the file, or if it's a directory, for all contained files (one level deep).
protected  void mergeSite(String siteId, String fromSiteId, Element element, HashMap useIdTrans, String creatorId)
          Merge the site definition from the site part of the archive file into the site service.
protected  void mergeSiteInfo(Element el, String siteId)
          Merge the site info like description from the site part of the archive file into the site service.
protected  void mergeSiteRoles(Element el, String siteId, HashMap useIdTrans)
          Merge the the permission-roles settings into the site
protected  String mergeUsers(Element element, HashMap useIdTrans)
          Merge the user list into the the system.
protected  void processMerge(String fileName, String siteId, StringBuffer results, Map attachmentNames, String creatorId)
          Read in an archive file and merge the entries into the specified site.
 void setEntityManager(EntityManager service)
          Dependency: EntityManager.
 void setLogger(Logger service)
          Dependency: logging service.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: ServerConfigurationService.
 void setStoragePath(String path)
          Configuration: Set the Storage Path.
protected  String translateServiceName(String name)
          Old archives have the old CHEF 1.2 service names...
protected  void unlock(String lock, String reference)
          Check security permission.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_storagePath

protected String m_storagePath
A full path and file name to the storage file.


userIdTrans

protected static HashMap userIdTrans
A tag for the input system.


UsersListAllowImport

protected HashSet UsersListAllowImport

SAKAI_roles

public String[] SAKAI_roles

CT_roles

public String[] CT_roles

WT_roles

public String[] WT_roles

SakaiServicesToImport

public String[] SakaiServicesToImport

CT_tools_toImport

public String[] CT_tools_toImport

WT_tools_toImport

public String[] WT_tools_toImport

tool_draft_flag

public HashMap tool_draft_flag

m_logger

protected Logger m_logger
Dependency: logging service


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: ServerConfigurationService.


m_entityManager

protected EntityManager m_entityManager
Dependency: EntityManager.

Constructor Detail

BasicArchiveService

public BasicArchiveService()
Method Detail

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: ServerConfigurationService.

Parameters:
service - The ServerConfigurationService.

setStoragePath

public void setStoragePath(String path)
Configuration: Set the Storage Path.

Parameters:
path - The storage path.

setEntityManager

public void setEntityManager(EntityManager service)
Dependency: EntityManager.

Parameters:
service - The EntityManager.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Final cleanup.


archive

public String archive(String siteId)
Create an archive for the resources of a site.

Specified by:
archive in interface ArchiveService
Parameters:
siteId - The id of the site to archive.
Returns:
A log of messages from the archive.

archiveSite

protected static String archiveSite(Site site,
                                    Document doc,
                                    Stack stack)
Archive the site definition.

Parameters:
site - the site.
doc - The document to contain the xml.
stack - The stack of elements, the top of which will be the containing element of the "site" element.

archiveUsers

protected static String archiveUsers(Site site,
                                     Document doc,
                                     Stack stack)
Archive the users defined in this site (internal users only).

Parameters:
site - the site.
doc - The document to contain the xml.
stack - The stack of elements, the top of which will be the containing element of the "site" element.

merge

public String merge(String fileName,
                    String siteId,
                    String creatorId)
Process a merge for the file, or if it's a directory, for all contained files (one level deep).

Specified by:
merge in interface ArchiveService
Parameters:
fileName - The site name (for the archive file) to read from.
creatorId - The creator id If null or blank, the date/time string of the merge is used.
siteId - The id of the site to merge the content into.
Returns:
A log of messages from the merge.

checkSakaiRole

public boolean checkSakaiRole(String siteId,
                              String userId)
When Sakai is importing an item archived by Sakai, check the creator's role first. The item is imported when the role is in the acceptance list,

Parameters:
siteId -
userId -
Returns:
boolean value - true: the role is accepted for importing; otherwise, not;

checkSystemRole

protected boolean checkSystemRole(String system,
                                  String roleId)
When Sakai is importing a role in site.xml, check if it is a qualified role.

Parameters:
roleId -
Returns:
boolean value - true: the role is accepted for importing; otherwise, not;

checkSakaiService

protected boolean checkSakaiService(String serviceName)

processMerge

protected void processMerge(String fileName,
                            String siteId,
                            StringBuffer results,
                            Map attachmentNames,
                            String creatorId)
Read in an archive file and merge the entries into the specified site.

Parameters:
fileName - The site name (for the archive file) to read from.
siteId - The id of the site to merge the content into.
results - A buffer to accumulate result messages.
attachmentNames - A map of old to new attachment names.
creatorId - The creator id

unlock

protected void unlock(String lock,
                      String reference)
               throws PermissionException
Check security permission.

Parameters:
lock - The lock id string.
reference - The resource's reference string, or null if no resource is involved.
Throws:
PermissionException - thrown if the user does not have access

mergeSiteInfo

protected void mergeSiteInfo(Element el,
                             String siteId)
                      throws IdInvalidException,
                             IdUsedException,
                             PermissionException,
                             IdUnusedException,
                             InUseException
Merge the site info like description from the site part of the archive file into the site service.

Parameters:
siteId - The id of the site getting imported into.
Throws:
IdInvalidException
IdUsedException
PermissionException
IdUnusedException
InUseException

mergeSiteRoles

protected void mergeSiteRoles(Element el,
                              String siteId,
                              HashMap useIdTrans)
                       throws PermissionException
Merge the the permission-roles settings into the site

Parameters:
siteId - The id of the site getting imported into.
Throws:
PermissionException

mergeUsers

protected String mergeUsers(Element element,
                            HashMap useIdTrans)
                     throws IdInvalidException,
                            IdUsedException,
                            PermissionException
Merge the user list into the the system. Translate the id to the siteId.

Parameters:
element - The XML DOM tree of messages to merge.
Throws:
IdInvalidException
IdUsedException
PermissionException

mergeSite

protected void mergeSite(String siteId,
                         String fromSiteId,
                         Element element,
                         HashMap useIdTrans,
                         String creatorId)
Merge the site definition from the site part of the archive file into the site service. Translate the id to the siteId.

Parameters:
siteId - The id of the site getting imported into.
fromSiteId - The id of the site the archive was made from.
element - The XML DOM tree of messages to merge.
creatorId - The creator id

translateServiceName

protected String translateServiceName(String name)
Old archives have the old CHEF 1.2 service names...