Request copy of protected item.

This commit is contained in:
aroman
2013-07-22 12:29:57 +02:00
committed by Ivan Masár
parent 3bccc1c7c0
commit b24588022e
27 changed files with 2111 additions and 166 deletions

View File

@@ -8,11 +8,14 @@
package org.dspace.core;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -20,6 +23,7 @@ import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.Address;
import javax.mail.BodyPart;
@@ -94,7 +98,8 @@ import org.dspace.utils.DSpace;
*
* @author Robert Tansley
* @author Jim Downing - added attachment handling code
* @version $Revision$
* @author Adan Roman Ruiz at arvo.es - added inputstream attachment handling code
* @version $Revision: 5844 $
*/
public class Email
{
@@ -114,6 +119,7 @@ public class Email
private String replyTo;
private List<FileAttachment> attachments;
private List<InputStreamAttachment> moreAttachments;
/** The character set this message will be sent in */
private String charset;
@@ -128,6 +134,7 @@ public class Email
arguments = new ArrayList<Object>(50);
recipients = new ArrayList<String>(50);
attachments = new ArrayList<FileAttachment>(10);
moreAttachments = new ArrayList<InputStreamAttachment>(10);
subject = "";
content = "";
replyTo = null;
@@ -196,6 +203,10 @@ public class Email
{
attachments.add(new FileAttachment(f, name));
}
public void addAttachment(InputStream is, String name,String mimetype)
{
moreAttachments.add(new InputStreamAttachment(is, name,mimetype));
}
public void setCharset(String cs)
{
@@ -211,6 +222,7 @@ public class Email
arguments = new ArrayList<Object>(50);
recipients = new ArrayList<String>(50);
attachments = new ArrayList<FileAttachment>(10);
moreAttachments = new ArrayList<InputStreamAttachment>(10);
replyTo = null;
charset = null;
}
@@ -220,8 +232,9 @@ public class Email
*
* @throws MessagingException
* if there was a problem sending the mail.
* @throws IOException
*/
public void send() throws MessagingException
public void send() throws MessagingException, IOException
{
// Get the mail configuration properties
String from = ConfigurationManager.getProperty("mail.from.address");
@@ -269,7 +282,7 @@ public class Email
}
// Add attachments
if (attachments.isEmpty())
if (attachments.isEmpty() && moreAttachments.isEmpty())
{
// If a character set has been specified, or a default exists
if (charset != null)
@@ -281,25 +294,37 @@ public class Email
message.setText(fullMessage);
}
}
else
{
Multipart multipart = new MimeMultipart();
// create the first part of the email
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(fullMessage);
multipart.addBodyPart(messageBodyPart);
for (Iterator<FileAttachment> iter = attachments.iterator(); iter.hasNext();)
{
FileAttachment f = iter.next();
// add the file
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(
new FileDataSource(f.file)));
messageBodyPart.setFileName(f.name);
multipart.addBodyPart(messageBodyPart);
}
message.setContent(multipart);
else{
Multipart multipart = new MimeMultipart();
// create the first part of the email
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(fullMessage);
multipart.addBodyPart(messageBodyPart);
if(!attachments.isEmpty()){
for (Iterator<FileAttachment> iter = attachments.iterator(); iter.hasNext();)
{
FileAttachment f = iter.next();
// add the file
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(
new FileDataSource(f.file)));
messageBodyPart.setFileName(f.name);
multipart.addBodyPart(messageBodyPart);
}
message.setContent(multipart);
}
if(!moreAttachments.isEmpty()){
for (Iterator<InputStreamAttachment> iter = moreAttachments.iterator(); iter.hasNext();)
{
InputStreamAttachment isa = iter.next();
// add the stream
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(new InputStreamDataSource(isa.name,isa.mimetype,isa.is)));
messageBodyPart.setFileName(isa.name);
multipart.addBodyPart(messageBodyPart);
}
message.setContent(multipart);
}
}
if (replyTo != null)
@@ -460,6 +485,12 @@ public class Email
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
System.err.println("\n");
System.exit(1);
}catch (IOException e1) {
System.err.println("\nError sending email:");
System.err.println(" - Error: " + e1);
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
System.err.println("\n");
System.exit(1);
}
System.out.println("\nEmail sent successfully!\n");
}
@@ -482,4 +513,62 @@ public class Email
String name;
}
/**
* Utility struct class for handling file attachments.
*
* @author Adán Román Ruiz at arvo.es
*
*/
private static class InputStreamAttachment
{
public InputStreamAttachment(InputStream is, String name, String mimetype)
{
this.is = is;
this.name = name;
this.mimetype = mimetype;
}
InputStream is;
String mimetype;
String name;
}
/**
*
* @author arnaldo
*/
public class InputStreamDataSource implements DataSource {
private String name;
private String contentType;
private ByteArrayOutputStream baos;
InputStreamDataSource(String name, String contentType, InputStream inputStream) throws IOException {
this.name = name;
this.contentType = contentType;
baos = new ByteArrayOutputStream();
int read;
byte[] buff = new byte[256];
while((read = inputStream.read(buff)) != -1) {
baos.write(buff, 0, read);
}
}
public String getContentType() {
return contentType;
}
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(baos.toByteArray());
}
public String getName() {
return name;
}
public OutputStream getOutputStream() throws IOException {
throw new IOException("Cannot write to this read-only resource");
}
}
}

View File

@@ -1712,3 +1712,5 @@ jsp.version.notice.new_version_head = Notice
jsp.version.notice.new_version_help = This is not the latest version of this item. The latest version can be found at:
jsp.version.notice.workflow_version_head = Notice
jsp.version.notice.workflow_version_help = A more recent version of this item is in the Workflow.
itemRequest.all = All files

View File

@@ -0,0 +1,148 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.HashUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.HandleUtil;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.app.xmlui.wing.element.Radio;
import org.dspace.app.xmlui.wing.element.Text;
import org.dspace.app.xmlui.wing.element.TextArea;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.xml.sax.SAXException;
/**
* Display to the user a form to request change of permissions of a item.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestChangeStatusForm extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
/** Language Strings */
private static final Message T_title =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.title");
private static final Message T_dspace_home =
message("xmlui.general.dspace_home");
private static final Message T_trail =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.trail");
private static final Message T_head =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.head");
private static final Message T_para1 =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.para1");
private static final Message T_name =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.name");
private static final Message T_email =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.email");
private static final Message T_name_error =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.name.error");
private static final Message T_email_error =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.email.error");
private static final Message T_changeToOpen =
message("xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.changeToOpen");
/**
* Generate the unique caching key.
* This key must be unique inside the space of this component.
*/
public Serializable getKey() {
String token = parameters.getParameter("token","");
String name = parameters.getParameter("name","");
String email = parameters.getParameter("email","");
Request request = ObjectModelHelper.getRequest(objectModel);
String openAccess = request.getParameter("openAccess");
return HashUtil.hash(token+name+email+openAccess);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity()
{
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
{
Request request = ObjectModelHelper.getRequest(objectModel);
// Build the item viewer division.
Division itemRequest = body.addInteractiveDivision("itemRequest-form",
request.getRequestURI(),Division.METHOD_POST,"primary");
itemRequest.setHead(T_head);
itemRequest.addPara(T_para1);
List form = itemRequest.addList("form",List.TYPE_FORM);
Text name = form.addItem().addText("name");
name.setLabel(T_name);
name.setValue(parameters.getParameter("name",""));
Text mail = form.addItem().addText("email");
mail.setLabel(T_email);
mail.setValue(parameters.getParameter("email",""));
if(request.getParameter("openAccess")!=null){
if(StringUtils.isEmpty(parameters.getParameter("name", ""))){
name.addError(T_name_error);
}
if(StringUtils.isEmpty(parameters.getParameter("email", ""))){
mail.addError(T_email_error);
}
}
// mail.setValue(parameters.getParameter("mail",""));
form.addItem().addHidden("isSent").setValue("true");
form.addItem().addButton("openAccess").setValue(T_changeToOpen);
}
}

View File

@@ -0,0 +1,192 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.HashUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.HandleUtil;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.app.xmlui.wing.element.Radio;
import org.dspace.app.xmlui.wing.element.Text;
import org.dspace.app.xmlui.wing.element.TextArea;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.xml.sax.SAXException;
/**
* Display to the user a simple form letting the user to request a protected item.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestForm extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
/** Language Strings */
private static final Message T_title =
message("xmlui.ArtifactBrowser.ItemRequestForm.title");
private static final Message T_dspace_home =
message("xmlui.general.dspace_home");
private static final Message T_trail =
message("xmlui.ArtifactBrowser.ItemRequestForm.trail");
private static final Message T_head =
message("xmlui.ArtifactBrowser.ItemRequestForm.head");
private static final Message T_para1 =
message("xmlui.ArtifactBrowser.ItemRequestForm.para1");
private static final Message T_requesterEmail =
message("xmlui.ArtifactBrowser.ItemRequestForm.requesterEmail");
private static final Message T_requesterEmail_help =
message("xmlui.ArtifactBrowser.ItemRequestForm.requesterEmail_help");
private static final Message T_requesterEmail_error =
message("xmlui.ArtifactBrowser.ItemRequestForm.requesterEmail.error");
private static final Message T_message =
message("xmlui.ArtifactBrowser.ItemRequestForm.message");
private static final Message T_message_error =
message("xmlui.ArtifactBrowser.ItemRequestForm.message.error");
private static final Message T_requesterName =
message("xmlui.ArtifactBrowser.ItemRequestForm.requesterName");
private static final Message T_requesterName_error =
message("xmlui.ArtifactBrowser.ItemRequestForm.requesterName.error");
private static final Message T_allFiles =
message("xmlui.ArtifactBrowser.ItemRequestForm.allFiles");
private static final Message T_files =
message("xmlui.ArtifactBrowser.ItemRequestForm.files");
private static final Message T_notAllFiles =
message("xmlui.ArtifactBrowser.ItemRequestForm.notAllFiles");
private static final Message T_submit =
message("xmlui.ArtifactBrowser.ItemRequestForm.submit");
/**
* Generate the unique caching key.
* This key must be unique inside the space of this component.
*/
public Serializable getKey() {
String requesterName = parameters.getParameter("requesterName","");
String requesterEmail = parameters.getParameter("requesterEmail","");
String allFiles = parameters.getParameter("allFiles","");
String message = parameters.getParameter("message","");
String bitstreamId = parameters.getParameter("bitstreamId","");
return HashUtil.hash(requesterName + "-" + requesterEmail + "-" + allFiles +"-"+message+"-"+bitstreamId);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity()
{
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException {
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
if (!(dso instanceof Item)) {
return;
}
Request request = ObjectModelHelper.getRequest(objectModel);
boolean firstVisit=Boolean.valueOf(request.getParameter("firstVisit"));
Item item = (Item) dso;
// Build the item viewer division.
Division itemRequest = body.addInteractiveDivision("itemRequest-form",
request.getRequestURI(), Division.METHOD_POST, "primary");
itemRequest.setHead(T_head);
itemRequest.addPara(T_para1);
DCValue[] titleDC = item.getDC("title", null, Item.ANY);
if (titleDC != null || titleDC.length > 0)
itemRequest.addPara(titleDC[0].value);
List form = itemRequest.addList("form", List.TYPE_FORM);
Text requesterName = form.addItem().addText("requesterName");
requesterName.setLabel(T_requesterName);
requesterName.setValue(parameters.getParameter("requesterName", ""));
Text requesterEmail = form.addItem().addText("requesterEmail");
requesterEmail.setLabel(T_requesterEmail);
requesterEmail.setHelp(T_requesterEmail_help);
requesterEmail.setValue(parameters.getParameter("requesterEmail", ""));
Radio radio = form.addItem().addRadio("allFiles");
String selected=!parameters.getParameter("allFiles","true").equalsIgnoreCase("false")?"true":"false";
radio.setOptionSelected(selected);
radio.setLabel(T_files);
radio.addOption("true", T_allFiles);
radio.addOption("false", T_notAllFiles);
TextArea message = form.addItem().addTextArea("message");
message.setLabel(T_message);
message.setValue(parameters.getParameter("message", ""));
form.addItem().addHidden("bitstreamId").setValue(parameters.getParameter("bitstreamId", ""));
form.addItem().addButton("submit").setValue(T_submit);
// if button is pressed and form is re-loaded it means some parameter is missing
if(request.getParameter("submit")!=null){
if(StringUtils.isEmpty(parameters.getParameter("requesterName", ""))){
requesterName.addError(T_requesterName_error);
}
if(StringUtils.isEmpty(parameters.getParameter("requesterEmail", ""))){
requesterEmail.addError(T_requesterEmail_error);
}
if(StringUtils.isEmpty(parameters.getParameter("message", ""))){
message.addError(T_message_error);
}
}
itemRequest.addHidden("page").setValue(parameters.getParameter("page", "unknown"));
}
}

View File

@@ -0,0 +1,217 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.net.InetAddress;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.mail.MessagingException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.app.xmlui.utils.ContextUtil;
import org.dspace.app.xmlui.utils.HandleUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.Email;
import org.dspace.core.I18nUtil;
import org.dspace.core.LogManager;
import org.dspace.core.Utils;
import org.dspace.eperson.EPerson;
import org.dspace.handle.HandleManager;
import org.dspace.storage.bitstore.BitstreamStorageManager;
import org.dspace.storage.rdbms.DatabaseManager;
import org.dspace.storage.rdbms.TableRow;
/**
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestResponseAction extends AbstractAction
{
/** log4j log */
private static Logger log = Logger.getLogger(ItemRequestResponseAction.class);
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel,
String source, Parameters parameters) throws Exception
{
Request request = ObjectModelHelper.getRequest(objectModel);
String token = parameters.getParameter("token","");
String decision = request.getParameter("decision");
String isSent = request.getParameter("isSent");
String message = request.getParameter("message");
Context context = ContextUtil.obtainContext(objectModel);
TableRow requestItem = DatabaseManager.findByUnique(context, "requestitem", "token", token);
String title;
Item item = Item.find(context, requestItem.getIntColumn("item_id"));
DCValue[] titleDC = item.getDC("title", null, Item.ANY);
if (titleDC != null || titleDC.length > 0)
title=titleDC[0].value;
else
title="untitled";
String button="";
// Botones de las paginas:
if(request.getParameter("send")!=null){
decision="true";
button="send";
}else if(request.getParameter("dontSend")!=null){
decision="false";
button="dontSend";
}
if(request.getParameter("mail")!=null){
button="mail";
}else if(request.getParameter("back")!=null){
button="back";
}
if(request.getParameter("openAccess")!=null){
button="openAccess";
}
if(button.equals("mail")&& StringUtils.isNotEmpty(decision) && decision.equals("true")){
processSendDocuments(context,request,requestItem,item,title);
isSent="true";
}else if(button.equals("mail")&& StringUtils.isNotEmpty(decision) && decision.equals("false")){
processDeny(context,request,requestItem,item,title);
isSent="true";
}else if(button.equals("openAccess")){
if(processOpenAccessRequest(context,request,requestItem,item,title)){
// se acabo el flujo
return null;
}
}else if(button.equals("back")){
decision=null;
}
Map<String, String> map = new HashMap<String, String>();
map.put("decision", decision);
map.put("token", token);
map.put("isSent", isSent);
map.put("title", title);
map.put("name", request.getParameter("name"));
map.put("email",request.getParameter("email"));
return map;
}
private boolean processOpenAccessRequest(Context context,Request request, TableRow requestItem,Item item,String title) throws SQLException, IOException, MessagingException {
String name = request.getParameter("name");
String mail = request.getParameter("email");
if(StringUtils.isNotEmpty(name)&&StringUtils.isNotEmpty(mail)){
String emailRequest;
EPerson submiter = item.getSubmitter();
if(submiter!=null){
emailRequest=submiter.getEmail();
}else{
emailRequest=ConfigurationManager.getProperty("mail.helpdesk");
}
if(emailRequest==null){
emailRequest=ConfigurationManager.getProperty("mail.admin");
}
Email email = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "requestItem.admin"));
email.addRecipient(emailRequest);
email.addArgument(Bitstream.find(context,requestItem.getIntColumn("bitstream_id")).getName());
email.addArgument(HandleManager.getCanonicalForm(item.getHandle()));
email.addArgument(requestItem.getStringColumn("token"));
email.addArgument(name);
email.addArgument(mail);
email.send();
return true;
}
return false;
}
private void processSendDocuments(Context context,Request request, TableRow requestItem,Item item,String title) throws SQLException, MessagingException, IOException {
String message = request.getParameter("message");
EPerson submiter = item.getSubmitter();
Email email = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "requestItem.aprove"));
email.addRecipient(requestItem.getStringColumn("request_email"));
email.addArgument(requestItem.getStringColumn("request_name"));
email.addArgument("");
email.addArgument("");
email.addArgument(HandleManager.getCanonicalForm(item.getHandle())); // User agent
email.addArgument(title); // request item title
email.addArgument(message); // message
email.addArgument(""); //# token link
email.addArgument(submiter.getFullName()); //# submmiter name
email.addArgument(submiter.getEmail()); //# submmiter email
if (requestItem.getBooleanColumn("allfiles")){
Bundle[] bundles = item.getBundles("ORIGINAL");
for (int i = 0; i < bundles.length; i++){
Bitstream[] bitstreams = bundles[i].getBitstreams();
for (int k = 0; k < bitstreams.length; k++){
if (!bitstreams[k].getFormat().isInternal() /*&& RequestItemManager.isRestricted(context, bitstreams[k])*/){
email.addAttachment(BitstreamStorageManager.retrieve(context, bitstreams[k].getID()), bitstreams[k].getName(), bitstreams[k].getFormat().getMIMEType());
}
}
}
}else{
Bitstream bit = Bitstream.find(context,requestItem.getIntColumn("bitstream_id"));
email.addAttachment(BitstreamStorageManager.retrieve(context, requestItem.getIntColumn("bitstream_id")), bit.getName(), bit.getFormat().getMIMEType());
}
email.send();
requestItem.setColumn("decision_date",new Date());
requestItem.setColumn("accept_request",true);
DatabaseManager.update(context, requestItem);
}
private void processDeny(Context context,Request request, TableRow requestItem,Item item,String title) throws SQLException, IOException, MessagingException {
String message = request.getParameter("message");
EPerson submiter = item.getSubmitter();
Email email = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "requestItem.reject"));
email.addRecipient(requestItem.getStringColumn("request_email"));
email.addArgument(requestItem.getStringColumn("request_name"));
email.addArgument("");
email.addArgument("");
email.addArgument(HandleManager.getCanonicalForm(item.getHandle())); // User agent
email.addArgument(title); // request item title
email.addArgument(message); // message
email.addArgument(""); //# token link
email.addArgument(submiter.getFullName()); //# submmiter name
email.addArgument(submiter.getEmail()); //# submmiter email
email.send();
requestItem.setColumn("decision_date",new Date());
requestItem.setColumn("accept_request",false);
DatabaseManager.update(context, requestItem);
}
}

View File

@@ -0,0 +1,112 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.HashUtil;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.HandleUtil;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.app.xmlui.wing.element.Para;
import org.dspace.app.xmlui.wing.element.Radio;
import org.dspace.app.xmlui.wing.element.Text;
import org.dspace.app.xmlui.wing.element.TextArea;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.xml.sax.SAXException;
/**
* Display to the user a simple decision form to select sending or not a file to
* requester.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestResponseDecisionForm extends AbstractDSpaceTransformer
implements CacheableProcessingComponent {
/** Language Strings */
private static final Message T_title = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.title");
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
private static final Message T_trail = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.trail");
private static final Message T_head = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.head");
private static final Message T_para1 = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.para1");
private static final Message T_para2 = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.para2");
private static final Message T_send = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.send");
private static final Message T_dontSend = message("xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.dontSend");
/**
* Generate the unique caching key. This key must be unique inside the space
* of this component.
*/
public Serializable getKey() {
String title = parameters.getParameter("title","");
return HashUtil.hash(title);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity() {
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException {
Request request = ObjectModelHelper.getRequest(objectModel);
String title = parameters.getParameter("title","");
// Build the item viewer division.
Division itemRequest = body.addInteractiveDivision("itemRequest-form",
request.getRequestURI(), Division.METHOD_POST, "primary");
itemRequest.setHead(T_head);
itemRequest.addPara(T_para1.parameterize(title));
itemRequest.addPara(T_para2);
List form = itemRequest.addList("form", List.TYPE_FORM);
form.addItem().addButton("send").setValue(T_send);
form.addItem().addButton("dontSend").setValue(T_dontSend);
}
}

View File

@@ -0,0 +1,122 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.HashUtil;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.HandleUtil;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.app.xmlui.wing.element.Radio;
import org.dspace.app.xmlui.wing.element.Text;
import org.dspace.app.xmlui.wing.element.TextArea;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.xml.sax.SAXException;
/**
* Display to the user a simple form to send a message rejecting the file send.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestResponseFalseForm extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
/** Language Strings */
private static final Message T_title =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.title");
private static final Message T_dspace_home =
message("xmlui.general.dspace_home");
private static final Message T_trail =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.trail");
private static final Message T_head =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.head");
private static final Message T_para1 =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.para1");
private static final Message T_mail =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.mail");
private static final Message T_back =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.back");
private static final Message T_message =
message("xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.message");
/**
* Generate the unique caching key.
* This key must be unique inside the space of this component.
*/
public Serializable getKey() {
String token = parameters.getParameter("token", "");
String decision = parameters.getParameter("decision", "");
return HashUtil.hash(token+"-"+decision);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity()
{
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
{
Request request = ObjectModelHelper.getRequest(objectModel);
// Build the item viewer division.
Division itemRequest = body.addInteractiveDivision("itemRequest-form",
request.getRequestURI(),Division.METHOD_POST,"primary");
itemRequest.setHead(T_head);
itemRequest.addPara(T_para1);
List form = itemRequest.addList("form",List.TYPE_FORM);
TextArea message = form.addItem().addTextArea("message");
message.setLabel(T_message);
message.setValue(parameters.getParameter("message",""));
form.addItem().addHidden("decision").setValue(parameters.getParameter("decision",""));
form.addItem().addButton("back").setValue(T_back);
form.addItem().addButton("mail").setValue(T_mail);
}
}

View File

@@ -0,0 +1,115 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.HashUtil;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.app.xmlui.wing.element.TextArea;
import org.dspace.authorize.AuthorizeException;
import org.xml.sax.SAXException;
/**
* Display to the user a simple form letting the user send a document with a message.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestResponseTrueForm extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
/** Language Strings */
private static final Message T_title =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.title");
private static final Message T_dspace_home =
message("xmlui.general.dspace_home");
private static final Message T_trail =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.trail");
private static final Message T_head =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.head");
private static final Message T_para1 =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.para1");
private static final Message T_mail =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.mail");
private static final Message T_back =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.back");
private static final Message T_message =
message("xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.message");
/**
* Generate the unique caching key.
* This key must be unique inside the space of this component.
*/
public Serializable getKey() {
String token = parameters.getParameter("token", "");
String decision = parameters.getParameter("decision", "");
return HashUtil.hash(token+"-"+decision);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity()
{
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
{
Request request = ObjectModelHelper.getRequest(objectModel);
Division itemRequest = body.addInteractiveDivision("itemRequest-form", request.getRequestURI(),Division.METHOD_POST,"primary");
itemRequest.setHead(T_head);
itemRequest.addPara(T_para1);
List form = itemRequest.addList("form",List.TYPE_FORM);
TextArea message = form.addItem().addTextArea("message");
message.setLabel(T_message);
message.setValue(parameters.getParameter("message",""));
form.addItem().addHidden("decision").setValue(parameters.getParameter("decision",""));
form.addItem().addButton("back").setValue(T_back);
form.addItem().addButton("mail").setValue(T_mail);
}
}

View File

@@ -0,0 +1,91 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.authorize.AuthorizeException;
import org.xml.sax.SAXException;
/**
* Simple page to let the user know their mail and file has been sent.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestSent extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
/** language strings */
public static final Message T_title =
message("xmlui.ArtifactBrowser.ItemRequestSent.title");
public static final Message T_dspace_home =
message("xmlui.general.dspace_home");
public static final Message T_trail =
message("xmlui.ArtifactBrowser.ItemRequestSent.trail");
public static final Message T_head =
message("xmlui.ArtifactBrowser.ItemRequestSent.head");
public static final Message T_para1 =
message("xmlui.ArtifactBrowser.ItemRequestSent.para1");
/**
* Generate the unique caching key.
*/
public Serializable getKey() {
return 0;
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity()
{
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
{
Division feedback = body.addDivision("itemRequest-sent","primary");
feedback.setHead(T_head);
feedback.addPara(T_para1);
}
}

View File

@@ -0,0 +1,106 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.util.HashUtil;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.HandleUtil;
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.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.app.xmlui.wing.element.Radio;
import org.dspace.app.xmlui.wing.element.Text;
import org.dspace.app.xmlui.wing.element.TextArea;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.xml.sax.SAXException;
/**
* Display to the user a simple page to let the user know the mail to request change status of a item is sent.
*
* @author Adán Román Ruiz at arvo.es
*/
public class ItemRequestStatusChanged extends AbstractDSpaceTransformer implements CacheableProcessingComponent
{
/** Language Strings */
private static final Message T_title =
message("xmlui.ArtifactBrowser.ItemRequestStatusChanged.title");
private static final Message T_dspace_home =
message("xmlui.general.dspace_home");
private static final Message T_trail =
message("xmlui.ArtifactBrowser.ItemRequestStatusChanged.trail");
private static final Message T_head =
message("xmlui.ArtifactBrowser.ItemRequestStatusChanged.head");
private static final Message T_para1 =
message("xmlui.ArtifactBrowser.ItemRequestStatusChanged.para1");
private static final Message T_para2 =
message("xmlui.ArtifactBrowser.ItemRequestStatusChanged.para2");
/**
* Generate the unique caching key.
* This key must be unique inside the space of this component.
*/
public Serializable getKey() {
String token = parameters.getParameter("token", "");
return HashUtil.hash(token);
}
/**
* Generate the cache validity object.
*/
public SourceValidity getValidity()
{
return NOPValidity.SHARED_INSTANCE;
}
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);
}
public void addBody(Body body) throws SAXException, WingException,
UIException, SQLException, IOException, AuthorizeException
{
Division itemRequest = body.addDivision("itemRequestStatus");
itemRequest.setHead(T_head);
itemRequest.addPara(T_para1);
itemRequest.addPara(T_para2);
}
}

View File

@@ -0,0 +1,198 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.artifactbrowser;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.app.xmlui.utils.ContextUtil;
import org.dspace.app.xmlui.utils.HandleUtil;
import org.dspace.content.Bitstream;
import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.Email;
import org.dspace.core.I18nUtil;
import org.dspace.core.Utils;
import org.dspace.eperson.EPerson;
import org.dspace.handle.HandleManager;
import org.dspace.storage.rdbms.DatabaseManager;
import org.dspace.storage.rdbms.TableRow;
/**
* This action will send a mail to request a item to administrator when all mandatory data is present.
* It will record the request into the database.
*
* @author Adán Román Ruiz at arvo.es
*/
public class SendItemRequestAction extends AbstractAction
{
private static Logger log = Logger.getLogger(SendItemRequestAction.class);
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel,
String source, Parameters parameters) throws Exception
{
Request request = ObjectModelHelper.getRequest(objectModel);
String requesterName = request.getParameter("requesterName");
String requesterEmail = request.getParameter("requesterEmail");
String allFiles = request.getParameter("allFiles");
String message = request.getParameter("message");
String bitstreamId = request.getParameter("bitstreamId");
// User email from context
Context context = ContextUtil.obtainContext(objectModel);
EPerson loggedin = context.getCurrentUser();
String eperson = null;
if (loggedin != null)
{
eperson = loggedin.getEmail();
}
// Check all data is there
if (StringUtils.isEmpty(requesterName) || StringUtils.isEmpty(requesterEmail) || StringUtils.isEmpty(allFiles) || StringUtils.isEmpty(message))
{
// Either the user did not fill out the form or this is the
// first time they are visiting the page.
Map<String,String> map = new HashMap<String,String>();
map.put("bitstreamId",bitstreamId);
if (StringUtils.isEmpty(requesterEmail))
{
map.put("requesterEmail", eperson);
}
else
{
map.put("requesterEmail", requesterEmail);
}
map.put("requesterName",requesterName);
map.put("allFiles",allFiles);
map.put("message",message);
return map;
}
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
if (!(dso instanceof Item))
{
throw new Exception("Invalid DspaceObject at ItemRequest.");
}
Item item = (Item) dso;
String title="";
DCValue[] titleDC = item.getDC("title", null, Item.ANY);
if (titleDC != null || titleDC.length > 0) {
title=titleDC[0].value;
}
String emailRequest;
EPerson submiter = item.getSubmitter();
if(submiter!=null){
emailRequest=submiter.getEmail();
}else{
emailRequest=ConfigurationManager.getProperty("mail.helpdesk");
}
if(emailRequest==null){
emailRequest=ConfigurationManager.getProperty("mail.admin");
}
// All data is there, send the email
Email email = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(), "requestItem.author"));
email.addRecipient(emailRequest);
email.addArgument(requesterName);
email.addArgument(requesterEmail);
email.addArgument(allFiles.equals("true")?I18nUtil.getMessage("itemRequest.all"):Bitstream.find(context,Integer.parseInt(bitstreamId)).getName());
email.addArgument(HandleManager.getCanonicalForm(item.getHandle()));
email.addArgument(title); // request item title
email.addArgument(message); // message
email.addArgument(getLinkTokenEmail(context,request, bitstreamId, item.getID(), requesterEmail, requesterName, Boolean.parseBoolean(allFiles)));
email.addArgument(submiter.getFullName()); // submmiter name
email.addArgument(submiter.getEmail()); // submmiter email
email.addArgument(ConfigurationManager.getProperty("dspace.name"));
email.addArgument(ConfigurationManager.getProperty("mail.helpdesk"));
email.setReplyTo(requesterEmail);
email.send();
// Finished, allow to pass.
return null;
}
/**
* Get the link to the author in RequestLink email.
*
* @param email
* The email address to mail to
*
* @exception SQLExeption
*
*/
protected String getLinkTokenEmail(Context context,Request request, String bitstreamId
, int itemID, String reqEmail, String reqName, boolean allfiles)
throws SQLException
{
String base = ConfigurationManager.getProperty("dspace.url");
request.getPathInfo();
String specialLink = (new StringBuffer()).append(base).append(
base.endsWith("/") ? "" : "/").append(
"itemRequestResponse/").append(getNewToken(context, Integer.parseInt(bitstreamId), itemID, reqEmail, reqName, allfiles))
.toString()+"/";
return specialLink;
}
/**
* Generate a unique id of the request and put it into the ddbb
* @param context
* @param bitstreamId
* @param itemID
* @param reqEmail
* @param reqName
* @param allfiles
* @return
* @throws SQLException
*/
protected String getNewToken(Context context, int bitstreamId, int itemID, String reqEmail, String reqName, boolean allfiles) throws SQLException
{
TableRow rd = DatabaseManager.create(context, "requestitem");
rd.setColumn("token", Utils.generateHexKey());
rd.setColumn("bitstream_id", bitstreamId);
rd.setColumn("item_id",itemID);
rd.setColumn("allfiles", allfiles);
rd.setColumn("request_email", reqEmail);
rd.setColumn("request_name", reqName);
rd.setColumnNull("accept_request");
rd.setColumn("request_date", new Date());
rd.setColumnNull("decision_date");
rd.setColumnNull("expires");
DatabaseManager.update(context, rd);
if (log.isDebugEnabled())
{
log.debug("Created requestitem_token "
+ rd.getIntColumn("requestitem_id")
+ " with token " + rd.getStringColumn("token")
+ "\"");
}
return rd.getStringColumn("token");
}
}

View File

@@ -0,0 +1,86 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
*
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*/
package org.dspace.app.xmlui.aspect.general;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.matching.Matcher;
import org.apache.cocoon.sitemap.PatternException;
import org.apache.cocoon.util.ConfigurationUtil;
import org.apache.commons.lang.StringUtils;
import org.dspace.app.xmlui.utils.ContextUtil;
import org.dspace.app.xmlui.utils.HandleUtil;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.DSpaceObject;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
/**
* Use the configuration in Dspace.cfg to select paths in sitemap.xmap
*
* @author Adán Román Ruiz at arvo.es
*/
public class ConfigurationMatcher extends AbstractLogEnabled implements Matcher
{
/**
* Format "keyInDspace.cfg,value,value"
* "Only property" check if it is defined(not empty),
* "property,value" check if property has this value,
* "property, value,value..." check that property has one of the following values.
* operator ! is alowed: "!property, value, value2" property has not value 1 nor value 2
* @param pattern
* name of sitemap parameter to find
* @param objectModel
* environment passed through via cocoon
* @return null or map containing value of sitemap parameter 'pattern'
*/
public Map match(String pattern, Map objectModel, Parameters parameters) throws PatternException
{
boolean not = false;
boolean itMatch = false;
if (pattern.startsWith("!")) {
not = true;
pattern = pattern.substring(1);
}
String[] expressions = pattern.split(",");
String propertyValue = ConfigurationManager.getProperty(expressions[0]);
if (expressions.length == 1) {
if (StringUtils.isNotEmpty(propertyValue)) {
itMatch = true;
} else {
itMatch = false;
}
} else {
for (int i = 1; i < expressions.length; i++) {
if (StringUtils.equalsIgnoreCase(expressions[i], propertyValue)) {
itMatch = true;
break;
}
}
itMatch = false;
}
if (itMatch && !not) {
return new HashMap();
} else if (itMatch && not) {
return null;
} else if (!itMatch && !not) {
return null;
} else if (!itMatch && not) {
return new HashMap();
}
return null;
}
}

View File

@@ -29,6 +29,7 @@ import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.cocoon.environment.http.HttpResponse;
import org.apache.cocoon.reading.AbstractReader;
import org.apache.cocoon.util.ByteRange;
import org.apache.commons.lang.StringUtils;
import org.dspace.app.xmlui.utils.AuthenticationUtil;
import org.dspace.app.xmlui.utils.ContextUtil;
import org.dspace.authorize.AuthorizeException;
@@ -93,7 +94,12 @@ import org.dspace.core.LogManager;
* &lt;map:parameter name="name" value="{2}"/&gt;
* &lt;/map:read&gt;
*
* Added request-item support.
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*
* @author Scott Phillips
* @author Adán Román Ruiz at arvo.es (added request item support)
*/
public class BitstreamReader extends AbstractReader implements Recyclable
@@ -271,10 +277,11 @@ public class BitstreamReader extends AbstractReader implements Recyclable
isAuthorized = false;
log.info(LogManager.getHeader(context, "view_bitstream", "handle=" + item.getHandle() + ",withdrawn=true"));
}
// It item-request is enabled to all request we redirect to restricted-resource immediately without login request
String requestItemType = ConfigurationManager.getProperty("request.item.type");
if (!isAuthorized)
{
if(context.getCurrentUser() != null){
if(context.getCurrentUser() != null || StringUtils.equalsIgnoreCase("all", requestItemType)){
// A user is logged in, but they are not authorized to read this bitstream,
// instead of asking them to login again we'll point them to a friendly error
// message that tells them the bitstream is restricted.
@@ -293,7 +300,8 @@ public class BitstreamReader extends AbstractReader implements Recyclable
return;
}
else{
if(ConfigurationManager.getProperty("request.item.type")==null||
ConfigurationManager.getProperty("request.item.type").equalsIgnoreCase("logged")){
// The user does not have read access to this bitstream. Interrupt this current request
// and then forward them to the login page so that they can be authenticated. Once that is
// successful, their request will be resumed.
@@ -306,6 +314,7 @@ public class BitstreamReader extends AbstractReader implements Recyclable
objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
httpResponse.sendRedirect(redictURL);
return;
}
}
}

View File

@@ -8,10 +8,13 @@
package org.dspace.app.xmlui.objectmanager;
import org.dspace.app.util.MetadataExposure;
import org.dspace.app.util.Util;
import org.dspace.app.xmlui.wing.AttributeMap;
import org.dspace.app.xmlui.wing.WingException;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.Bitstream;
import org.dspace.content.BitstreamFormat;
import org.dspace.content.Bundle;
import org.dspace.content.DCValue;
import org.dspace.content.Item;
@@ -31,6 +34,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.*;
@@ -52,8 +56,13 @@ import org.dspace.content.DSpaceObject;
*
* There are four parts to an item's METS document: descriptive metadata,
* file section, structural map, and extra sections.
*
*
* Request item-support
* Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
* Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es
*
* @author Scott Phillips
* @author Adán Román Ruiz at arvo.es (for request item support)
*/
public class ItemAdapter extends AbstractAdapter
@@ -728,7 +737,7 @@ public class ItemAdapter extends AbstractAdapter
}
// Render the actual file & flocate elements.
renderFile(item, bitstream, fileID, groupID, admIDs);
renderFileWithAllowed(item, bitstream, fileID, groupID, admIDs);
// Remember all the viewable content bitstreams for later in the
// structMap.
@@ -973,4 +982,141 @@ public class ItemAdapter extends AbstractAdapter
// Didn't find it
return null;
}
/**
* Generate a METS file element for a given bitstream.
*
* @param item
* If the bitstream is associated with an item provide the item
* otherwise leave null.
* @param bitstream
* The bitstream to build a file element for.
* @param fileID
* The unique file id for this file.
* @param groupID
* The group id for this file, if it is derived from another file
* then they should share the same groupID.
* @param admID
* The IDs of the administrative metadata sections which pertain
* to this file
*/
// FIXME: this method is a copy of the one inherited. However the
// original method is final so we must rename it.
protected void renderFileWithAllowed(Item item, Bitstream bitstream, String fileID, String groupID, String admID) throws SAXException
{
AttributeMap attributes;
// //////////////////////////////
// Determine the file attributes
BitstreamFormat format = bitstream.getFormat();
String mimeType = null;
if (format != null)
{
mimeType = format.getMIMEType();
}
String checksumType = bitstream.getChecksumAlgorithm();
String checksum = bitstream.getChecksum();
long size = bitstream.getSize();
// ////////////////////////////////
// Start the actual file
attributes = new AttributeMap();
attributes.put("ID", fileID);
attributes.put("GROUPID",groupID);
if (admID != null && admID.length()>0)
{
attributes.put("ADMID", admID);
}
if (mimeType != null && mimeType.length()>0)
{
attributes.put("MIMETYPE", mimeType);
}
if (checksumType != null && checksum != null)
{
attributes.put("CHECKSUM", checksum);
attributes.put("CHECKSUMTYPE", checksumType);
}
attributes.put("SIZE", String.valueOf(size));
startElement(METS,"file",attributes);
// ////////////////////////////////////
// Determine the file location attributes
String name = bitstream.getName();
String description = bitstream.getDescription();
// If possible reference this bitstream via a handle, however this may
// be null if a handle has not yet been assigned. In this case reference the
// item its internal id. In the last case where the bitstream is not associated
// with an item (such as a community logo) then reference the bitstreamID directly.
String identifier = null;
if (item != null && item.getHandle() != null)
{
identifier = "handle/" + item.getHandle();
}
else if (item != null)
{
identifier = "item/" + item.getID();
}
else
{
identifier = "id/" + bitstream.getID();
}
String url = contextPath + "/bitstream/"+identifier+"/";
// If we can put the pretty name of the bitstream on the end of the URL
try
{
if (bitstream.getName() != null)
{
url += Util.encodeBitstreamName(bitstream.getName(), "UTF-8");
}
}
catch (UnsupportedEncodingException uee)
{
// just ignore it, we don't have to have a pretty
// name on the end of the URL because the sequence id will
// locate it. However it means that links in this file might
// not work....
}
url += "?sequence="+bitstream.getSequenceID();
// Test if we are allowed to see this item
String isAllowed = "n";
try {
if (AuthorizeManager.authorizeActionBoolean(context, bitstream, Constants.READ)) {
isAllowed = "y";
}
} catch (SQLException e) {/* Do nothing */}
url += "&isAllowed=" + isAllowed;
// //////////////////////
// Start the file location
attributes = new AttributeMap();
AttributeMap attributesXLINK = new AttributeMap();
attributesXLINK.setNamespace(XLINK);
attributes.put("LOCTYPE", "URL");
attributesXLINK.put("type","locator");
attributesXLINK.put("title", name);
if (description != null)
{
attributesXLINK.put("label", description);
}
attributesXLINK.put("href", url);
startElement(METS,"FLocat",attributes,attributesXLINK);
// ///////////////////////
// End file location
endElement(METS,"FLocate");
// ////////////////////////////////
// End the file
endElement(METS,"file");
}
}

View File

@@ -14,47 +14,62 @@
The ArtifactBrowser Aspect is responsible for browsing communities /
collections / items / and bitstreams, viewing an individual item,
and searching the repository.
-->
<!-- Added request-item support
Original Concept, JSPUI version: Universidade do Minho at www.uminho.pt
Sponsorship of XMLUI version: Instituto Oceanográfico de España at www.ieo.es -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:transformers>
<map:transformer name="Navigation" src="org.dspace.app.xmlui.aspect.viewArtifacts.Navigation"/>
<map:transformer name="CommunityViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.CommunityViewer"/>
<map:transformer name="CollectionViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.CollectionViewer"/>
<map:transformer name="ItemViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemViewer"/>
<map:transformer name="FeedbackForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.FeedbackForm"/>
<map:transformer name="FeedbackSent" src="org.dspace.app.xmlui.aspect.artifactbrowser.FeedbackSent"/>
<map:transformer name="Contact" src="org.dspace.app.xmlui.aspect.artifactbrowser.Contact"/>
<map:transformer name="RestrictedItem" src="org.dspace.app.xmlui.aspect.artifactbrowser.RestrictedItem"/>
<map:transformers>
<map:transformer name="Navigation" src="org.dspace.app.xmlui.aspect.viewArtifacts.Navigation" />
<map:transformer name="CommunityViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.CommunityViewer" />
<map:transformer name="CollectionViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.CollectionViewer" />
<map:transformer name="ItemViewer" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemViewer" />
<map:transformer name="ItemRequestForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestForm" />
<map:transformer name="ItemRequestSent" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestSent" />
<map:transformer name="FeedbackForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.FeedbackForm" />
<map:transformer name="FeedbackSent" src="org.dspace.app.xmlui.aspect.artifactbrowser.FeedbackSent" />
<map:transformer name="Contact" src="org.dspace.app.xmlui.aspect.artifactbrowser.Contact" />
<map:transformer name="RestrictedItem" src="org.dspace.app.xmlui.aspect.artifactbrowser.RestrictedItem" />
<map:transformer name="ItemRequestResponseDecisionForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseDecisionForm" />
<map:transformer name="ItemRequestChangeStatusForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestChangeStatusForm" />
<map:transformer name="ItemRequestResponseFalseForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseFalseForm" />
<map:transformer name="ItemRequestResponseTrueForm" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseTrueForm" />
<map:transformer name="ItemRequestStatusChanged" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestStatusChanged" />
<map:transformer name="Statistics" src="org.dspace.app.xmlui.aspect.artifactbrowser.StatisticsViewer"/>
</map:transformers>
<map:matchers default="wildcard">
<map:matcher name="HandleTypeMatcher" src="org.dspace.app.xmlui.aspect.general.HandleTypeMatcher"/>
<map:matcher name="HandleAuthorizedMatcher" src="org.dspace.app.xmlui.aspect.general.HandleAuthorizedMatcher"/>
</map:matchers>
<map:matchers default="wildcard">
<map:matcher name="HandleTypeMatcher" src="org.dspace.app.xmlui.aspect.general.HandleTypeMatcher" />
<map:matcher name="HandleAuthorizedMatcher" src="org.dspace.app.xmlui.aspect.general.HandleAuthorizedMatcher" />
<map:matcher name="ConfigurationMatcher" src="org.dspace.app.xmlui.aspect.general.ConfigurationMatcher" />
</map:matchers>
<map:actions>
<map:action name="SendFeedbackAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.SendFeedbackAction"/>
<map:action name="UsageLoggerAction" src="org.dspace.app.xmlui.cocoon.UsageLoggerAction"/>
<map:action name="NotModifiedAction" src="org.dspace.app.xmlui.aspect.general.NotModifiedAction"/>
</map:actions>
<map:actions>
<map:action name="SendFeedbackAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.SendFeedbackAction" />
<map:action name="SendItemRequestAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.SendItemRequestAction" />
<map:action name="UsageLoggerAction" src="org.dspace.app.xmlui.cocoon.UsageLoggerAction" />
<map:action name="NotModifiedAction" src="org.dspace.app.xmlui.aspect.general.NotModifiedAction" />
<map:action name="ItemRequestResponseAction" src="org.dspace.app.xmlui.aspect.artifactbrowser.ItemRequestResponseAction" />
</map:actions>
<map:selectors>
<map:selector name="AuthenticatedSelector" src="org.dspace.app.xmlui.aspect.general.AuthenticatedSelector"/>
<map:selector name="IfModifiedSinceSelector" src="org.dspace.app.xmlui.aspect.general.IfModifiedSinceSelector"/>
</map:selectors>
<map:selectors>
<map:selector name="AuthenticatedSelector" src="org.dspace.app.xmlui.aspect.general.AuthenticatedSelector" />
<map:selector name="IfModifiedSinceSelector" src="org.dspace.app.xmlui.aspect.general.IfModifiedSinceSelector" />
</map:selectors>
</map:components>
<map:pipelines>
<map:pipeline>
</map:components>
<map:pipelines>
<map:pipeline>
<map:generate/>
@@ -91,132 +106,238 @@ and searching the repository.
</map:match>
<!-- Display statistics -->
<map:match pattern="statistics">
<map:transform type="Statistics"/>
<map:serialize type="xml"/>
</map:match>
<!-- Display statistics -->
<map:match pattern="statistics">
<map:transform type="Statistics" />
<map:serialize type="xml" />
</map:match>
<!-- restricted resource -->
<map:match pattern="restricted-resource">
<map:transform type="RestrictedItem"/>
<map:serialize type="xml"/>
</map:match>
<!-- restricted resource -->
<map:match pattern="restricted-resource">
<map:transform type="RestrictedItem" />
<map:serialize type="xml" />
</map:match>
<!-- Handle specific features -->
<map:match pattern="handle/*/**">
<!-- Handle specific features -->
<map:match pattern="handle/*/**">
<!-- Inform the user that the item they are viewing is a restricted resource -->
<map:match pattern="handle/*/*/restricted-resource">
<map:transform type="RestrictedItem"/>
<map:serialize type="xml"/>
</map:match>
<!-- Inform the user that the item they are viewing is a restricted resource -->
<map:match pattern="handle/*/*/restricted-resource">
<!-- If request copy is enabled it comes here -->
<map:match type="ConfigurationMatcher" pattern="request.item.type">
<map:act type="SendItemRequestAction">
<map:transform type="ItemRequestForm">
<map:parameter name="requesterName" value="{requesterName}" />
<map:parameter name="requesterEmail" value="{requesterEmail}" />
<map:parameter name="allFiles" value="{allFiles}" />
<map:parameter name="message" value="{message}" />
<map:parameter name="bitstreamId" value="{bitstreamId}" />
</map:transform>
<map:serialize type="xml" />
</map:act>
<map:transform type="ItemRequestSent" />
<map:serialize type="xml" />
</map:match>
<!-- If request copy is disabled normal flow -->
<map:transform type="RestrictedItem"/>
<map:serialize type="xml"/>
</map:match>
<!-- Community, Collection, and Item Viewers -->
<map:match pattern="handle/*/*">
<map:match type="HandleAuthorizedMatcher" pattern="READ">
<map:match type="HandleTypeMatcher" pattern="community">
<map:act type="UsageLoggerAction">
<map:parameter name="type" value="community"/>
<map:parameter name="eventType" value="view"/>
</map:act>
<map:transform type="CommunityViewer"/>
<map:serialize type="xml"/>
</map:match>
<map:match type="HandleTypeMatcher" pattern="collection">
<map:act type="UsageLoggerAction">
<map:parameter name="type" value="collection"/>
<map:parameter name="eventType" value="view"/>
</map:act>
<map:transform type="CollectionViewer"/>
<map:serialize type="xml"/>
</map:match>
<map:match type="HandleTypeMatcher" pattern="item">
<map:act type="UsageLoggerAction">
<map:parameter name="type" value="item"/>
<map:parameter name="eventType" value="view"/>
</map:act>
<!-- Implement HTTP If-Modified-Since protocol (commonly used by search
- engine crawlers): return 304 NOT MODIFIED status if Item's
- last-modified date is before If-Modified-Since header.
-
- NOTE: Do NOT do this for interactive users since it might encourage
- browser to cache a view that is only shown to authenticated users.
- ONLY do this when user-agent is a spider (search-engine crawler robot)
- since they should only ever have "anonymous" access.
-
- NOTE: Cocoon always automatically sets Last-Modified: header on its
- transformed pages with the current timestamp, which we cannot override.
- It won't prevent a spider's If-Modified-Since from working, though.
-->
<map:select type="browser">
<map:when test="spider">
<map:select type="IfModifiedSinceSelector">
<map:when test="true">
<map:act type="NotModifiedAction"/>
<map:serialize/>
</map:when>
<map:otherwise>
<map:transform type="ItemViewer"/>
<map:serialize type="xml"/>
</map:otherwise>
</map:select>
</map:when>
<map:otherwise>
<map:transform type="ItemViewer"/>
<map:serialize type="xml"/>
</map:otherwise>
</map:select>
</map:match>
</map:match>
<!-- Community, Collection, and Item Viewers -->
<map:match pattern="handle/*/*">
<map:match type="HandleAuthorizedMatcher" pattern="READ">
<map:match type="HandleTypeMatcher" pattern="community">
<map:act type="UsageLoggerAction">
<map:parameter name="type" value="community" />
<map:parameter name="eventType" value="view" />
</map:act>
<map:transform type="CommunityViewer" />
<map:serialize type="xml" />
</map:match>
<map:match type="HandleTypeMatcher" pattern="collection">
<map:act type="UsageLoggerAction">
<map:parameter name="type" value="collection" />
<map:parameter name="eventType" value="view" />
</map:act>
<map:transform type="CollectionViewer" />
<map:serialize type="xml" />
</map:match>
<map:match type="HandleTypeMatcher" pattern="item">
<map:act type="UsageLoggerAction">
<map:parameter name="type" value="item" />
<map:parameter name="eventType" value="view" />
</map:act>
<!-- Implement HTTP If-Modified-Since protocol (commonly used by search
- engine crawlers): return 304 NOT MODIFIED status if Item's - last-modified
date is before If-Modified-Since header. - - NOTE: Do NOT do this for interactive
users since it might encourage - browser to cache a view that is only shown
to authenticated users. - ONLY do this when user-agent is a spider (search-engine
crawler robot) - since they should only ever have "anonymous" access. - -
NOTE: Cocoon always automatically sets Last-Modified: header on its - transformed
pages with the current timestamp, which we cannot override. - It won't prevent
a spider's If-Modified-Since from working, though. -->
<map:select type="browser">
<map:when test="spider">
<map:select type="IfModifiedSinceSelector">
<map:when test="true">
<map:act type="NotModifiedAction" />
<map:serialize />
</map:when>
<map:otherwise>
<map:transform type="ItemViewer" />
<map:serialize type="xml" />
</map:otherwise>
</map:select>
</map:when>
<map:otherwise>
<map:transform type="ItemViewer" />
<map:serialize type="xml" />
</map:otherwise>
</map:select>
</map:match>
</map:match>
<map:match type="HandleAuthorizedMatcher" pattern="!READ">
<map:transform type="RestrictedItem">
<map:parameter name="header" value="xmlui.ArtifactBrowser.RestrictedItem.auth_header"/>
<map:parameter name="message" value="xmlui.ArtifactBrowser.RestrictedItem.auth_message"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
</map:match>
<map:match type="HandleAuthorizedMatcher" pattern="!READ">
<map:match type="HandleTypeMatcher" pattern="community">
<map:transform type="RestrictedItem">
<map:parameter name="header"
value="xmlui.ArtifactBrowser.RestrictedItem.auth_header" />
<map:parameter name="message"
value="xmlui.ArtifactBrowser.RestrictedItem.auth_message" />
</map:transform>
<map:serialize type="xml" />
</map:match>
<map:match type="HandleTypeMatcher" pattern="collection">
<map:transform type="RestrictedItem">
<map:parameter name="header"
value="xmlui.ArtifactBrowser.RestrictedItem.auth_header" />
<map:parameter name="message"
value="xmlui.ArtifactBrowser.RestrictedItem.auth_message" />
</map:transform>
<map:serialize type="xml" />
</map:match>
<map:match type="HandleTypeMatcher" pattern="item">
<!-- <map:match type="ConfigurationMatcher" pattern="request.item.type,logged">
<map:act type="SendItemRequestAction">
<map:parameter name="type" value="item" />
<map:parameter name="eventType" value="view" />
</map:act>
</map:match>-->
<map:transform type="RestrictedItem">
<map:parameter name="header"
value="xmlui.ArtifactBrowser.RestrictedItem.auth_header" />
<map:parameter name="message"
value="xmlui.ArtifactBrowser.RestrictedItem.auth_message" />
</map:transform>
<map:serialize type="xml" />
<!-- Implement HTTP If-Modified-Since protocol (commonly used by search
- engine crawlers): return 304 NOT MODIFIED status if Item's - last-modified
date is before If-Modified-Since header. - - NOTE: Do NOT do this for interactive
users since it might encourage - browser to cache a view that is only shown
to authenticated users. - ONLY do this when user-agent is a spider (search-engine
crawler robot) - since they should only ever have "anonymous" access. - -
NOTE: Cocoon always automatically sets Last-Modified: header on its - transformed
pages with the current timestamp, which we cannot override. - It won't prevent
a spider's If-Modified-Since from working, though. -->
<map:select type="browser">
<map:when test="spider">
<map:select type="IfModifiedSinceSelector">
<map:when test="true">
<map:act type="NotModifiedAction" />
<map:serialize />
</map:when>
<map:otherwise>
<map:transform type="ItemViewer" />
<map:serialize type="xml" />
</map:otherwise>
</map:select>
</map:when>
<map:otherwise>
<map:transform type="ItemViewer" />
<map:serialize type="xml" />
</map:otherwise>
</map:select>
</map:match>
</map:match>
</map:match>
</map:match> <!-- End match handle/*/** -->
</map:match> <!-- End match handle/*/** -->
<!--
A simple feedback utility that presents the user with a form to fill out,
the results of which are emailed to the site administrator.
-->
<map:match pattern="feedback">
<map:act type="SendFeedbackAction">
<map:transform type="FeedbackForm">
<map:parameter name="comments" value="{comments}"/>
<map:parameter name="email" value="{email}"/>
<map:parameter name="page" value="{page}"/>
</map:transform>
<!-- A simple feedback utility that presents the user with a form to fill
out, the results of which are emailed to the site administrator. -->
<map:match pattern="feedback">
<map:act type="SendFeedbackAction">
<map:transform type="FeedbackForm">
<map:parameter name="comments" value="{comments}" />
<map:parameter name="email" value="{email}" />
<map:parameter name="page" value="{page}" />
</map:transform>
<map:serialize type="xml"/>
</map:act>
<map:transform type="FeedbackSent"/>
<map:serialize type="xml"/>
</map:match>
<!--
The most basic & generic contact us page. It is expected that most
themes will override this page and replace it with a more detailed
version.
-->
<map:match pattern="contact">
<map:transform type="Contact"/>
<map:serialize type="xml"/>
</map:match>
<map:serialize type="xml" />
</map:act>
<map:transform type="FeedbackSent" />
<map:serialize type="xml" />
</map:match>
<!-- A request item flow -->
<map:match pattern="itemRequestResponse/*/">
<map:act type="ItemRequestResponseAction">
<map:parameter name="token" value="{1}" />
<map:parameter name="decision" value="{decision}" />
<map:parameter name="isSent" value="{isSent}" />
<map:select type="parameter">
<map:parameter name="parameter-selector-test" value="{isSent}" />
<map:when test="true">
<map:transform type="ItemRequestChangeStatusForm">
<map:parameter name="token" value="{1}" />
<map:parameter name="name" value="{name}" />
<map:parameter name="email" value="{email}" />
</map:transform>
</map:when>
<map:otherwise>
<map:select type="parameter">
<map:parameter name="parameter-selector-test" value="{decision}" />
<map:when test="false">
<map:transform type="ItemRequestResponseFalseForm">
<map:parameter name="decision" value="{decision}" />
</map:transform>
</map:when>
<map:when test="true">
<map:transform type="ItemRequestResponseTrueForm">
<map:parameter name="decision" value="{decision}" />
</map:transform>
</map:when>
<map:otherwise>
<map:transform type="ItemRequestResponseDecisionForm">
<map:parameter name="decision" value="{decision}" />
<map:parameter name="title" value="{title}" />
</map:transform>
</map:otherwise>
</map:select>
</map:otherwise>
</map:select>
<map:serialize type="xml" />
</map:act>
<map:transform type="ItemRequestStatusChanged" />
<map:serialize type="xml" />
</map:match>
<!-- The most basic & generic contact us page. It is expected that most
themes will override this page and replace it with a more detailed version. -->
<map:match pattern="contact">
<map:transform type="Contact" />
<map:serialize type="xml" />
</map:match>
<!-- Not a URL we care about, so just pass it on. -->
<map:serialize type="xml"/>
<!-- Not a URL we care about, so just pass it on. -->
<map:serialize type="xml" />
</map:pipeline>
</map:pipelines>
</map:pipeline>
</map:pipelines>
</map:sitemap>

View File

@@ -313,6 +313,76 @@
<message key="xmlui.ItemExportDownloadReader.auth_header">This export archive is restricted.</message>
<message key="xmlui.ItemExportDownloadReader.auth_message">The export archive you are attempting to access is a restricted resource and requires credentials to view. Please login below to access the export archive.</message>
<!-- REQUEST COPY -->
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestForm.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestForm.title">Request a copy of the document</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.trail">Request a copy of the document</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.head">Request a copy of the document</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.para1">Enter the following information to request a copy of the document to the responsible</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.requesterEmail">E-mail</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.requesterEmail_help">This email address is used for sending the document.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.requesterEmail.error">E-mail is mandatory</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.message">Mensaje</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.message.error">Mensaje is mandatory</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.files">Files</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.allFiles">All files (of this document) in restricted access.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.notAllFiles">Only The requested file.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.requesterName">Name</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.requesterName.error">Name is mandatory</message>
<message key="xmlui.ArtifactBrowser.ItemRequestForm.submit">Request copy</message>
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestSent.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestSent.title">Your request has been sent.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestSent.trail">Your request has been sent.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestSent.head">Your request has been sent.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestSent.para1">Your request has been sent to the author or responsible.</message>
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestResponseDecisionForm.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.title">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.trail">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.head">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.para1">IF YOU ARE THE AUTHOR (OR ONE AUTHOR) DOCUMENT "{0}" uses the buttons to answer the user's request.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.para2">According to your choice will be generated a model answer customizable.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.send">Send copy</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseDecisionForm.dontSend">Don't send copy</message>
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestResponseTrueForm.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.title">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.trail">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.head">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.para1">This is the text to be sent to the applicant.</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.message">Denegado por </message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.mail">Send</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseFalseForm.back">Back</message>
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestResponseFalseForm.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.title">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.trail">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.head">Document copy request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.para1">This is the text that will send the applicant (together with the document).</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.message">Thanks for your interest in </message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.mail">Send</message>
<message key="xmlui.ArtifactBrowser.ItemRequestResponseTrueForm.back">Back</message>
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestChangeStatusForm.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.title">Change permissions request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.trail">Change permissions request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.head">Change permissions request</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.para1">You can take advantage of the occasion to reconsider the free disposition of the document (to avoid having to respond to these requests), if there is no reason to keep it restricted. This may apply inserting your data below and press the button</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.name">Name</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.email">E-mail</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.name.error">The name is mandatory</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.email.error">The e-mail is mandatory</message>
<message key="xmlui.ArtifactBrowser.ItemRequestChangeStatusForm.changeToOpen">Change to open access</message>
<!-- org.dspace.app.xmlui.artifactbrowser.ItemRequestResponseFalseForm.java -->
<message key="xmlui.ArtifactBrowser.ItemRequestStatusChanged.title">Request sent</message>
<message key="xmlui.ArtifactBrowser.ItemRequestStatusChanged.trail">Request sent</message>
<message key="xmlui.ArtifactBrowser.ItemRequestStatusChanged.head">Your request to change permissions has been sent</message>
<message key="xmlui.ArtifactBrowser.ItemRequestStatusChanged.para1">Your request has been sent to the administrator</message>
<message key="xmlui.ArtifactBrowser.ItemRequestStatusChanged.para2">Thanks</message>
<!--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EPerson Aspect

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

View File

@@ -407,6 +407,17 @@
<img alt="Icon" src="{concat($theme-path, '/images/mime.png')}" style="height: {$thumbnail.maxheight}px;"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="contains(mets:FLocat[@LOCTYPE='URL']/@xlink:href,'isAllowed=n')">
<img>
<xsl:attribute name="src">
<xsl:value-of select="$context-path"/>
<xsl:text>/static/icons/lock24.png</xsl:text>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:text>Bloqueado</xsl:text>
</xsl:attribute>
</img>
</xsl:if>
</a>
</div>
<div class="file-metadata" style="height: {$thumbnail.maxheight}px;">

View File

@@ -464,6 +464,17 @@
<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:title"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="contains(mets:FLocat[@LOCTYPE='URL']/@xlink:href,'isAllowed=n')">
<img>
<xsl:attribute name="src">
<xsl:value-of select="$context-path"/>
<xsl:text>/static/icons/lock24.png</xsl:text>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:text>Bloqueado</xsl:text>
</xsl:attribute>
</img>
</xsl:if>
</a>
</td>
<!-- File size always comes in bytes and thus needs conversion -->

View File

@@ -111,6 +111,17 @@
<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:title"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="contains(mets:FLocat[@LOCTYPE='URL']/@xlink:href,'isAllowed=n')">
<img>
<xsl:attribute name="src">
<xsl:value-of select="$context-path"/>
<xsl:text>/static/icons/lock24.png</xsl:text>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:text>Bloqueado</xsl:text>
</xsl:attribute>
</img>
</xsl:if>
</a>
</td>
<!-- File size always comes in bytes and thus needs conversion -->

View File

@@ -1907,3 +1907,23 @@ webui.suggest.enable = false
# context-switch then you will need to set the paramater to the HTTP parameter that
# records the original IP address.
#xmlui.controlpanel.activity.ipheader = X-Forward-For
# Special Group for UI: all the groups nested inside this group
# will be loaded in the multiple select list of the RestrictStep
xmlui.submission.restrictstep.groups=SubmissionAdmin
xmlui.submission.restrictstep.enableAdvancedForm=true
#---------------------------------------------------------------#
#----------------REQUEST ITEM CONFIGURATION---------------------#
#---------------------------------------------------------------#
# Configuration of request-item. Possible values:
# all - Anonymous users can request an item
# logged - Login is mandatory to request an item
# empty/commented out - request-copy not allowed
request.item.type = all
# Helpdesk E-mail
mail.helpdesk = ${mail.admin}
#------------END REQUEST ITEM CONFIGURATION---------------------#

View File

@@ -0,0 +1,8 @@
Subject: Request for Open Access
{3} with address {4},
requested the following document/file to be in Open Access:
Document Handle:{1}
File ID: {0}
Token:{2}

View File

@@ -0,0 +1,11 @@
Subject: Request copy of document
Dear {0},
In response to your request I have the pleasure to send you in attachment a copy of the file(s), concerning the document: "{4}" ({3}), which I am author (or co-author) of.
{5}
Best regards,
Name: [Insert your name to sign the message]
Contacts: [If you think it's convenient you can also put your contacts - Email, etc.]

View File

@@ -0,0 +1,17 @@
Subject: Request copy of document
Dear {7},
A user of {9}, named {0} and using the email {1} requested a copy of the file(s), concerning to the document: "{4}" ({3}) submitted by you.
This request came along with the following message:
"{5}"
to answer click {6} In both cases, we think that it''s in your best interest to answer this request.
IF YOU AREN''T THE AUTHOR OR ONE OF THE AUTHORS OF THIS DOCUMENT, and only submitted the document on his behalf, PLEASE REDIRECT THIS MESSAGE TO THE AUTHOR(S), only the author(s) should answer the request to send a copy.
IF YOU ARE THE AUTHOR OR ONE OF THE AUTHOR(S) OF THE REQUESTED DOCUMENT,
Thank you for your collaboration!
If you have any doubt concerning this request, please contact {10}

View File

@@ -0,0 +1,11 @@
Subject: Request copy of document
Dear {0},
In response to your request I regret to inform you that it''s not possible to send you a copy of the file(s) you have requested, concerning the document: "{4}" ({3}), which I am author (or co-author) of.
{5}
Best regards,
Name: [Insert your name to sign the message]
Contacts: [If you think it's convenient you can also put your contacts - Email, etc.]

View File

@@ -0,0 +1,21 @@
CREATE SEQUENCE requestitem_seq;
-------------------------------------------------------
-- RequestItem table
-------------------------------------------------------
CREATE TABLE requestitem
(
requestitem_id int4 NOT NULL,
token varchar(48),
item_id int4,
bitstream_id int4,
allfiles bool,
request_email varchar(64),
request_name varchar(64),
request_date timestamp,
accept_request bool,
decision_date timestamp,
expires timestamp,
CONSTRAINT requestitem_pkey PRIMARY KEY (requestitem_id),
CONSTRAINT requestitem_token_key UNIQUE (token)
) WITH OIDS;