mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
[DS-1144] Maven Project Consolidation : SWORD Client
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-api</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<name>DSpace Sword Client :: Sword Client API</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<relativePath>..</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-xmlui-api</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<name>DSpace Sword Client :: Sword Client XMLUI API</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<relativePath>..</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-xmlui-api</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>solr-solrj</artifactId>
|
|
||||||
<groupId>org.apache.solr</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- external -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@@ -1,78 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>war</packaging>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-xmlui-webapp</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<name>DSpace Sword Client :: Sword Client XMLUI Webapp</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<relativePath>..</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-xmlui-api</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>solr-solrj</artifactId>
|
|
||||||
<groupId>org.apache.solr</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-xmlui-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- external -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<archiveClasses>false</archiveClasses>
|
|
||||||
<attachClasses>true</attachClasses>
|
|
||||||
<classesClassifier>classes</classesClassifier>
|
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
|
||||||
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
|
|
||||||
<warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
|
|
||||||
<webResources>
|
|
||||||
<resource>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<directory>${basedir}/src/main/webapp</directory>
|
|
||||||
<includes>
|
|
||||||
<include>WEB-INF/web.xml</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</webResources>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<name>DSpace Sword Client</name>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>dspace-parent</artifactId>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<relativePath>..</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>dspace-sword-client-api</module>
|
|
||||||
<module>dspace-sword-client-xmlui-api</module>
|
|
||||||
<module>dspace-sword-client-xmlui-webapp</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<issueManagement>
|
|
||||||
<system>JIRA</system>
|
|
||||||
<url>http://jira.dspace.org/jira/browse/SWORD</url>
|
|
||||||
</issueManagement>
|
|
||||||
|
|
||||||
</project>
|
|
@@ -17,7 +17,11 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.swordapp</groupId>
|
||||||
|
<artifactId>sword-common</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</dependency>
|
||||||
<!-- Wing framework -->
|
<!-- Wing framework -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
|
@@ -1,83 +1,83 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.sword.client.*;
|
import org.dspace.sword.client.*;
|
||||||
import org.dspace.sword.client.exceptions.HttpException;
|
import org.dspace.sword.client.exceptions.HttpException;
|
||||||
import org.dspace.sword.client.exceptions.InvalidHandleException;
|
import org.dspace.sword.client.exceptions.InvalidHandleException;
|
||||||
import org.dspace.sword.client.exceptions.PackageFormatException;
|
import org.dspace.sword.client.exceptions.PackageFormatException;
|
||||||
import org.dspace.sword.client.exceptions.PackagerException;
|
import org.dspace.sword.client.exceptions.PackagerException;
|
||||||
import org.purl.sword.client.SWORDClientException;
|
import org.purl.sword.client.SWORDClientException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 27/03/11
|
* Date: 27/03/11
|
||||||
* Time: 15:47
|
* Time: 15:47
|
||||||
*/
|
*/
|
||||||
public class DepositAction {
|
public class DepositAction {
|
||||||
|
|
||||||
private static final Message T_success = new Message("default", "xmlui.swordclient.DepositAction.success");
|
private static final Message T_success = new Message("default", "xmlui.swordclient.DepositAction.success");
|
||||||
private static final Message T_package_format_error = new Message("default", "xmlui.swordclient.DepositAction.package_format_error");
|
private static final Message T_package_format_error = new Message("default", "xmlui.swordclient.DepositAction.package_format_error");
|
||||||
private static final Message T_invalid_handle = new Message("default", "xmlui.swordclient.DepositAction.invalid_handle");
|
private static final Message T_invalid_handle = new Message("default", "xmlui.swordclient.DepositAction.invalid_handle");
|
||||||
private static final Message T_package_error = new Message("default", "xmlui.swordclient.DepositAction.package_error");
|
private static final Message T_package_error = new Message("default", "xmlui.swordclient.DepositAction.package_error");
|
||||||
private static final Message T_error = new Message("default", "xmlui.swordclient.DepositAction.error");
|
private static final Message T_error = new Message("default", "xmlui.swordclient.DepositAction.error");
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(DepositAction.class);
|
private static Logger log = Logger.getLogger(DepositAction.class);
|
||||||
|
|
||||||
public FlowResult processDeposit(Context context, String handle, DSpaceSwordClient DSClient)
|
public FlowResult processDeposit(Context context, String handle, DSpaceSwordClient DSClient)
|
||||||
{
|
{
|
||||||
FlowResult result = new FlowResult();
|
FlowResult result = new FlowResult();
|
||||||
result.setContinue(false);
|
result.setContinue(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DSClient.deposit(context, handle);
|
DSClient.deposit(context, handle);
|
||||||
result.setContinue(true);
|
result.setContinue(true);
|
||||||
result.setOutcome(true);
|
result.setOutcome(true);
|
||||||
result.setMessage(T_success);
|
result.setMessage(T_success);
|
||||||
}
|
}
|
||||||
catch (PackageFormatException e)
|
catch (PackageFormatException e)
|
||||||
{
|
{
|
||||||
log.error("Package Format Exception", e);
|
log.error("Package Format Exception", e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_package_format_error);
|
result.setMessage(T_package_format_error);
|
||||||
}
|
}
|
||||||
catch (InvalidHandleException e)
|
catch (InvalidHandleException e)
|
||||||
{
|
{
|
||||||
log.error("Invalid handle Exception", e);
|
log.error("Invalid handle Exception", e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_invalid_handle);
|
result.setMessage(T_invalid_handle);
|
||||||
}
|
}
|
||||||
catch (PackagerException e)
|
catch (PackagerException e)
|
||||||
{
|
{
|
||||||
log.error("Packager Exception", e);
|
log.error("Packager Exception", e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_package_error);
|
result.setMessage(T_package_error);
|
||||||
}
|
}
|
||||||
catch (SWORDClientException e)
|
catch (SWORDClientException e)
|
||||||
{
|
{
|
||||||
log.error("SWORDClientException encountered " + e.getMessage(), e);
|
log.error("SWORDClientException encountered " + e.getMessage(), e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_error.parameterize(e.getMessage()));
|
result.setMessage(T_error.parameterize(e.getMessage()));
|
||||||
}
|
}
|
||||||
catch (HttpException e)
|
catch (HttpException e)
|
||||||
{
|
{
|
||||||
log.error("HttpException encountered " + e.getMessage(), e);
|
log.error("HttpException encountered " + e.getMessage(), e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_error.parameterize(e.getMessage()));
|
result.setMessage(T_error.parameterize(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,84 +1,84 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.caching.CacheableProcessingComponent;
|
import org.apache.cocoon.caching.CacheableProcessingComponent;
|
||||||
import org.apache.excalibur.source.SourceValidity;
|
import org.apache.excalibur.source.SourceValidity;
|
||||||
import org.apache.excalibur.source.impl.validity.NOPValidity;
|
import org.apache.excalibur.source.impl.validity.NOPValidity;
|
||||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||||
import org.dspace.app.xmlui.utils.HandleUtil;
|
import org.dspace.app.xmlui.utils.HandleUtil;
|
||||||
import org.dspace.app.xmlui.utils.UIException;
|
import org.dspace.app.xmlui.utils.UIException;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.app.xmlui.wing.WingException;
|
import org.dspace.app.xmlui.wing.WingException;
|
||||||
import org.dspace.app.xmlui.wing.element.List;
|
import org.dspace.app.xmlui.wing.element.List;
|
||||||
import org.dspace.app.xmlui.wing.element.Options;
|
import org.dspace.app.xmlui.wing.element.Options;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.AuthorizeManager;
|
import org.dspace.authorize.AuthorizeManager;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Navigation extends AbstractDSpaceTransformer implements CacheableProcessingComponent
|
public class Navigation extends AbstractDSpaceTransformer implements CacheableProcessingComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Message T_context_swordclient_head = message("xmlui.swordclient.Navigation.context_head");
|
private static final Message T_context_swordclient_head = message("xmlui.swordclient.Navigation.context_head");
|
||||||
private static final Message T_swordclient_copy = message("xmlui.swordclient.Navigation.context_copy");
|
private static final Message T_swordclient_copy = message("xmlui.swordclient.Navigation.context_copy");
|
||||||
|
|
||||||
/** Cached validity object */
|
/** Cached validity object */
|
||||||
private SourceValidity validity;
|
private SourceValidity validity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the unique caching key.
|
* Generate the unique caching key.
|
||||||
* This key must be unique inside the space of this component.
|
* This key must be unique inside the space of this component.
|
||||||
*/
|
*/
|
||||||
public Serializable getKey() {
|
public Serializable getKey() {
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the cache validity object.
|
* Generate the cache validity object.
|
||||||
*
|
*
|
||||||
* The cache is always valid.
|
* The cache is always valid.
|
||||||
*/
|
*/
|
||||||
public SourceValidity getValidity() {
|
public SourceValidity getValidity() {
|
||||||
return NOPValidity.SHARED_INSTANCE;
|
return NOPValidity.SHARED_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addOptions(Options options) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException
|
public void addOptions(Options options) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException
|
||||||
{
|
{
|
||||||
// todo : Some other navigation classes seem to add skeleton lists. I haven't done so here as
|
// todo : Some other navigation classes seem to add skeleton lists. I haven't done so here as
|
||||||
// todo : I don't understand what they do.
|
// todo : I don't understand what they do.
|
||||||
|
|
||||||
List context = options.addList("context");
|
List context = options.addList("context");
|
||||||
|
|
||||||
// Context Administrative options
|
// Context Administrative options
|
||||||
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
|
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
|
||||||
if (dso instanceof Item)
|
if (dso instanceof Item)
|
||||||
{
|
{
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
|
|
||||||
if (AuthorizeManager.isAdmin(this.context, dso))
|
if (AuthorizeManager.isAdmin(this.context, dso))
|
||||||
{
|
{
|
||||||
context.setHead(T_context_swordclient_head);
|
context.setHead(T_context_swordclient_head);
|
||||||
context.addItemXref(contextPath + "/swordclient?itemID="+item.getID(), T_swordclient_copy);
|
context.addItemXref(contextPath + "/swordclient?itemID="+item.getID(), T_swordclient_copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,59 +1,59 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.sword.client.DSpaceSwordClient;
|
import org.dspace.sword.client.DSpaceSwordClient;
|
||||||
import org.dspace.sword.client.ServiceDocumentHelper;
|
import org.dspace.sword.client.ServiceDocumentHelper;
|
||||||
import org.purl.sword.base.Collection;
|
import org.purl.sword.base.Collection;
|
||||||
import org.purl.sword.base.ServiceDocument;
|
import org.purl.sword.base.ServiceDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 21/03/11
|
* Date: 21/03/11
|
||||||
* Time: 22:12
|
* Time: 22:12
|
||||||
*/
|
*/
|
||||||
public class SelectCollectionAction
|
public class SelectCollectionAction
|
||||||
{
|
{
|
||||||
private static Logger log = Logger.getLogger(SelectCollectionAction.class);
|
private static Logger log = Logger.getLogger(SelectCollectionAction.class);
|
||||||
|
|
||||||
public FlowResult processSelectCollection(Context context, Request request, DSpaceSwordClient DSClient)
|
public FlowResult processSelectCollection(Context context, Request request, DSpaceSwordClient DSClient)
|
||||||
{
|
{
|
||||||
FlowResult result = new FlowResult();
|
FlowResult result = new FlowResult();
|
||||||
result.setContinue(false);
|
result.setContinue(false);
|
||||||
|
|
||||||
// Get all our request parameters
|
// Get all our request parameters
|
||||||
String location = request.getParameter("location");
|
String location = request.getParameter("location");
|
||||||
ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
|
ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
|
||||||
|
|
||||||
log.info("Collection selected is " + location);
|
log.info("Collection selected is " + location);
|
||||||
log.info("Service Doc reference is " + serviceDoc);
|
log.info("Service Doc reference is " + serviceDoc);
|
||||||
|
|
||||||
// Set the target collection.
|
// Set the target collection.
|
||||||
DSClient.setCollection(location);
|
DSClient.setCollection(location);
|
||||||
|
|
||||||
//Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
//Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
||||||
|
|
||||||
// Find out what file types and package formats are available and return them to let the user select.
|
// Find out what file types and package formats are available and return them to let the user select.
|
||||||
String[] fileTypes = ServiceDocumentHelper.getCommonFileTypes(serviceDoc, location);
|
String[] fileTypes = ServiceDocumentHelper.getCommonFileTypes(serviceDoc, location);
|
||||||
String[] packageFormats = ServiceDocumentHelper.getCommonPackageFormats(serviceDoc, location);
|
String[] packageFormats = ServiceDocumentHelper.getCommonPackageFormats(serviceDoc, location);
|
||||||
|
|
||||||
result.setParameter("location", location);
|
result.setParameter("location", location);
|
||||||
result.setParameter("serviceDoc", serviceDoc);
|
result.setParameter("serviceDoc", serviceDoc);
|
||||||
result.setParameter("fileTypes", fileTypes);
|
result.setParameter("fileTypes", fileTypes);
|
||||||
result.setParameter("packageFormats", packageFormats);
|
result.setParameter("packageFormats", packageFormats);
|
||||||
result.setContinue(true);
|
result.setContinue(true);
|
||||||
result.setOutcome(true);
|
result.setOutcome(true);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,148 +1,148 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.environment.ObjectModelHelper;
|
import org.apache.cocoon.environment.ObjectModelHelper;
|
||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||||
import org.dspace.app.xmlui.utils.UIException;
|
import org.dspace.app.xmlui.utils.UIException;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.app.xmlui.wing.WingException;
|
import org.dspace.app.xmlui.wing.WingException;
|
||||||
import org.dspace.app.xmlui.wing.element.*;
|
import org.dspace.app.xmlui.wing.element.*;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.sword.client.ServiceDocumentHelper;
|
import org.dspace.sword.client.ServiceDocumentHelper;
|
||||||
import org.purl.sword.base.Collection;
|
import org.purl.sword.base.Collection;
|
||||||
import org.purl.sword.base.ServiceDocument;
|
import org.purl.sword.base.ServiceDocument;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 21-Sep-2010
|
* Date: 21-Sep-2010
|
||||||
* Time: 13:44:28
|
* Time: 13:44:28
|
||||||
*/
|
*/
|
||||||
public class SelectCollectionTransformer extends AbstractDSpaceTransformer {
|
public class SelectCollectionTransformer extends AbstractDSpaceTransformer {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(SelectCollectionTransformer.class);
|
private static Logger log = Logger.getLogger(SelectCollectionTransformer.class);
|
||||||
|
|
||||||
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
||||||
private static final Message T_title = message("xmlui.swordclient.SelectCollection.title");
|
private static final Message T_title = message("xmlui.swordclient.SelectCollection.title");
|
||||||
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
||||||
private static final Message T_trail = message("xmlui.swordclient.SelectCollection.trail");
|
private static final Message T_trail = message("xmlui.swordclient.SelectCollection.trail");
|
||||||
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
||||||
|
|
||||||
private static final Message T_collection_head = message("xmlui.swordclient.SelectCollection.collection_head");
|
private static final Message T_collection_head = message("xmlui.swordclient.SelectCollection.collection_head");
|
||||||
private static final Message T_collection_title = message("xmlui.swordclient.SelectCollection.collection_title");
|
private static final Message T_collection_title = message("xmlui.swordclient.SelectCollection.collection_title");
|
||||||
private static final Message T_collection_policy = message("xmlui.swordclient.SelectCollection.collection policy");
|
private static final Message T_collection_policy = message("xmlui.swordclient.SelectCollection.collection policy");
|
||||||
private static final Message T_collection_mediation = message("xmlui.swordclient.SelectCollection.collection_mediation");
|
private static final Message T_collection_mediation = message("xmlui.swordclient.SelectCollection.collection_mediation");
|
||||||
private static final Message T_collection_file_types = message("xmlui.swordclient.SelectCollection.collection_file_types");
|
private static final Message T_collection_file_types = message("xmlui.swordclient.SelectCollection.collection_file_types");
|
||||||
private static final Message T_collection_package_formats = message("xmlui.swordclient.SelectCollection.collection_package_formats");
|
private static final Message T_collection_package_formats = message("xmlui.swordclient.SelectCollection.collection_package_formats");
|
||||||
private static final Message T_collection_deposit_button = message("xmlui.swordclient.SelectCollection.collection_deposit_button");
|
private static final Message T_collection_deposit_button = message("xmlui.swordclient.SelectCollection.collection_deposit_button");
|
||||||
private static final Message T_sub_service_target = message("xmlui.swordclient.SelectCollection.sub_service_target");
|
private static final Message T_sub_service_target = message("xmlui.swordclient.SelectCollection.sub_service_target");
|
||||||
private static final Message T_sub_service_target_button = message("xmlui.swordclient.SelectCollection.sub_service_target_button");
|
private static final Message T_sub_service_target_button = message("xmlui.swordclient.SelectCollection.sub_service_target_button");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final Message T_submit_cancel = message("xmlui.general.cancel");
|
private static final Message T_submit_cancel = message("xmlui.general.cancel");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a page title and trail links
|
* Add a page title and trail links
|
||||||
*/
|
*/
|
||||||
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
||||||
pageMeta.addMetadata("title").addContent(T_title);
|
pageMeta.addMetadata("title").addContent(T_title);
|
||||||
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
||||||
|
|
||||||
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
||||||
pageMeta.addTrail().addContent(T_trail);
|
pageMeta.addTrail().addContent(T_trail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
||||||
String handle = parameters.getParameter("handle", null);
|
String handle = parameters.getParameter("handle", null);
|
||||||
|
|
||||||
Division main = body.addDivision("main");
|
Division main = body.addDivision("main");
|
||||||
main.setHead(T_main_head.parameterize(handle));
|
main.setHead(T_main_head.parameterize(handle));
|
||||||
|
|
||||||
Request request = ObjectModelHelper.getRequest(objectModel);
|
Request request = ObjectModelHelper.getRequest(objectModel);
|
||||||
ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
|
ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
|
||||||
|
|
||||||
java.util.List<Collection> collections = ServiceDocumentHelper.getCollections(serviceDoc);
|
java.util.List<Collection> collections = ServiceDocumentHelper.getCollections(serviceDoc);
|
||||||
for (Collection collection : collections)
|
for (Collection collection : collections)
|
||||||
{
|
{
|
||||||
Division collectionDiv = main.addInteractiveDivision("collection", contextPath + "/swordclient", Division.METHOD_POST, "");
|
Division collectionDiv = main.addInteractiveDivision("collection", contextPath + "/swordclient", Division.METHOD_POST, "");
|
||||||
|
|
||||||
// Add a header for each individual collection.
|
// Add a header for each individual collection.
|
||||||
collectionDiv.setHead(T_collection_head.parameterize(collection.getLocation()));
|
collectionDiv.setHead(T_collection_head.parameterize(collection.getLocation()));
|
||||||
|
|
||||||
// Now add another list of the remaining collection parameters.
|
// Now add another list of the remaining collection parameters.
|
||||||
List paramsList = collectionDiv.addList(collection + "Params", List.TYPE_BULLETED);
|
List paramsList = collectionDiv.addList(collection + "Params", List.TYPE_BULLETED);
|
||||||
|
|
||||||
paramsList.addItem().addContent(T_collection_title.parameterize(collection.getTitle()));
|
paramsList.addItem().addContent(T_collection_title.parameterize(collection.getTitle()));
|
||||||
paramsList.addItem().addContent(T_collection_policy.parameterize(collection.getCollectionPolicy()));
|
paramsList.addItem().addContent(T_collection_policy.parameterize(collection.getCollectionPolicy()));
|
||||||
paramsList.addItem().addContent(T_collection_mediation.parameterize(Boolean.toString(collection.getMediation())));
|
paramsList.addItem().addContent(T_collection_mediation.parameterize(Boolean.toString(collection.getMediation())));
|
||||||
|
|
||||||
String[] fileTypes = collection.getAccepts();
|
String[] fileTypes = collection.getAccepts();
|
||||||
String fileTypesString = arrayToString(fileTypes);
|
String fileTypesString = arrayToString(fileTypes);
|
||||||
paramsList.addItem().addContent(T_collection_file_types.parameterize(fileTypesString));
|
paramsList.addItem().addContent(T_collection_file_types.parameterize(fileTypesString));
|
||||||
|
|
||||||
String[] packageFormats = ServiceDocumentHelper.getPackageFormats(collection);
|
String[] packageFormats = ServiceDocumentHelper.getPackageFormats(collection);
|
||||||
String packageFormatsString = arrayToString(packageFormats);
|
String packageFormatsString = arrayToString(packageFormats);
|
||||||
paramsList.addItem().addContent(T_collection_package_formats.parameterize(packageFormatsString));
|
paramsList.addItem().addContent(T_collection_package_formats.parameterize(packageFormatsString));
|
||||||
|
|
||||||
// Assuming there are available file types and package formats then add a deposit button.
|
// Assuming there are available file types and package formats then add a deposit button.
|
||||||
if ((fileTypes.length > 0 ) && (packageFormats.length > 0))
|
if ((fileTypes.length > 0 ) && (packageFormats.length > 0))
|
||||||
{
|
{
|
||||||
collectionDiv.addPara().addButton("deposit").setValue(T_collection_deposit_button);
|
collectionDiv.addPara().addButton("deposit").setValue(T_collection_deposit_button);
|
||||||
collectionDiv.addHidden("location").setValue(collection.getLocation());
|
collectionDiv.addHidden("location").setValue(collection.getLocation());
|
||||||
collectionDiv.addHidden("swordclient-continue").setValue(knot.getId());
|
collectionDiv.addHidden("swordclient-continue").setValue(knot.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the collection contains a reference to a 'sub service' then allow the user to select
|
// If the collection contains a reference to a 'sub service' then allow the user to select
|
||||||
// the service doc for that sub service.
|
// the service doc for that sub service.
|
||||||
if ((collection.getService() != null) && (collection.getService().length() > 0))
|
if ((collection.getService() != null) && (collection.getService().length() > 0))
|
||||||
{
|
{
|
||||||
collectionDiv.addPara(T_sub_service_target + collection.getService());
|
collectionDiv.addPara(T_sub_service_target + collection.getService());
|
||||||
collectionDiv.addPara().addButton("sub-service").setValue(T_sub_service_target_button);
|
collectionDiv.addPara().addButton("sub-service").setValue(T_sub_service_target_button);
|
||||||
collectionDiv.addHidden("sub-service").setValue(collection.getService());
|
collectionDiv.addHidden("sub-service").setValue(collection.getService());
|
||||||
collectionDiv.addHidden("swordclient-continue").setValue(knot.getId());
|
collectionDiv.addHidden("swordclient-continue").setValue(knot.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Division buttons = main.addInteractiveDivision("buttons", contextPath + "/swordclient", Division.METHOD_POST, "");
|
Division buttons = main.addInteractiveDivision("buttons", contextPath + "/swordclient", Division.METHOD_POST, "");
|
||||||
|
|
||||||
Para buttonList = buttons.addPara();
|
Para buttonList = buttons.addPara();
|
||||||
buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
|
buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
|
||||||
buttons.addHidden("swordclient-continue").setValue(knot.getId());
|
buttons.addHidden("swordclient-continue").setValue(knot.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String arrayToString(String[] strings)
|
private String arrayToString(String[] strings)
|
||||||
{
|
{
|
||||||
if (strings.length == 0)
|
if (strings.length == 0)
|
||||||
{
|
{
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuffer text = new StringBuffer("");
|
StringBuffer text = new StringBuffer("");
|
||||||
for (String string : strings)
|
for (String string : strings)
|
||||||
{
|
{
|
||||||
text.append(string).append(", ");
|
text.append(string).append(", ");
|
||||||
}
|
}
|
||||||
text.delete(text.length() - 2, text.length() - 1);
|
text.delete(text.length() - 2, text.length() - 1);
|
||||||
return text.toString();
|
return text.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,54 +1,54 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.sword.client.DSpaceSwordClient;
|
import org.dspace.sword.client.DSpaceSwordClient;
|
||||||
import org.dspace.sword.client.exceptions.PackageFormatException;
|
import org.dspace.sword.client.exceptions.PackageFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 21/03/11
|
* Date: 21/03/11
|
||||||
* Time: 22:12
|
* Time: 22:12
|
||||||
*/
|
*/
|
||||||
public class SelectPackagingAction
|
public class SelectPackagingAction
|
||||||
{
|
{
|
||||||
private static final Message T_packageFormat_error = new Message("default", "xmlui.swordclient.SelectPackagingFormat.packageFormat_error");
|
private static final Message T_packageFormat_error = new Message("default", "xmlui.swordclient.SelectPackagingFormat.packageFormat_error");
|
||||||
|
|
||||||
public FlowResult processSelectPackaging(Context context, Request request, DSpaceSwordClient DSClient)
|
public FlowResult processSelectPackaging(Context context, Request request, DSpaceSwordClient DSClient)
|
||||||
{
|
{
|
||||||
FlowResult result = new FlowResult();
|
FlowResult result = new FlowResult();
|
||||||
result.setContinue(false);
|
result.setContinue(false);
|
||||||
|
|
||||||
// Get all our request parameters
|
// Get all our request parameters
|
||||||
String fileType = request.getParameter("fileType");
|
String fileType = request.getParameter("fileType");
|
||||||
String packageFormat = request.getParameter("packageFormat");
|
String packageFormat = request.getParameter("packageFormat");
|
||||||
|
|
||||||
DSClient.setFileType(fileType);
|
DSClient.setFileType(fileType);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DSClient.setPackageFormat(packageFormat);
|
DSClient.setPackageFormat(packageFormat);
|
||||||
result.setContinue(true);
|
result.setContinue(true);
|
||||||
result.setOutcome(true);
|
result.setOutcome(true);
|
||||||
}
|
}
|
||||||
catch (PackageFormatException e)
|
catch (PackageFormatException e)
|
||||||
{
|
{
|
||||||
// This exception should never actually happen since the user selects from a drop down list but...
|
// This exception should never actually happen since the user selects from a drop down list but...
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_packageFormat_error);
|
result.setMessage(T_packageFormat_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,107 +1,107 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.environment.ObjectModelHelper;
|
import org.apache.cocoon.environment.ObjectModelHelper;
|
||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||||
import org.dspace.app.xmlui.utils.UIException;
|
import org.dspace.app.xmlui.utils.UIException;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.app.xmlui.wing.WingException;
|
import org.dspace.app.xmlui.wing.WingException;
|
||||||
import org.dspace.app.xmlui.wing.element.*;
|
import org.dspace.app.xmlui.wing.element.*;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.sword.client.ServiceDocumentHelper;
|
import org.dspace.sword.client.ServiceDocumentHelper;
|
||||||
import org.purl.sword.base.Collection;
|
import org.purl.sword.base.Collection;
|
||||||
import org.purl.sword.base.ServiceDocument;
|
import org.purl.sword.base.ServiceDocument;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 21-Sep-2010
|
* Date: 21-Sep-2010
|
||||||
* Time: 13:44:28
|
* Time: 13:44:28
|
||||||
*/
|
*/
|
||||||
public class SelectPackagingTransformer extends AbstractDSpaceTransformer
|
public class SelectPackagingTransformer extends AbstractDSpaceTransformer
|
||||||
{
|
{
|
||||||
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
||||||
private static final Message T_title = message("xmlui.swordclient.SelectCollection.title");
|
private static final Message T_title = message("xmlui.swordclient.SelectCollection.title");
|
||||||
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
||||||
private static final Message T_trail = message("xmlui.swordclient.SelectCollection.trail");
|
private static final Message T_trail = message("xmlui.swordclient.SelectCollection.trail");
|
||||||
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
||||||
|
|
||||||
private static final Message T_collection_head = message("xmlui.swordclient.SelectPackagingAction.head");
|
private static final Message T_collection_head = message("xmlui.swordclient.SelectPackagingAction.head");
|
||||||
private static final Message T_collection_title = message("xmlui.swordclient.SelectPackagingAction.title");
|
private static final Message T_collection_title = message("xmlui.swordclient.SelectPackagingAction.title");
|
||||||
private static final Message T_collection_policy = message("xmlui.swordclient.SelectPackagingAction.policy");
|
private static final Message T_collection_policy = message("xmlui.swordclient.SelectPackagingAction.policy");
|
||||||
private static final Message T_collection_mediation = message("xmlui.swordclient.SelectPackagingAction.mediation");
|
private static final Message T_collection_mediation = message("xmlui.swordclient.SelectPackagingAction.mediation");
|
||||||
private static final Message T_collection_file_types = message("xmlui.swordclient.SelectPackagingAction.file_types");
|
private static final Message T_collection_file_types = message("xmlui.swordclient.SelectPackagingAction.file_types");
|
||||||
private static final Message T_collection_package_formats = message("xmlui.swordclient.SelectPackagingAction.package_formats");
|
private static final Message T_collection_package_formats = message("xmlui.swordclient.SelectPackagingAction.package_formats");
|
||||||
|
|
||||||
private static final Message T_submit_next = message("xmlui.general.next");
|
private static final Message T_submit_next = message("xmlui.general.next");
|
||||||
private static final Message T_submit_cancel = message("xmlui.general.cancel");
|
private static final Message T_submit_cancel = message("xmlui.general.cancel");
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(SelectPackagingTransformer.class);
|
private static Logger log = Logger.getLogger(SelectPackagingTransformer.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a page title and trail links
|
* Add a page title and trail links
|
||||||
*/
|
*/
|
||||||
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
||||||
pageMeta.addMetadata("title").addContent(T_title);
|
pageMeta.addMetadata("title").addContent(T_title);
|
||||||
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
||||||
|
|
||||||
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
||||||
pageMeta.addTrail().addContent(T_trail);
|
pageMeta.addTrail().addContent(T_trail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
|
||||||
String handle = parameters.getParameter("handle", null);
|
String handle = parameters.getParameter("handle", null);
|
||||||
|
|
||||||
Request request = ObjectModelHelper.getRequest(objectModel);
|
Request request = ObjectModelHelper.getRequest(objectModel);
|
||||||
|
|
||||||
ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
|
ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
|
||||||
String location = (String) request.getAttribute("location");
|
String location = (String) request.getAttribute("location");
|
||||||
String[] fileTypes = (String[]) request.getAttribute("fileTypes");
|
String[] fileTypes = (String[]) request.getAttribute("fileTypes");
|
||||||
String[] packageFormats = (String[]) request.getAttribute("packageFormats");
|
String[] packageFormats = (String[]) request.getAttribute("packageFormats");
|
||||||
|
|
||||||
Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
||||||
|
|
||||||
Division main = body.addInteractiveDivision("confirm-collection", contextPath + "/swordclient", Division.METHOD_POST, "");
|
Division main = body.addInteractiveDivision("confirm-collection", contextPath + "/swordclient", Division.METHOD_POST, "");
|
||||||
main.setHead(T_main_head.parameterize(handle));
|
main.setHead(T_main_head.parameterize(handle));
|
||||||
|
|
||||||
List collectionList = main.addList("collectionList", List.TYPE_FORM);
|
List collectionList = main.addList("collectionList", List.TYPE_FORM);
|
||||||
|
|
||||||
collectionList.setHead(T_collection_head.parameterize(location));
|
collectionList.setHead(T_collection_head.parameterize(location));
|
||||||
collectionList.addItem().addContent(T_collection_title.parameterize(collection.getTitle()));
|
collectionList.addItem().addContent(T_collection_title.parameterize(collection.getTitle()));
|
||||||
collectionList.addItem().addContent(T_collection_policy.parameterize(collection.getCollectionPolicy()));
|
collectionList.addItem().addContent(T_collection_policy.parameterize(collection.getCollectionPolicy()));
|
||||||
collectionList.addItem().addContent(T_collection_mediation.parameterize(Boolean.toString(collection.getMediation())));
|
collectionList.addItem().addContent(T_collection_mediation.parameterize(Boolean.toString(collection.getMediation())));
|
||||||
|
|
||||||
Select fileType = collectionList.addItem().addSelect("fileType");
|
Select fileType = collectionList.addItem().addSelect("fileType");
|
||||||
for (String ft : fileTypes) {
|
for (String ft : fileTypes) {
|
||||||
fileType.addOption(false, ft, ft);
|
fileType.addOption(false, ft, ft);
|
||||||
}
|
}
|
||||||
fileType.setLabel(T_collection_file_types);
|
fileType.setLabel(T_collection_file_types);
|
||||||
|
|
||||||
Select packageFormat = collectionList.addItem().addSelect("packageFormat");
|
Select packageFormat = collectionList.addItem().addSelect("packageFormat");
|
||||||
for (String pf : packageFormats) {
|
for (String pf : packageFormats) {
|
||||||
packageFormat.addOption(false, pf, pf);
|
packageFormat.addOption(false, pf, pf);
|
||||||
}
|
}
|
||||||
packageFormat.setLabel(T_collection_package_formats);
|
packageFormat.setLabel(T_collection_package_formats);
|
||||||
|
|
||||||
Para buttonList = main.addPara();
|
Para buttonList = main.addPara();
|
||||||
buttonList.addButton("submit_next").setValue(T_submit_next);
|
buttonList.addButton("submit_next").setValue(T_submit_next);
|
||||||
buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
|
buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
|
||||||
|
|
||||||
main.addHidden("swordclient-continue").setValue(knot.getId());
|
main.addHidden("swordclient-continue").setValue(knot.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,176 +1,176 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
import org.dspace.app.xmlui.aspect.administrative.FlowResult;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.sword.client.exceptions.HttpException;
|
import org.dspace.sword.client.exceptions.HttpException;
|
||||||
import org.dspace.sword.client.DSpaceSwordClient;
|
import org.dspace.sword.client.DSpaceSwordClient;
|
||||||
import org.purl.sword.base.ServiceDocument;
|
import org.purl.sword.base.ServiceDocument;
|
||||||
import org.purl.sword.client.SWORDClientException;
|
import org.purl.sword.client.SWORDClientException;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 08/02/11
|
* Date: 08/02/11
|
||||||
* Time: 21:41
|
* Time: 21:41
|
||||||
*/
|
*/
|
||||||
public class SelectTargetAction
|
public class SelectTargetAction
|
||||||
{
|
{
|
||||||
private static final Message T_url_error = new Message("default", "xmlui.swordclient.SelectTargetAction.url_error");
|
private static final Message T_url_error = new Message("default", "xmlui.swordclient.SelectTargetAction.url_error");
|
||||||
private static final Message T_serviceDoc_error = new Message("default", "xmlui.swordclient.SelectTargetAction.serviceDoc_error");
|
private static final Message T_serviceDoc_error = new Message("default", "xmlui.swordclient.SelectTargetAction.serviceDoc_error");
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(SelectTargetAction.class);
|
private static Logger log = Logger.getLogger(SelectTargetAction.class);
|
||||||
|
|
||||||
|
|
||||||
public FlowResult processSelectTarget(Context context, Request request, DSpaceSwordClient DSClient)
|
public FlowResult processSelectTarget(Context context, Request request, DSpaceSwordClient DSClient)
|
||||||
{
|
{
|
||||||
FlowResult result = new FlowResult();
|
FlowResult result = new FlowResult();
|
||||||
result.setContinue(false);
|
result.setContinue(false);
|
||||||
|
|
||||||
// Get all our request parameters
|
// Get all our request parameters
|
||||||
String url = request.getParameter("url").trim();
|
String url = request.getParameter("url").trim();
|
||||||
String otherUrl = request.getParameter("otherUrl").trim();
|
String otherUrl = request.getParameter("otherUrl").trim();
|
||||||
String username = request.getParameter("username").trim();
|
String username = request.getParameter("username").trim();
|
||||||
String password = request.getParameter("password").trim();
|
String password = request.getParameter("password").trim();
|
||||||
String onBehalfOf = request.getParameter("onBehalfOf").trim();
|
String onBehalfOf = request.getParameter("onBehalfOf").trim();
|
||||||
|
|
||||||
// If we have errors, the form needs to be resubmitted to fix those problems
|
// If we have errors, the form needs to be resubmitted to fix those problems
|
||||||
|
|
||||||
String chosenUrl = "";
|
String chosenUrl = "";
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(otherUrl))
|
if (!StringUtils.isEmpty(otherUrl))
|
||||||
{
|
{
|
||||||
// If otherUrl has been entered then it will take precedence.
|
// If otherUrl has been entered then it will take precedence.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new URL(otherUrl);
|
new URL(otherUrl);
|
||||||
chosenUrl = otherUrl;
|
chosenUrl = otherUrl;
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e)
|
catch (MalformedURLException e)
|
||||||
{
|
{
|
||||||
result.addError("otherUrl");
|
result.addError("otherUrl");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!StringUtils.isEmpty(url))
|
if (!StringUtils.isEmpty(url))
|
||||||
{
|
{
|
||||||
chosenUrl = url;
|
chosenUrl = url;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.addError("url");
|
result.addError("url");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(username))
|
if (StringUtils.isEmpty(username))
|
||||||
{
|
{
|
||||||
result.addError("username");
|
result.addError("username");
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(password))
|
if (StringUtils.isEmpty(password))
|
||||||
{
|
{
|
||||||
result.addError("password");
|
result.addError("password");
|
||||||
}
|
}
|
||||||
|
|
||||||
// No errors, the input parameters look healthy.
|
// No errors, the input parameters look healthy.
|
||||||
if (result.getErrors() == null)
|
if (result.getErrors() == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DSClient.setRemoteServer(chosenUrl);
|
DSClient.setRemoteServer(chosenUrl);
|
||||||
DSClient.setCredentials(username, password, onBehalfOf);
|
DSClient.setCredentials(username, password, onBehalfOf);
|
||||||
ServiceDocument serviceDoc = DSClient.getServiceDocument();
|
ServiceDocument serviceDoc = DSClient.getServiceDocument();
|
||||||
result.setParameter("serviceDoc", serviceDoc);
|
result.setParameter("serviceDoc", serviceDoc);
|
||||||
result.setContinue(true);
|
result.setContinue(true);
|
||||||
result.setOutcome(true);
|
result.setOutcome(true);
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e)
|
catch (MalformedURLException e)
|
||||||
{
|
{
|
||||||
log.error("Malformed URL : " + chosenUrl);
|
log.error("Malformed URL : " + chosenUrl);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_url_error);
|
result.setMessage(T_url_error);
|
||||||
}
|
}
|
||||||
catch (HttpException e)
|
catch (HttpException e)
|
||||||
{
|
{
|
||||||
log.error("HttpException encountered", e);
|
log.error("HttpException encountered", e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
||||||
}
|
}
|
||||||
catch (SWORDClientException e)
|
catch (SWORDClientException e)
|
||||||
{
|
{
|
||||||
log.error("SwordClientException : " + e.getMessage(), e);
|
log.error("SwordClientException : " + e.getMessage(), e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowResult processSelectSubTarget(Context context, Request request, DSpaceSwordClient DSClient)
|
public FlowResult processSelectSubTarget(Context context, Request request, DSpaceSwordClient DSClient)
|
||||||
{
|
{
|
||||||
FlowResult result = new FlowResult();
|
FlowResult result = new FlowResult();
|
||||||
result.setContinue(false);
|
result.setContinue(false);
|
||||||
|
|
||||||
|
|
||||||
// Get all our request parameters.
|
// Get all our request parameters.
|
||||||
String url = request.getParameter("sub-service").trim();
|
String url = request.getParameter("sub-service").trim();
|
||||||
|
|
||||||
log.info("target selected is : " + url);
|
log.info("target selected is : " + url);
|
||||||
|
|
||||||
if (StringUtils.isEmpty(url))
|
if (StringUtils.isEmpty(url))
|
||||||
{
|
{
|
||||||
// Note : this shouldn't ever happen since the user doesn't enter it manually.
|
// Note : this shouldn't ever happen since the user doesn't enter it manually.
|
||||||
result.addError("sub-service");
|
result.addError("sub-service");
|
||||||
}
|
}
|
||||||
|
|
||||||
// No errors, the input parameters look healthy.
|
// No errors, the input parameters look healthy.
|
||||||
if (result.getErrors() == null)
|
if (result.getErrors() == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DSClient.setRemoteServer(url);
|
DSClient.setRemoteServer(url);
|
||||||
ServiceDocument serviceDoc = DSClient.getServiceDocument();
|
ServiceDocument serviceDoc = DSClient.getServiceDocument();
|
||||||
result.setParameter("serviceDoc", serviceDoc);
|
result.setParameter("serviceDoc", serviceDoc);
|
||||||
result.setOutcome(true);
|
result.setOutcome(true);
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e)
|
catch (MalformedURLException e)
|
||||||
{
|
{
|
||||||
log.error("Malformed URL : " + url);
|
log.error("Malformed URL : " + url);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_url_error);
|
result.setMessage(T_url_error);
|
||||||
}
|
}
|
||||||
catch (HttpException e)
|
catch (HttpException e)
|
||||||
{
|
{
|
||||||
log.error("HttpException encountered", e);
|
log.error("HttpException encountered", e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
||||||
}
|
}
|
||||||
catch (SWORDClientException e)
|
catch (SWORDClientException e)
|
||||||
{
|
{
|
||||||
log.error("SwordClientException : " + e.getMessage(), e);
|
log.error("SwordClientException : " + e.getMessage(), e);
|
||||||
result.setOutcome(false);
|
result.setOutcome(false);
|
||||||
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -1,150 +1,148 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.apache.cocoon.environment.ObjectModelHelper;
|
import org.apache.cocoon.environment.ObjectModelHelper;
|
||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||||
import org.dspace.app.xmlui.utils.UIException;
|
import org.dspace.app.xmlui.utils.UIException;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.app.xmlui.wing.WingException;
|
import org.dspace.app.xmlui.wing.WingException;
|
||||||
import org.dspace.app.xmlui.wing.element.*;
|
import org.dspace.app.xmlui.wing.element.*;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.xml.sax.SAXException;
|
||||||
import org.dspace.utils.DSpace;
|
|
||||||
import org.xml.sax.SAXException;
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.io.IOException;
|
import java.util.ArrayList;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
/**
|
||||||
|
* User: Robin Taylor
|
||||||
/**
|
* Date: 21-Sep-2010
|
||||||
* User: Robin Taylor
|
* Time: 13:44:28
|
||||||
* Date: 21-Sep-2010
|
*/
|
||||||
* Time: 13:44:28
|
public class SelectTargetTransformer extends AbstractDSpaceTransformer
|
||||||
*/
|
{
|
||||||
public class SelectTargetTransformer extends AbstractDSpaceTransformer
|
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
||||||
{
|
private static final Message T_title = message("xmlui.swordclient.SelectTarget.title");
|
||||||
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
||||||
private static final Message T_title = message("xmlui.swordclient.SelectTarget.title");
|
private static final Message T_trail = message("xmlui.swordclient.SelectTarget.trail");
|
||||||
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
||||||
private static final Message T_trail = message("xmlui.swordclient.SelectTarget.trail");
|
private static final Message T_submit_next = message("xmlui.general.next");
|
||||||
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
private static final Message T_submit_cancel = message("xmlui.general.cancel");
|
||||||
private static final Message T_submit_next = message("xmlui.general.next");
|
|
||||||
private static final Message T_submit_cancel = message("xmlui.general.cancel");
|
private static final Message T_url = message("xmlui.swordclient.SelectTarget.url");
|
||||||
|
private static final Message T_other_url = message("xmlui.swordclient.SelectTarget.other_url");
|
||||||
private static final Message T_url = message("xmlui.swordclient.SelectTarget.url");
|
private static final Message T_username = message("xmlui.swordclient.SelectTarget.username");
|
||||||
private static final Message T_other_url = message("xmlui.swordclient.SelectTarget.other_url");
|
private static final Message T_password = message("xmlui.swordclient.SelectTarget.password");
|
||||||
private static final Message T_username = message("xmlui.swordclient.SelectTarget.username");
|
private static final Message T_on_behalf_of = message("xmlui.swordclient.SelectTarget.on_behalf_of");
|
||||||
private static final Message T_password = message("xmlui.swordclient.SelectTarget.password");
|
|
||||||
private static final Message T_on_behalf_of = message("xmlui.swordclient.SelectTarget.on_behalf_of");
|
private static final Message T_url_error = message("xmlui.swordclient.SelectTargetAction.url_error");
|
||||||
|
private static final Message T_username_error = message("xmlui.swordclient.SelectTargetAction.username_error");
|
||||||
private static final Message T_url_error = message("xmlui.swordclient.SelectTargetAction.url_error");
|
private static final Message T_password_error = message("xmlui.swordclient.SelectTargetAction.password_error");
|
||||||
private static final Message T_username_error = message("xmlui.swordclient.SelectTargetAction.username_error");
|
|
||||||
private static final Message T_password_error = message("xmlui.swordclient.SelectTargetAction.password_error");
|
private static Logger log = Logger.getLogger(SelectTargetTransformer.class);
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(SelectTargetTransformer.class);
|
|
||||||
|
/**
|
||||||
|
* Add a page title and trail links
|
||||||
/**
|
*/
|
||||||
* Add a page title and trail links
|
public void addPageMeta(PageMeta pageMeta) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException
|
||||||
*/
|
{
|
||||||
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.addMetadata("title").addContent(T_title);
|
|
||||||
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
||||||
|
pageMeta.addTrail().addContent(T_trail);
|
||||||
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
}
|
||||||
pageMeta.addTrail().addContent(T_trail);
|
|
||||||
}
|
|
||||||
|
public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException
|
||||||
|
{
|
||||||
public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException
|
Request request = ObjectModelHelper.getRequest(objectModel);
|
||||||
{
|
|
||||||
Request request = ObjectModelHelper.getRequest(objectModel);
|
String handle = parameters.getParameter("handle", null);
|
||||||
|
String errorString = parameters.getParameter("errors",null);
|
||||||
String handle = parameters.getParameter("handle", null);
|
ArrayList<String> errors = new ArrayList<String>();
|
||||||
String errorString = parameters.getParameter("errors",null);
|
if (!StringUtils.isEmpty(errorString))
|
||||||
ArrayList<String> errors = new ArrayList<String>();
|
{
|
||||||
if (!StringUtils.isEmpty(errorString))
|
for (String error : errorString.split(","))
|
||||||
{
|
{
|
||||||
for (String error : errorString.split(","))
|
errors.add(error);
|
||||||
{
|
}
|
||||||
errors.add(error);
|
}
|
||||||
}
|
|
||||||
}
|
// If this screen is being redisplayed then get the previously entered values.
|
||||||
|
String urlValue = request.getParameter("url");
|
||||||
// If this screen is being redisplayed then get the previously entered values.
|
String otherUrlValue = request.getParameter("otherUrl");
|
||||||
String urlValue = request.getParameter("url");
|
String usernameValue = request.getParameter("username");
|
||||||
String otherUrlValue = request.getParameter("otherUrl");
|
String passwordValue = request.getParameter("password");
|
||||||
String usernameValue = request.getParameter("username");
|
|
||||||
String passwordValue = request.getParameter("password");
|
Division main = body.addInteractiveDivision("service-document", contextPath + "/swordclient", Division.METHOD_POST, "");
|
||||||
|
main.setHead(T_main_head.parameterize(handle));
|
||||||
Division main = body.addInteractiveDivision("service-document", contextPath + "/swordclient", Division.METHOD_POST, "");
|
|
||||||
main.setHead(T_main_head.parameterize(handle));
|
List targetDetails = main.addList("target_details",List.TYPE_FORM);
|
||||||
|
|
||||||
List targetDetails = main.addList("target_details",List.TYPE_FORM);
|
Select source = targetDetails.addItem().addSelect("url");
|
||||||
|
String targetsString = ConfigurationManager.getProperty("sword-client", "targets");
|
||||||
Select source = targetDetails.addItem().addSelect("url");
|
String[] targets = targetsString.split(",");
|
||||||
String targetsString = ConfigurationManager.getProperty("sword-client", "targets");
|
for (String target : targets)
|
||||||
String[] targets = targetsString.split(",");
|
{
|
||||||
for (String target : targets)
|
if ((urlValue != null) && (urlValue.length() > 0) && (urlValue.equals(target)))
|
||||||
{
|
{
|
||||||
if ((urlValue != null) && (urlValue.length() > 0) && (urlValue.equals(target)))
|
source.addOption(false, target, target);
|
||||||
{
|
}
|
||||||
source.addOption(false, target, target);
|
else
|
||||||
}
|
{
|
||||||
else
|
source.addOption(false, target, target);
|
||||||
{
|
}
|
||||||
source.addOption(false, target, target);
|
}
|
||||||
}
|
source.setLabel(T_url);
|
||||||
}
|
|
||||||
source.setLabel(T_url);
|
Text otherUrl = targetDetails.addItem().addText("otherUrl");
|
||||||
|
otherUrl.setLabel(T_other_url);
|
||||||
Text otherUrl = targetDetails.addItem().addText("otherUrl");
|
otherUrl.setValue(otherUrlValue);
|
||||||
otherUrl.setLabel(T_other_url);
|
if (errors.contains("otherUrl"))
|
||||||
otherUrl.setValue(otherUrlValue);
|
{
|
||||||
if (errors.contains("otherUrl"))
|
otherUrl.addError(T_url_error);
|
||||||
{
|
}
|
||||||
otherUrl.addError(T_url_error);
|
|
||||||
}
|
Text username = targetDetails.addItem().addText("username");
|
||||||
|
username.setRequired();
|
||||||
Text username = targetDetails.addItem().addText("username");
|
username.setLabel(T_username);
|
||||||
username.setRequired();
|
username.setValue(usernameValue);
|
||||||
username.setLabel(T_username);
|
if (errors.contains("username"))
|
||||||
username.setValue(usernameValue);
|
{
|
||||||
if (errors.contains("username"))
|
username.addError(T_username_error);
|
||||||
{
|
}
|
||||||
username.addError(T_username_error);
|
|
||||||
}
|
Password password = targetDetails.addItem().addPassword("password");
|
||||||
|
password.setRequired();
|
||||||
Password password = targetDetails.addItem().addPassword("password");
|
password.setLabel(T_password);
|
||||||
password.setRequired();
|
// Comment - Element Password doesn't allow me to set a value, don't know why not.
|
||||||
password.setLabel(T_password);
|
//password.setValue(passwordValue);
|
||||||
// Comment - Element Password doesn't allow me to set a value, don't know why not.
|
if (errors.contains("password"))
|
||||||
//password.setValue(passwordValue);
|
{
|
||||||
if (errors.contains("password"))
|
password.addError(T_password_error);
|
||||||
{
|
}
|
||||||
password.addError(T_password_error);
|
|
||||||
}
|
Text onBehalfOf = targetDetails.addItem().addText("onBehalfOf");
|
||||||
|
onBehalfOf.setLabel(T_on_behalf_of);
|
||||||
Text onBehalfOf = targetDetails.addItem().addText("onBehalfOf");
|
|
||||||
onBehalfOf.setLabel(T_on_behalf_of);
|
Para buttonList = main.addPara();
|
||||||
|
buttonList.addButton("submit_next").setValue(T_submit_next);
|
||||||
Para buttonList = main.addPara();
|
buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
|
||||||
buttonList.addButton("submit_next").setValue(T_submit_next);
|
|
||||||
buttonList.addButton("submit_cancel").setValue(T_submit_cancel);
|
main.addHidden("swordclient-continue").setValue(knot.getId());
|
||||||
|
}
|
||||||
main.addHidden("swordclient-continue").setValue(knot.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
@@ -1,56 +1,56 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.app.xmlui.aspect.swordclient;
|
package org.dspace.app.xmlui.aspect.swordclient;
|
||||||
|
|
||||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||||
import org.dspace.app.xmlui.wing.Message;
|
import org.dspace.app.xmlui.wing.Message;
|
||||||
import org.dspace.app.xmlui.wing.WingException;
|
import org.dspace.app.xmlui.wing.WingException;
|
||||||
import org.dspace.app.xmlui.wing.element.Body;
|
import org.dspace.app.xmlui.wing.element.Body;
|
||||||
import org.dspace.app.xmlui.wing.element.PageMeta;
|
import org.dspace.app.xmlui.wing.element.PageMeta;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 08-Apr-2010
|
* Date: 08-Apr-2010
|
||||||
* Time: 09:54:52
|
* Time: 09:54:52
|
||||||
*/
|
*/
|
||||||
public class SwordResponseTransformer extends AbstractDSpaceTransformer
|
public class SwordResponseTransformer extends AbstractDSpaceTransformer
|
||||||
{
|
{
|
||||||
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
private static final Message T_dspace_home = message("xmlui.general.dspace_home");
|
||||||
|
|
||||||
private static final Message T_title = message("xmlui.swordclient.SwordResponse.title");
|
private static final Message T_title = message("xmlui.swordclient.SwordResponse.title");
|
||||||
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
private static final Message T_SwordCopy_trail = message("xmlui.swordclient.general.SwordCopy_trail");
|
||||||
private static final Message T_trail = message("xmlui.swordclient.SwordResponse.trail");
|
private static final Message T_trail = message("xmlui.swordclient.SwordResponse.trail");
|
||||||
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
private static final Message T_main_head = message("xmlui.swordclient.general.main_head");
|
||||||
|
|
||||||
|
|
||||||
public void addPageMeta(PageMeta pageMeta) throws WingException
|
public void addPageMeta(PageMeta pageMeta) throws WingException
|
||||||
{
|
{
|
||||||
pageMeta.addMetadata("title").addContent(T_title);
|
pageMeta.addMetadata("title").addContent(T_title);
|
||||||
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
|
||||||
|
|
||||||
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
pageMeta.addTrail().addContent(T_SwordCopy_trail);
|
||||||
pageMeta.addTrail().addContent(T_trail);
|
pageMeta.addTrail().addContent(T_trail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBody(Body body) throws WingException, SQLException, AuthorizeException
|
public void addBody(Body body) throws WingException, SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
String handle = parameters.getParameter("handle", null);
|
String handle = parameters.getParameter("handle", null);
|
||||||
|
|
||||||
//Division main = body.addDivision("deposit-response");
|
//Division main = body.addDivision("deposit-response");
|
||||||
//main.setHead(T_main_head.parameterize(handle));
|
//main.setHead(T_main_head.parameterize(handle));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,234 +1,233 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.sword.client;
|
package org.dspace.sword.client;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.log4j.Logger;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.packager.PackageDisseminator;
|
||||||
import org.dspace.content.packager.PackageDisseminator;
|
import org.dspace.content.packager.PackageParameters;
|
||||||
import org.dspace.content.packager.PackageParameters;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.PluginManager;
|
||||||
import org.dspace.core.PluginManager;
|
import org.dspace.handle.HandleManager;
|
||||||
import org.dspace.handle.HandleManager;
|
import org.dspace.sword.client.exceptions.HttpException;
|
||||||
import org.dspace.sword.client.exceptions.HttpException;
|
import org.dspace.sword.client.exceptions.InvalidHandleException;
|
||||||
import org.dspace.sword.client.exceptions.InvalidHandleException;
|
import org.dspace.sword.client.exceptions.PackageFormatException;
|
||||||
import org.dspace.sword.client.exceptions.PackageFormatException;
|
import org.dspace.sword.client.exceptions.PackagerException;
|
||||||
import org.dspace.sword.client.exceptions.PackagerException;
|
import org.purl.sword.base.DepositResponse;
|
||||||
import org.purl.sword.base.DepositResponse;
|
import org.purl.sword.base.SWORDEntry;
|
||||||
import org.purl.sword.base.SWORDEntry;
|
import org.purl.sword.base.ServiceDocument;
|
||||||
import org.purl.sword.base.ServiceDocument;
|
import org.purl.sword.client.Client;
|
||||||
import org.purl.sword.client.Client;
|
import org.purl.sword.client.PostMessage;
|
||||||
import org.purl.sword.client.PostMessage;
|
import org.purl.sword.client.SWORDClientException;
|
||||||
import org.purl.sword.client.SWORDClientException;
|
import org.purl.sword.client.Status;
|
||||||
import org.purl.sword.client.Status;
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.File;
|
import java.net.MalformedURLException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.URL;
|
||||||
import java.net.URL;
|
import java.sql.SQLException;
|
||||||
import java.sql.SQLException;
|
import java.util.UUID;
|
||||||
import java.util.UUID;
|
|
||||||
|
/**
|
||||||
/**
|
* User: Robin Taylor
|
||||||
* User: Robin Taylor
|
* Date: 15/02/11
|
||||||
* Date: 15/02/11
|
* Time: 21:12
|
||||||
* Time: 21:12
|
*/
|
||||||
*/
|
|
||||||
|
public class DSpaceSwordClient
|
||||||
public class DSpaceSwordClient
|
{
|
||||||
{
|
private Client client;
|
||||||
private Client client;
|
private PostMessage message;
|
||||||
private PostMessage message;
|
private String onBehalfOf;
|
||||||
private String onBehalfOf;
|
private String serviceDocUrl;
|
||||||
private String serviceDocUrl;
|
|
||||||
|
private String filename;
|
||||||
private String filename;
|
private String tempDirectory;
|
||||||
private String tempDirectory;
|
|
||||||
|
private String packageFormat;
|
||||||
private String packageFormat;
|
private PackageParameters pkgParams;
|
||||||
private PackageParameters pkgParams;
|
|
||||||
|
private static Logger log = Logger.getLogger(DSpaceSwordClient.class);
|
||||||
private static Logger log = Logger.getLogger(DSpaceSwordClient.class);
|
|
||||||
|
|
||||||
|
public DSpaceSwordClient()
|
||||||
public DSpaceSwordClient()
|
{
|
||||||
{
|
client = new Client();
|
||||||
client = new Client();
|
// The default timeout is way too low so increase it x10.
|
||||||
// The default timeout is way too low so increase it x10.
|
client.setSocketTimeout(200000);
|
||||||
client.setSocketTimeout(200000);
|
client.setUserAgent("DSpace Sword Client");
|
||||||
client.setUserAgent("DSpace Sword Client");
|
|
||||||
|
message = new PostMessage();
|
||||||
message = new PostMessage();
|
message.setUseMD5(false);
|
||||||
message.setUseMD5(false);
|
message.setChecksumError(false);
|
||||||
message.setChecksumError(false);
|
message.setVerbose(false);
|
||||||
message.setVerbose(false);
|
message.setNoOp(false);
|
||||||
message.setNoOp(false);
|
message.setUserAgent("DSpace Sword Client");
|
||||||
message.setUserAgent("DSpace Sword Client");
|
|
||||||
|
setFilename();
|
||||||
setFilename();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void setFilename()
|
||||||
public void setFilename()
|
{
|
||||||
{
|
if ((tempDirectory == null) || (tempDirectory.equals("")))
|
||||||
if ((tempDirectory == null) || (tempDirectory.equals("")))
|
{
|
||||||
{
|
tempDirectory = System.getProperty("java.io.tmpdir");
|
||||||
tempDirectory = System.getProperty("java.io.tmpdir");
|
}
|
||||||
}
|
|
||||||
|
if (!tempDirectory.endsWith(System.getProperty("file.separator")))
|
||||||
if (!tempDirectory.endsWith(System.getProperty("file.separator")))
|
{
|
||||||
{
|
tempDirectory += System.getProperty("file.separator");
|
||||||
tempDirectory += System.getProperty("file.separator");
|
}
|
||||||
}
|
|
||||||
|
filename = tempDirectory + UUID.randomUUID().toString();
|
||||||
filename = tempDirectory + UUID.randomUUID().toString();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void setRemoteServer(String chosenUrl) throws MalformedURLException
|
||||||
public void setRemoteServer(String chosenUrl) throws MalformedURLException
|
{
|
||||||
{
|
serviceDocUrl = chosenUrl;
|
||||||
serviceDocUrl = chosenUrl;
|
URL url = new URL(chosenUrl);
|
||||||
URL url = new URL(chosenUrl);
|
client.setServer(url.getHost(), url.getPort());
|
||||||
client.setServer(url.getHost(), url.getPort());
|
}
|
||||||
}
|
|
||||||
|
public void setCredentials(String username, String password, String onBehalfOf)
|
||||||
public void setCredentials(String username, String password, String onBehalfOf)
|
{
|
||||||
{
|
client.setCredentials(username, password);
|
||||||
client.setCredentials(username, password);
|
this.onBehalfOf = onBehalfOf;
|
||||||
this.onBehalfOf = onBehalfOf;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public ServiceDocument getServiceDocument() throws HttpException, SWORDClientException
|
||||||
public ServiceDocument getServiceDocument() throws HttpException, SWORDClientException
|
{
|
||||||
{
|
log.info("Getting Sword Service Document from " + serviceDocUrl);
|
||||||
log.info("Getting Sword Service Document from " + serviceDocUrl);
|
ServiceDocument sd = client.getServiceDocument(serviceDocUrl, onBehalfOf);
|
||||||
ServiceDocument sd = client.getServiceDocument(serviceDocUrl, onBehalfOf);
|
|
||||||
|
Status status = client.getStatus();
|
||||||
Status status = client.getStatus();
|
|
||||||
|
if (status.getCode() == 200)
|
||||||
if (status.getCode() == 200)
|
{
|
||||||
{
|
log.info("Sword Service Document successfully retrieved from " + serviceDocUrl);
|
||||||
log.info("Sword Service Document successfully retrieved from " + serviceDocUrl);
|
return sd;
|
||||||
return sd;
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
log.info("Error retrieving Sword Service Document from " + serviceDocUrl);
|
||||||
log.info("Error retrieving Sword Service Document from " + serviceDocUrl);
|
throw new HttpException("No service document available - Http status code " + status);
|
||||||
throw new HttpException("No service document available - Http status code " + status);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void setCollection(String destination)
|
||||||
public void setCollection(String destination)
|
{
|
||||||
{
|
message.setDestination(destination);
|
||||||
message.setDestination(destination);
|
}
|
||||||
}
|
|
||||||
|
public void setFileType(String fileType)
|
||||||
public void setFileType(String fileType)
|
{
|
||||||
{
|
message.setFiletype(fileType);
|
||||||
message.setFiletype(fileType);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void setPackageFormat(String packageFormat) throws PackageFormatException
|
||||||
public void setPackageFormat(String packageFormat) throws PackageFormatException
|
{
|
||||||
{
|
// todo : Read all this stuff from config
|
||||||
// todo : Read all this stuff from config
|
if (packageFormat.equals("http://purl.org/net/sword-types/METSDSpaceSIP"))
|
||||||
if (packageFormat.equals("http://purl.org/net/sword-types/METSDSpaceSIP"))
|
{
|
||||||
{
|
this.packageFormat = "METS";
|
||||||
this.packageFormat = "METS";
|
pkgParams = new PackageParameters();
|
||||||
pkgParams = new PackageParameters();
|
pkgParams.addProperty("dmd", "MODS");
|
||||||
pkgParams.addProperty("dmd", "MODS");
|
message.setFormatNamespace("http://purl.org/net/sword-types/METSDSpaceSIP");
|
||||||
message.setFormatNamespace("http://purl.org/net/sword-types/METSDSpaceSIP");
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
throw new PackageFormatException("Invalid package format selected");
|
||||||
throw new PackageFormatException("Invalid package format selected");
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void deposit(Context context, String handle) throws InvalidHandleException, PackagerException, SWORDClientException, PackageFormatException, HttpException
|
||||||
public void deposit(Context context, String handle) throws InvalidHandleException, PackagerException, SWORDClientException, PackageFormatException, HttpException
|
{
|
||||||
{
|
File file = new File(filename);
|
||||||
File file = new File(filename);
|
createPackage(context, handle, file);
|
||||||
createPackage(context, handle, file);
|
sendMessage();
|
||||||
sendMessage();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Create the package and write it to disk.
|
||||||
* Create the package and write it to disk.
|
*/
|
||||||
*/
|
public void createPackage(Context context, String handle, File file) throws InvalidHandleException, PackagerException, PackageFormatException
|
||||||
public void createPackage(Context context, String handle, File file) throws InvalidHandleException, PackagerException, PackageFormatException
|
{
|
||||||
{
|
// Note - in the future we may need to allow for more than zipped up packages.
|
||||||
// Note - in the future we may need to allow for more than zipped up packages.
|
|
||||||
|
PackageDisseminator dip = (PackageDisseminator) PluginManager
|
||||||
PackageDisseminator dip = (PackageDisseminator) PluginManager
|
.getNamedPlugin(PackageDisseminator.class, packageFormat);
|
||||||
.getNamedPlugin(PackageDisseminator.class, packageFormat);
|
|
||||||
|
if (dip == null)
|
||||||
if (dip == null)
|
{
|
||||||
{
|
log.error("Error - unknown package type " + packageFormat);
|
||||||
log.error("Error - unknown package type " + packageFormat);
|
throw new PackageFormatException("Unknown package type " + packageFormat);
|
||||||
throw new PackageFormatException("Unknown package type " + packageFormat);
|
}
|
||||||
}
|
|
||||||
|
DSpaceObject dso = null;
|
||||||
DSpaceObject dso = null;
|
try
|
||||||
try
|
{
|
||||||
{
|
dso = HandleManager.resolveToObject(context, handle);
|
||||||
dso = HandleManager.resolveToObject(context, handle);
|
}
|
||||||
}
|
catch (SQLException e)
|
||||||
catch (SQLException e)
|
{
|
||||||
{
|
log.error("Unable to resolve handle " + handle);
|
||||||
log.error("Unable to resolve handle " + handle);
|
throw new InvalidHandleException("Unable to resolve handle " + handle);
|
||||||
throw new InvalidHandleException("Unable to resolve handle " + handle);
|
}
|
||||||
}
|
|
||||||
|
if (dso == null)
|
||||||
if (dso == null)
|
{
|
||||||
{
|
log.error("Unable to resolve handle " + handle);
|
||||||
log.error("Unable to resolve handle " + handle);
|
throw new InvalidHandleException("Unable to resolve handle " + handle);
|
||||||
throw new InvalidHandleException("Unable to resolve handle " + handle);
|
}
|
||||||
}
|
|
||||||
|
try
|
||||||
try
|
{
|
||||||
{
|
dip.disseminate(context, dso, pkgParams, file);
|
||||||
dip.disseminate(context, dso, pkgParams, file);
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
log.error("Error creating package", e);
|
||||||
log.error("Error creating package", e);
|
throw new PackagerException("Error creating package", e);
|
||||||
throw new PackagerException("Error creating package", e);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Reads the file, probably a zipped package, and sends it to the Sword server.
|
||||||
* Reads the file, probably a zipped package, and sends it to the Sword server.
|
*
|
||||||
*
|
* @return A unique ID returned by a successful deposit
|
||||||
* @return A unique ID returned by a successful deposit
|
* @throws org.purl.sword.client.SWORDClientException
|
||||||
* @throws org.purl.sword.client.SWORDClientException
|
*
|
||||||
*
|
*/
|
||||||
*/
|
public String sendMessage() throws SWORDClientException, HttpException
|
||||||
public String sendMessage() throws SWORDClientException, HttpException
|
{
|
||||||
{
|
message.setFilepath(filename);
|
||||||
message.setFilepath(filename);
|
DepositResponse resp = client.postFile(message);
|
||||||
DepositResponse resp = client.postFile(message);
|
Status status = client.getStatus();
|
||||||
Status status = client.getStatus();
|
|
||||||
|
if ((status.getCode() == 201) || (status.getCode() == 202))
|
||||||
if ((status.getCode() == 201) || (status.getCode() == 202))
|
{
|
||||||
{
|
SWORDEntry se = resp.getEntry();
|
||||||
SWORDEntry se = resp.getEntry();
|
return se.getId();
|
||||||
return se.getId();
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
String error = status.getCode() + " " + status.getMessage() + " - " + resp.getEntry().getSummary().getContent();
|
||||||
String error = status.getCode() + " " + status.getMessage() + " - " + resp.getEntry().getSummary().getContent();
|
log.info("Error depositing Sword package : " + error);
|
||||||
log.info("Error depositing Sword package : " + error);
|
throw new HttpException(error);
|
||||||
throw new HttpException(error);
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
@@ -1,111 +1,111 @@
|
|||||||
/**
|
/**
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dspace.sword.client;
|
package org.dspace.sword.client;
|
||||||
|
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.purl.sword.base.Collection;
|
import org.purl.sword.base.Collection;
|
||||||
import org.purl.sword.base.ServiceDocument;
|
import org.purl.sword.base.ServiceDocument;
|
||||||
import org.purl.sword.base.SwordAcceptPackaging;
|
import org.purl.sword.base.SwordAcceptPackaging;
|
||||||
import org.purl.sword.base.Workspace;
|
import org.purl.sword.base.Workspace;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: Robin Taylor
|
* User: Robin Taylor
|
||||||
* Date: 15/02/11
|
* Date: 15/02/11
|
||||||
* Time: 21:12
|
* Time: 21:12
|
||||||
*/
|
*/
|
||||||
public class ServiceDocumentHelper {
|
public class ServiceDocumentHelper {
|
||||||
|
|
||||||
public static List<Collection> getCollections(ServiceDocument serviceDoc)
|
public static List<Collection> getCollections(ServiceDocument serviceDoc)
|
||||||
{
|
{
|
||||||
List<Collection> allCollections = new ArrayList<Collection>();
|
List<Collection> allCollections = new ArrayList<Collection>();
|
||||||
List<Workspace> workspaces = serviceDoc.getService().getWorkspacesList();
|
List<Workspace> workspaces = serviceDoc.getService().getWorkspacesList();
|
||||||
|
|
||||||
for (Workspace ws : workspaces)
|
for (Workspace ws : workspaces)
|
||||||
{
|
{
|
||||||
List<Collection> collections = ws.getCollections();
|
List<Collection> collections = ws.getCollections();
|
||||||
allCollections.addAll(collections);
|
allCollections.addAll(collections);
|
||||||
}
|
}
|
||||||
|
|
||||||
return allCollections;
|
return allCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection getCollection(ServiceDocument serviceDoc, String location)
|
public static Collection getCollection(ServiceDocument serviceDoc, String location)
|
||||||
{
|
{
|
||||||
List<Collection> allCollections = getCollections(serviceDoc);
|
List<Collection> allCollections = getCollections(serviceDoc);
|
||||||
for (Collection collection : allCollections)
|
for (Collection collection : allCollections)
|
||||||
{
|
{
|
||||||
if (collection.getLocation().equals(location))
|
if (collection.getLocation().equals(location))
|
||||||
{
|
{
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got here then we didn't find a match.
|
// If we got here then we didn't find a match.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getCommonFileTypes(ServiceDocument serviceDoc, String location)
|
public static String[] getCommonFileTypes(ServiceDocument serviceDoc, String location)
|
||||||
{
|
{
|
||||||
String FTsString = ConfigurationManager.getProperty("sword-client", "file-types");
|
String FTsString = ConfigurationManager.getProperty("sword-client", "file-types");
|
||||||
String[] clientFTsArray = FTsString.split(",");
|
String[] clientFTsArray = FTsString.split(",");
|
||||||
List<String> clientFTs = Arrays.asList(clientFTsArray);
|
List<String> clientFTs = Arrays.asList(clientFTsArray);
|
||||||
|
|
||||||
List<String> commonFTs = new ArrayList<String>();
|
List<String> commonFTs = new ArrayList<String>();
|
||||||
|
|
||||||
Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
||||||
String[] serverFTs = collection.getAccepts();
|
String[] serverFTs = collection.getAccepts();
|
||||||
for (String serverFT : serverFTs)
|
for (String serverFT : serverFTs)
|
||||||
{
|
{
|
||||||
if (clientFTs.contains(serverFT))
|
if (clientFTs.contains(serverFT))
|
||||||
{
|
{
|
||||||
commonFTs.add(serverFT);
|
commonFTs.add(serverFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return commonFTs.toArray(new String[commonFTs.size()]);
|
return commonFTs.toArray(new String[commonFTs.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getCommonPackageFormats(ServiceDocument serviceDoc, String location)
|
public static String[] getCommonPackageFormats(ServiceDocument serviceDoc, String location)
|
||||||
{
|
{
|
||||||
String PFsString = ConfigurationManager.getProperty("sword-client", "package-formats");
|
String PFsString = ConfigurationManager.getProperty("sword-client", "package-formats");
|
||||||
String[] clientPFsArray = PFsString.split(",");
|
String[] clientPFsArray = PFsString.split(",");
|
||||||
List<String> clientPFs = Arrays.asList(clientPFsArray);
|
List<String> clientPFs = Arrays.asList(clientPFsArray);
|
||||||
|
|
||||||
List<String> commonPFs = new ArrayList<String>();
|
List<String> commonPFs = new ArrayList<String>();
|
||||||
|
|
||||||
Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
|
||||||
List<SwordAcceptPackaging> serverPFs = collection.getAcceptPackaging();
|
List<SwordAcceptPackaging> serverPFs = collection.getAcceptPackaging();
|
||||||
for (SwordAcceptPackaging serverPF : serverPFs)
|
for (SwordAcceptPackaging serverPF : serverPFs)
|
||||||
{
|
{
|
||||||
if (clientPFs.contains(serverPF.getContent()))
|
if (clientPFs.contains(serverPF.getContent()))
|
||||||
{
|
{
|
||||||
commonPFs.add(serverPF.getContent());
|
commonPFs.add(serverPF.getContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return commonPFs.toArray(new String[commonPFs.size()]);
|
return commonPFs.toArray(new String[commonPFs.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getPackageFormats(Collection collection)
|
public static String[] getPackageFormats(Collection collection)
|
||||||
{
|
{
|
||||||
List<String> packageFormats = new ArrayList<String>();
|
List<String> packageFormats = new ArrayList<String>();
|
||||||
List<SwordAcceptPackaging> pfs = collection.getAcceptPackaging();
|
List<SwordAcceptPackaging> pfs = collection.getAcceptPackaging();
|
||||||
for (SwordAcceptPackaging pf : pfs)
|
for (SwordAcceptPackaging pf : pfs)
|
||||||
{
|
{
|
||||||
packageFormats.add(pf.getContent());
|
packageFormats.add(pf.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
return packageFormats.toArray(new String[pfs.size()]);
|
return packageFormats.toArray(new String[pfs.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,287 +1,287 @@
|
|||||||
/*
|
/*
|
||||||
* The contents of this file are subject to the license and copyright
|
* 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
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
* tree and available online at
|
* tree and available online at
|
||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
importClass(Packages.org.dspace.authorize.AuthorizeManager);
|
importClass(Packages.org.dspace.authorize.AuthorizeManager);
|
||||||
|
|
||||||
importClass(Packages.org.dspace.app.xmlui.utils.FlowscriptUtils);
|
importClass(Packages.org.dspace.app.xmlui.utils.FlowscriptUtils);
|
||||||
importClass(Packages.org.dspace.app.xmlui.utils.ContextUtil);
|
importClass(Packages.org.dspace.app.xmlui.utils.ContextUtil);
|
||||||
importClass(Packages.org.dspace.sword.client.DSpaceSwordClient);
|
importClass(Packages.org.dspace.sword.client.DSpaceSwordClient);
|
||||||
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.SelectTargetAction);
|
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.SelectTargetAction);
|
||||||
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.SelectCollectionAction);
|
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.SelectCollectionAction);
|
||||||
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.SelectPackagingAction);
|
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.SelectPackagingAction);
|
||||||
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.DepositAction);
|
importClass(Packages.org.dspace.app.xmlui.aspect.swordclient.DepositAction);
|
||||||
importClass(Packages.org.dspace.content.Item);
|
importClass(Packages.org.dspace.content.Item);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple access method to access the current cocoon object model.
|
* Simple access method to access the current cocoon object model.
|
||||||
*/
|
*/
|
||||||
function getObjectModel()
|
function getObjectModel()
|
||||||
{
|
{
|
||||||
return FlowscriptUtils.getObjectModel(cocoon);
|
return FlowscriptUtils.getObjectModel(cocoon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the DSpace context for this request since each HTTP request generates
|
* Return the DSpace context for this request since each HTTP request generates
|
||||||
* a new context this object should never be stored and instead always accessed
|
* a new context this object should never be stored and instead always accessed
|
||||||
* through this method so you are ensured that it is the correct one.
|
* through this method so you are ensured that it is the correct one.
|
||||||
*/
|
*/
|
||||||
function getDSContext()
|
function getDSContext()
|
||||||
{
|
{
|
||||||
return ContextUtil.obtainContext(getObjectModel());
|
return ContextUtil.obtainContext(getObjectModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result object could potentially contain a notice message and a list of
|
* The result object could potentially contain a notice message and a list of
|
||||||
* errors. If either of these are present then they are added to the sitemap's
|
* errors. If either of these are present then they are added to the sitemap's
|
||||||
* parameters.
|
* parameters.
|
||||||
*/
|
*/
|
||||||
function sendPage(uri,bizData,result)
|
function sendPage(uri,bizData,result)
|
||||||
{
|
{
|
||||||
if (bizData == null)
|
if (bizData == null)
|
||||||
bizData = {};
|
bizData = {};
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
var outcome = result.getOutcome();
|
var outcome = result.getOutcome();
|
||||||
var header = result.getHeader();
|
var header = result.getHeader();
|
||||||
var message = result.getMessage();
|
var message = result.getMessage();
|
||||||
var characters = result.getCharacters();
|
var characters = result.getCharacters();
|
||||||
|
|
||||||
if (message != null || characters != null)
|
if (message != null || characters != null)
|
||||||
{
|
{
|
||||||
bizData["notice"] = "true";
|
bizData["notice"] = "true";
|
||||||
bizData["outcome"] = outcome;
|
bizData["outcome"] = outcome;
|
||||||
bizData["header"] = header;
|
bizData["header"] = header;
|
||||||
bizData["message"] = message;
|
bizData["message"] = message;
|
||||||
bizData["characters"] = characters;
|
bizData["characters"] = characters;
|
||||||
}
|
}
|
||||||
|
|
||||||
var errors = result.getErrorString();
|
var errors = result.getErrorString();
|
||||||
if (errors != null)
|
if (errors != null)
|
||||||
{
|
{
|
||||||
bizData["errors"] = errors;
|
bizData["errors"] = errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comment - Ugh ! In Cocoon terms 'sendPage' should be used when there is no 'flow' but Manakin sets this misleading parameter
|
// Comment - Ugh ! In Cocoon terms 'sendPage' should be used when there is no 'flow' but Manakin sets this misleading parameter
|
||||||
// to force it through another part of the sitemap - Robin.
|
// to force it through another part of the sitemap - Robin.
|
||||||
bizData["flow"] = "true";
|
bizData["flow"] = "true";
|
||||||
cocoon.sendPage(uri,bizData);
|
cocoon.sendPage(uri,bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendPageAndWait(uri,bizData,result)
|
function sendPageAndWait(uri,bizData,result)
|
||||||
{
|
{
|
||||||
if (bizData == null)
|
if (bizData == null)
|
||||||
bizData = {};
|
bizData = {};
|
||||||
|
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
var outcome = result.getOutcome();
|
var outcome = result.getOutcome();
|
||||||
var header = result.getHeader();
|
var header = result.getHeader();
|
||||||
var message = result.getMessage();
|
var message = result.getMessage();
|
||||||
var characters = result.getCharacters();
|
var characters = result.getCharacters();
|
||||||
|
|
||||||
if (message != null || characters != null)
|
if (message != null || characters != null)
|
||||||
{
|
{
|
||||||
bizData["notice"] = "true";
|
bizData["notice"] = "true";
|
||||||
bizData["outcome"] = outcome;
|
bizData["outcome"] = outcome;
|
||||||
bizData["header"] = header;
|
bizData["header"] = header;
|
||||||
bizData["message"] = message;
|
bizData["message"] = message;
|
||||||
bizData["characters"] = characters;
|
bizData["characters"] = characters;
|
||||||
}
|
}
|
||||||
|
|
||||||
var errors = result.getErrorString();
|
var errors = result.getErrorString();
|
||||||
if (errors != null)
|
if (errors != null)
|
||||||
{
|
{
|
||||||
bizData["errors"] = errors;
|
bizData["errors"] = errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// just to remember where we came from.
|
// just to remember where we came from.
|
||||||
bizData["flow"] = "true";
|
bizData["flow"] = "true";
|
||||||
cocoon.sendPageAndWait(uri,bizData);
|
cocoon.sendPageAndWait(uri,bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the currently authenticated eperson is an
|
* Return whether the currently authenticated eperson is an
|
||||||
* administrator.
|
* administrator.
|
||||||
*/
|
*/
|
||||||
function isAdministrator() {
|
function isAdministrator() {
|
||||||
return AuthorizeManager.isAdmin(getDSContext());
|
return AuthorizeManager.isAdmin(getDSContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert that the currently authenticated eperson is an administrator.
|
* Assert that the currently authenticated eperson is an administrator.
|
||||||
* If they are not then an error page is returned and this function
|
* If they are not then an error page is returned and this function
|
||||||
* will NEVER return.
|
* will NEVER return.
|
||||||
*/
|
*/
|
||||||
function assertAdministrator() {
|
function assertAdministrator() {
|
||||||
|
|
||||||
if ( ! isAdministrator()) {
|
if ( ! isAdministrator()) {
|
||||||
sendPage("admin/not-authorized");
|
sendPage("admin/not-authorized");
|
||||||
cocoon.exit();
|
cocoon.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* Entry Point flows
|
* Entry Point flows
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
function startSwordDeposit()
|
function startSwordDeposit()
|
||||||
{
|
{
|
||||||
assertAdministrator();
|
assertAdministrator();
|
||||||
|
|
||||||
var itemID = cocoon.request.get("itemID");
|
var itemID = cocoon.request.get("itemID");
|
||||||
var item = Item.find(getDSContext(),itemID);
|
var item = Item.find(getDSContext(),itemID);
|
||||||
var handle = item.getHandle();
|
var handle = item.getHandle();
|
||||||
var DSClient = new DSpaceSwordClient();
|
var DSClient = new DSpaceSwordClient();
|
||||||
var result = null;
|
var result = null;
|
||||||
|
|
||||||
// The URL of the service document (or 'sub' service document).
|
// The URL of the service document (or 'sub' service document).
|
||||||
var serviceDoc;
|
var serviceDoc;
|
||||||
// The URL of the selected collection.
|
// The URL of the selected collection.
|
||||||
var location;
|
var location;
|
||||||
// The available file types. An intersection of what the client and server can support.
|
// The available file types. An intersection of what the client and server can support.
|
||||||
var fileTypes;
|
var fileTypes;
|
||||||
// The available package formats. An intersection of what the client and server can support.
|
// The available package formats. An intersection of what the client and server can support.
|
||||||
var packageFormats;
|
var packageFormats;
|
||||||
|
|
||||||
// Retrieve the high level service document
|
// Retrieve the high level service document
|
||||||
|
|
||||||
result = getServiceDoc(handle, DSClient);
|
result = getServiceDoc(handle, DSClient);
|
||||||
serviceDoc = result.getParameter("serviceDoc");
|
serviceDoc = result.getParameter("serviceDoc");
|
||||||
|
|
||||||
// Select a collection in which to deposit.
|
// Select a collection in which to deposit.
|
||||||
|
|
||||||
result = getCollection(handle, serviceDoc, DSClient);
|
result = getCollection(handle, serviceDoc, DSClient);
|
||||||
location = result.getParameter("location");
|
location = result.getParameter("location");
|
||||||
serviceDoc = result.getParameter("serviceDoc");
|
serviceDoc = result.getParameter("serviceDoc");
|
||||||
fileTypes = result.getParameter("fileTypes");
|
fileTypes = result.getParameter("fileTypes");
|
||||||
packageFormats = result.getParameter("packageFormats");
|
packageFormats = result.getParameter("packageFormats");
|
||||||
|
|
||||||
// Ask the user to select which file type and package format combo they want.
|
// Ask the user to select which file type and package format combo they want.
|
||||||
|
|
||||||
getPackageType(handle, fileTypes, packageFormats, location, serviceDoc, DSClient);
|
getPackageType(handle, fileTypes, packageFormats, location, serviceDoc, DSClient);
|
||||||
|
|
||||||
// Now send the item.
|
// Now send the item.
|
||||||
|
|
||||||
sendItem(handle, DSClient);
|
sendItem(handle, DSClient);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServiceDoc(handle, DSClient)
|
function getServiceDoc(handle, DSClient)
|
||||||
{
|
{
|
||||||
var selectTargetAction;
|
var selectTargetAction;
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sendPageAndWait("swordclient/select-target", {handle: handle}, result);
|
sendPageAndWait("swordclient/select-target", {handle: handle}, result);
|
||||||
|
|
||||||
if (cocoon.request.get("submit_next"))
|
if (cocoon.request.get("submit_next"))
|
||||||
{
|
{
|
||||||
selectTargetAction = new SelectTargetAction();
|
selectTargetAction = new SelectTargetAction();
|
||||||
result = selectTargetAction.processSelectTarget(getDSContext(), cocoon.request, DSClient);
|
result = selectTargetAction.processSelectTarget(getDSContext(), cocoon.request, DSClient);
|
||||||
}
|
}
|
||||||
else if (cocoon.request.get("submit_cancel"))
|
else if (cocoon.request.get("submit_cancel"))
|
||||||
{
|
{
|
||||||
cocoon.redirectTo(cocoon.request.getContextPath() + "/handle/" + handle, true);
|
cocoon.redirectTo(cocoon.request.getContextPath() + "/handle/" + handle, true);
|
||||||
getDSContext().complete();
|
getDSContext().complete();
|
||||||
cocoon.exit();
|
cocoon.exit();
|
||||||
}
|
}
|
||||||
} while (result == null || !result.getContinue());
|
} while (result == null || !result.getContinue());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCollection(handle, serviceDoc, DSClient)
|
function getCollection(handle, serviceDoc, DSClient)
|
||||||
{
|
{
|
||||||
var selectCollectionAction;
|
var selectCollectionAction;
|
||||||
var selectTargetAction;
|
var selectTargetAction;
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
cocoon.request.setAttribute("serviceDoc", serviceDoc);
|
cocoon.request.setAttribute("serviceDoc", serviceDoc);
|
||||||
sendPageAndWait("swordclient/select-collection", {handle: handle}, result);
|
sendPageAndWait("swordclient/select-collection", {handle: handle}, result);
|
||||||
|
|
||||||
if (cocoon.request.get("deposit"))
|
if (cocoon.request.get("deposit"))
|
||||||
{
|
{
|
||||||
// A collection, or rather the location of one, has been selected, so let's
|
// A collection, or rather the location of one, has been selected, so let's
|
||||||
// see what file type and package format combos are available.
|
// see what file type and package format combos are available.
|
||||||
|
|
||||||
// We have a new request so need to attach the service doc again.
|
// We have a new request so need to attach the service doc again.
|
||||||
cocoon.request.setAttribute("serviceDoc", serviceDoc);
|
cocoon.request.setAttribute("serviceDoc", serviceDoc);
|
||||||
|
|
||||||
selectCollectionAction = new SelectCollectionAction();
|
selectCollectionAction = new SelectCollectionAction();
|
||||||
result = selectCollectionAction.processSelectCollection(getDSContext(), cocoon.request, DSClient);
|
result = selectCollectionAction.processSelectCollection(getDSContext(), cocoon.request, DSClient);
|
||||||
}
|
}
|
||||||
else if (cocoon.request.get("sub-service"))
|
else if (cocoon.request.get("sub-service"))
|
||||||
{
|
{
|
||||||
// The user has opted to drill down into a 'sub' service document
|
// The user has opted to drill down into a 'sub' service document
|
||||||
// Note : The 'result' from this action should never have 'continue=true'.
|
// Note : The 'result' from this action should never have 'continue=true'.
|
||||||
|
|
||||||
selectTargetAction = new SelectTargetAction();
|
selectTargetAction = new SelectTargetAction();
|
||||||
result = selectTargetAction.processSelectSubTarget(getDSContext(), cocoon.request, DSClient);
|
result = selectTargetAction.processSelectSubTarget(getDSContext(), cocoon.request, DSClient);
|
||||||
|
|
||||||
// Reset serviceDoc so that when we loop round we display the contents of the new service document.
|
// Reset serviceDoc so that when we loop round we display the contents of the new service document.
|
||||||
serviceDoc = result.getParameter("serviceDoc");
|
serviceDoc = result.getParameter("serviceDoc");
|
||||||
}
|
}
|
||||||
else if (cocoon.request.get("submit_cancel"))
|
else if (cocoon.request.get("submit_cancel"))
|
||||||
{
|
{
|
||||||
cocoon.redirectTo(cocoon.request.getContextPath() + "/handle/" + handle, true);
|
cocoon.redirectTo(cocoon.request.getContextPath() + "/handle/" + handle, true);
|
||||||
getDSContext().complete();
|
getDSContext().complete();
|
||||||
cocoon.exit();
|
cocoon.exit();
|
||||||
}
|
}
|
||||||
} while (result == null || !result.getContinue());
|
} while (result == null || !result.getContinue());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPackageType(handle, fileTypes, packageFormats, location, serviceDoc, DSClient)
|
function getPackageType(handle, fileTypes, packageFormats, location, serviceDoc, DSClient)
|
||||||
{
|
{
|
||||||
var selectPackagingAction;
|
var selectPackagingAction;
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
cocoon.request.setAttribute("fileTypes", fileTypes);
|
cocoon.request.setAttribute("fileTypes", fileTypes);
|
||||||
cocoon.request.setAttribute("packageFormats", packageFormats);
|
cocoon.request.setAttribute("packageFormats", packageFormats);
|
||||||
cocoon.request.setAttribute("location", location);
|
cocoon.request.setAttribute("location", location);
|
||||||
cocoon.request.setAttribute("serviceDoc", serviceDoc);
|
cocoon.request.setAttribute("serviceDoc", serviceDoc);
|
||||||
sendPageAndWait("swordclient/select-packaging", {handle: handle}, result);
|
sendPageAndWait("swordclient/select-packaging", {handle: handle}, result);
|
||||||
|
|
||||||
if (cocoon.request.get("submit_next"))
|
if (cocoon.request.get("submit_next"))
|
||||||
{
|
{
|
||||||
// Update the Sword Client with the selected file type and package format
|
// Update the Sword Client with the selected file type and package format
|
||||||
|
|
||||||
selectPackagingAction = new SelectPackagingAction();
|
selectPackagingAction = new SelectPackagingAction();
|
||||||
result = selectPackagingAction.processSelectPackaging(getDSContext(), cocoon.request, DSClient);
|
result = selectPackagingAction.processSelectPackaging(getDSContext(), cocoon.request, DSClient);
|
||||||
}
|
}
|
||||||
else if (cocoon.request.get("submit_cancel"))
|
else if (cocoon.request.get("submit_cancel"))
|
||||||
{
|
{
|
||||||
cocoon.redirectTo(cocoon.request.getContextPath() + "/handle/" + handle, true);
|
cocoon.redirectTo(cocoon.request.getContextPath() + "/handle/" + handle, true);
|
||||||
getDSContext().complete();
|
getDSContext().complete();
|
||||||
cocoon.exit();
|
cocoon.exit();
|
||||||
}
|
}
|
||||||
} while (result == null || !result.getContinue());
|
} while (result == null || !result.getContinue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendItem(handle, DSClient)
|
function sendItem(handle, DSClient)
|
||||||
{
|
{
|
||||||
var depositAction;
|
var depositAction;
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
depositAction = new DepositAction();
|
depositAction = new DepositAction();
|
||||||
result = depositAction.processDeposit(getDSContext(), handle, DSClient);
|
result = depositAction.processDeposit(getDSContext(), handle, DSClient);
|
||||||
sendPage("swordclient/deposit-response", {handle: handle}, result);
|
sendPage("swordclient/deposit-response", {handle: handle}, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
pom.xml
16
pom.xml
@@ -448,22 +448,6 @@
|
|||||||
<version>3.0-SNAPSHOT</version>
|
<version>3.0-SNAPSHOT</version>
|
||||||
<type>war</type>
|
<type>war</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-api</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-xmlui-api</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace</groupId>
|
|
||||||
<artifactId>dspace-sword-client-xmlui-webapp</artifactId>
|
|
||||||
<version>3.0-SNAPSHOT</version>
|
|
||||||
<type>war</type>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
|
Reference in New Issue
Block a user