comparison flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java @ 1367:ab8eb2f544f2

Replaced stdout and stderr logging with log4j loggers in server classes. flys-client/trunk@3069 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 25 Oct 2011 12:31:15 +0000
parents a3c04eb326f3
children 0d3bbe4240b1
comparison
equal deleted inserted replaced
1366:d0eb2202ffbe 1367:ab8eb2f544f2
1 package de.intevation.flys.client.server; 1 package de.intevation.flys.client.server;
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.HashMap; 4 import java.util.HashMap;
5
6 import org.apache.log4j.Logger;
5 7
6 import de.intevation.flys.client.shared.exceptions.ServerException; 8 import de.intevation.flys.client.shared.exceptions.ServerException;
7 import de.intevation.flys.client.shared.model.Artifact; 9 import de.intevation.flys.client.shared.model.Artifact;
8 import de.intevation.flys.client.shared.model.Collection; 10 import de.intevation.flys.client.shared.model.Collection;
9 import de.intevation.flys.client.shared.model.Recommendation; 11 import de.intevation.flys.client.shared.model.Recommendation;
18 */ 20 */
19 public class LoadArtifactServiceImpl 21 public class LoadArtifactServiceImpl
20 extends ArtifactServiceImpl 22 extends ArtifactServiceImpl
21 implements LoadArtifactService 23 implements LoadArtifactService
22 { 24 {
25 private static final Logger logger =
26 Logger.getLogger(LoadArtifactServiceImpl.class);
27
28
23 public static final String ERROR_LOAD_ARTIFACT = "error_load_artifact"; 29 public static final String ERROR_LOAD_ARTIFACT = "error_load_artifact";
24 30
25 31
26 /** 32 /**
27 * Clones or creates a single artifact and adds it to a collection. 33 * Clones or creates a single artifact and adds it to a collection.
41 String factory, 47 String factory,
42 String url, 48 String url,
43 String locale 49 String locale
44 ) 50 )
45 throws ServerException { 51 throws ServerException {
46 System.out.println( 52 logger.info(
47 "LoadArtifactServiceImpl.load: " + recom.getMasterArtifact()); 53 "LoadArtifactServiceImpl.load: " + recom.getMasterArtifact());
48 54
49 // 1) Clone the Artifact specified in >>recom<< 55 // 1) Clone the Artifact specified in >>recom<<
50 Artifact clone = ArtifactHelper.createArtifact( 56 Artifact clone = ArtifactHelper.createArtifact(
51 url, locale, factory, recom); 57 url, locale, factory, recom);
52 58
53 if (clone != null) { 59 if (clone != null) {
54 System.out.println("Successfully create Artifact Clone. Add now!"); 60 logger.debug("Successfully create Artifact Clone. Add now!");
55 Collection c = CollectionHelper.addArtifact( 61 Collection c = CollectionHelper.addArtifact(
56 parent, clone, url, locale); 62 parent, clone, url, locale);
57 63
58 if (c != null) { 64 if (c != null) {
59 System.out.println("Successfully added Clone to Collection."); 65 logger.debug("Successfully added Clone to Collection.");
60 66
61 return clone; 67 return clone;
62 } 68 }
63 } 69 }
64 70
87 String factory, 93 String factory,
88 String url, 94 String url,
89 String locale 95 String locale
90 ) 96 )
91 throws ServerException { 97 throws ServerException {
92 System.out.println("LoadArtifactServiceImpl.loadMany"); 98 logger.debug("LoadArtifactServiceImpl.loadMany");
93 99
94 ArrayList<Artifact> artifacts = new ArrayList<Artifact>(); 100 ArrayList<Artifact> artifacts = new ArrayList<Artifact>();
95 HashMap<Recommendation, Artifact> cloneMap = 101 HashMap<Recommendation, Artifact> cloneMap =
96 new HashMap<Recommendation, Artifact>(); 102 new HashMap<Recommendation, Artifact>();
97 103
101 for (Recommendation recom : recoms) { 107 for (Recommendation recom : recoms) {
102 // Do not do two clones of two identical recommendations. 108 // Do not do two clones of two identical recommendations.
103 Artifact prevClone = cloneMap.get(recom); 109 Artifact prevClone = cloneMap.get(recom);
104 if (prevClone != null) { 110 if (prevClone != null) {
105 // Already cloned a recommendation like this. 111 // Already cloned a recommendation like this.
106 System.out.println("LoadArtifactServiceImpl: Avoid reclones, " 112 logger.debug("LoadArtifactServiceImpl: Avoid reclones, "
107 + "clone already exists."); 113 + "clone already exists.");
108 artifacts.add(prevClone); 114 artifacts.add(prevClone);
109 } 115 }
110 else { 116 else {
111 // Not already cloned. 117 // Not already cloned.
112 String realFactory = factory != null 118 String realFactory = factory != null
113 ? factory 119 ? factory
114 : recom.getFactory(); 120 : recom.getFactory();
115 121
116 System.out.println("One will be cloned with : " + realFactory); 122 logger.debug("One will be cloned with : " + realFactory);
117 123
118 Artifact clone = ArtifactHelper.createArtifact( 124 Artifact clone = ArtifactHelper.createArtifact(
119 url, locale, realFactory, recom); 125 url, locale, realFactory, recom);
120 126
121 if (clone != null) { 127 if (clone != null) {
122 System.out.println("LoadArtifactServiceImple: Successfully " 128 logger.debug("LoadArtifactServiceImple: Successfully "
123 + "loaded Artifact Clone."); 129 + "loaded Artifact Clone.");
124 Collection c = CollectionHelper.addArtifact( 130 Collection c = CollectionHelper.addArtifact(
125 parent, clone, url, locale); 131 parent, clone, url, locale);
126 132
127 if (c != null) { 133 if (c != null) {

http://dive4elements.wald.intevation.org