forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from ufal/issue_289
Issue 289
- Loading branch information
Showing
14 changed files
with
248 additions
and
113 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
dspace-api/src/main/java/cz/cuni/mff/ufal/curation/DepositLicenseCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package cz.cuni.mff.ufal.curation; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.dspace.content.*; | ||
import org.dspace.core.Constants; | ||
import org.dspace.core.Context; | ||
import org.dspace.curate.AbstractCurationTask; | ||
import org.dspace.curate.Curator; | ||
|
||
public class DepositLicenseCheck extends AbstractCurationTask { | ||
|
||
private String msg = null; | ||
private int status = Curator.CURATE_UNSET; | ||
|
||
@Override | ||
public int perform(DSpaceObject dso) { | ||
if(dso.getType() == Constants.ITEM){ | ||
Item item = (Item)dso; | ||
//everything OK unless prove otherwise | ||
msg = String.format("Item %s OK", item.getHandle()); | ||
status = Curator.CURATE_SUCCESS; | ||
try { | ||
Collection col = item.getOwningCollection(); | ||
String colLicense = col.getLicense(); | ||
//we have some deposited content | ||
if(item.getBundles("ORIGINAL").length > 0 && item.getBundles("ORIGINAL")[0].getBitstreams().length > 0) { | ||
//if we have a license check if it's ok or some junk. | ||
if (item.getBundles("LICENSE").length == 1 && item.getBundles("LICENSE")[0].getBitstreams().length == 1) { | ||
Bundle bundle = item.getBundles("LICENSE")[0]; | ||
Bitstream bit = bundle.getBitstreams()[0]; | ||
String bitLicense = IOUtils.toString(bit.retrieve(), "UTF-8"); | ||
if (!colLicense.equals(bitLicense)) { | ||
//This is the generic "Replace me" license, use colLicense instead | ||
if (bitLicense != null && bitLicense.contains(placeholderLicenseText)) { | ||
item.removeDSpaceLicense(); | ||
Context context = new Context(); | ||
LicenseUtils.grantLicense(context, item, colLicense); | ||
context.complete(); | ||
msg = String.format("Replaced default \"placeholder\" deposit license in %s", item.getHandle()); | ||
//Something unexpected, just report | ||
} else { | ||
msg = String.format("Deposit license for item %s (/xmlui/bitstream/id/%s/?sequence=%s) and collection %s differ.", | ||
item.getHandle(), bit.getID(), bit.getSequenceID(), col.getName()); | ||
status = Curator.CURATE_FAIL; | ||
} | ||
} | ||
//there is no license bundle or bitstream, add it | ||
} else if (item.getBundles("LICENSE").length == 0 || (item.getBundles("LICENSE").length == 1 && item.getBundles("LICENSE")[0].getBitstreams().length == 0)) { | ||
//if the bundle is there remove it | ||
item.removeDSpaceLicense(); | ||
Context context = new Context(); | ||
LicenseUtils.grantLicense(context, item, colLicense); | ||
context.complete(); | ||
msg = String.format("Adding missing deposit license for %s", item.getHandle()); | ||
} else { | ||
throw new Exception("More than one LICENSE bundles or license bitstreams."); | ||
} | ||
} | ||
} catch (Exception e) { | ||
msg = String.format("Exception while running DepositLicenseCheck on %s: %s", item.getHandle(), e.getMessage()); | ||
status = Curator.CURATE_ERROR; | ||
} | ||
|
||
} else { | ||
status = Curator.CURATE_SKIP; | ||
} | ||
if(msg != null){ | ||
report(msg); | ||
setResult(msg); | ||
} | ||
return status; | ||
} | ||
|
||
private String placeholderLicenseText = "NOTE: PLACE YOUR OWN LICENSE HERE"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
dspace-xmlui/src/main/java/cz/cuni/mff/ufal/ContractPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* Created for LINDAT/CLARIN */ | ||
package cz.cuni.mff.ufal; | ||
|
||
import org.apache.cocoon.ProcessingException; | ||
import org.apache.xalan.xsltc.util.IntegerArray; | ||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer; | ||
import org.dspace.app.xmlui.utils.UIException; | ||
import org.dspace.app.xmlui.wing.Message; | ||
import org.dspace.app.xmlui.wing.WingException; | ||
import org.dspace.app.xmlui.wing.element.*; | ||
import org.dspace.authorize.AuthorizeException; | ||
import org.dspace.content.Collection; | ||
import org.dspace.core.ConfigurationManager; | ||
import org.dspace.core.I18nUtil; | ||
import org.dspace.core.LicenseManager; | ||
import org.xml.sax.SAXException; | ||
|
||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
|
||
public class ContractPage extends AbstractDSpaceTransformer { | ||
|
||
private static final Message T_dspace_home = message("xmlui.general.dspace_home"); | ||
private static final Message T_title = message("xmlui.ContractPage.title"); | ||
private static final Message T_trail = message("xmlui.ContractPage.trail"); | ||
private static final Message T_head = message("xmlui.ContractPage.head"); | ||
private static final Message T_collection_name = message("xmlui.ContractPage.collection_name"); | ||
private static final Message T_explain_non_localized_license = message("xmlui.ContractPage.explain_non_localized_license"); | ||
|
||
private static final String alternativeLicenseText; | ||
static{ | ||
String alternativePath = ConfigurationManager.getProperty("lr","license.alternative.path"); | ||
if(isNotBlank(alternativePath)){ | ||
alternativeLicenseText = LicenseManager.getLicenseText(alternativePath); | ||
}else{ | ||
alternativeLicenseText = null; | ||
} | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException { | ||
pageMeta.addMetadata("title").addContent(T_title); | ||
pageMeta.addTrailLink(contextPath + "/",T_dspace_home); | ||
pageMeta.addTrail().addContent(T_trail); | ||
} | ||
|
||
@Override | ||
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException, ProcessingException { | ||
Division division = body.addDivision("licenses", "well"); | ||
|
||
division.setHead(T_head); | ||
|
||
boolean showExplanation = ConfigurationManager.getBooleanProperty("lr","license.show_localized_explanation", true); | ||
|
||
if(!context.getCurrentLocale().equals(I18nUtil.getDefaultLocale()) && showExplanation ){ | ||
division.addPara().addContent(T_explain_non_localized_license); | ||
if(isNotBlank(alternativeLicenseText)){ | ||
addLicense(division, "default_license_alternative", T_collection_name.parameterize("Default license"), | ||
alternativeLicenseText); | ||
} | ||
} | ||
|
||
for(Collection col : Collection.findAll(context)){ | ||
addLicense(division, Integer.toString(col.getID()), T_collection_name.parameterize(col.getName()), col.getLicense()); | ||
} | ||
} | ||
|
||
private void addLicense(Division division, String id, Message head, String text) throws WingException { | ||
Division license = division.addDivision("license_" + id, "well well-sm well-white"); | ||
license.setHead(head); | ||
TextArea textArea = license.addPara().addTextArea("license_text_" + id); | ||
textArea.setSize(34,0); //cols are overridden by .form-control | ||
textArea.setValue(text); | ||
textArea.setDisabled(); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
dspace-xmlui/src/main/webapp/themes/UFAL/lib/html/contract.html
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
dspace-xmlui/src/main/webapp/themes/UFAL/lib/html/contract.xml
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
dspace-xmlui/src/main/webapp/themes/UFAL/lib/html/cs/contract.html
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
dspace-xmlui/src/main/webapp/themes/UFAL/lib/html/cs/contract.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
NEVÝHRADNÍ LICENCE NA DISTRIBUCI | ||
|
||
Podpisem a odesláním této licence vy (autor/autoři nebo vlastník/vlastníci autorských práv) udělujete | ||
Univerzitě Karlově v Praze (UK) nevýhradní právo celosvětově reprodukovat, | ||
překládat (jak je definováno níže) a/nebo distribuovat vaše příspěvky (včetně abstraktů) | ||
v tištěné i elektronické podobě a za pomoci jakéhokoli média (včetně audia nebo videa, ale i jakýchkoliv jiných médií). | ||
|
||
Souhlasíte s tím, že UK může, pokud nezmění obsah, převést váš příspěvek do jakéhokoli formátu | ||
nebo na jakékoli médium za účelem jeho uchování. | ||
|
||
Rovněž souhlasíte, že UK si může ponechat více než jednu kopii tohoto příspěvku pro | ||
účely jeho bezpečnosti, zálohování a dlouhodobého uchovávání. | ||
|
||
Prohlašujete, že váš příspěvek k dílu je původní a že máte právo udělovat práva uvedená v této licenci k celému dílu. | ||
Prohlašujete také, že podle vašeho nejlepšího vědomí a svědomí, neporušujete tímto ničí autorská práva. | ||
|
||
V případě, že příspěvek obsahuje materiál, pro který nevlastníte autorská práva, | ||
prohlašujete, že jste obdržel(i) neomezené povolení | ||
vlastníka autorských práv udělit UK práva požadovaná touto licencí a že | ||
takový materiál ve vlastnictví třetí strany je zřetelně označen a citován | ||
v textu nebo obsahu vašeho příspěvku. | ||
|
||
POKUD JE PŘÍSPĚVEK ZALOŽEN NA PRÁCI, KTERÁ BYLA SPONZOROVÁNA NEBO PODPOROVÁNA JAKOUKOLI JINOU AGENTUROU NEBO ORGANIZACÍ, | ||
NEŽ JE UK, PROHLAŠUJETE, ŽE JSTE SPLNIL(I) VŠECHNA PRÁVA NA PŘEZKOUMÁNÍ A TAKÉ JINÉ ZÁVAZKY | ||
VYŽADOVANÉ TAKOVOUTO SMLOUVOU NEBO UJEDNÁNÍM. | ||
|
||
UK bude jasně identifikovat vaše jméno (jména) jako autora (autorů) nebo vlastníka (vlastníků) | ||
poskytnutého díla a nebude provádět žádné jiné změny tohoto díla než ty, které povoluje tato licence. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.