Skip to content

Commit

Permalink
added cancelCheckOut tests
Browse files Browse the repository at this point in the history
* added a more detailed test to clarify the ckeckin-pwc-cancelchecout behavior
* fixed auto-clearing of client cache on certain repository operations
  • Loading branch information
MichaelDaum committed Aug 31, 2012
1 parent 112e623 commit 8c0eda4
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 28 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Revision history for WebService-Cmis:

2012-08-29 MichaelDaum <github@michaeldaumconsulting.com>

* improved changelog generator
* preparing release 0.03
* pick up proprietary properties as well
* added example code to getAllowableActions()
Expand Down
26 changes: 13 additions & 13 deletions SIGNATURE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SHA1 d0b91959bb00f530e422ae79f6c21629d457ea4c Changes
SHA1 bc6c1f8e2f546e5e8ba6e1ae3e4bd8a040f8cd55 Changes
SHA1 b7725aa322a04f09f20980fd151d78f9babdd965 MANIFEST
SHA1 c848e901d3c945d92a788e89ef840ea47fba105a MANIFEST.SKIP
SHA1 a7afe7cf166d8fcc3e294303b17c8fe76f3aa08b META.yml
Expand All @@ -38,7 +38,7 @@ SHA1 ee2d1f47ae8f84a119989ed5ccd87f4b523d26bc inc/WebService/Cmis/Test/ACL.pm
SHA1 be26e6757570ea724278f3581c35c80e90efa423 inc/WebService/Cmis/Test/AtomFeed.pm
SHA1 174b3e05b64319257e762b6f7043bee185abd5b8 inc/WebService/Cmis/Test/Basics.pm
SHA1 fb1dfc81891566ce01a866f86b8bc11a5673e0d6 inc/WebService/Cmis/Test/Client.pm
SHA1 4e38cfba0cacc8a3ff2267baf1077bce276bd174 inc/WebService/Cmis/Test/Document.pm
SHA1 b1557999e27cdccaf23271bf8ed296dae8efd07f inc/WebService/Cmis/Test/Document.pm
SHA1 17cbd765372d036a6392ba21223cab15e62ad16d inc/WebService/Cmis/Test/Folder.pm
SHA1 3a0dfae9f8783f73c49b93f90b3240fdc4a457b0 inc/WebService/Cmis/Test/Object.pm
SHA1 8271611f5c7f9b6e16ef5075353f3b22a72de906 inc/WebService/Cmis/Test/ObjectType.pm
Expand All @@ -54,13 +54,13 @@ SHA1 0e1206c4e645e77f679db7395b4c7e5fdf9d6c65 lib/WebService/Cmis/AtomFeed/Chang
SHA1 c7f71e6ea12cc31d9766f43171fd065b0c56f008 lib/WebService/Cmis/AtomFeed/ObjectTypes.pm
SHA1 c7f63942cbc7ad1848c59912d7ba669390216d32 lib/WebService/Cmis/AtomFeed/Objects.pm
SHA1 f1fa0c37b98d5713882f4736007b550bc8ee426f lib/WebService/Cmis/ChangeEntry.pm
SHA1 aa6d861dd9540feae3676b837f71ceea08da1e7f lib/WebService/Cmis/Client.pm
SHA1 098243e067131e532d150c30e931e3e27d1b9c21 lib/WebService/Cmis/Client.pm
SHA1 b375c389ab0cc30a05f733eb4f99d709b5f034d2 lib/WebService/Cmis/ClientException.pm
SHA1 67e840854538d9f60274ac00ad880f9dfa679edb lib/WebService/Cmis/Document.pm
SHA1 2ef5b91f89b155e500fa66d47cc8dec91714b2af lib/WebService/Cmis/Document.pm
SHA1 4f64a574fd13444c9ccfb6eb2e91e956e117235e lib/WebService/Cmis/Folder.pm
SHA1 43971364b5925648c9c737947bd8fac9270dfc93 lib/WebService/Cmis/NotImplementedException.pm
SHA1 a52c47f8ad74e1f68a4a35598d4c76faaa353d29 lib/WebService/Cmis/NotSupportedException.pm
SHA1 256081480a82bb4ac8c11cae253bf10a57b2107b lib/WebService/Cmis/Object.pm
SHA1 4184e5ec56003da7362d73c53bc6f96e8766749f lib/WebService/Cmis/Object.pm
SHA1 fc133f02b03b41fa352c6b4294f240c5da343c3e lib/WebService/Cmis/ObjectType.pm
SHA1 cfbaf2ab10507df45cec1a1ac54f55cc0b8ea954 lib/WebService/Cmis/Policy.pm
SHA1 ad9587a666bacff6a06827e12c430676568d4edb lib/WebService/Cmis/Property.pm
Expand All @@ -72,7 +72,7 @@ SHA1 21204fff98f2de23dcf8beb103659526d31853fd lib/WebService/Cmis/Property/Integ
SHA1 5be26b9b80f667e94d98181ad51e1b46bd265f98 lib/WebService/Cmis/Property/String.pm
SHA1 d46ffd703d68aadf949863d47db90dfa596e2b18 lib/WebService/Cmis/PropertyDefinition.pm
SHA1 679a05c140fd632bf845d1d6eef9ac045b6ef2d1 lib/WebService/Cmis/Relationship.pm
SHA1 576dfb007b473e7ae6cfe1f344c16f27944b7f4f lib/WebService/Cmis/Repository.pm
SHA1 c7535cd734ad0ef675cb26a0934ab2a66695ba8c lib/WebService/Cmis/Repository.pm
SHA1 cda23db4a3ec536829f4d3e31de96c526c1d3870 lib/WebService/Cmis/ServerException.pm
SHA1 7087acf319a86f70d0cf4e59fe626d5635c5a034 t/00-load.t
SHA1 3ec6171779122b0bdc69937c283be11b2a15dd89 t/00-signature.t
Expand All @@ -95,11 +95,11 @@ SHA1 a284683173bea40e9e4679c1a044700443f8a333 t/pod.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJQPo9NAAoJEFbHzikUeAido/wH/2m6LUHfOdALGUKuEOz3u5/B
C/CWP/FeRp8vuP2v9GFRikTJf21PCDemW9ugKAsqmL9n5J/MU9PxrfbINFo4NF3U
lGeKKxWu2Z1BAeQKixft60dIzywBZlwtW4c4rajuUtQIJLOdUbXVa4OuBghnaSlu
GZXxK3VcTAjAO6peJQC5bET0BcYXV5gKQrh8dl5e6ekPeSMGrxE9F7AIzHyk00Mp
Ngr0Fa3tkjFaviZmXy2lcoB6zraKOdwpifWqWezhYvc2p71bbe8hldE7BCSrrQ6U
cKNV2WTuX/sG5CF92Lfnf+guzbiNQWlV8iPXYoIP5l7RQ4sTp9NBVN2AVhAAp30=
=1cxG
iQEcBAEBAgAGBQJQQI+oAAoJEFbHzikUeAid4FAH/1SxSpc590rpVYJQgpYdD5mn
Qfd2X0yd13fjwqvg1iWyuhqwBaZv8XaloMUYpYxxlbJ8Pf9nmz3vOCjVWgmNyUnE
+lR8LCNmSPFJ23pEWu9hxoULjtQJG7LEB5R6Z+j4jqVQHVYJBeveYolEn9aR7vgC
kJLZsE8ylcXsAolcD5P/hb1xd8KUPWAoA3Q44AhsujKeHbZkoMQgx7QVGCh0IG+I
oUlpfdRnnis89qDU8u6bdOmGfYzfvs+CwvUlfW1OmFRIxptTAr/5lu7mrl9Pstev
EwLrWbHAWVr/lollmlwlZA2vhe82K8qLULTCnSyoinVyJqOQ1Pfwd8lcQ8EIhRY=
=y9DM
-----END PGP SIGNATURE-----
52 changes: 48 additions & 4 deletions inc/WebService/Cmis/Test/Document.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ sub _saveFile {
close($FILE);
}


sub test_Document_getAllVersions : Tests {
my $this = shift;
my $repo = $this->getRepository;
Expand Down Expand Up @@ -163,7 +162,7 @@ sub test_Document_getContentLink : Test {
ok(defined $contentLink) or diag("can't get content link for test file");
}

sub test_Document_getLatestVersion : Test(5) {
sub test_Document_getLatestVersion : Test(7) {
my $this = shift;
my $repo = $this->getRepository;

Expand All @@ -173,8 +172,15 @@ sub test_Document_getLatestVersion : Test(5) {
note("versionLabel=$versionLabel");
is("1.0", $versionLabel);

my $beforeCheckedOutDocs = $repo->getCheckedOutDocs->getSize;
note("beforeCheckedOutDocs=$beforeCheckedOutDocs");

$doc->checkOut;

is($repo->getCheckedOutDocs->getSize, $beforeCheckedOutDocs+1) or diag("checked out queue should be increasing");

$doc->checkIn("this is a major checkin time=".time);
is($repo->getCheckedOutDocs->getSize, $beforeCheckedOutDocs) or diag("checked out queue the same as before");

$doc = $doc->getLatestVersion;
$versionLabel = $doc->getProperty("cmis:versionLabel");
Expand All @@ -194,8 +200,7 @@ sub test_Document_getLatestVersion : Test(5) {
note("latest major versionLabel=$versionLabel");
is("2.0", $versionLabel);

my $checkedOutDocs = $repo->getCheckedOutDocs;
ok($checkedOutDocs->getSize == 0) or diag("checked out queue should be empty");
is($repo->getCheckedOutDocs->getSize, $beforeCheckedOutDocs) or diag("checked out queue the same as before");
}

sub test_Document_moveTo : Test(4) {
Expand Down Expand Up @@ -344,4 +349,43 @@ sub test_Document_getRenditionLink : Test(5) {
ok(!defined $link);
}

sub test_Document_checkOut_cancelCheckOut : Test(8) {
# SMELL: skip some when there is no support for pwc

my $this = shift;

my $repo = $this->getRepository;
my $obj = $this->getTestDocument;

my $id1 = $obj->getId;
note("id1=$id1");

my $pwc = $obj->getPrivateWorkingCopy;
ok(!defined $pwc) or diag("oops, we didn't check it out yet, so there shouldn't be a pwc yet");

$obj->checkOut;
my $id2 = $obj->getId;
note("id2=$id2");
is($id1, $id2);
ok($repo->getObject($id1));

$pwc = $obj->getPrivateWorkingCopy;
ok(defined $pwc) or diag("oops, where's my pwc");
my $id3 = $obj->getId;
note("id3=$id3");
is($id1, $id3);

my $pwcId = $pwc->getId;
note("pwcId=".$pwcId);
isnt($obj->getId, $pwc->getId) or diag("document id should be different from pwc id");

$obj->cancelCheckOut;
my $id4 = $obj->getId;
note("id4=".$id4);
ok($repo->getObject($id1));
ok(!defined $repo->getObject($pwcId)) or diag("pwc should been gone by now");
}



1;
28 changes: 23 additions & 5 deletions lib/WebService/Cmis/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ sub purgeCache {
return $cache->purge(@_);
}

=item removeFromCache($path, %params)
removes an item from the cache associated with the given path
and url parameters
=cut

sub removeFromCache {
my $this = shift;
my $path = shift;

my $uri = _getUri($path, @_);
writeCmisDebug("removing from cache $uri");
return $this->_cacheRemove($uri);
}

# internal cache layer
sub _cacheGet {
my $this = shift;
Expand Down Expand Up @@ -209,7 +225,7 @@ sub _cacheKey {
return _untaint(Digest::MD5::md5_hex(Data::Dumper::Dumper($_[0])));
}

=item get($path)
=item get($path, %params)
does a get against the CMIS service. More than likely, you will not
need to call this method. Instead, let the other objects to it for you.
Expand All @@ -235,7 +251,7 @@ sub get {
}

my $uri = _getUri($url, @_);
writeCmisDebug("called get($uri)");
#writeCmisDebug("called get($uri)");

# do it
$this->GET($uri);
Expand Down Expand Up @@ -269,13 +285,12 @@ sub request {
my $method = shift;
my $url = shift;

#print STDERR "url=$url\n";

if($this->{_cacheEntry} = $this->_cacheGet($url)) {
writeCmisDebug("found in cache");
writeCmisDebug("found in cache: $url");
$this->{_cacheHits}++;
return $this;
}
writeCmisDebug("request url=$url");

my $result = $this->SUPER::request($method, $url, @_);

Expand Down Expand Up @@ -397,6 +412,9 @@ sub post {
# do it
$this->POST($url, $payload, \%params);

# auto clear the cache
$this->clearCache;

my $code = $this->responseCode;
return $this->_parseResponse if $code >= 200 && $code < 300;
$this->processErrors;
Expand Down
3 changes: 1 addition & 2 deletions lib/WebService/Cmis/Document.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ sub cancelCheckOut {
my $this = shift;

my $pwcDoc = $this->getPrivateWorkingCopy;
return unless defined $pwcDoc;
$pwcDoc->delete;
$pwcDoc->delete if defined $pwcDoc;
$this->reload;

return $this;
Expand Down
2 changes: 1 addition & 1 deletion lib/WebService/Cmis/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ sub reload {
$byObjectIdUrl =~ s/{renditionFilter}/$params{renditionFilter}||''/ge;

# auto clear cache
#$this->{repository}{client}->clearCache;
#$this->{repository}{client}->removeFromCache($byObjectIdUrl, %{$this->{extra_params}});

$this->{xmlDoc} = $this->{repository}{client}->get($byObjectIdUrl, %{$this->{extra_params}});
$this->_initData;
Expand Down
3 changes: 0 additions & 3 deletions lib/WebService/Cmis/Repository.pm
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,6 @@ sub createObject {
# build the Atom entry
my $xmlDoc = $this->createEntryXmlDoc(folder=>$parentFolder, @_);

# auto-clear cache
#$this->{client}->clearCache;

# post the Atom entry
my $result = $this->{client}->post($postUrl, $xmlDoc->toString, ATOM_XML_ENTRY_TYPE);

Expand Down

0 comments on commit 8c0eda4

Please sign in to comment.