Skip to content

Commit

Permalink
SAK-22177 improvements to the archiving service lookups and logging
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/common/trunk@108112 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
Aaron Zeckoski committed May 14, 2012
1 parent 2b1bf80 commit 95fbfd6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,24 @@ public void setMergeFilteredSakaiRoles(String[] filtered) {
* Init and Destroy
*******************************************************************************/
public void init() {


m_storagePath = m_serverConfigurationService.getString("archive.storage.path", m_storagePath);
if ((m_storagePath != null) && (!m_storagePath.endsWith("/"))) {
m_storagePath = m_storagePath + "/";
}

M_log.info("init(): storage path: " + m_storagePath);
m_filterSakaiServices = m_serverConfigurationService.getBoolean("archive.merge.filter.services", m_filterSakaiServices);
m_filterSakaiRoles = m_serverConfigurationService.getBoolean("archive.merge.filter.roles", m_filterSakaiRoles);
String[] filteredServices = m_serverConfigurationService.getStrings("archive.merge.filtered.services");
if (filteredServices != null) {
m_filteredSakaiServices = filteredServices;
}
String[] filteredRoles = m_serverConfigurationService.getStrings("archive.merge.filtered.roles");
if (filteredRoles != null) {
m_filteredSakaiRoles = filteredRoles;
}

M_log.info("init(): storage path: " + m_storagePath + ", merge filter{services="+m_filterSakaiServices+", roles="+m_filterSakaiRoles+"}");
}

public void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.sakaiproject.archive.impl;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -34,6 +35,7 @@
import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.content.api.ContentHostingService;
import org.sakaiproject.entity.api.EntityManager;
import org.sakaiproject.entity.api.EntityProducer;
import org.sakaiproject.exception.IdInvalidException;
import org.sakaiproject.exception.IdUnusedException;
Expand Down Expand Up @@ -77,7 +79,12 @@ public void setSecurityService(SecurityService service) {
m_securityService = service;
}

// only the resources created by the followinng roles will be imported
protected EntityManager m_entityManager = null;
public void setEntityManager(EntityManager m_entityManager) {
this.m_entityManager = m_entityManager;
}

// only the resources created by the followinng roles will be imported
// role sets are different to different system
//public String[] SAKAI_roles = m_filteredSakaiRoles; //= {"Affiliate", "Assistant", "Instructor", "Maintain", "Organizer", "Owner"};

Expand Down Expand Up @@ -259,14 +266,37 @@ else if (element.getTagName().equals(UserDirectoryService.APPLICATION_ID))
try
{
EntityProducer service = (EntityProducer) ComponentManager.get(serviceName);

try
if (service == null) {
// find the service using the EntityManager
List<EntityProducer> entityProducers = m_entityManager.getEntityProducers();
for (EntityProducer entityProducer : entityProducers) {
if (serviceName.equals(entityProducer.getClass().getName())
|| serviceName.equals(entityProducer.getLabel())
) {
service = entityProducer;
break;
}
}
}

try
{
String msg = "";
if ((system.equalsIgnoreCase(ArchiveService.FROM_SAKAI) || system.equalsIgnoreCase(ArchiveService.FROM_SAKAI_2_8))
&& (checkSakaiService(filterSakaiService,filteredSakaiService, serviceName)))
msg = service.merge(siteId, element, fileName, fromSite, attachmentNames, new HashMap() /* empty userIdTran map */, usersListAllowImport);

if (service != null) {
if ((system.equalsIgnoreCase(ArchiveService.FROM_SAKAI) || system.equalsIgnoreCase(ArchiveService.FROM_SAKAI_2_8))) {
if (checkSakaiService(filterSakaiService, filteredSakaiService, serviceName)) {
// checks passed so now we attempt to do the merge
if (M_log.isDebugEnabled()) M_log.debug("Merging archive data for "+serviceName+" ("+fileName+") to site "+siteId);
msg = service.merge(siteId, element, fileName, fromSite, attachmentNames, new HashMap() /* empty userIdTran map */, usersListAllowImport);
} else {
M_log.warn("Skipping merge archive data for "+serviceName+" ("+fileName+") to site "+siteId+", checked filter failed (filtersOn="+filterSakaiService+", filters="+Arrays.toString(filteredSakaiService)+")");
}
} else {
M_log.warn("Skipping archive data for for "+serviceName+" ("+fileName+") to site "+siteId+", this does not appear to be a sakai archive");
}
} else {
M_log.warn("Skipping archive data for for "+serviceName+" ("+fileName+") to site "+siteId+", no service (EntityProducer) could be found to deal with this data");
}
results.append(msg);
}
catch (Throwable t)
Expand Down

0 comments on commit 95fbfd6

Please sign in to comment.