mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +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;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.transform.Templates;
|
||||
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.StreamSource;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
@@ -34,10 +30,12 @@ import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.license.CCLookup;
|
||||
|
||||
public class CreativeCommons
|
||||
{
|
||||
/** log4j category */
|
||||
private static Logger log = Logger.getLogger(CreativeCommons.class);
|
||||
|
||||
/**
|
||||
* The Bundle Name
|
||||
*/
|
||||
@@ -429,30 +427,23 @@ public class CreativeCommons
|
||||
{
|
||||
try
|
||||
{
|
||||
String line = "";
|
||||
URL url = new URL(url_string);
|
||||
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
|
||||
int offset = 0;
|
||||
|
||||
while (true)
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
int len = connection.getInputStream().read(bytes, offset,
|
||||
bytes.length - offset);
|
||||
|
||||
if (len == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
offset += len;
|
||||
sb.append(line);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return sb.toString().getBytes();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
log.error(exc.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user