comparison gwt-client/src/main/java/org/dive4elements/river/client/server/CollectionHelper.java @ 8203:238fc722f87a

sed 's/logger/log/g' src/**/*.java
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 13:19:22 +0200
parents 63975955ec61
children 5e38e2924c07
comparison
equal deleted inserted replaced
8202:e4606eae8ea5 8203:238fc722f87a
67 /** 67 /**
68 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 68 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
69 */ 69 */
70 public class CollectionHelper { 70 public class CollectionHelper {
71 71
72 private static final Logger logger = 72 private static final Logger log =
73 Logger.getLogger(CollectionHelper.class); 73 Logger.getLogger(CollectionHelper.class);
74 74
75 public static final String ERROR_ADD_ARTIFACT = "error_add_artifact"; 75 public static final String ERROR_ADD_ARTIFACT = "error_add_artifact";
76 76
77 public static final String ERROR_REMOVE_ARTIFACT = "error_remove_artifact"; 77 public static final String ERROR_REMOVE_ARTIFACT = "error_remove_artifact";
81 public static final String XPATH_LOADED_RECOMMENDATIONS = 81 public static final String XPATH_LOADED_RECOMMENDATIONS =
82 "/art:artifact-collection/art:attribute/art:loaded-recommendations/art:recommendation"; 82 "/art:artifact-collection/art:attribute/art:loaded-recommendations/art:recommendation";
83 83
84 84
85 public static Document createAttribute(Collection collection) { 85 public static Document createAttribute(Collection collection) {
86 logger.debug("CollectionHelper.createAttribute"); 86 log.debug("CollectionHelper.createAttribute");
87 87
88 Document doc = XMLUtils.newDocument(); 88 Document doc = XMLUtils.newDocument();
89 89
90 ElementCreator cr = new ElementCreator( 90 ElementCreator cr = new ElementCreator(
91 doc, 91 doc,
125 protected static Element createOutputElements( 125 protected static Element createOutputElements(
126 ElementCreator cr, 126 ElementCreator cr,
127 Collection c, 127 Collection c,
128 Map<String, OutputMode> mmodes) 128 Map<String, OutputMode> mmodes)
129 { 129 {
130 logger.debug("CollectionHelper.createOutputElements"); 130 log.debug("CollectionHelper.createOutputElements");
131 131
132 java.util.Collection<OutputMode> modes = mmodes != null 132 java.util.Collection<OutputMode> modes = mmodes != null
133 ? mmodes.values() 133 ? mmodes.values()
134 : null; 134 : null;
135 135
136 if (modes == null || modes.size() == 0) { 136 if (modes == null || modes.size() == 0) {
137 logger.debug("Collection has no modes: " + c.identifier()); 137 log.debug("Collection has no modes: " + c.identifier());
138 return null; 138 return null;
139 } 139 }
140 140
141 Element outs = cr.create("outputs"); 141 Element outs = cr.create("outputs");
142 142
164 protected static Element createOutputElement( 164 protected static Element createOutputElement(
165 ElementCreator cr, 165 ElementCreator cr,
166 Collection collection, 166 Collection collection,
167 OutputMode mode) 167 OutputMode mode)
168 { 168 {
169 logger.debug("CollectionHelper.createOutputElement"); 169 log.debug("CollectionHelper.createOutputElement");
170 170
171 Element out = cr.create("output"); 171 Element out = cr.create("output");
172 cr.addAttr(out, "name", mode.getName(), false); 172 cr.addAttr(out, "name", mode.getName(), false);
173 173
174 ThemeList themeList = collection.getThemeList(mode.getName()); 174 ThemeList themeList = collection.getThemeList(mode.getName());
175 List<Theme> themes = themeList != null ? themeList.getThemes() : null; 175 List<Theme> themes = themeList != null ? themeList.getThemes() : null;
176 176
177 if (themes == null || themes.size() == 0) { 177 if (themes == null || themes.size() == 0) {
178 logger.debug("No themes for output mode: " + mode.getName()); 178 log.debug("No themes for output mode: " + mode.getName());
179 return null; 179 return null;
180 } 180 }
181 181
182 for (Theme theme: themes) { 182 for (Theme theme: themes) {
183 Element t = createThemeElement(cr, collection, theme); 183 Element t = createThemeElement(cr, collection, theme);
193 193
194 Settings settings = collection.getSettings(mode.getName()); 194 Settings settings = collection.getSettings(mode.getName());
195 if (settings == null || 195 if (settings == null ||
196 settings.getCategories().size() == 0) 196 settings.getCategories().size() == 0)
197 { 197 {
198 logger.debug("No settings for output mode: " + mode.getName()); 198 log.debug("No settings for output mode: " + mode.getName());
199 } 199 }
200 else { 200 else {
201 Element s = createSettingsElement(settingscr, collection, settings); 201 Element s = createSettingsElement(settingscr, collection, settings);
202 if (s != null) { 202 if (s != null) {
203 out.appendChild(s); 203 out.appendChild(s);
204 } 204 }
205 } 205 }
206 logger.info(XMLUtils.toString(out)); 206 log.info(XMLUtils.toString(out));
207 return out; 207 return out;
208 } 208 }
209 209
210 210
211 /** 211 /**
260 */ 260 */
261 protected static Element createRecommendationsElements( 261 protected static Element createRecommendationsElements(
262 ElementCreator cr, 262 ElementCreator cr,
263 Collection c) 263 Collection c)
264 { 264 {
265 logger.debug("CollectionHelper.createRecommendationsElements"); 265 log.debug("CollectionHelper.createRecommendationsElements");
266 266
267 List<Recommendation> rs = c.getRecommendations(); 267 List<Recommendation> rs = c.getRecommendations();
268 268
269 if (rs == null || rs.size() == 0) { 269 if (rs == null || rs.size() == 0) {
270 logger.debug("Collection did not load recommendations: " + 270 log.debug("Collection did not load recommendations: " +
271 c.identifier()); 271 c.identifier());
272 return null; 272 return null;
273 } 273 }
274 274
275 Element loaded = cr.create("loaded-recommendations"); 275 Element loaded = cr.create("loaded-recommendations");
298 protected static Element createRecommendationElement( 298 protected static Element createRecommendationElement(
299 ElementCreator cr, 299 ElementCreator cr,
300 Collection c, 300 Collection c,
301 Recommendation r) 301 Recommendation r)
302 { 302 {
303 logger.debug("CollectionHelper.createRecommendationElement"); 303 log.debug("CollectionHelper.createRecommendationElement");
304 304
305 Element recommendation = cr.create("recommendation"); 305 Element recommendation = cr.create("recommendation");
306 cr.addAttr(recommendation, "factory", r.getFactory(), true); 306 cr.addAttr(recommendation, "factory", r.getFactory(), true);
307 cr.addAttr(recommendation, "ids", r.getIDs(), true); 307 cr.addAttr(recommendation, "ids", r.getIDs(), true);
308 308
316 protected static Element createSettingsElement( 316 protected static Element createSettingsElement(
317 ElementCreator cr, 317 ElementCreator cr,
318 Collection c, 318 Collection c,
319 Settings s) 319 Settings s)
320 { 320 {
321 logger.debug("CollectionHelper.createSettingsElement"); 321 log.debug("CollectionHelper.createSettingsElement");
322 Element settings = cr.create("settings"); 322 Element settings = cr.create("settings");
323 323
324 List<String> categories = s.getCategories(); 324 List<String> categories = s.getCategories();
325 325
326 for (String category: categories) { 326 for (String category: categories) {
399 * operation. 399 * operation.
400 * 400 *
401 * @return a Collection with CollectionItems. 401 * @return a Collection with CollectionItems.
402 */ 402 */
403 public static Collection parseCollection(Document description) { 403 public static Collection parseCollection(Document description) {
404 logger.debug("CollectionHelper.parseCollection"); 404 log.debug("CollectionHelper.parseCollection");
405 405
406 if (logger.isDebugEnabled()) { 406 if (log.isDebugEnabled()) {
407 logger.debug(XMLUtils.toString(description)); 407 log.debug(XMLUtils.toString(description));
408 } 408 }
409 409
410 if (description == null) { 410 if (description == null) {
411 logger.warn("The DESCRIBE of the Collection is null!"); 411 log.warn("The DESCRIBE of the Collection is null!");
412 return null; 412 return null;
413 } 413 }
414 414
415 String uuid = XMLUtils.xpathString( 415 String uuid = XMLUtils.xpathString(
416 description, 416 description,
426 description, 426 description,
427 "art:artifact-collection/@art:name", 427 "art:artifact-collection/@art:name",
428 ArtifactNamespaceContext.INSTANCE); 428 ArtifactNamespaceContext.INSTANCE);
429 429
430 if (uuid.length() == 0) { 430 if (uuid.length() == 0) {
431 logger.warn("Found an invalid (zero length uuid) Collection!"); 431 log.warn("Found an invalid (zero length uuid) Collection!");
432 return null; 432 return null;
433 } 433 }
434 434
435 if (ttlStr.length() == 0) { 435 if (ttlStr.length() == 0) {
436 logger.warn("Found an invalid Collection (zero length ttl)!"); 436 log.warn("Found an invalid Collection (zero length ttl)!");
437 return null; 437 return null;
438 } 438 }
439 439
440 440
441 long ttl = -1; 441 long ttl = -1;
459 "art:artifact-collection/art:artifacts/art:artifact", 459 "art:artifact-collection/art:artifacts/art:artifact",
460 XPathConstants.NODESET, 460 XPathConstants.NODESET,
461 ArtifactNamespaceContext.INSTANCE); 461 ArtifactNamespaceContext.INSTANCE);
462 462
463 if (items == null || items.getLength() == 0) { 463 if (items == null || items.getLength() == 0) {
464 logger.debug("No collection item found for this collection."); 464 log.debug("No collection item found for this collection.");
465 465
466 return c; 466 return c;
467 } 467 }
468 468
469 int size = items.getLength(); 469 int size = items.getLength();
482 Map<String, ThemeList> themeLists = parseThemeLists(description, collectionItems); 482 Map<String, ThemeList> themeLists = parseThemeLists(description, collectionItems);
483 c.setThemeLists(themeLists); 483 c.setThemeLists(themeLists);
484 484
485 Map<String, Settings> outSettings = parseSettings(description); 485 Map<String, Settings> outSettings = parseSettings(description);
486 c.setSettings(outSettings); 486 c.setSettings(outSettings);
487 logger.debug( 487 log.debug(
488 "Found " + c.getItemLength() + " collection items " + 488 "Found " + c.getItemLength() + " collection items " +
489 "for the Collection '" + c.identifier() + "'."); 489 "for the Collection '" + c.identifier() + "'.");
490 490
491 return c; 491 return c;
492 } 492 }
497 * (artifact) uuid. 497 * (artifact) uuid.
498 */ 498 */
499 protected static Map<String, ThemeList> parseThemeLists( 499 protected static Map<String, ThemeList> parseThemeLists(
500 Document desc, Map<String, CollectionItem> collectionItems 500 Document desc, Map<String, CollectionItem> collectionItems
501 ) { 501 ) {
502 logger.debug("CollectionHelper.parseThemeLists"); 502 log.debug("CollectionHelper.parseThemeLists");
503 503
504 NodeList lists = (NodeList) XMLUtils.xpath( 504 NodeList lists = (NodeList) XMLUtils.xpath(
505 desc, 505 desc,
506 "/art:artifact-collection/art:attribute/art:outputs/art:output", 506 "/art:artifact-collection/art:attribute/art:outputs/art:output",
507 XPathConstants.NODESET, 507 XPathConstants.NODESET,
536 * (artifact) uuid. 536 * (artifact) uuid.
537 */ 537 */
538 protected static ThemeList parseThemeList( 538 protected static ThemeList parseThemeList(
539 Element node, Map<String, CollectionItem> collectionItems 539 Element node, Map<String, CollectionItem> collectionItems
540 ) { 540 ) {
541 logger.debug("CollectionHelper.parseThemeList"); 541 log.debug("CollectionHelper.parseThemeList");
542 542
543 NodeList themes = node.getElementsByTagNameNS( 543 NodeList themes = node.getElementsByTagNameNS(
544 ArtifactNamespaceContext.NAMESPACE_URI, 544 ArtifactNamespaceContext.NAMESPACE_URI,
545 "facet"); 545 "facet");
546 546
560 return new ThemeList(themeList); 560 return new ThemeList(themeList);
561 } 561 }
562 562
563 563
564 protected static Theme parseTheme(Element ele) { 564 protected static Theme parseTheme(Element ele) {
565 logger.debug("CollectionHelper.parseTheme"); 565 log.debug("CollectionHelper.parseTheme");
566 566
567 String uri = ArtifactNamespaceContext.NAMESPACE_URI; 567 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
568 568
569 NamedNodeMap attrMap = ele.getAttributes(); 569 NamedNodeMap attrMap = ele.getAttributes();
570 int attrNum = attrMap != null ? attrMap.getLength() : 0; 570 int attrNum = attrMap != null ? attrMap.getLength() : 0;
591 * @param description The collection description. 591 * @param description The collection description.
592 * 592 *
593 * @return Map containing the settings. 593 * @return Map containing the settings.
594 */ 594 */
595 protected static Map<String, Settings> parseSettings(Document description) { 595 protected static Map<String, Settings> parseSettings(Document description) {
596 logger.info("parseSettings"); 596 log.info("parseSettings");
597 597
598 NodeList lists = (NodeList) XMLUtils.xpath( 598 NodeList lists = (NodeList) XMLUtils.xpath(
599 description, 599 description,
600 "/art:artifact-collection/art:attribute/art:outputs/art:output", 600 "/art:artifact-collection/art:attribute/art:outputs/art:output",
601 XPathConstants.NODESET, 601 XPathConstants.NODESET,
731 */ 731 */
732 protected static CollectionItem parseCollectionItem( 732 protected static CollectionItem parseCollectionItem(
733 Element node, 733 Element node,
734 boolean outs 734 boolean outs
735 ) { 735 ) {
736 logger.debug("CollectionHelper.parseCollectionItem"); 736 log.debug("CollectionHelper.parseCollectionItem");
737 737
738 if (node == null) { 738 if (node == null) {
739 logger.debug("The node for parsing CollectionItem is null!"); 739 log.debug("The node for parsing CollectionItem is null!");
740 return null; 740 return null;
741 } 741 }
742 742
743 String uri = ArtifactNamespaceContext.NAMESPACE_URI; 743 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
744 744
745 String uuid = node.getAttributeNS(uri, "uuid"); 745 String uuid = node.getAttributeNS(uri, "uuid");
746 String hash = node.getAttributeNS(uri, "hash"); 746 String hash = node.getAttributeNS(uri, "hash");
747 747
748 if (uuid == null || uuid.length() == 0) { 748 if (uuid == null || uuid.length() == 0) {
749 logger.warn("Found an invalid CollectionItem!"); 749 log.warn("Found an invalid CollectionItem!");
750 return null; 750 return null;
751 } 751 }
752 752
753 List<OutputMode> modes = new ArrayList<OutputMode>(); 753 List<OutputMode> modes = new ArrayList<OutputMode>();
754 754
784 * @param node The root node of the outputmodes list. 784 * @param node The root node of the outputmodes list.
785 * 785 *
786 * @return a list of OutputModes. 786 * @return a list of OutputModes.
787 */ 787 */
788 protected static List<OutputMode> parseOutputModes(Element node) { 788 protected static List<OutputMode> parseOutputModes(Element node) {
789 logger.debug("CollectionHelper.parseOutputModes"); 789 log.debug("CollectionHelper.parseOutputModes");
790 790
791 if (node == null) { 791 if (node == null) {
792 logger.debug("The node for parsing OutputModes is null!"); 792 log.debug("The node for parsing OutputModes is null!");
793 return null; 793 return null;
794 } 794 }
795 795
796 String uri = ArtifactNamespaceContext.NAMESPACE_URI; 796 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
797 797
798 NodeList list = node.getElementsByTagNameNS(uri, "output"); 798 NodeList list = node.getElementsByTagNameNS(uri, "output");
799 799
800 int size = list.getLength(); 800 int size = list.getLength();
801 801
802 if (size == 0) { 802 if (size == 0) {
803 logger.debug("No outputmode nodes found!"); 803 log.debug("No outputmode nodes found!");
804 return null; 804 return null;
805 } 805 }
806 806
807 List<OutputMode> modes = new ArrayList<OutputMode>(size); 807 List<OutputMode> modes = new ArrayList<OutputMode>(size);
808 808
813 String desc = tmp.getAttributeNS(uri, "description"); 813 String desc = tmp.getAttributeNS(uri, "description");
814 String mime = tmp.getAttributeNS(uri, "mime-type"); 814 String mime = tmp.getAttributeNS(uri, "mime-type");
815 String type = tmp.getAttributeNS(uri, "type"); 815 String type = tmp.getAttributeNS(uri, "type");
816 816
817 if (name.length() == 0) { 817 if (name.length() == 0) {
818 logger.warn("Found an invalid output mode."); 818 log.warn("Found an invalid output mode.");
819 continue; 819 continue;
820 } 820 }
821 821
822 OutputMode outmode = null; 822 OutputMode outmode = null;
823 List<Facet> fs = extractFacets(tmp); 823 List<Facet> fs = extractFacets(tmp);
836 } 836 }
837 else if (type.equals("overview")) { 837 else if (type.equals("overview")) {
838 outmode = new OverviewMode(name, desc, mime, fs, type); 838 outmode = new OverviewMode(name, desc, mime, fs, type);
839 } 839 }
840 else { 840 else {
841 logger.warn("Broken Output mode without type found."); 841 log.warn("Broken Output mode without type found.");
842 continue; 842 continue;
843 } 843 }
844 844
845 modes.add(outmode); 845 modes.add(outmode);
846 } 846 }
851 851
852 /** 852 /**
853 * Create a Key/Value map for data nodes of artifact/collectionitem. 853 * Create a Key/Value map for data nodes of artifact/collectionitem.
854 */ 854 */
855 protected static HashMap<String, String> parseDataItems(Element node) { 855 protected static HashMap<String, String> parseDataItems(Element node) {
856 logger.debug("CollectionHelper.parseDataItems"); 856 log.debug("CollectionHelper.parseDataItems");
857 857
858 if (node == null) { 858 if (node == null) {
859 logger.debug("The node for parsing DataItems is null!"); 859 log.debug("The node for parsing DataItems is null!");
860 return null; 860 return null;
861 } 861 }
862 862
863 String uri = ArtifactNamespaceContext.NAMESPACE_URI; 863 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
864 864
865 NodeList list = node.getElementsByTagNameNS(uri, "data"); 865 NodeList list = node.getElementsByTagNameNS(uri, "data");
866 866
867 int size = list.getLength(); 867 int size = list.getLength();
868 868
869 if (size == 0) { 869 if (size == 0) {
870 logger.debug("No static data-item nodes found!"); 870 log.debug("No static data-item nodes found!");
871 } 871 }
872 872
873 HashMap<String, String> data = new HashMap<String, String>(size*2); 873 HashMap<String, String> data = new HashMap<String, String>(size*2);
874 874
875 for (int i = 0; i < size; i++) { 875 for (int i = 0; i < size; i++) {
876 Element tmp = (Element)list.item(i); 876 Element tmp = (Element)list.item(i);
877 877
878 String key = tmp.getAttributeNS(uri, "name"); 878 String key = tmp.getAttributeNS(uri, "name");
879 879
880 if (key.length() == 0) { 880 if (key.length() == 0) {
881 logger.warn("Found an invalid data item mode."); 881 log.warn("Found an invalid data item mode.");
882 continue; 882 continue;
883 } 883 }
884 884
885 // XXX We are restricted on 1/1 key/values in the data map here. 885 // XXX We are restricted on 1/1 key/values in the data map here.
886 NodeList valueNodes = tmp.getElementsByTagName("art:item"); 886 NodeList valueNodes = tmp.getElementsByTagName("art:item");
887 887
888 Element item = (Element) valueNodes.item(0); 888 Element item = (Element) valueNodes.item(0);
889 String value = item.getAttributeNS(uri, "value"); 889 String value = item.getAttributeNS(uri, "value");
890 logger.debug("Found a data item " + key + " : " + value); 890 log.debug("Found a data item " + key + " : " + value);
891 891
892 data.put(key, value); 892 data.put(key, value);
893 } 893 }
894 894
895 895
897 list = node.getElementsByTagNameNS(uri, "select"); 897 list = node.getElementsByTagNameNS(uri, "select");
898 898
899 size = list.getLength(); 899 size = list.getLength();
900 900
901 if (size == 0) { 901 if (size == 0) {
902 logger.debug("No dynamic data-item nodes found!"); 902 log.debug("No dynamic data-item nodes found!");
903 } 903 }
904 904
905 for (int i = 0; i < size; i++) { 905 for (int i = 0; i < size; i++) {
906 Element tmp = (Element)list.item(i); 906 Element tmp = (Element)list.item(i);
907 907
908 String key = tmp.getAttributeNS(uri, "name"); 908 String key = tmp.getAttributeNS(uri, "name");
909 909
910 if (key.length() == 0) { 910 if (key.length() == 0) {
911 logger.warn("Found an invalid data item node (missing key)."); 911 log.warn("Found an invalid data item node (missing key).");
912 continue; 912 continue;
913 } 913 }
914 914
915 String value = tmp.getAttributeNS(uri, "defaultValue"); 915 String value = tmp.getAttributeNS(uri, "defaultValue");
916 916
917 if (value.length() == 0) { 917 if (value.length() == 0) {
918 logger.warn("Found an invalid data item node (missing value)."); 918 log.warn("Found an invalid data item node (missing value).");
919 continue; 919 continue;
920 } 920 }
921 921
922 logger.debug("Found a (dyn) data item " + key + " : " + value); 922 log.debug("Found a (dyn) data item " + key + " : " + value);
923 923
924 data.put(key, value); 924 data.put(key, value);
925 } 925 }
926 926
927 return data; 927 return data;
928 } 928 }
929 929
930 protected static List<Facet> extractFacets(Element outmode) { 930 protected static List<Facet> extractFacets(Element outmode) {
931 logger.debug("CollectionHelper - extractFacets()"); 931 log.debug("CollectionHelper - extractFacets()");
932 932
933 NodeList facetList = (NodeList) XMLUtils.xpath( 933 NodeList facetList = (NodeList) XMLUtils.xpath(
934 outmode, 934 outmode,
935 XPATH_FACETS, 935 XPATH_FACETS,
936 XPathConstants.NODESET, 936 XPathConstants.NODESET,
957 return facets; 957 return facets;
958 } 958 }
959 959
960 960
961 public static List<Recommendation> parseRecommendations(Document doc) { 961 public static List<Recommendation> parseRecommendations(Document doc) {
962 logger.debug("CollectionHelper.parseRecommendations"); 962 log.debug("CollectionHelper.parseRecommendations");
963 963
964 NodeList list = (NodeList) XMLUtils.xpath( 964 NodeList list = (NodeList) XMLUtils.xpath(
965 doc, 965 doc,
966 XPATH_LOADED_RECOMMENDATIONS, 966 XPATH_LOADED_RECOMMENDATIONS,
967 XPathConstants.NODESET, 967 XPathConstants.NODESET,
998 Artifact artifact, 998 Artifact artifact,
999 String url, 999 String url,
1000 String locale) 1000 String locale)
1001 throws ServerException 1001 throws ServerException
1002 { 1002 {
1003 logger.debug("CollectionHelper.addArtifact"); 1003 log.debug("CollectionHelper.addArtifact");
1004 1004
1005 if (collection == null) { 1005 if (collection == null) {
1006 logger.warn("The given Collection is null!"); 1006 log.warn("The given Collection is null!");
1007 return null; 1007 return null;
1008 } 1008 }
1009 1009
1010 Document add = ClientProtocolUtils.newAddArtifactDocument( 1010 Document add = ClientProtocolUtils.newAddArtifactDocument(
1011 artifact.getUuid(), null); 1011 artifact.getUuid(), null);
1012 1012
1013 HttpClient client = new HttpClientImpl(url, locale); 1013 HttpClient client = new HttpClientImpl(url, locale);
1014 1014
1015 try { 1015 try {
1016 logger.debug("Do HTTP request now."); 1016 log.debug("Do HTTP request now.");
1017 1017
1018 Document response = (Document) client.doCollectionAction( 1018 Document response = (Document) client.doCollectionAction(
1019 add, collection.identifier(), new DocumentResponseHandler()); 1019 add, collection.identifier(), new DocumentResponseHandler());
1020 1020
1021 logger.debug( 1021 log.debug(
1022 "Finished HTTP request successfully. Parse Collection now."); 1022 "Finished HTTP request successfully. Parse Collection now.");
1023 1023
1024 Collection c = CollectionHelper.parseCollection(response); 1024 Collection c = CollectionHelper.parseCollection(response);
1025 1025
1026 if (c == null) { 1026 if (c == null) {
1028 } 1028 }
1029 1029
1030 return c; 1030 return c;
1031 } 1031 }
1032 catch (ConnectionException ce) { 1032 catch (ConnectionException ce) {
1033 logger.error(ce, ce); 1033 log.error(ce, ce);
1034 } 1034 }
1035 catch (Exception e) { 1035 catch (Exception e) {
1036 logger.error(e, e); 1036 log.error(e, e);
1037 } 1037 }
1038 1038
1039 throw new ServerException(ERROR_ADD_ARTIFACT); 1039 throw new ServerException(ERROR_ADD_ARTIFACT);
1040 } 1040 }
1041 1041
1050 String artifactId, 1050 String artifactId,
1051 String url, 1051 String url,
1052 String locale) 1052 String locale)
1053 throws ServerException 1053 throws ServerException
1054 { 1054 {
1055 logger.debug("CollectionHelper.removeArtifact"); 1055 log.debug("CollectionHelper.removeArtifact");
1056 1056
1057 if (collection == null) { 1057 if (collection == null) {
1058 logger.warn("The given Collection is null!"); 1058 log.warn("The given Collection is null!");
1059 return null; 1059 return null;
1060 } 1060 }
1061 1061
1062 Document remove = ClientProtocolUtils.newRemoveArtifactDocument( 1062 Document remove = ClientProtocolUtils.newRemoveArtifactDocument(
1063 artifactId); 1063 artifactId);
1064 1064
1065 HttpClient client = new HttpClientImpl(url, locale); 1065 HttpClient client = new HttpClientImpl(url, locale);
1066 1066
1067 try { 1067 try {
1068 logger.debug("Do HTTP request now."); 1068 log.debug("Do HTTP request now.");
1069 1069
1070 Document response = (Document) client.doCollectionAction( 1070 Document response = (Document) client.doCollectionAction(
1071 remove, collection.identifier(), new DocumentResponseHandler()); 1071 remove, collection.identifier(), new DocumentResponseHandler());
1072 1072
1073 logger.debug( 1073 log.debug(
1074 "Finished HTTP request successfully. Parse Collection now."); 1074 "Finished HTTP request successfully. Parse Collection now.");
1075 logger.debug(XMLUtils.toString(response)); 1075 log.debug(XMLUtils.toString(response));
1076 1076
1077 Collection c = CollectionHelper.parseCollection(response); 1077 Collection c = CollectionHelper.parseCollection(response);
1078 1078
1079 if (c == null) { 1079 if (c == null) {
1080 throw new ServerException(ERROR_REMOVE_ARTIFACT); 1080 throw new ServerException(ERROR_REMOVE_ARTIFACT);
1081 } 1081 }
1082 1082
1083 return c; 1083 return c;
1084 } 1084 }
1085 catch (ConnectionException ce) { 1085 catch (ConnectionException ce) {
1086 logger.error(ce, ce); 1086 log.error(ce, ce);
1087 } 1087 }
1088 catch (Exception e) { 1088 catch (Exception e) {
1089 logger.error(e, e); 1089 log.error(e, e);
1090 } 1090 }
1091 throw new ServerException(ERROR_REMOVE_ARTIFACT); 1091 throw new ServerException(ERROR_REMOVE_ARTIFACT);
1092 } 1092 }
1093 } 1093 }
1094 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 1094 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org