comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/HWSBarriersState.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents a56fe3bc6700
children 5e38e2924c07
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
35 35
36 public class HWSBarriersState 36 public class HWSBarriersState
37 extends DefaultState 37 extends DefaultState
38 { 38 {
39 39
40 /** The logger that is used in this class.*/ 40 /** The log that is used in this class.*/
41 private static Logger logger = Logger.getLogger(HWSBarriersState.class); 41 private static Logger log = Logger.getLogger(HWSBarriersState.class);
42 private static final String HWS_SHAPEFILE_LINES = "hws-lines.shp"; 42 private static final String HWS_SHAPEFILE_LINES = "hws-lines.shp";
43 private static final String HWS_SHAPEFILE_POINTS = "hws-points.shp"; 43 private static final String HWS_SHAPEFILE_POINTS = "hws-points.shp";
44 44
45 45
46 @Override 46 @Override
81 Object old 81 Object old
82 ) { 82 ) {
83 File artifactDir = getDirectory(artifact); 83 File artifactDir = getDirectory(artifact);
84 84
85 if (artifactDir == null) { 85 if (artifactDir == null) {
86 logger.error("Could not create directory for HWS shapefile!"); 86 log.error("Could not create directory for HWS shapefile!");
87 return null; 87 return null;
88 } 88 }
89 89
90 MapAccess access = new MapAccess(artifact); 90 MapAccess access = new MapAccess(artifact);
91 String river = access.getRiverName(); 91 String river = access.getRiverName();
164 epsg = 164 epsg =
165 proj.substring(proj.indexOf("EPSG\",\"") + 7, 165 proj.substring(proj.indexOf("EPSG\",\"") + 7,
166 proj.indexOf("\"]]")); 166 proj.indexOf("\"]]"));
167 } 167 }
168 else { 168 else {
169 logger.warn("Could not read EPSG code from shapefile."); 169 log.warn("Could not read EPSG code from shapefile.");
170 return null; 170 return null;
171 } 171 }
172 if (type.contains("Line")) { 172 if (type.contains("Line")) {
173 type = "LINE"; 173 type = "LINE";
174 } 174 }
186 type, 186 type,
187 epsg, 187 epsg,
188 FloodMapState.WSPLGEN_USER_RGD); 188 FloodMapState.WSPLGEN_USER_RGD);
189 } 189 }
190 catch (IOException e) { 190 catch (IOException e) {
191 logger.warn("No mapfile for user-rgd created!"); 191 log.warn("No mapfile for user-rgd created!");
192 } 192 }
193 } 193 }
194 } 194 }
195 return null; 195 return null;
196 } 196 }
197 197
198 private boolean extractUserShp(File dir) { 198 private boolean extractUserShp(File dir) {
199 File archive = new File(dir, FloodMapState.WSPLGEN_USER_RGD_ZIP); 199 File archive = new File(dir, FloodMapState.WSPLGEN_USER_RGD_ZIP);
200 boolean exists = archive.exists(); 200 boolean exists = archive.exists();
201 logger.debug("Zip file exists: " + exists); 201 log.debug("Zip file exists: " + exists);
202 if (exists) { 202 if (exists) {
203 try { 203 try {
204 File tmpDir = new File(dir, "usr_tmp"); 204 File tmpDir = new File(dir, "usr_tmp");
205 FileTools.extractArchive(archive, tmpDir); 205 FileTools.extractArchive(archive, tmpDir);
206 moveFiles(tmpDir, dir); 206 moveFiles(tmpDir, dir);
207 return true; 207 return true;
208 } 208 }
209 catch (IOException ioe) { 209 catch (IOException ioe) {
210 logger.warn("Zip archive " + dir + "/" 210 log.warn("Zip archive " + dir + "/"
211 + FloodMapState.WSPLGEN_USER_RGD_ZIP + " could not be extracted."); 211 + FloodMapState.WSPLGEN_USER_RGD_ZIP + " could not be extracted.");
212 return false; 212 return false;
213 } 213 }
214 } 214 }
215 return false; 215 return false;
239 } 239 }
240 try { 240 try {
241 FileTools.copyFile(file, new File(target, FloodMapState.WSPLGEN_USER_RGD + "." + suffix)); 241 FileTools.copyFile(file, new File(target, FloodMapState.WSPLGEN_USER_RGD + "." + suffix));
242 } 242 }
243 catch (IOException ioe) { 243 catch (IOException ioe) {
244 logger.warn ("Error while copying file " + file.getName()); 244 log.warn ("Error while copying file " + file.getName());
245 return true; 245 return true;
246 } 246 }
247 } 247 }
248 return true; 248 return true;
249 } 249 }
254 254
255 255
256 @Override 256 @Override
257 public void endOfLife(Artifact artifact, Object callContext) { 257 public void endOfLife(Artifact artifact, Object callContext) {
258 super.endOfLife(artifact, callContext); 258 super.endOfLife(artifact, callContext);
259 logger.info("ScenarioSelect.endOfLife: " + artifact.identifier()); 259 log.info("ScenarioSelect.endOfLife: " + artifact.identifier());
260 260
261 D4EArtifact flys = (D4EArtifact) artifact; 261 D4EArtifact flys = (D4EArtifact) artifact;
262 removeDirectory(flys); 262 removeDirectory(flys);
263 } 263 }
264 264
273 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); 273 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR);
274 274
275 File artifactDir = new File(shapePath, artifact.identifier()); 275 File artifactDir = new File(shapePath, artifact.identifier());
276 276
277 if (artifactDir.exists()) { 277 if (artifactDir.exists()) {
278 logger.debug("Delete directory: " + artifactDir.getAbsolutePath()); 278 log.debug("Delete directory: " + artifactDir.getAbsolutePath());
279 boolean success = FileTools.deleteRecursive(artifactDir); 279 boolean success = FileTools.deleteRecursive(artifactDir);
280 if (!success) { 280 if (!success) {
281 logger.warn("could not remove dir '" + artifactDir + "'"); 281 log.warn("could not remove dir '" + artifactDir + "'");
282 } 282 }
283 } 283 }
284 else { 284 else {
285 logger.debug("There is no directory to remove."); 285 log.debug("There is no directory to remove.");
286 } 286 }
287 } 287 }
288 288
289 /** 289 /**
290 * Returns (and creates if not existing) the directory for storing WSPLEN 290 * Returns (and creates if not existing) the directory for storing WSPLEN

http://dive4elements.wald.intevation.org