Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/CollectionHelper.java @ 1320:5733c05ce24c
Added removeArtifact CollectionHelper method.
flys-client/trunk@2961 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 13 Oct 2011 12:30:08 +0000 |
parents | ecd0243bc09e |
children | ab2b1a4a9ead |
comparison
equal
deleted
inserted
replaced
1319:6ba17b628552 | 1320:5733c05ce24c |
---|---|
664 e.printStackTrace(); | 664 e.printStackTrace(); |
665 } | 665 } |
666 | 666 |
667 throw new ServerException(ERROR_ADD_ARTIFACT); | 667 throw new ServerException(ERROR_ADD_ARTIFACT); |
668 } | 668 } |
669 | |
670 | |
671 /** | |
672 * Remove an artifact from a collection. | |
673 * @param collection Collection to remove artifact to. | |
674 * @param artifact Artifact to add to collection | |
675 */ | |
676 public static Collection removeArtifact( | |
677 Collection collection, | |
678 String artifactId, | |
679 String url, | |
680 String locale) | |
681 throws ServerException | |
682 { | |
683 System.out.println("Collection.removeArtifact"); | |
684 | |
685 if (collection == null) { | |
686 System.err.println("The given Collection is null!"); | |
687 return null; | |
688 } | |
689 | |
690 Document remove = ClientProtocolUtils.newRemoveArtifactDocument( | |
691 artifactId); | |
692 | |
693 HttpClient client = new HttpClientImpl(url, locale); | |
694 | |
695 try { | |
696 System.out.println("Do HTTP request now."); | |
697 | |
698 Document response = (Document) client.doCollectionAction( | |
699 remove, collection.identifier(), new DocumentResponseHandler()); | |
700 | |
701 System.out.println( | |
702 "Finished HTTP request successfully. Parse Collection now."); | |
703 System.out.println(XMLUtils.toString(response)); | |
704 | |
705 Collection c = CollectionHelper.parseCollection(response); | |
706 | |
707 if (c == null) { | |
708 throw new ServerException(ERROR_ADD_ARTIFACT); | |
709 } | |
710 | |
711 return c; | |
712 } | |
713 catch (ConnectionException ce) { | |
714 System.err.println(ce.getLocalizedMessage()); | |
715 } | |
716 catch (Exception e) { | |
717 e.printStackTrace(); | |
718 } | |
719 // TODO other err | |
720 throw new ServerException(ERROR_ADD_ARTIFACT); | |
721 } | |
669 } | 722 } |
670 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 723 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |