'Aktor'-relevanten Code vom Filter in den Aktor verlegt
| | |
| | | public static final String JPG = ".jpg"; |
| | | public static final String JPEG = ".jpeg"; |
| | | public static final String PNG = ".png"; |
| | | |
| | | public void createImages(String baseDir, String fName, String uriStr) throws IOException { |
| | | if(uriStr.endsWith(ImageActor.JPG) || uriStr.endsWith(ImageActor.JPEG) || uriStr.endsWith(ImageActor.PNG)) { |
| | | File dir = new File(baseDir); |
| | | File imgfile = new File(dir, fName); |
| | | ImageActor actor = new ImageActor(); |
| | | if(uriStr.contains(ImageActor.TN)) { |
| | | actor.createImage(dir, fName, ImageActor.TN, 120, imgfile); |
| | | } else if(uriStr.contains(ImageActor.KL)) { |
| | | actor.createImage(dir, fName, ImageActor.KL, 240, imgfile); |
| | | } else if(uriStr.contains(ImageActor.SM)) { |
| | | actor.createImage(dir, fName, ImageActor.SM, 500, imgfile); |
| | | } else if(uriStr.contains(ImageActor.MT)) { |
| | | actor.createImage(dir, fName, ImageActor.MT, 700, imgfile); |
| | | } else if(uriStr.contains(ImageActor.GR)) { |
| | | actor.createImage(dir, fName, ImageActor.GR, 1200, imgfile); |
| | | } else if(uriStr.contains(ImageActor.B64)) { |
| | | File b64File = imgfile; |
| | | String fromName = fName.replace(ImageActor.B64, ""); |
| | | File fromfile = new File(dir, fromName); |
| | | actor.b64Image(fromfile, b64File); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Wenn b64 gewuenscht ist verweist tnfile auf dateiname_tn_b64.png Wenn b64 |
| | |
| | | @Override |
| | | public void doFilter(HttpExchange exchange, Chain chain) throws IOException { |
| | | String uriStr = exchange.getRequestURI().toString(); |
| | | //logger.fine(uriStr); |
| | | //String ctxPath = exchange.getHttpContext().getPath(); |
| | | //String uriPath = exchange.getRequestURI().getPath(); |
| | | //logger.fine(uriPath); |
| | | //String fName = uriPath.substring(ctxPath.length()); |
| | | String fName = new HttpHelper().getFileName(exchange); |
| | | //logger.fine(fName); |
| | | if(uriStr.endsWith(ImageActor.JPG) || uriStr.endsWith(ImageActor.JPEG) || uriStr.endsWith(ImageActor.PNG)) { |
| | | File dir = new File(exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString()); |
| | | File imgfile = new File(dir, fName); |
| | | ImageActor actor = new ImageActor(); |
| | | if(uriStr.contains(ImageActor.TN)) { |
| | | actor.createImage(dir, fName, ImageActor.TN, 120, imgfile); |
| | | } else if(uriStr.contains(ImageActor.KL)) { |
| | | actor.createImage(dir, fName, ImageActor.KL, 240, imgfile); |
| | | } else if(uriStr.contains(ImageActor.SM)) { |
| | | actor.createImage(dir, fName, ImageActor.SM, 500, imgfile); |
| | | } else if(uriStr.contains(ImageActor.MT)) { |
| | | actor.createImage(dir, fName, ImageActor.MT, 700, imgfile); |
| | | } else if(uriStr.contains(ImageActor.GR)) { |
| | | actor.createImage(dir, fName, ImageActor.GR, 1200, imgfile); |
| | | } else if(uriStr.contains(ImageActor.B64)) { |
| | | File b64File = imgfile; |
| | | String fromName = fName.replace(ImageActor.B64, ""); |
| | | File fromfile = new File(dir, fromName); |
| | | //be.bildErzeugen(dir, fName, BildErzeuger.GR, 1200, imgfile); |
| | | //logger.fine("from: " + fromfile.getAbsolutePath() + ", to: " + b64File.getAbsolutePath()); |
| | | actor.b64Image(fromfile, b64File); |
| | | } |
| | | } |
| | | ImageActor actor = new ImageActor(); |
| | | actor.createImages(exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), |
| | | fName, uriStr); |
| | | chain.doFilter(exchange); |
| | | } |
| | | |