You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(11) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(2) |
Feb
(64) |
Mar
(4) |
Apr
(2) |
May
(10) |
Jun
(26) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(14) |
Feb
(7) |
Mar
(7) |
Apr
(37) |
May
(59) |
Jun
(4) |
Jul
(16) |
Aug
(3) |
Sep
(9) |
Oct
(1) |
Nov
|
Dec
(25) |
2012 |
Jan
(68) |
Feb
(5) |
Mar
(28) |
Apr
(12) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-05-01 16:18:33
|
Revision: 510 http://sword-app.svn.sourceforge.net/sword-app/?rev=510&view=rev Author: richard-jones Date: 2012-05-01 16:18:27 +0000 (Tue, 01 May 2012) Log Message: ----------- explicitly cast location headers to string for supporting mod_wsgi Modified Paths: -------------- sss/branches/sss-2/sss/pylons_sword_controller.py Modified: sss/branches/sss-2/sss/pylons_sword_controller.py =================================================================== --- sss/branches/sss-2/sss/pylons_sword_controller.py 2012-05-01 15:51:53 UTC (rev 509) +++ sss/branches/sss-2/sss/pylons_sword_controller.py 2012-05-01 16:18:27 UTC (rev 510) @@ -669,7 +669,7 @@ else: response.content_type = media_resource.content_type if media_resource.packaging is not None: - response.headers["Packaging"] = media_resource.packaging + response.headers["Packaging"] = str(media_resource.packaging) f = open(media_resource.filepath, "r") response.status_int = 200 response.status = "200 OK" @@ -838,7 +838,7 @@ cont = ss.get_container(path, accept_parameters) ssslog.info("Returning " + response.status + " from request on " + inspect.stack()[0][3]) if cont is not None: - response.headers["Content-Type"] = accept_parameters.content_type.mimetype() + response.headers["Content-Type"] = str(accept_parameters.content_type.mimetype()) return cont except SwordError as e: @@ -1007,7 +1007,7 @@ edit_uri = ss.get_edit_uri() response.status_int = 303 response.status = "303 See Other" - response.headers["Content-Location"] = edit_uri + response.headers["Content-Location"] = str(edit_uri) return def _GET_webui(self, path=None): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-05-01 15:51:59
|
Revision: 509 http://sword-app.svn.sourceforge.net/sword-app/?rev=509&view=rev Author: richard-jones Date: 2012-05-01 15:51:53 +0000 (Tue, 01 May 2012) Log Message: ----------- explicitly cast location headers to string for supporting mod_wsgi Modified Paths: -------------- sss/branches/sss-2/sss/pylons_sword_controller.py Modified: sss/branches/sss-2/sss/pylons_sword_controller.py =================================================================== --- sss/branches/sss-2/sss/pylons_sword_controller.py 2012-04-30 15:23:48 UTC (rev 508) +++ sss/branches/sss-2/sss/pylons_sword_controller.py 2012-05-01 15:51:53 UTC (rev 509) @@ -610,7 +610,7 @@ # created ssslog.info("Item created") response.content_type = "application/atom+xml;type=entry" - response.headers["Location"] = result.location + response.headers["Location"] = str(result.location) # explicit cast to string response.status_int = 201 response.status = "201 Created" if config.return_deposit_receipt: @@ -744,7 +744,7 @@ result = ss.add_content(path, deposit) response.content_type = "application/atom+xml;type=entry" - response.headers["Location"] = result.location + response.headers["Location"] = str(result.location) # explict cast to str response.status_int = 201 response.status = "201 Created" if config.return_deposit_receipt: @@ -869,7 +869,7 @@ ss = SwordServer(config, auth) result = ss.replace(path, deposit) - response.headers["Location"] = result.location + response.headers["Location"] = str(result.location) # explicit cast to str if config.return_deposit_receipt: response.content_type = "application/atom+xml;type=entry" response.status_int = 200 @@ -919,7 +919,7 @@ # in this case the spec is incorrect (correction need to be implemented # asap) - response.headers["Location"] = result.location + response.headers["Location"] = str(result.location) # explict cast to str response.status_int = 200 response.status = "200 OK" if config.return_deposit_receipt: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-30 15:23:54
|
Revision: 508 http://sword-app.svn.sourceforge.net/sword-app/?rev=508&view=rev Author: richard-jones Date: 2012-04-30 15:23:48 +0000 (Mon, 30 Apr 2012) Log Message: ----------- clean up after ourselves close the input stream on the media resource once it has been flushed to the client. Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-29 17:05:07 UTC (rev 507) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-30 15:23:48 UTC (rev 508) @@ -106,6 +106,7 @@ InputStream in = resource.getInputStream(); this.copyInputToOutput(in, out); out.flush(); + in.close(); } } catch (SwordError se) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-29 17:05:13
|
Revision: 507 http://sword-app.svn.sourceforge.net/sword-app/?rev=507&view=rev Author: richard-jones Date: 2012-04-29 17:05:07 +0000 (Sun, 29 Apr 2012) Log Message: ----------- allow for unauthenticated GET requests on media resource Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-27 16:37:03 UTC (rev 506) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-29 17:05:07 UTC (rev 507) @@ -40,7 +40,7 @@ AuthCredentials auth = null; try { - auth = this.getAuthCredentials(req); + auth = this.getAuthCredentials(req, true); } catch (SwordAuthException e) { Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-27 16:37:03 UTC (rev 506) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-29 17:05:07 UTC (rev 507) @@ -35,35 +35,40 @@ this.config = config; } - protected AuthCredentials getAuthCredentials(HttpServletRequest request) + protected AuthCredentials getAuthCredentials(HttpServletRequest request) + throws SwordAuthException + { + return this.getAuthCredentials(request, false); + } + + protected AuthCredentials getAuthCredentials(HttpServletRequest request, boolean allowUnauthenticated) throws SwordAuthException { + // is the user authenticating? + String authHeader = request.getHeader("Authorization"); + // is there an On-Behalf-Of header? String obo = request.getHeader("On-Behalf-Of"); - // is authentication required + // which authentication scheme do we recognise (should only be Basic) String authType = this.config.getAuthType(); - boolean authRequired = "Basic".equals(authType); + boolean isBasic = "Basic".equals(authType); - // is the user authenticating? - String authHeader = request.getHeader("Authorization"); + if (isBasic && (authHeader == null || "".equals(authHeader))) + { + if (!allowUnauthenticated) + { + throw new SwordAuthException(true); + } + else + { + log.debug("No Authentication Credentials supplied"); + return new AuthCredentials(null, null, obo); + } + } - // are we meant to authenticate, but haven't been given anything? - if (authRequired && (authHeader == null || "".equals(authHeader))) - { - throw new SwordAuthException(true); - } - - // by this stage we are either meant to authenticate and have been given credentials or - // we don't need to authenticate. Either way we just fill in the AuthCredentials + // decode the auth header and populate the authcredentials object for return String[] userPass = this.decodeAuthHeader(authHeader); - - if (userPass == null) - { - log.debug("No Authentication Credentials supplied"); - return new AuthCredentials(null, null, obo); - } - AuthCredentials auth = new AuthCredentials(userPass[0], userPass[1], obo); return auth; } @@ -85,7 +90,7 @@ if (!"Basic".equalsIgnoreCase(authBits[0].trim())) { log.warn("Authentication method not supported: " + authBits[0]); - return null; + throw new SwordAuthException("Authentication method not supported: " + authBits[0]); } // get the username and password out of the base64 encoded Basic auth string This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-27 16:37:09
|
Revision: 506 http://sword-app.svn.sourceforge.net/sword-app/?rev=506&view=rev Author: richard-jones Date: 2012-04-27 16:37:03 +0000 (Fri, 27 Apr 2012) Log Message: ----------- Error handling improvements * add default title to error documents * support configurable alternate urls to error documents * max upload size now expects bytes not kilobytes Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfiguration.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfigurationDefault.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java 2012-04-27 12:44:54 UTC (rev 505) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java 2012-04-27 16:37:03 UTC (rev 506) @@ -85,6 +85,7 @@ // write some boiler-plate text into the document Element title = new Element("atom:title", UriRegistry.ATOM_NAMESPACE); + title.appendChild("ERROR"); Element updates = new Element("atom:updated", UriRegistry.ATOM_NAMESPACE); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); updates.appendChild(sdf.format(new Date())); @@ -118,6 +119,20 @@ error.appendChild(vd); } + String alternate = config.getAlternateUrl(); + String altContentType = config.getAlternateUrlContentType(); + if (alternate != null && !"".equals(alternate)) + { + Element altLink = new Element("atom:link", UriRegistry.ATOM_NAMESPACE); + altLink.addAttribute(new Attribute("rel", "alternate")); + if (altContentType != null && !"".equals(altContentType)) + { + altLink.addAttribute(new Attribute("type", altContentType)); + } + altLink.addAttribute(new Attribute("href", alternate)); + error.appendChild(altLink); + } + try { // now get it written out Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-27 12:44:54 UTC (rev 505) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-27 16:37:03 UTC (rev 506) @@ -164,12 +164,12 @@ // Set the file to be deposited deposit.setFile(file); - long fLength = file.length() / 1024; // in kilobytes + long fLength = file.length(); // in bytes if ((config.getMaxUploadSize() != -1) && (fLength > config.getMaxUploadSize())) { String msg = "The uploaded file exceeded the maximum file size this server will accept (the file is " + - fLength + "kB but the server will only accept files as large as " + - config.getMaxUploadSize() + "kB)"; + fLength + " bytes but the server will only accept files as large as " + + config.getMaxUploadSize() + " bytes)"; throw new SwordError(UriRegistry.ERROR_MAX_UPLOAD_SIZE_EXCEEDED, msg); } Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfiguration.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfiguration.java 2012-04-27 12:44:54 UTC (rev 505) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfiguration.java 2012-04-27 16:37:03 UTC (rev 506) @@ -21,4 +21,8 @@ String getTempDirectory(); int getMaxUploadSize(); + + String getAlternateUrl(); + + String getAlternateUrlContentType(); } Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfigurationDefault.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfigurationDefault.java 2012-04-27 12:44:54 UTC (rev 505) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordConfigurationDefault.java 2012-04-27 16:37:03 UTC (rev 506) @@ -51,4 +51,14 @@ { return -1; } + + public String getAlternateUrl() + { + return null; + } + + public String getAlternateUrlContentType() + { + return null; + } } Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java 2012-04-27 12:44:54 UTC (rev 505) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java 2012-04-27 16:37:03 UTC (rev 506) @@ -1,8 +1,5 @@ package org.swordapp.server; -import java.util.HashMap; -import java.util.Map; - public class SwordError extends Exception { private String errorUri; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-27 12:45:05
|
Revision: 505 http://sword-app.svn.sourceforge.net/sword-app/?rev=505&view=rev Author: richard-jones Date: 2012-04-27 12:44:54 +0000 (Fri, 27 Apr 2012) Log Message: ----------- Improved Statement support * Namespace prefixes in ORE formatted statement are now more sensible (i.e. "sword" and "ore" not "j.0", "j.1") * Author in atom feed is always set (fixes bug which didn't catch the empty string) Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/AtomStatement.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/OREStatement.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/UriRegistry.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/AtomStatement.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/AtomStatement.java 2012-04-26 16:17:19 UTC (rev 504) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/AtomStatement.java 2012-04-27 12:44:54 UTC (rev 505) @@ -23,7 +23,7 @@ public AtomStatement(String feedUri, String author, String title, String updated) { this.contentType = "application/atom+xml;type=feed"; - this.author = author != null ? author : "Unknown"; + this.author = (author != null && !"".equals(author)) ? author : "Unknown"; this.feedUri = feedUri; this.title = title != null ? title : "Untitled"; this.updated = updated; Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/OREStatement.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/OREStatement.java 2012-04-26 16:17:19 UTC (rev 504) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/OREStatement.java 2012-04-27 12:44:54 UTC (rev 505) @@ -31,10 +31,16 @@ // create the default model (in memory) to start with Model model = ModelFactory.createDefaultModel(); + // set up some sensible namespaces for the prefixes + model.setNsPrefix(UriRegistry.ORE_PREFIX, UriRegistry.ORE_NAMESPACE); + model.setNsPrefix(UriRegistry.SWORD_PREFIX, UriRegistry.SWORD_TERMS_NAMESPACE); + // create the resource map in the model Resource rem = model.createResource(this.remUri); rem.addProperty(RDF.type, model.createResource(UriRegistry.ORE_NAMESPACE + "ResourceMap")); + + // create the aggregation Resource agg = model.createResource(this.aggUri); agg.addProperty(RDF.type, model.createResource(UriRegistry.ORE_NAMESPACE + "Aggregation")); Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/UriRegistry.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/UriRegistry.java 2012-04-26 16:17:19 UTC (rev 504) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/UriRegistry.java 2012-04-27 12:44:54 UTC (rev 505) @@ -4,6 +4,13 @@ public class UriRegistry { + // Namespace prefixes + public static String SWORD_PREFIX = "sword"; + public static String ORE_PREFIX = "ore"; + public static String APP_PREFIX = "app"; + public static String DC_PREFIX = "dcterms"; + public static String ATOM_PREFIX = "atom"; + // Namespaces public static String SWORD_TERMS_NAMESPACE = "http://purl.org/net/sword/terms/"; public static String APP_NAMESPACE = "http://www.w3.org/2007/app"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-26 16:17:30
|
Revision: 504 http://sword-app.svn.sourceforge.net/sword-app/?rev=504&view=rev Author: richard-jones Date: 2012-04-26 16:17:19 +0000 (Thu, 26 Apr 2012) Log Message: ----------- add support for 404 Previously this library did not expressly support 404 responses (although it was possible with a workaround). This patch: * allows implementers to throw a sworderror with just a the status code as an argument * allows errors which have only status code arguments to be returned to the client with an empty body (rather than the server's 404 page or a sword error document) Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java 2012-04-25 13:39:56 UTC (rev 503) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/ErrorDocument.java 2012-04-26 16:17:19 UTC (rev 504) @@ -16,7 +16,7 @@ public class ErrorDocument { - private String errorUri; + private String errorUri = null; private Map<String, Integer> errorCodes = new HashMap<String, Integer>(); private String summary = null; private String verboseDescription = null; @@ -66,7 +66,7 @@ return this.status; } - if (this.errorCodes.containsKey(errorUri)) + if (errorUri != null && this.errorCodes.containsKey(errorUri)) { return this.errorCodes.get(errorUri); } Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-25 13:39:56 UTC (rev 503) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-26 16:17:19 UTC (rev 504) @@ -347,10 +347,10 @@ { try { - if (!this.config.returnErrorBody()) + if (!this.config.returnErrorBody() || !e.hasBody()) { ErrorDocument doc = new ErrorDocument(e.getErrorUri(), e.getStatus()); - resp.sendError(doc.getStatus()); + resp.setStatus(doc.getStatus()); return; } Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java 2012-04-25 13:39:56 UTC (rev 503) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordError.java 2012-04-26 16:17:19 UTC (rev 504) @@ -7,12 +7,20 @@ { private String errorUri; private int status = -1; + private boolean hasBody = true; public SwordError() { super(); } + public SwordError(int status) + { + super(); + this.status = status; + this.hasBody = false; + } + public SwordError(String errorUri) { super(errorUri); @@ -74,4 +82,9 @@ { return status; } + + public boolean hasBody() + { + return hasBody; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-25 13:40:06
|
Revision: 503 http://sword-app.svn.sourceforge.net/sword-app/?rev=503&view=rev Author: richard-jones Date: 2012-04-25 13:39:56 +0000 (Wed, 25 Apr 2012) Log Message: ----------- replace uses of redirect_to with redirect Modified Paths: -------------- sss/branches/sss-2/sss/pylons_sword_controller.py Modified: sss/branches/sss-2/sss/pylons_sword_controller.py =================================================================== --- sss/branches/sss-2/sss/pylons_sword_controller.py 2012-04-25 11:53:04 UTC (rev 502) +++ sss/branches/sss-2/sss/pylons_sword_controller.py 2012-04-25 13:39:56 UTC (rev 503) @@ -1,5 +1,5 @@ from pylons import request, response, session, tmpl_context as c -from pylons.controllers.util import abort, redirect_to +from pylons.controllers.util import abort, redirect from pylons.controllers import WSGIController from pylons.templating import render_mako as render @@ -664,7 +664,7 @@ # either send the client a redirect, or stream the content out if media_resource.redirect: - redirect_to(media_resource.url, _code=302) # FOUND (not SEE OTHER) + redirect(media_resource.url, _code=302) # FOUND (not SEE OTHER) return else: response.content_type = media_resource.content_type This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-25 11:53:14
|
Revision: 502 http://sword-app.svn.sourceforge.net/sword-app/?rev=502&view=rev Author: richard-jones Date: 2012-04-25 11:53:04 +0000 (Wed, 25 Apr 2012) Log Message: ----------- Add dependency declarations and some extra logging * setup.py now lists web.py and lxml==2.3.4 as dependencies * the ingesters_disseminators.py now logs (in debug mode) the incoming atom (default repository implementation only) Modified Paths: -------------- sss/branches/sss-2/setup.py sss/branches/sss-2/sss/ingesters_disseminators.py Modified: sss/branches/sss-2/setup.py =================================================================== --- sss/branches/sss-2/setup.py 2012-04-22 16:11:41 UTC (rev 501) +++ sss/branches/sss-2/setup.py 2012-04-25 11:53:04 UTC (rev 502) @@ -10,4 +10,5 @@ author_email='ric...@gm...', url='http://www.swordapp.org/', packages=find_packages(exclude=['tests']), + setup_requires=["web.py", "lxml==2.3.4"] ) Modified: sss/branches/sss-2/sss/ingesters_disseminators.py =================================================================== --- sss/branches/sss-2/sss/ingesters_disseminators.py 2012-04-22 16:11:41 UTC (rev 501) +++ sss/branches/sss-2/sss/ingesters_disseminators.py 2012-04-25 11:53:04 UTC (rev 502) @@ -204,6 +204,7 @@ ssslog.debug("Existing Metadata (before new ingest): " + str(metadata)) + ssslog.debug("Incoming atom: " + atom) entry = etree.fromstring(atom) # go through each element in the atom entry and just process the ones we care about This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-22 16:11:48
|
Revision: 501 http://sword-app.svn.sourceforge.net/sword-app/?rev=501&view=rev Author: richard-jones Date: 2012-04-22 16:11:41 +0000 (Sun, 22 Apr 2012) Log Message: ----------- Fix bug with "alternate" url A bug in the DepositReceipt meant that "alternate" urls were never placed into serialised deposit receipts. This is now fixed. Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java 2012-04-21 17:40:26 UTC (rev 500) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java 2012-04-22 16:11:41 UTC (rev 501) @@ -99,7 +99,7 @@ abderaEntry.addSimpleExtension(UriRegistry.SWORD_VERBOSE_DESCRIPTION, this.verboseDescription); } - if (this.splashUri == null) + if (this.splashUri != null) { abderaEntry.addLink(this.splashUri, "alternate"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-21 17:40:32
|
Revision: 500 http://sword-app.svn.sourceforge.net/sword-app/?rev=500&view=rev Author: richard-jones Date: 2012-04-21 17:40:26 +0000 (Sat, 21 Apr 2012) Log Message: ----------- add default text for treatment This is because in GET in the Edit-IRI often the treatment will not have a sensible value from the repository's point of view, but the field is required by the profile Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java 2012-04-21 13:52:27 UTC (rev 499) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/DepositReceipt.java 2012-04-21 17:40:26 UTC (rev 500) @@ -24,7 +24,7 @@ private IRI location = null; private Entry entry; private Map<String, String> statements = new HashMap<String, String>(); - private String treatment = null; + private String treatment = "no treatment information available"; private String verboseDescription = null; private String splashUri = null; private String originalDepositUri = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-21 13:52:34
|
Revision: 499 http://sword-app.svn.sourceforge.net/sword-app/?rev=499&view=rev Author: richard-jones Date: 2012-04-21 13:52:27 +0000 (Sat, 21 Apr 2012) Log Message: ----------- File cleanup enhancements Previously, in the case of an error, file cleanup wasn't successful. This update adds calls to the cleanup operation in more places, enhances the cleanup process, and fixes a bug in the SwordAPIEndpoint which caused the cleanup not to function correctly Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java 2012-04-20 15:02:55 UTC (rev 498) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java 2012-04-21 13:52:27 UTC (rev 499) @@ -198,6 +198,9 @@ } catch (SwordError se) { + // get rid of any temp files used + this.cleanup(deposit); + this.swordError(req, resp, se); } catch (SwordServerException e) @@ -210,6 +213,9 @@ } catch (SwordAuthException e) { + // get rid of any temp files used + this.cleanup(deposit); + // authentication actually failed at the server end; not a SwordError, but // need to throw a 403 Forbidden resp.sendError(403); Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java 2012-04-20 15:02:55 UTC (rev 498) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java 2012-04-21 13:52:27 UTC (rev 499) @@ -262,6 +262,9 @@ } catch (SwordError se) { + // get rid of any temp files used + this.cleanup(deposit); + this.swordError(req, resp, se); } catch (SwordServerException e) @@ -274,6 +277,9 @@ } catch (SwordAuthException e) { + // get rid of any temp files used + this.cleanup(deposit); + // authentication actually failed at the server end; not a SwordError, but // need to throw a 403 Forbidden resp.sendError(403); @@ -391,6 +397,9 @@ } catch (SwordError se) { + // get rid of any temp files used + this.cleanup(deposit); + this.swordError(req, resp, se); } catch (SwordServerException e) @@ -403,6 +412,9 @@ } catch (SwordAuthException e) { + // get rid of any temp files used + this.cleanup(deposit); + // authentication actually failed at the server end; not a SwordError, but // need to throw a 403 Forbidden resp.sendError(403); Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-20 15:02:55 UTC (rev 498) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-21 13:52:27 UTC (rev 499) @@ -176,6 +176,9 @@ } catch (SwordError se) { + // get rid of any temp files used + this.cleanup(deposit); + this.swordError(req, resp, se); } catch (SwordServerException e) @@ -184,6 +187,9 @@ } catch (SwordAuthException e) { + // get rid of any temp files used + this.cleanup(deposit); + // authentication actually failed at the server end; not a SwordError, but // need to throw a 403 Forbidden resp.sendError(403); @@ -270,8 +276,10 @@ } catch (SwordError se) { + // get rid of any temp files used + this.cleanup(deposit); + this.swordError(req, resp, se); - return; } catch (SwordServerException e) { @@ -279,6 +287,9 @@ } catch (SwordAuthException e) { + // get rid of any temp files used + this.cleanup(deposit); + // authentication actually failed at the server end; not a SwordError, but // need to throw a 403 Forbidden resp.sendError(403); Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-20 15:02:55 UTC (rev 498) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-21 13:52:27 UTC (rev 499) @@ -161,7 +161,10 @@ // Check the size is OK File file = new File(filename); - long fLength = file.length() / 1024; // in kilobytes + // Set the file to be deposited + deposit.setFile(file); + + long fLength = file.length() / 1024; // in kilobytes if ((config.getMaxUploadSize() != -1) && (fLength > config.getMaxUploadSize())) { String msg = "The uploaded file exceeded the maximum file size this server will accept (the file is " + @@ -184,11 +187,6 @@ String msg = "The received MD5 checksum for the deposited file did not match the checksum sent by the deposit client"; throw new SwordError(UriRegistry.ERROR_CHECKSUM_MISMATCH, msg); } - else - { - // Set the file to be deposited - deposit.setFile(file); - } log.debug("Package temporarily stored as: " + filename); } catch (NoSuchAlgorithmException e) @@ -271,6 +269,7 @@ } tmp.delete(); + deposit.setFile(null); } protected Element getGenerator(SwordConfiguration config) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-20 15:03:06
|
Revision: 498 http://sword-app.svn.sourceforge.net/sword-app/?rev=498&view=rev Author: richard-jones Date: 2012-04-20 15:02:55 +0000 (Fri, 20 Apr 2012) Log Message: ----------- Add clean up operation to deposit operations All deposit operations which take a Deposit object now run a cleanup on the deposit object to remove any temp files that are created Modified Paths: -------------- JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java 2012-04-20 10:41:40 UTC (rev 497) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/CollectionAPI.java 2012-04-20 15:02:55 UTC (rev 498) @@ -122,6 +122,7 @@ } } + Deposit deposit = null; try { // the first thing to do is determine what the deposit type is: @@ -134,7 +135,7 @@ String slug = req.getHeader("Slug"); boolean inProgress = this.getInProgress(req); - Deposit deposit = new Deposit(); + deposit = new Deposit(); deposit.setInProgress(inProgress); deposit.setSlug(slug); DepositReceipt receipt = null; @@ -213,6 +214,11 @@ // need to throw a 403 Forbidden resp.sendError(403); } + finally + { + // get rid of any temp files used + this.cleanup(deposit); + } } protected void addGenerator(DepositReceipt doc, SwordConfiguration config) { Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java 2012-04-20 10:41:40 UTC (rev 497) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/ContainerAPI.java 2012-04-20 15:02:55 UTC (rev 498) @@ -179,6 +179,7 @@ } } + Deposit deposit = null; try { // the first thing to do is determine what the deposit type is: @@ -189,7 +190,7 @@ // get the In-Progress header boolean inProgress = this.getInProgress(req); - Deposit deposit = new Deposit(); + deposit = new Deposit(); deposit.setInProgress(inProgress); String iri = this.getFullUrl(req); DepositReceipt receipt; @@ -277,6 +278,11 @@ // need to throw a 403 Forbidden resp.sendError(403); } + finally + { + // get rid of any temp files used + this.cleanup(deposit); + } } public void post(HttpServletRequest req, HttpServletResponse resp) @@ -304,6 +310,7 @@ } } + Deposit deposit = null; try { // the first thing to do is determine what the deposit type is: @@ -321,7 +328,7 @@ boolean inProgress = this.getInProgress(req); String iri = this.getFullUrl(req); - Deposit deposit = new Deposit(); + deposit = new Deposit(); deposit.setInProgress(inProgress); DepositReceipt receipt; @@ -400,6 +407,11 @@ // need to throw a 403 Forbidden resp.sendError(403); } + finally + { + // get rid of any temp files used + this.cleanup(deposit); + } } public void delete(HttpServletRequest req, HttpServletResponse resp) Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-20 10:41:40 UTC (rev 497) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/MediaResourceAPI.java 2012-04-20 15:02:55 UTC (rev 498) @@ -156,10 +156,12 @@ } } + Deposit deposit = null; + try { String editMediaIRI = this.getFullUrl(req); - Deposit deposit = new Deposit(); + deposit = new Deposit(); // add the properties from the binary deposit this.addDepositPropertiesFromBinary(deposit, req); @@ -186,6 +188,11 @@ // need to throw a 403 Forbidden resp.sendError(403); } + finally + { + // get rid of any temp files used + this.cleanup(deposit); + } } public void post(HttpServletRequest req, HttpServletResponse resp) @@ -213,6 +220,7 @@ } } + Deposit deposit = null; try { // the first thing to do is determine what the deposit type is: @@ -220,7 +228,7 @@ boolean isMultipart = contentType.startsWith("multipart/related"); String uri = this.getFullUrl(req); - Deposit deposit = new Deposit(); + deposit = new Deposit(); if (isMultipart) { @@ -275,6 +283,11 @@ // need to throw a 403 Forbidden resp.sendError(403); } + finally + { + // get rid of any temp files used + this.cleanup(deposit); + } } public void delete(HttpServletRequest req, HttpServletResponse resp) Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-20 10:41:40 UTC (rev 497) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordAPIEndpoint.java 2012-04-20 15:02:55 UTC (rev 498) @@ -257,6 +257,22 @@ } } + protected void cleanup(Deposit deposit) + { + if (deposit == null) + { + return; + } + + File tmp = deposit.getFile(); + if (tmp == null) + { + return; + } + + tmp.delete(); + } + protected Element getGenerator(SwordConfiguration config) { String generatorUri = config.generator(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-04-20 10:41:51
|
Revision: 497 http://sword-app.svn.sourceforge.net/sword-app/?rev=497&view=rev Author: richard-jones Date: 2012-04-20 10:41:40 +0000 (Fri, 20 Apr 2012) Log Message: ----------- modify identity of artefact for ongoing use, and fix bug with multipart-related support in service documents Modified Paths: -------------- JavaServer2.0/trunk/pom.xml JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordCollection.java Modified: JavaServer2.0/trunk/pom.xml =================================================================== --- JavaServer2.0/trunk/pom.xml 2012-03-27 12:43:38 UTC (rev 496) +++ JavaServer2.0/trunk/pom.xml 2012-04-20 10:41:40 UTC (rev 497) @@ -3,8 +3,8 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.swordapp</groupId> - <artifactId>server</artifactId> - <version>2.1-SNAPSHOT</version> + <artifactId>sword2-server</artifactId> + <version>1.0</version> <packaging>war</packaging> <!-- brings the sonatype snapshot repository and signing requirement on board --> Modified: JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordCollection.java =================================================================== --- JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordCollection.java 2012-03-27 12:43:38 UTC (rev 496) +++ JavaServer2.0/trunk/src/main/java/org/swordapp/server/SwordCollection.java 2012-04-20 10:41:40 UTC (rev 497) @@ -56,7 +56,7 @@ for (String mpa : this.multipartAccept) { Element element = this.abdera.getFactory().newElement(UriRegistry.APP_ACCEPT); - element.setAttributeValue("alternate", "multipart/related"); + element.setAttributeValue("alternate", "multipart-related"); element.setText(mpa); abderaCollection.addExtension(element); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-27 12:43:45
|
Revision: 496 http://sword-app.svn.sourceforge.net/sword-app/?rev=496&view=rev Author: richard-jones Date: 2012-03-27 12:43:38 +0000 (Tue, 27 Mar 2012) Log Message: ----------- add enhancements to the object model to support scaleability, and a pylons implementation which uses the webob built-in file-like object for reading from the http stream Modified Paths: -------------- sss/branches/sss-2/sss/core.py sss/branches/sss-2/sss/pylons_sword_controller.py Modified: sss/branches/sss-2/sss/core.py =================================================================== --- sss/branches/sss-2/sss/core.py 2012-03-26 14:14:12 UTC (rev 495) +++ sss/branches/sss-2/sss/core.py 2012-03-27 12:43:38 UTC (rev 496) @@ -1,4 +1,4 @@ -import web, os, base64, uuid +import web, os, base64, uuid, StringIO from lxml import etree from datetime import datetime from spec import Namespaces, HttpHeaders, Errors @@ -650,7 +650,8 @@ # content related self.content_type = "application/octet-stream" - self.content = None + self._content = None + self._content_file = None self.atom = None self.entry_document = None self.filename = "unnamed.file" @@ -661,7 +662,32 @@ if self.atom is not None: self.entry_document = EntryDocument(xml_source=self.atom) return self.entry_document - + + def has_content(self): + return self._content is not None or self._content_file is not None + + @property + def content(self): + # FIXME: this is for back-compat only; use self.content_file + if self._content is not None: + return self._content + if self._content is None and self.content_file is not None: + return self.content_file.read() + + @content.setter + def content(self, content): + self._content = content + + @property + def content_file(self): + if self._content_file is None and self._content is not None: + self._content_file = StringIO.StringIO(self._content) + return self._content_file + + @content_file.setter + def content_file(self, fh): + self._content_file = fh + class DepositResponse(object): """ Class to represent the response to a deposit request Modified: sss/branches/sss-2/sss/pylons_sword_controller.py =================================================================== --- sss/branches/sss-2/sss/pylons_sword_controller.py 2012-03-26 14:14:12 UTC (rev 495) +++ sss/branches/sss-2/sss/pylons_sword_controller.py 2012-03-27 12:43:38 UTC (rev 496) @@ -164,6 +164,82 @@ is_empty = False #if len(webin) != 2: # if it is not multipart # FIXME: this is reading everything in, and should be re-evaluated for performance/scalability + # wsgi_input = request.environ['wsgi.input'] + f = request.body_file + f.seek(0, 0) + + # FIXME: can't we just look at the Content-Type header???? + + # read a byte in, to see if the body is empty + if f is not None: + byte = f.read(1) + if byte == "" and allow_empty: + ssslog.debug("first byte of deposit request is the empty string") + is_empty = True + else: + ssslog.debug("first byte of deposit request is \"" + str(byte) + "\" ... not an empty request") + f.seek(0, 0) + else: + is_empty = True + + # validate whether we allow an empty deposit + if is_empty and not allow_empty: + raise ValidationException("No content sent to the server") + elif is_empty and allow_empty: + ssslog.info("Validating an empty deposit (could be a control operation)") + + #else: + # ssslog.info("Validating a multipart deposit") + # is_multipart = True + + is_entry = False + content_type = mapped_headers.get("CONTENT-TYPE") + if content_type is not None and content_type.startswith("application/atom+xml"): + ssslog.info("Validating an atom-only deposit") + is_entry = True + + if not is_entry and not is_multipart and not is_empty: + ssslog.info("Validating a binary deposit") + + section = entry_section if is_entry else multipart_section if is_multipart else empty_section if is_empty else binary_section + + # now validate the http headers + h.validate(mapped_headers, section) + + except ValidationException as e: + raise SwordError(error_uri=Errors.bad_request, msg=e.message) + + ''' ORIGINAL NOT SCALEABLE IMPL + def validate_deposit_request(self, entry_section=None, binary_section=None, multipart_section=None, empty_section=None, allow_multipart=True, allow_empty=False): + h = HttpHeaders() + + # map the headers to standard http + mapped_headers = self._map_webpy_headers(request.environ) + ssslog.debug("Validating on header dictionary: " + str(mapped_headers)) + + # run the validation + try: + # there must be both an "atom" and "payload" input or data in web.data() + + # FIXME: deposit does NOT support multipart + if request.environ["CONTENT_TYPE"].startswith("multipart"): + raise SwordError(error_uri=Errors.method_not_allowed, msg="Pylons implementation does not currently support multipart/related requests") + """ + # leave this out until we can get multipart sorted (at a later date) + webin = request.POST + if len(webin) != 2 and len(webin) > 0: + raise ValidationException("Multipart request does not contain exactly 2 parts") + if len(webin) >= 2 and not webin.has_key("atom") and not webin.has_key("payload"): + raise ValidationException("Multipart request must contain Content-Dispositions with names 'atom' and 'payload'") + if len(webin) > 0 and not allow_multipart: + raise ValidationException("Multipart request not permitted in this context") + """ + + # if we get to here then we have a valid multipart or no multipart + is_multipart = False + is_empty = False + #if len(webin) != 2: # if it is not multipart + # FIXME: this is reading everything in, and should be re-evaluated for performance/scalability wsgi_input = request.environ['wsgi.input'] if hasattr(wsgi_input, "seek"): # in empty requests, the wsgi input object doesn't have a seek() method @@ -196,7 +272,85 @@ except ValidationException as e: raise SwordError(error_uri=Errors.bad_request, msg=e.message) + ''' + + def get_deposit(self, auth=None, atom_only=False): + # FIXME: this does not deal with the Media Part headers on a multipart deposit + """ + Take a request object and extract from it the parameters and content required for a SWORD deposit. This + includes determining whether this is an Atom Multipart request or not, and extracting the atom/payload where + appropriate. It also includes extracting the HTTP headers which are relevant to deposit, and for those not + supplied providing their defaults in the returned DepositRequest object + """ + d = DepositRequest() + + # map the webpy headers to something more standard + mapped_headers = self._map_webpy_headers(request.environ) + + # get the headers that have been provided. Any headers which have not been provided will + # will have default values applied + h = HttpHeaders() + d.set_from_headers(h.get_sword_headers(mapped_headers)) + + if d.content_type.startswith("application/atom+xml"): + atom_only=True + + empty_request = False + if d.content_length == 0: + ssslog.info("Received empty deposit request") + empty_request = True + if config.max_upload_size is not None and d.content_length > config.max_upload_size: + raise SwordError(error_uri=Errors.max_upload_size_exceeded, + msg="Max upload size is " + str(config.max_upload_size) + + "; incoming content length was " + str(d.content_length)) + + # FIXME: this method does NOT support multipart + # find out if this is a multipart or not + is_multipart = False + + # FIXME: these headers aren't populated yet, because the webpy api doesn't + # appear to have a mechanism to retrieve them. urgh. + #entry_part_headers = {} + #media_part_headers = {} + #webin = request.POST + #ssslog.debug(webin) + #if len(webin) == 2: + # ssslog.info("Received multipart deposit request") + # d.atom = webin['atom'] + # FIXME: this reads the payload into memory, we need to sort that out + # read the zip file from the base64 encoded string + # d.content = base64.decodestring(webin['payload']) + # is_multipart = True + #elif not empty_request: + if not empty_request: + # for this section, we have to reset the file pointer in the body_file + # part of the request back to the start, since it may have + # already been read once + f = request.body_file + f.seek(0, 0) + # if this wasn't a multipart, and isn't an empty request, then read the + # data from the body_file + if atom_only: + # we don't worry about scalability here - the entries should be + # generally small + ssslog.info("Received Entry deposit request") + d.atom = f.read() + else: + ssslog.info("Received Binary deposit request") + # FIXME: this is reading everything in, and should be re-evaluated for performance/scalability + d.content_file = f + + if is_multipart: + d.filename = h.extract_filename(media_part_headers) + else: + d.filename = h.extract_filename(mapped_headers) + + # now just attach the authentication data and return + d.auth = auth + return d + + ''' ORIGINAL NOT SCALEABLE IMPL def get_deposit(self, auth=None, atom_only=False): # FIXME: this reads files into memory, and therefore does not scale # FIXME: this does not deal with the Media Part headers on a multipart deposit @@ -272,7 +426,8 @@ # now just attach the authentication data and return d.auth = auth return d - + ''' + def get_delete(self, web, auth=None): """ Take a web.py web object and extract from it the parameters and content required for a SWORD delete request. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-26 14:14:23
|
Revision: 495 http://sword-app.svn.sourceforge.net/sword-app/?rev=495&view=rev Author: richard-jones Date: 2012-03-26 14:14:12 +0000 (Mon, 26 Mar 2012) Log Message: ----------- tag first major (0.9) release of the java client Added Paths: ----------- JavaClient2.0/tags/sword2-client-0.9/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-26 14:07:14
|
Revision: 494 http://sword-app.svn.sourceforge.net/sword-app/?rev=494&view=rev Author: richard-jones Date: 2012-03-26 14:07:03 +0000 (Mon, 26 Mar 2012) Log Message: ----------- add readme and update pom file with version and project name Modified Paths: -------------- JavaClient2.0/trunk/pom.xml Added Paths: ----------- JavaClient2.0/trunk/README Added: JavaClient2.0/trunk/README =================================================================== --- JavaClient2.0/trunk/README (rev 0) +++ JavaClient2.0/trunk/README 2012-03-26 14:07:03 UTC (rev 494) @@ -0,0 +1,88 @@ +SWORD 2.0 Client +================ + +This client library is an implementation of the SWORD 2.0 standard defined here + +http://swordapp.org/sword-v2/sword-v2-specifications/ + + +Build +----- + +To build this library use maven 2: + + mvn clean package + +In the root directory will build the software + + +Usage +----- + +The main point of entry for client operations is org.swordapp.client.SWORDClient + +To perform deposits, create instances of org.swordapp.client.Deposit and pass it to the SWORDClient's methods. + +To authenticate, create instances of org.swordapp.client.AuthCredentials and pass them in with the Deposit object to the SWORDClient. + + +For example: + + SWORDClient client = new SWORDClient() + +Obtain a service document: + + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass)); + +Get the first collection from the first workspace in the service document: + + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); + +Create a binary file only Deposit object: + + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(myFile)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(fileMD5); + deposit.setInProgress(true); + deposit.setSuggestedIdentifier("abcdefg"); + +Pass the deposit object to the client: + + DepositReceipt receipt = client.deposit(col, deposit, auth) + +We can create entry-only depsits too: + + EntryPart ep = new EntryPart(); + ep.addDublinCore("title", "My Title"); + + Deposit deposit = new Deposit(); + deposit.setEntryPart(ep); + +For some deposit operations we get back a DepositReceipt object, from which we can get all the details we might want about the item: + + receipt.getStatusCode(); + receipt.getLocation(); + receipt.getDerivedResourceLinks(); + receipt.getOriginalDepositLink(); + receipt.getEditMediaLink(); + receipt.getAtomStatementLink(); + receipt.getContentLink(); + receipt.getEditLink(); + receipt.getOREStatementLink(); + receipt.getPackaging(); + receipt.getSplashPageLink(); + receipt.getStatementLink("application/rdf+xml"); + receipt.getStatementLink("application/atom+xml;type=feed"); + receipt.getSwordEditLink(); + receipt.getTreatment(); + receipt.getVerboseDescription(); + + +Limitations +----------- + +Currently the client DOES NOT support multipart deposit. Therefore the specification sections 6.3.2, 6.5.3, and 6.7.3 are not supported yet. + Modified: JavaClient2.0/trunk/pom.xml =================================================================== --- JavaClient2.0/trunk/pom.xml 2012-03-26 13:32:42 UTC (rev 493) +++ JavaClient2.0/trunk/pom.xml 2012-03-26 14:07:03 UTC (rev 494) @@ -4,8 +4,8 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.swordapp</groupId> - <artifactId>sword-client</artifactId> - <version>2.0</version> + <artifactId>sword2-client</artifactId> + <version>0.9</version> <build> <plugins> @@ -86,4 +86,4 @@ <version>1.6.1</version> </dependency> </dependencies> -</project> \ No newline at end of file +</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-26 13:32:51
|
Revision: 493 http://sword-app.svn.sourceforge.net/sword-app/?rev=493&view=rev Author: richard-jones Date: 2012-03-26 13:32:42 +0000 (Mon, 26 Mar 2012) Log Message: ----------- remove dev environment specific file Removed Paths: ------------- JavaClient2.0/trunk/sword-client.iml Deleted: JavaClient2.0/trunk/sword-client.iml =================================================================== --- JavaClient2.0/trunk/sword-client.iml 2012-03-26 13:22:32 UTC (rev 492) +++ JavaClient2.0/trunk/sword-client.iml 2012-03-26 13:32:42 UTC (rev 493) @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="false"> - <output url="file://$MODULE_DIR$/target/classes" /> - <output-test url="file://$MODULE_DIR$/target/test-classes" /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-annotations" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" /> - <excludeFolder url="file://$MODULE_DIR$/target/classes" /> - <excludeFolder url="file://$MODULE_DIR$/target/test-classes" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" /> - <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" /> - <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" /> - <orderEntry type="library" name="Maven: log4j:log4j:1.2.15" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-client:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-core:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-i18n:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.0.2_spec:1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-parser:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-impl:1.2.10" level="project" /> - <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-api:1.2.10" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.6" level="project" /> - <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.codehaus.woodstox:wstx-asl:3.0.0" level="project" /> - <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.3.03" level="project" /> - <orderEntry type="library" name="Maven: xerces:xercesImpl:2.8.0" level="project" /> - <orderEntry type="library" name="Maven: org.dspace:foresite:0.9" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:jena:2.5.5" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:arq:2.2" level="project" /> - <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:2.2.0" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:arq-extra:2.2" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:jenatest:2.5.5" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:iri:0.5" level="project" /> - <orderEntry type="library" name="Maven: com.ibm.icu:icu4j:3.4.4" level="project" /> - <orderEntry type="library" name="Maven: antlr:antlr:2.7.5" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:concurrent-jena:1.3.2" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:json-jena:1.0" level="project" /> - <orderEntry type="library" name="Maven: stax:stax-api:1.0" level="project" /> - <orderEntry type="library" name="Maven: xerces:xmlParserAPIs:2.0.2" level="project" /> - <orderEntry type="library" name="Maven: rome:rome:0.9" level="project" /> - <orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" /> - <orderEntry type="library" name="Maven: xalan:xalan:2.7.0" level="project" /> - <orderEntry type="library" name="Maven: commons-cli:commons-cli:1.0" level="project" /> - <orderEntry type="library" name="Maven: commons-lang:commons-lang:1.0" level="project" /> - <orderEntry type="library" name="Maven: junit:junit:4.4" level="project" /> - <orderEntry type="library" name="Maven: joda-time:joda-time:1.6" level="project" /> - <orderEntry type="library" name="Maven: xom:xom:1.2.5" level="project" /> - <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.4" level="project" /> - <orderEntry type="library" name="Maven: org.jsoup:jsoup:1.6.1" level="project" /> - </component> -</module> - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-26 13:22:42
|
Revision: 492 http://sword-app.svn.sourceforge.net/sword-app/?rev=492&view=rev Author: richard-jones Date: 2012-03-26 13:22:32 +0000 (Mon, 26 Mar 2012) Log Message: ----------- move main code into trunk directory Added Paths: ----------- JavaClient2.0/trunk/TODO JavaClient2.0/trunk/pom.xml JavaClient2.0/trunk/src/ JavaClient2.0/trunk/sword-client.iml Removed Paths: ------------- JavaClient2.0/TODO JavaClient2.0/pom.xml JavaClient2.0/src/ JavaClient2.0/sword-client.iml Deleted: JavaClient2.0/TODO =================================================================== --- JavaClient2.0/TODO 2012-03-26 13:01:45 UTC (rev 491) +++ JavaClient2.0/TODO 2012-03-26 13:22:32 UTC (rev 492) @@ -1,24 +0,0 @@ -TODO List -========= - -This is a register of some things that still need to be adequately handled in this code library - -1/ Multipart does not work. - -This occurs when a 401 Unauthorised challenge is received. In making the initial request, the library -reads all of the data from the input stream to be delivered, and therefore cannot re-deliver it once -authentication has taken place. - - -Notes ------ - -- Create mechanism for handling arbitrary response codes (might act on response codes that we understand, like -302, etc); possible value in a response code handler with default behaviour that can be customised per-request - -- documentation - -- logging - -- modify foresite to allow namespace prefixes to be passed in - Deleted: JavaClient2.0/pom.xml =================================================================== --- JavaClient2.0/pom.xml 2012-03-26 13:01:45 UTC (rev 491) +++ JavaClient2.0/pom.xml 2012-03-26 13:22:32 UTC (rev 492) @@ -1,89 +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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>org.swordapp</groupId> - <artifactId>sword-client</artifactId> - <version>2.0</version> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>2.3.2</version> - <configuration> - <source>6</source> - <target>6</target> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - <version>3.1</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.15</version> - <exclusions> - <exclusion> - <groupId>javax.mail</groupId> - <artifactId>mail</artifactId> - </exclusion> - <exclusion> - <groupId>javax.jms</groupId> - <artifactId>jms</artifactId> - </exclusion> - <exclusion> - <groupId>com.sun.jdmk</groupId> - <artifactId>jmxtools</artifactId> - </exclusion> - <exclusion> - <groupId>com.sun.jmx</groupId> - <artifactId>jmxri</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.abdera</groupId> - <artifactId>abdera-client</artifactId> - <version>1.1.1</version> - </dependency> - <dependency> - <groupId>org.dspace</groupId> - <artifactId>foresite</artifactId> - <version>0.9</version> - </dependency> - <dependency> - <groupId>xom</groupId> - <artifactId>xom</artifactId> - <version>1.2.5</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.4</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.4</version> - </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>1.4</version> - </dependency> - <dependency> - <groupId>org.jsoup</groupId> - <artifactId>jsoup</artifactId> - <version>1.6.1</version> - </dependency> - </dependencies> -</project> \ No newline at end of file Deleted: JavaClient2.0/sword-client.iml =================================================================== --- JavaClient2.0/sword-client.iml 2012-03-26 13:01:45 UTC (rev 491) +++ JavaClient2.0/sword-client.iml 2012-03-26 13:22:32 UTC (rev 492) @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="false"> - <output url="file://$MODULE_DIR$/target/classes" /> - <output-test url="file://$MODULE_DIR$/target/test-classes" /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-annotations" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> - <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" /> - <excludeFolder url="file://$MODULE_DIR$/target/classes" /> - <excludeFolder url="file://$MODULE_DIR$/target/test-classes" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" /> - <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" /> - <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" /> - <orderEntry type="library" name="Maven: log4j:log4j:1.2.15" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-client:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-core:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-i18n:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.0.2_spec:1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.abdera:abdera-parser:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-impl:1.2.10" level="project" /> - <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-api:1.2.10" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" /> - <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.6" level="project" /> - <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.1" level="project" /> - <orderEntry type="library" name="Maven: org.codehaus.woodstox:wstx-asl:3.0.0" level="project" /> - <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.3.03" level="project" /> - <orderEntry type="library" name="Maven: xerces:xercesImpl:2.8.0" level="project" /> - <orderEntry type="library" name="Maven: org.dspace:foresite:0.9" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:jena:2.5.5" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:arq:2.2" level="project" /> - <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:2.2.0" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:arq-extra:2.2" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:jenatest:2.5.5" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:iri:0.5" level="project" /> - <orderEntry type="library" name="Maven: com.ibm.icu:icu4j:3.4.4" level="project" /> - <orderEntry type="library" name="Maven: antlr:antlr:2.7.5" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:concurrent-jena:1.3.2" level="project" /> - <orderEntry type="library" name="Maven: com.hp.hpl.jena:json-jena:1.0" level="project" /> - <orderEntry type="library" name="Maven: stax:stax-api:1.0" level="project" /> - <orderEntry type="library" name="Maven: xerces:xmlParserAPIs:2.0.2" level="project" /> - <orderEntry type="library" name="Maven: rome:rome:0.9" level="project" /> - <orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" /> - <orderEntry type="library" name="Maven: xalan:xalan:2.7.0" level="project" /> - <orderEntry type="library" name="Maven: commons-cli:commons-cli:1.0" level="project" /> - <orderEntry type="library" name="Maven: commons-lang:commons-lang:1.0" level="project" /> - <orderEntry type="library" name="Maven: junit:junit:4.4" level="project" /> - <orderEntry type="library" name="Maven: joda-time:joda-time:1.6" level="project" /> - <orderEntry type="library" name="Maven: xom:xom:1.2.5" level="project" /> - <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.4" level="project" /> - <orderEntry type="library" name="Maven: org.jsoup:jsoup:1.6.1" level="project" /> - </component> -</module> - Copied: JavaClient2.0/trunk/TODO (from rev 491, JavaClient2.0/TODO) =================================================================== --- JavaClient2.0/trunk/TODO (rev 0) +++ JavaClient2.0/trunk/TODO 2012-03-26 13:22:32 UTC (rev 492) @@ -0,0 +1,24 @@ +TODO List +========= + +This is a register of some things that still need to be adequately handled in this code library + +1/ Multipart does not work. + +This occurs when a 401 Unauthorised challenge is received. In making the initial request, the library +reads all of the data from the input stream to be delivered, and therefore cannot re-deliver it once +authentication has taken place. + + +Notes +----- + +- Create mechanism for handling arbitrary response codes (might act on response codes that we understand, like +302, etc); possible value in a response code handler with default behaviour that can be customised per-request + +- documentation + +- logging + +- modify foresite to allow namespace prefixes to be passed in + Copied: JavaClient2.0/trunk/pom.xml (from rev 491, JavaClient2.0/pom.xml) =================================================================== --- JavaClient2.0/trunk/pom.xml (rev 0) +++ JavaClient2.0/trunk/pom.xml 2012-03-26 13:22:32 UTC (rev 492) @@ -0,0 +1,89 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.swordapp</groupId> + <artifactId>sword-client</artifactId> + <version>2.0</version> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>6</source> + <target>6</target> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.15</version> + <exclusions> + <exclusion> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </exclusion> + <exclusion> + <groupId>javax.jms</groupId> + <artifactId>jms</artifactId> + </exclusion> + <exclusion> + <groupId>com.sun.jdmk</groupId> + <artifactId>jmxtools</artifactId> + </exclusion> + <exclusion> + <groupId>com.sun.jmx</groupId> + <artifactId>jmxri</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.abdera</groupId> + <artifactId>abdera-client</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>org.dspace</groupId> + <artifactId>foresite</artifactId> + <version>0.9</version> + </dependency> + <dependency> + <groupId>xom</groupId> + <artifactId>xom</artifactId> + <version>1.2.5</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.4</version> + </dependency> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.4</version> + </dependency> + <dependency> + <groupId>org.jsoup</groupId> + <artifactId>jsoup</artifactId> + <version>1.6.1</version> + </dependency> + </dependencies> +</project> \ No newline at end of file Copied: JavaClient2.0/trunk/sword-client.iml (from rev 491, JavaClient2.0/sword-client.iml) =================================================================== --- JavaClient2.0/trunk/sword-client.iml (rev 0) +++ JavaClient2.0/trunk/sword-client.iml 2012-03-26 13:22:32 UTC (rev 492) @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-annotations" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" /> + <excludeFolder url="file://$MODULE_DIR$/target/classes" /> + <excludeFolder url="file://$MODULE_DIR$/target/test-classes" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" /> + <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.4" level="project" /> + <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" /> + <orderEntry type="library" name="Maven: log4j:log4j:1.2.15" level="project" /> + <orderEntry type="library" name="Maven: org.apache.abdera:abdera-client:1.1.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.abdera:abdera-core:1.1.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.abdera:abdera-i18n:1.1.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.0.2_spec:1.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.abdera:abdera-parser:1.1.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-impl:1.2.10" level="project" /> + <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-api:1.2.10" level="project" /> + <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" /> + <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.6" level="project" /> + <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.1" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.woodstox:wstx-asl:3.0.0" level="project" /> + <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.3.03" level="project" /> + <orderEntry type="library" name="Maven: xerces:xercesImpl:2.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.dspace:foresite:0.9" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:jena:2.5.5" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:arq:2.2" level="project" /> + <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:arq-extra:2.2" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:jenatest:2.5.5" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:iri:0.5" level="project" /> + <orderEntry type="library" name="Maven: com.ibm.icu:icu4j:3.4.4" level="project" /> + <orderEntry type="library" name="Maven: antlr:antlr:2.7.5" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:concurrent-jena:1.3.2" level="project" /> + <orderEntry type="library" name="Maven: com.hp.hpl.jena:json-jena:1.0" level="project" /> + <orderEntry type="library" name="Maven: stax:stax-api:1.0" level="project" /> + <orderEntry type="library" name="Maven: xerces:xmlParserAPIs:2.0.2" level="project" /> + <orderEntry type="library" name="Maven: rome:rome:0.9" level="project" /> + <orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" /> + <orderEntry type="library" name="Maven: xalan:xalan:2.7.0" level="project" /> + <orderEntry type="library" name="Maven: commons-cli:commons-cli:1.0" level="project" /> + <orderEntry type="library" name="Maven: commons-lang:commons-lang:1.0" level="project" /> + <orderEntry type="library" name="Maven: junit:junit:4.4" level="project" /> + <orderEntry type="library" name="Maven: joda-time:joda-time:1.6" level="project" /> + <orderEntry type="library" name="Maven: xom:xom:1.2.5" level="project" /> + <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.4" level="project" /> + <orderEntry type="library" name="Maven: org.jsoup:jsoup:1.6.1" level="project" /> + </component> +</module> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-26 13:01:54
|
Revision: 491 http://sword-app.svn.sourceforge.net/sword-app/?rev=491&view=rev Author: richard-jones Date: 2012-03-26 13:01:45 +0000 (Mon, 26 Mar 2012) Log Message: ----------- add directory structure for proper branches/tags/trunk layout Added Paths: ----------- JavaClient2.0/branches/ JavaClient2.0/tags/ JavaClient2.0/trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-25 17:41:37
|
Revision: 490 http://sword-app.svn.sourceforge.net/sword-app/?rev=490&view=rev Author: richard-jones Date: 2012-03-25 17:41:23 +0000 (Sun, 25 Mar 2012) Log Message: ----------- add content type to demo web interface, and correct content type of declared available statements in web ui Modified Paths: -------------- sss/branches/sss-2/sss/repository.py sss/branches/sss-2/sss/webpy.py Modified: sss/branches/sss-2/sss/repository.py =================================================================== --- sss/branches/sss-2/sss/repository.py 2012-03-25 17:40:48 UTC (rev 489) +++ sss/branches/sss-2/sss/repository.py 2012-03-25 17:41:23 UTC (rev 490) @@ -1251,7 +1251,7 @@ frag += self._layout_sections(md_frag, file_frag) head_frag = "<link rel=\"http://purl.org/net/sword/terms/edit\" href=\"" + self.um.edit_uri(collection, id) + "\"/>" - head_frag += "<link rel=\"http://purl.org/net/sword/terms/statement\" type=\"application/atom+xml\" href=\"" + self.um.state_uri(collection, id, "atom") + "\"/>" + head_frag += "<link rel=\"http://purl.org/net/sword/terms/statement\" type=\"application/atom+xml;type=feed\" href=\"" + self.um.state_uri(collection, id, "atom") + "\"/>" head_frag += "<link rel=\"http://purl.org/net/sword/terms/statement\" type=\"application/rdf+xml\" href=\"" + self.um.state_uri(collection, id, "ore") + "\"/>" return self._wrap_html("Item: " + id, frag, head_frag) Modified: sss/branches/sss-2/sss/webpy.py =================================================================== --- sss/branches/sss-2/sss/webpy.py 2012-03-25 17:40:48 UTC (rev 489) +++ sss/branches/sss-2/sss/webpy.py 2012-03-25 17:41:23 UTC (rev 490) @@ -957,6 +957,7 @@ """ def GET(self, path=None): w = WebInterface(config) + web.header("Content-Type", "text/html") return w.get(path) class Part(SwordHttpHandler): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-25 17:40:58
|
Revision: 489 http://sword-app.svn.sourceforge.net/sword-app/?rev=489&view=rev Author: richard-jones Date: 2012-03-25 17:40:48 +0000 (Sun, 25 Mar 2012) Log Message: ----------- add auto-discovery service to client, and associated tests Modified Paths: -------------- JavaClient2.0/pom.xml JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java JavaClient2.0/src/main/java/org/swordapp/client/UriRegistry.java JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java JavaClient2.0/sword-client.iml Added Paths: ----------- JavaClient2.0/src/main/java/org/swordapp/client/Endpoints.java Modified: JavaClient2.0/pom.xml =================================================================== --- JavaClient2.0/pom.xml 2012-03-25 16:17:58 UTC (rev 488) +++ JavaClient2.0/pom.xml 2012-03-25 17:40:48 UTC (rev 489) @@ -80,5 +80,10 @@ <artifactId>commons-codec</artifactId> <version>1.4</version> </dependency> + <dependency> + <groupId>org.jsoup</groupId> + <artifactId>jsoup</artifactId> + <version>1.6.1</version> + </dependency> </dependencies> </project> \ No newline at end of file Added: JavaClient2.0/src/main/java/org/swordapp/client/Endpoints.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/Endpoints.java (rev 0) +++ JavaClient2.0/src/main/java/org/swordapp/client/Endpoints.java 2012-03-25 17:40:48 UTC (rev 489) @@ -0,0 +1,71 @@ +package org.swordapp.client; + +import java.util.HashMap; +import java.util.Map; + +public class Endpoints +{ + private String serviceDocument = null; + private String collection = null; + private String edit = null; + private Map<String, String> statements = new HashMap<String, String>(); + + public Endpoints() {} + + public Endpoints(String serviceDocument, String collection, String edit, Map<String, String> statements) + { + this.serviceDocument = serviceDocument; + this.collection = collection; + this.edit = edit; + this.statements = statements; + } + + public String getServiceDocument() + { + return serviceDocument; + } + + public void setServiceDocument(String serviceDocument) + { + this.serviceDocument = serviceDocument; + } + + public String getCollection() + { + return collection; + } + + public void setCollection(String collection) + { + this.collection = collection; + } + + public String getEdit() + { + return edit; + } + + public void setEdit(String edit) + { + this.edit = edit; + } + + public Map<String, String> getStatements() + { + if (statements.size() == 0) + { + return null; + } + return statements; + } + + public void setStatements(Map<String, String> statements) + { + this.statements = statements; + } + + public void addStatement(String url, String type) + { + this.statements.put(url, type); + } +} Modified: JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-25 16:17:58 UTC (rev 488) +++ JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-25 17:40:48 UTC (rev 489) @@ -1,26 +1,24 @@ package org.swordapp.client; import org.apache.abdera.Abdera; -import org.apache.abdera.i18n.iri.IRI; import org.apache.abdera.model.Document; -import org.apache.abdera.model.Element; import org.apache.abdera.model.Entry; import org.apache.abdera.model.Feed; -import org.apache.abdera.model.Link; import org.apache.abdera.model.Service; import org.apache.abdera.parser.ParseException; import org.apache.abdera.protocol.Response; import org.apache.abdera.protocol.client.AbderaClient; import org.apache.abdera.protocol.client.ClientResponse; import org.apache.abdera.protocol.client.RequestOptions; -import org.apache.abdera.protocol.client.util.MultipartRelatedRequestEntity; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.methods.InputStreamRequestEntity; import org.apache.log4j.Logger; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; import javax.activation.MimeType; import javax.activation.MimeTypeParseException; -import java.awt.print.PrinterException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -47,6 +45,51 @@ this.abdera = new Abdera(); } + public Endpoints autoDiscover(String url) + throws SWORDClientException + { + try + { + org.jsoup.nodes.Document doc = Jsoup.connect(url).get(); + Elements links = doc.select("link[rel]"); + Endpoints endpoints = new Endpoints(); + + for (int i = 0; i < links.size(); i++) + { + Element element = links.get(i); + String rel = element.attr("rel"); + if (rel == null) + { + continue; + } + rel = rel.toLowerCase(); + + if (rel.equals("sword") || rel.equals(UriRegistry.REL_SERVICE_DOCUMENT)) + { + endpoints.setServiceDocument(element.attr("href")); + } + else if (rel.equals(UriRegistry.REL_DEPOSIT)) + { + endpoints.setCollection(element.attr("href")); + } + else if (rel.equals(UriRegistry.REL_EDIT)) + { + endpoints.setEdit(element.attr("href")); + } + else if (rel.equals(UriRegistry.REL_STATEMENT)) + { + endpoints.addStatement(element.attr("href"), element.attr("type")); + } + } + + return endpoints; + } + catch (IOException e) + { + throw new SWORDClientException(e); + } + } + public ServiceDocument getServiceDocument(String sdURL) throws SWORDClientException, ProtocolViolationException { Modified: JavaClient2.0/src/main/java/org/swordapp/client/UriRegistry.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/UriRegistry.java 2012-03-25 16:17:58 UTC (rev 488) +++ JavaClient2.0/src/main/java/org/swordapp/client/UriRegistry.java 2012-03-25 17:40:48 UTC (rev 489) @@ -28,6 +28,9 @@ public static SQName SWORD_STATE_DESCRIPTION = new SQName(SWORD_TERMS_NAMESPACE, "stateDescription"); // rel values + public static String REL_SERVICE_DOCUMENT = "http://purl.org/net/sword/discovery/service-document"; + public static String REL_DEPOSIT = SWORD_TERMS_NAMESPACE + "deposit"; + public static String REL_EDIT = SWORD_TERMS_NAMESPACE + "edit"; public static String REL_STATEMENT = SWORD_TERMS_NAMESPACE + "statement"; public static String REL_SWORD_EDIT = SWORD_TERMS_NAMESPACE + "add"; public static String REL_ORIGINAL_DEPOSIT = SWORD_TERMS_NAMESPACE + "originalDeposit"; Modified: JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java =================================================================== --- JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-25 16:17:58 UTC (rev 488) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-25 17:40:48 UTC (rev 489) @@ -9,6 +9,7 @@ import org.swordapp.client.ClientConfiguration; import org.swordapp.client.Deposit; import org.swordapp.client.DepositReceipt; +import org.swordapp.client.Endpoints; import org.swordapp.client.EntryPart; import org.swordapp.client.OreStatement; import org.swordapp.client.ResourceState; @@ -24,8 +25,10 @@ import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; +import java.util.Map; import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * This class uses explicit knowledge of the SSS test server configuration @@ -37,6 +40,9 @@ */ public class SSSSemiUnits { + private String homePage = null; + private String depositPage = null; + private String resourcePage = null; private String sdIRI = null; private String user = null; private String pass = null; @@ -48,6 +54,9 @@ public void setUp() throws Exception { + this.homePage = "http://localhost:8080/"; + this.depositPage = "http://localhost:8080/html/ded3c328-d8f0-4307-8b86-086cf46a953c"; + this.resourcePage = "http://localhost:8080/html/ded3c328-d8f0-4307-8b86-086cf46a953c/f2966e10-c6a0-40ab-90ad-6fc90d5b8bd3"; this.sdIRI = "http://localhost:8080/sd-uri"; this.user = "sword"; this.pass = "sword"; @@ -308,4 +317,49 @@ } assertTrue(checked); } + + @Test + public void autoDiscoverService() + throws Exception + { + SWORDClient client = new SWORDClient(new ClientConfiguration()); + Endpoints endpoints = client.autoDiscover(this.homePage); + + assertEquals(endpoints.getServiceDocument(), this.sdIRI); + assertNull(endpoints.getCollection()); + assertNull(endpoints.getEdit()); + assertNull(endpoints.getStatements()); + + endpoints = client.autoDiscover(this.depositPage); + + assertNull(endpoints.getServiceDocument()); + assertEquals(endpoints.getCollection(), "http://localhost:8080/col-uri/ded3c328-d8f0-4307-8b86-086cf46a953c"); + assertNull(endpoints.getEdit()); + assertNull(endpoints.getStatements()); + + endpoints = client.autoDiscover(this.resourcePage); + + assertNull(endpoints.getServiceDocument()); + assertNull(endpoints.getCollection()); + assertEquals(endpoints.getEdit(), "http://localhost:8080/edit-uri/ded3c328-d8f0-4307-8b86-086cf46a953c/f2966e10-c6a0-40ab-90ad-6fc90d5b8bd3"); + + Map<String, String> statements = endpoints.getStatements(); + int count = 0; + for (String url : statements.keySet()) + { + String type = statements.get(url); + + if (type.equals("application/atom+xml") || type.equals("application/atom+xml;type=feed")) + { + assertEquals(url, "http://localhost:8080/state-uri/ded3c328-d8f0-4307-8b86-086cf46a953c/f2966e10-c6a0-40ab-90ad-6fc90d5b8bd3.atom"); + count++; + } + else if (type.equals("application/rdf+xml")) + { + assertEquals(url, "http://localhost:8080/state-uri/ded3c328-d8f0-4307-8b86-086cf46a953c/f2966e10-c6a0-40ab-90ad-6fc90d5b8bd3.rdf"); + count++; + } + } + assertEquals(count, 2); + } } Modified: JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java =================================================================== --- JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-25 16:17:58 UTC (rev 488) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-25 17:40:48 UTC (rev 489) @@ -12,6 +12,7 @@ import org.swordapp.client.Content; import org.swordapp.client.Deposit; import org.swordapp.client.DepositReceipt; +import org.swordapp.client.Endpoints; import org.swordapp.client.EntryPart; import org.swordapp.client.OreStatement; import org.swordapp.client.SWORDClient; @@ -25,7 +26,12 @@ import java.io.FileInputStream; import java.util.List; +import java.util.Map; +// FIXME: these tests rely on a hard-coded set of fixtures to do with my local +// set up. This means anyone else trying to run these tests will need to reconfigure +// and recompile. Sorry. + public class SpecTests { private String sdIRI = null; Modified: JavaClient2.0/sword-client.iml =================================================================== --- JavaClient2.0/sword-client.iml 2012-03-25 16:17:58 UTC (rev 488) +++ JavaClient2.0/sword-client.iml 2012-03-25 17:40:48 UTC (rev 489) @@ -54,6 +54,7 @@ <orderEntry type="library" name="Maven: joda-time:joda-time:1.6" level="project" /> <orderEntry type="library" name="Maven: xom:xom:1.2.5" level="project" /> <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.4" level="project" /> + <orderEntry type="library" name="Maven: org.jsoup:jsoup:1.6.1" level="project" /> </component> </module> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-25 16:18:09
|
Revision: 488 http://sword-app.svn.sourceforge.net/sword-app/?rev=488&view=rev Author: richard-jones Date: 2012-03-25 16:17:58 +0000 (Sun, 25 Mar 2012) Log Message: ----------- add error handling tests where possible Modified Paths: -------------- JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java Modified: JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java =================================================================== --- JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-25 15:57:48 UTC (rev 487) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-25 16:17:58 UTC (rev 488) @@ -1017,79 +1017,201 @@ assertEquals(newReceipt.getStatusCode(), 200); } - /* Python tests to mimic + @Test + public void errorChecksumMismatch() + throws Exception + { + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); - def test_35_error_checksum_mismatch(self): - conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, - error_response_raises_exceptions=False) - conn.get_service_document() - col = conn.sd.workspaces[0][1][0] - with open(PACKAGE) as pkg: - receipt = conn.create(col_iri = col.href, - payload=pkg, - mimetype=PACKAGE_MIME, - filename="example.zip", - packaging = 'http://purl.org/net/sword/package/SimpleZip', - in_progress = True, - suggested_identifier = "zyxwvutsrq", - md5sum="123456789") + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5("123456789"); // this is not correct + deposit.setInProgress(true); - assert receipt.code == 412 - assert isinstance(receipt, Error_Document) - assert receipt.error_href == "http://purl.org/net/sword/error/ErrorChecksumMismatch" + try + { + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, this.obo)); + assertTrue(false); + } + catch (SWORDError e) + { + assertEquals(e.getStatus(), 412); + assertEquals(e.getErrorURI(), "http://purl.org/net/sword/error/ErrorChecksumMismatch"); + } + } - def test_36_error_bad_request(self): - conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, - error_response_raises_exceptions=False) - conn.get_service_document() - col = conn.sd.workspaces[0][1][0] - with open(PACKAGE) as pkg: - receipt = conn.create(col_iri = col.href, - payload=pkg, - mimetype=PACKAGE_MIME, - filename="example.zip", - packaging = 'http://purl.org/net/sword/package/SimpleZip', - in_progress = "Invalid", # the API seems to allow this! - suggested_identifier = "zyxwvutsrq") + @Test + public void errorBadRequest() + throws Exception + { + // FIXME: it is highly non-trivial to make a bad request with the client library + // How can we do this? - assert receipt.code == 400 - assert isinstance(receipt, Error_Document) - assert receipt.error_href == "http://purl.org/net/sword/error/ErrorBadRequest" + /* + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); - def test_37_error_target_owner_unknown(self): - conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, - error_response_raises_exceptions=False) - conn.get_service_document() - col = conn.sd.workspaces[0][1][0] - with open(PACKAGE) as pkg: - receipt = conn.create(col_iri = col.href, - payload=pkg, - mimetype=PACKAGE_MIME, - filename="example.zip", - packaging = 'http://purl.org/net/sword/package/SimpleZip', - in_progress = True, - suggested_identifier = "zyxwvutsrq", - on_behalf_of="richard") # we expressly set the wrong obo on the request rather than the connection + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(this.fileMd5); + deposit.setInProgress(true); - assert receipt.code == 403 - assert isinstance(receipt, Error_Document) - assert receipt.error_href == "http://purl.org/net/sword/error/TargetOwnerUnknown" + try + { + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, this.obo)); + assertTrue(false); + } + catch (SWORDError e) + { + assertEquals(e.getStatus(), 400); + assertEquals(e.getErrorURI(), "http://purl.org/net/sword/error/ErrorBadRequest"); + } + */ + } - def test_38_error_mediation_not_allowed(self): - # this is a placeholder; it's not possible to reliably test for this - pass + @Test + public void errorTargetOwnerUnknown() + throws Exception + { + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); - def test_39_error_method_not_allowed(self): - # this is a placeholder; it's not possible to reliably test for this - pass + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(this.fileMd5); + deposit.setInProgress(true); - def test_40_error_max_upload_size_exceeded(self): - # this is a placeholder; it's not possible to reliably test for this - pass + try + { + // using an invalid OBO user + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, "richard")); + assertTrue(false); + } + catch (SWORDError e) + { + assertEquals(e.getStatus(), 403); + assertEquals(e.getErrorURI(), "http://purl.org/net/sword/error/TargetOwnerUnknown"); + } + } - def test_41_get_service_document_unauthorised(self): - conn = Connection(SSS_URL, user_name="alsdkfjsdz", user_pass="ZAKJKLASJDF") - conn.get_service_document() - assert conn.sd is None - */ + @Test + public void errorMediatonNotAllowed() + throws Exception + { + // FIXME: not possible to reliably test for this + + /* + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); + + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(this.fileMd5); + deposit.setInProgress(true); + + try + { + // using an invalid OBO user + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, "richard")); + assertTrue(false); + } + catch (SWORDError e) + { + assertEquals(e.getStatus(), 403); + assertEquals(e.getErrorURI(), "http://purl.org/net/sword/error/TargetOwnerUnknown"); + } + */ + } + + @Test + public void errorMethodNotAllowed() + throws Exception + { + // FIXME: not possible to reliably test for this + + /* + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); + + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(this.fileMd5); + deposit.setInProgress(true); + + try + { + // using an invalid OBO user + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, "richard")); + assertTrue(false); + } + catch (SWORDError e) + { + assertEquals(e.getStatus(), 403); + assertEquals(e.getErrorURI(), "http://purl.org/net/sword/error/TargetOwnerUnknown"); + } + */ + } + + @Test + public void errorMaxUploadSizeExceeded() + throws Exception + { + // FIXME: not possible to reliably test for this + + /* + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); + + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(this.fileMd5); + deposit.setInProgress(true); + + try + { + // using an invalid OBO user + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, "richard")); + assertTrue(false); + } + catch (SWORDError e) + { + assertEquals(e.getStatus(), 403); + assertEquals(e.getErrorURI(), "http://purl.org/net/sword/error/TargetOwnerUnknown"); + } + */ + } + + @Test + public void getServiceDocumentUnauthorised() + throws Exception + { + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials("adfasf", "awerwevwe")); + assertNull(sd); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-25 15:57:54
|
Revision: 487 http://sword-app.svn.sourceforge.net/sword-app/?rev=487&view=rev Author: richard-jones Date: 2012-03-25 15:57:48 +0000 (Sun, 25 Mar 2012) Log Message: ----------- add enhancements to statement tests Modified Paths: -------------- JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java Modified: JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java =================================================================== --- JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-25 15:48:21 UTC (rev 486) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-25 15:57:48 UTC (rev 487) @@ -11,6 +11,7 @@ import org.swordapp.client.DepositReceipt; import org.swordapp.client.EntryPart; import org.swordapp.client.OreStatement; +import org.swordapp.client.ResourceState; import org.swordapp.client.SWORDClient; import org.swordapp.client.SWORDCollection; import org.swordapp.client.SWORDWorkspace; @@ -237,11 +238,23 @@ boolean checked = false; for (ServerResource od : ods) { + assertTrue(od.getDepositedOn() != null); assertEquals(od.getDepositedBy(), this.user); assertEquals(od.getDepositedOnBehalfOf(), this.obo); + assertEquals(od.getPackaging().size(), 1); + assertTrue(od.getPackaging().contains(UriRegistry.PACKAGE_SIMPLE_ZIP)); checked = true; } assertTrue(checked); + + checked = false; + List<ResourceState> states = statement.getState(); + for (ResourceState state : states) + { + assertNotNull(state.getDescription()); + checked = true; + } + assertTrue(checked); } @Test @@ -277,10 +290,22 @@ boolean checked = false; for (ServerResource od : ods) { + assertTrue(od.getDepositedOn() != null); assertEquals(od.getDepositedBy(), this.user); assertEquals(od.getDepositedOnBehalfOf(), this.obo); + assertEquals(od.getPackaging().size(), 1); + assertTrue(od.getPackaging().contains(UriRegistry.PACKAGE_SIMPLE_ZIP)); checked = true; } assertTrue(checked); + + checked = false; + List<ResourceState> states = statement.getState(); + for (ResourceState state : states) + { + assertNotNull(state.getDescription()); + checked = true; + } + assertTrue(checked); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-25 15:48:27
|
Revision: 486 http://sword-app.svn.sourceforge.net/sword-app/?rev=486&view=rev Author: richard-jones Date: 2012-03-25 15:48:21 +0000 (Sun, 25 Mar 2012) Log Message: ----------- add more advanced deposit receipt tests, and fix associated bugs. In addition, add auto-lookup on deposit receipts for appropriate methods Modified Paths: -------------- JavaClient2.0/src/main/java/org/swordapp/client/DepositReceipt.java JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java Modified: JavaClient2.0/src/main/java/org/swordapp/client/DepositReceipt.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/DepositReceipt.java 2012-03-24 13:05:46 UTC (rev 485) +++ JavaClient2.0/src/main/java/org/swordapp/client/DepositReceipt.java 2012-03-25 15:48:21 UTC (rev 486) @@ -171,7 +171,7 @@ List<Element> allextensions = this.entry.getExtensions(); for (Element el : allextensions) { - if (el.getQName().toString().startsWith(UriRegistry.DC_NAMESPACE)) + if (el.getQName().toString().startsWith("{" + UriRegistry.DC_NAMESPACE)) { dc.add(el); } Modified: JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-24 13:05:46 UTC (rev 485) +++ JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-25 15:48:21 UTC (rev 486) @@ -352,6 +352,11 @@ public SwordResponse replaceMedia(DepositReceipt receipt, Deposit deposit, AuthCredentials auth) throws SWORDClientException, SWORDError, ProtocolViolationException { + if (receipt.getEditMediaLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } + String url = null; SwordIdentifier eml = receipt.getEditMediaLink(); if (eml != null) @@ -464,6 +469,10 @@ public SwordResponse replace(DepositReceipt receipt, Deposit deposit, AuthCredentials auth) throws SWORDClientException, SWORDError, ProtocolViolationException { + if (receipt.getEditLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } return this.replace(receipt.getEditLink().getHref(), deposit, auth); } @@ -576,12 +585,20 @@ public SwordResponse deleteContent(DepositReceipt receipt, AuthCredentials auth) throws SWORDClientException, SWORDError, ProtocolViolationException { + if (receipt.getEditMediaLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } return this.delete(receipt.getEditMediaLink().getHref(), auth); } public SwordResponse deleteContainer(DepositReceipt receipt, AuthCredentials auth) throws SWORDClientException, SWORDError, ProtocolViolationException { + if (receipt.getEditLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } return this.delete(receipt.getEditLink().getHref(), auth); } @@ -656,6 +673,10 @@ public SwordResponse addToMediaResource(DepositReceipt receipt, Deposit deposit, AuthCredentials auth) throws SWORDClientException, SWORDError, ProtocolViolationException { + if (receipt.getEditMediaLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } return this.addToMediaResource(receipt.getEditMediaLink().getHref(), deposit, auth); } @@ -774,6 +795,10 @@ public DepositReceipt addToContainer(DepositReceipt receipt, Deposit deposit, AuthCredentials auth) throws SWORDClientException, SWORDError, ProtocolViolationException { + if (receipt.getEditLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } return this.addToContainer(receipt.getEditLink().getHref(), deposit, auth); } @@ -948,6 +973,11 @@ public DepositReceipt complete(DepositReceipt receipt, AuthCredentials auth) throws SWORDClientException, ProtocolViolationException, SWORDError { + if (receipt.getEditLink() == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } + String url = null; SwordIdentifier el = receipt.getEditLink(); if (el != null) @@ -1187,6 +1217,11 @@ public Statement getStatement(DepositReceipt receipt, String type, AuthCredentials auth) throws SWORDClientException, StatementParseException, ProtocolViolationException, SWORDError { + if (receipt.getStatementLink(type) == null) + { + receipt = this.getDepositReceipt(receipt.getLocation(), auth); + } + SwordIdentifier si = receipt.getStatementLink(type); if (si == null) { Modified: JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java =================================================================== --- JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-24 13:05:46 UTC (rev 485) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-25 15:48:21 UTC (rev 486) @@ -1,5 +1,6 @@ package org.swordapp.client.test; +import org.apache.abdera.model.Element; import org.apache.commons.codec.digest.DigestUtils; import org.junit.Before; import org.junit.Test; @@ -8,6 +9,7 @@ import org.swordapp.client.ClientConfiguration; import org.swordapp.client.Deposit; import org.swordapp.client.DepositReceipt; +import org.swordapp.client.EntryPart; import org.swordapp.client.OreStatement; import org.swordapp.client.SWORDClient; import org.swordapp.client.SWORDCollection; @@ -15,6 +17,7 @@ import org.swordapp.client.ServerResource; import org.swordapp.client.ServiceDocument; import org.swordapp.client.Statement; +import org.swordapp.client.SwordResponse; import org.swordapp.client.UriRegistry; import java.io.FileInputStream; @@ -123,33 +126,82 @@ ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass)); SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); - Deposit deposit = new Deposit(); - deposit.setFile(new FileInputStream(this.file)); - deposit.setMimeType("application/zip"); - deposit.setFilename("example.zip"); - deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); - deposit.setMd5(this.fileMd5); + Deposit media = new Deposit(); + media.setFile(new FileInputStream(this.file)); + media.setMimeType("application/zip"); + media.setFilename("example.zip"); + media.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + media.setMd5(this.fileMd5); - DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass)); + DepositReceipt receipt = client.deposit(col, media, new AuthCredentials(this.user, this.pass, this.obo)); - // check all of the methods on the receipt + assertEquals(receipt.getStatusCode(), 201); + assertTrue(receipt.getLocation() != null); + assertEquals(receipt.getDerivedResourceLinks().size(), 4); + assertTrue(receipt.getOriginalDepositLink() != null); + assertTrue(receipt.getEditMediaLink() != null); - assertTrue(receipt.getLocation() != null); - assertEquals(receipt.getStatusCode(), 201); assertTrue(receipt.getAtomStatementLink() != null); assertEquals(receipt.getContentLink().getType(), "application/zip"); - assertEquals(receipt.getDerivedResourceLinks().size(), 4); assertTrue(receipt.getEditLink() != null); assertTrue(receipt.getOREStatementLink() != null); - assertTrue(receipt.getOriginalDepositLink() != null); assertEquals(receipt.getPackaging().size(), 1); assertTrue(receipt.getPackaging().contains(UriRegistry.PACKAGE_SIMPLE_ZIP)); assertTrue(receipt.getSplashPageLink() != null); assertTrue(receipt.getStatementLink("application/rdf+xml") != null); assertTrue(receipt.getStatementLink("application/atom+xml;type=feed") != null); assertTrue(receipt.getSwordEditLink() != null); + assertEquals(receipt.getTreatment(), "Treatment description"); + assertEquals(receipt.getVerboseDescription(), "SSS has done this, that and the other to process the deposit"); + + EntryPart ep = new EntryPart(); + ep.addDublinCore("title", "An entry only deposit"); + ep.addDublinCore("abstract", "abstract"); + ep.addDublinCore("identifier", "http://whatever/"); + + Deposit metadata = new Deposit(); + metadata.setEntryPart(ep); + + SwordResponse response = client.replace(receipt, metadata, new AuthCredentials(this.user, this.pass, this.obo)); + assertEquals(response.getStatusCode(), 200); + + receipt = client.getDepositReceipt(receipt.getLocation(), new AuthCredentials(this.user, this.pass, this.obo)); + + assertTrue(receipt.getEditMediaLink() != null); + assertTrue(receipt.getAtomStatementLink() != null); + assertEquals(receipt.getContentLink().getType(), "application/zip"); + assertTrue(receipt.getEditLink() != null); + assertTrue(receipt.getOREStatementLink() != null); + assertEquals(receipt.getPackaging().size(), 1); + assertTrue(receipt.getPackaging().contains(UriRegistry.PACKAGE_SIMPLE_ZIP)); + assertTrue(receipt.getSplashPageLink() != null); + assertTrue(receipt.getStatementLink("application/rdf+xml") != null); + assertTrue(receipt.getStatementLink("application/atom+xml;type=feed") != null); + assertTrue(receipt.getSwordEditLink() != null); assertTrue(receipt.getTreatment() != null); assertTrue(receipt.getVerboseDescription() != null); + + List<Element> dcs = receipt.getDublinCore(); + int count = 0; + for (Element dc : dcs) + { + if (dc.getQName().getLocalPart().equals("title")) + { + assertEquals(dc.getText(), "An entry only deposit"); + count++; + } + if (dc.getQName().getLocalPart().equals("abstract")) + { + assertEquals(dc.getText(), "abstract"); + count++; + } + if (dc.getQName().getLocalPart().equals("identifier")) + { + assertEquals(dc.getText(), "http://whatever/"); + count++; + } + } + assertEquals(count, 3); } @Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |