Fixed generation of the Creative Commons RDF, including the parsing change for the cc namespace.

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@2312 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2007-11-06 12:43:56 +00:00
parent acfcf672f1
commit c46b3d9d3b

View File

@@ -129,6 +129,7 @@ public class CreativeCommons
String cc_license_url) throws SQLException, IOException, String cc_license_url) throws SQLException, IOException,
AuthorizeException AuthorizeException
{ {
boolean hasCCnamespace = true;
Bundle bundle = getCcBundle(item); Bundle bundle = getCcBundle(item);
// get some more information // get some more information
@@ -137,20 +138,46 @@ public class CreativeCommons
// here we need to transform the license_rdf into a document_rdf // here we need to transform the license_rdf into a document_rdf
// first we find the beginning of "<License" // first we find the beginning of "<License"
int license_start = license_rdf.indexOf("<License"); int license_start = license_rdf.indexOf("<cc:License");
if (license_start < 0)
{
hasCCnamespace = false;
license_start = license_rdf.indexOf("<License");
}
// the 10 is the length of the license closing tag. int license_end;
int license_end = license_rdf.indexOf("</License>") + 10; String document_rdf;
String document_rdf = "<rdf:RDF xmlns=\"http://web.resource.org/cc/\"\n"
+ " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" if (hasCCnamespace)
+ " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" {
+ "<Work rdf:about=\"\">\n" // the 13 is the length of the license closing tag.
+ "<license rdf:resource=\"" license_end = license_rdf.indexOf("</cc:License>") + 13;
+ cc_license_url document_rdf = "<rdf:RDF xmlns:cc=\"http://web.resource.org/cc/\"\n"
+ "\">\n" + " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
+ "</Work>\n\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n"
+ license_rdf.substring(license_start, license_end) + "<cc:Work rdf:about=\"\">\n"
+ "\n\n</rdf:RDF>"; + "<cc:License rdf:resource=\""
+ cc_license_url
+ "\"/>\n"
+ "</cc:Work>\n\n"
+ license_rdf.substring(license_start, license_end)
+ "\n\n</rdf:RDF>";
}
else
{
// the 10 is the length of the license closing tag.
license_end = license_rdf.indexOf("</License>") + 10;
document_rdf = "<rdf:RDF xmlns=\"http://web.resource.org/cc/\"\n"
+ " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
+ " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n"
+ "<Work rdf:about=\"\">\n"
+ "<License rdf:resource=\""
+ cc_license_url
+ "\"/>\n"
+ "</Work>\n\n"
+ license_rdf.substring(license_start, license_end)
+ "\n\n</rdf:RDF>";
}
// set the format // set the format
BitstreamFormat bs_format = BitstreamFormat.findByShortDescription( BitstreamFormat bs_format = BitstreamFormat.findByShortDescription(
@@ -187,7 +214,7 @@ public class CreativeCommons
BSN_LICENSE_RDF : BSN_LICENSE_TEXT); BSN_LICENSE_RDF : BSN_LICENSE_TEXT);
bs.setFormat(bs_format); bs.setFormat(bs_format);
bs.update(); bs.update();
} }
public static void removeLicense(Context context, Item item) public static void removeLicense(Context context, Item item)
throws SQLException, IOException, AuthorizeException throws SQLException, IOException, AuthorizeException