From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-24 11:56:25
|
Revision: 483 http://sword-app.svn.sourceforge.net/sword-app/?rev=483&view=rev Author: richard-jones Date: 2012-03-24 11:56:14 +0000 (Sat, 24 Mar 2012) Log Message: ----------- validation and warnings for inadvisable deposits, plus test enhancements around packaging Modified Paths: -------------- JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java Modified: JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-24 11:02:34 UTC (rev 482) +++ JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-24 11:56:14 UTC (rev 483) @@ -192,7 +192,7 @@ public DepositReceipt deposit(SWORDCollection collection, Deposit deposit) throws SWORDClientException, SWORDError, ProtocolViolationException { - return this.deposit(collection.getHref().toString(), deposit, null); + return this.deposit(collection, deposit, null); } public DepositReceipt deposit(String targetURL, Deposit deposit) @@ -210,6 +210,15 @@ " mediation; an error in response is likely. Provide an AuthCredentials object with " + "valid contents on next run"); } + if (deposit.getPackaging() != null) + { + if (!collection.getAcceptPackaging().contains(deposit.getPackaging())) + { + log.warn("About to attempt a deposit of a package format that the collection does not " + + "support; an error response is likely. Check the collection object for acceptable " + + "package formats before next run"); + } + } return this.deposit(collection.getHref().toString(), deposit, auth); } @@ -1252,7 +1261,7 @@ throw new ProtocolViolationException("Unexpected response code " + status); } } - + public Content getContent(SwordIdentifier contentId) throws SWORDClientException, ProtocolViolationException, SWORDError { 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 11:02:34 UTC (rev 482) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SSSSemiUnits.java 2012-03-24 11:56:14 UTC (rev 483) @@ -17,6 +17,7 @@ import org.swordapp.client.UriRegistry; import java.io.FileInputStream; +import java.util.ArrayList; import java.util.List; import static org.junit.Assert.*; @@ -92,13 +93,22 @@ assertEquals(ma.size(), 1); assertEquals(sa.size(), 1); assertEquals(ma.get(0), sa.get(0)); + assertTrue("*/*".equals(ma.get(0))); assertTrue(collection.getCollectionPolicy() != null); assertTrue(collection.allowsMediation()); - assertTrue(collection.getTreatment() != null); + assertTrue("Treatment description".equals(collection.getTreatment())); List<String> ap = collection.getAcceptPackaging(); - assertTrue(ap.size() > 0); + assertTrue(ap.size() == 3); + List<String> expectedPackaging = new ArrayList<String>(); + expectedPackaging.add("http://purl.org/net/sword/package/SimpleZip"); + expectedPackaging.add("http://purl.org/net/sword/package/Binary"); + expectedPackaging.add("http://purl.org/net/sword/package/METSDSpaceSIP"); + for (String packaging : ap) + { + assertTrue(expectedPackaging.contains(packaging)); + } List<String> ss = collection.getSubServices(); assertTrue(ss.size() == 1); @@ -132,6 +142,7 @@ 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); 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-24 11:02:34 UTC (rev 482) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-24 11:56:14 UTC (rev 483) @@ -995,31 +995,6 @@ /* Python tests to mimic - def test_33_get_ore_statement(self): - conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO) - conn.get_service_document() - col = conn.sd.workspaces[0][1][0] - e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/") - with open(PACKAGE) as pkg: - receipt = conn.create(col_iri = col.href, - metadata_entry = e, - payload=pkg, - mimetype=PACKAGE_MIME, - filename="example.zip", - packaging = 'http://purl.org/net/sword/package/SimpleZip') - - # ensure that we have a receipt (the server may not give us one - # by default) - edit_iri = receipt.location - receipt = conn.get_deposit_receipt(edit_iri) - - assert receipt.ore_statement_iri is not None - - # get the statement - statement = conn.get_ore_sword_statement(receipt.ore_statement_iri) - - assert isinstance(statement, Ore_Sword_Statement) - def test_34_complete_deposit(self): conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO) conn.get_service_document() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |