mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 07:53:08 +00:00
DS-1090 Fix fetchURL method for CC License, so that it does not fail due to recent CC changes.
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6900 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -7,16 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.license;
|
package org.dspace.license;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.*;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import javax.xml.transform.Templates;
|
import javax.xml.transform.Templates;
|
||||||
import javax.xml.transform.TransformerConfigurationException;
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
@@ -25,6 +20,7 @@ import javax.xml.transform.TransformerFactory;
|
|||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.BitstreamFormat;
|
import org.dspace.content.BitstreamFormat;
|
||||||
@@ -34,10 +30,12 @@ import org.dspace.content.Item;
|
|||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
import org.dspace.license.CCLookup;
|
|
||||||
|
|
||||||
public class CreativeCommons
|
public class CreativeCommons
|
||||||
{
|
{
|
||||||
|
/** log4j category */
|
||||||
|
private static Logger log = Logger.getLogger(CreativeCommons.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Bundle Name
|
* The Bundle Name
|
||||||
*/
|
*/
|
||||||
@@ -429,30 +427,23 @@ public class CreativeCommons
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
String line = "";
|
||||||
URL url = new URL(url_string);
|
URL url = new URL(url_string);
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
byte[] bytes = new byte[connection.getContentLength()];
|
InputStream inputStream = connection.getInputStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
// loop and read the data until it's done
|
while ((line = reader.readLine()) != null)
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
int len = connection.getInputStream().read(bytes, offset,
|
sb.append(line);
|
||||||
bytes.length - offset);
|
|
||||||
|
|
||||||
if (len == -1)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += len;
|
return sb.toString().getBytes();
|
||||||
}
|
|
||||||
|
|
||||||
return bytes;
|
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
|
log.error(exc.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<default.dspace.dir>/dspace</default.dspace.dir>
|
<default.dspace.dir>/dspace-duraspace</default.dspace.dir>
|
||||||
<default.mail.server>smtp.example.com</default.mail.server>
|
<default.mail.server>smtp.example.com</default.mail.server>
|
||||||
<default.solr.server>http://localhost:8080/solr</default.solr.server>
|
<default.solr.server>http://localhost:8080/solr</default.solr.server>
|
||||||
</properties>
|
</properties>
|
||||||
|
Reference in New Issue
Block a user