Skip to content

Commit

Permalink
Merge pull request sakaiproject#616 from mcarropellicer/SAK-22065
Browse files Browse the repository at this point in the history
SAK-22065 - Duplicating site loses icon URL.
  • Loading branch information
ottenhoff committed Jun 8, 2015
2 parents 9713c81 + b1755ef commit fccb246
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -9786,13 +9790,22 @@ private void importSitesUsers(ParameterParser params, SessionState state) {
private String transferSiteResource(String oSiteId, String nSiteId, String siteAttribute) {
String rv = "";

String accessUrl = ServerConfigurationService.getAccessUrl();
if (siteAttribute!= null && siteAttribute.indexOf(oSiteId) != -1 && accessUrl != null)
String access = ServerConfigurationService.getAccessUrl();
if (siteAttribute!= null && siteAttribute.indexOf(oSiteId) != -1 && access != null)
{
// stripe out the access url, get the relative form of "url"
Reference ref = EntityManager.newReference(siteAttribute.replaceAll(accessUrl, ""));
Reference ref = null;
try
{
URI accessUrl = new URI(access);
URI url = new URI(siteAttribute);
String path = url.getPath();
String accessPath = accessUrl.getPath();

// stripe out the access url, get the relative form of "url"
String contentRef = path.replaceAll(accessPath, "");

ref = EntityManager.newReference(contentRef);

ContentResource resource = m_contentHostingService.getResource(ref.getId());
// the new resource
ContentResource nResource = null;
Expand All @@ -9818,6 +9831,10 @@ private String transferSiteResource(String oSiteId, String nSiteId, String siteA
rv = nResource != null?nResource.getUrl(false):"";

}
catch (URISyntaxException use)
{
M_log.warn("Couldn't update site resource: "+ siteAttribute + " "+ use.getMessage());
}
catch (Exception refException)
{
M_log.warn(this + ":transferSiteResource: cannot find resource with ref=" + ref.getReference() + " " + refException.getMessage());
Expand Down

0 comments on commit fccb246

Please sign in to comment.