Author: chrisg
Date: Tue May 26 16:11:43 2009 New Revision: 778786 URL: http://svn.apache.org/viewvc?rev=778786&view=rev Log: fixed eol-style Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java (contents, props changed) ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java (contents, props changed) ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java (contents, props changed) ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ProtectViewWorker.java (contents, props changed) Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java?rev=778786&r1=778785&r2=778786&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java Tue May 26 16:11:43 2009 @@ -13,11 +13,11 @@ * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations + * specific language governing permissions and limitations * under the License. *******************************************************************************/ package org.ofbiz.content.output; - + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -29,7 +29,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; - + import javax.print.Doc; import javax.print.DocFlavor; import javax.print.DocPrintJob; @@ -46,7 +46,7 @@ import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.PrinterName; import javax.xml.transform.stream.StreamSource; - + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilProperties; @@ -58,30 +58,30 @@ import org.ofbiz.widget.fo.FoFormRenderer; import org.ofbiz.widget.fo.FoScreenRenderer; import org.ofbiz.widget.screen.ScreenRenderer; - + import javolution.util.FastMap; import org.apache.fop.apps.Fop; import org.apache.fop.apps.MimeConstants; - - + + /** - * Output Services + * Output Services */ public class OutputServices { - + public final static String module = OutputServices.class.getName(); - + protected static final FoScreenRenderer foScreenRenderer = new FoScreenRenderer(); protected static final FoFormRenderer foFormRenderer = new FoFormRenderer(); - + public static Map<String, Object> sendPrintFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) { - + Locale locale = (Locale) serviceContext.get("locale"); String screenLocation = (String) serviceContext.remove("screenLocation"); Map screenContext = (Map) serviceContext.remove("screenContext"); String contentType = (String) serviceContext.remove("contentType"); String printerContentType = (String) serviceContext.remove("printerContentType"); - + if (UtilValidate.isEmpty(screenContext)) { screenContext = FastMap.newInstance(); } @@ -92,12 +92,12 @@ if (UtilValidate.isEmpty(printerContentType)) { printerContentType = contentType; } - + try { - + MapStack screenContextTmp = MapStack.create(); screenContextTmp.put("locale", locale); - + Writer writer = new StringWriter(); // substitute the freemarker variables... ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenRenderer); @@ -105,23 +105,23 @@ screenContextTmp.putAll(screenContext); screensAtt.getContext().put("formStringRenderer", foFormRenderer); screensAtt.render(screenLocation); - + // create the input stream for the generation StreamSource src = new StreamSource(new StringReader(writer.toString())); - + // create the output stream for the generation ByteArrayOutputStream baos = new ByteArrayOutputStream(); - + Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF); ApacheFopWorker.transform(src, null, fop); - + baos.flush(); baos.close(); - + // Print is sent DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType); InputStream bais = new ByteArrayInputStream(baos.toByteArray()); - + DocAttributeSet docAttributeSet = new HashDocAttributeSet(); List docAttributes = (List) serviceContext.remove("docAttributes"); if (UtilValidate.isNotEmpty(docAttributes)) { @@ -130,18 +130,18 @@ docAttributeSet.add((DocAttribute) da); } } - + Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet); - + PrintService printer = null; - + // lookup the print service for the supplied printer name String printerName = (String) serviceContext.remove("printerName"); if (UtilValidate.isNotEmpty(printerName)) { - + PrintServiceAttributeSet printServiceAttributes = new HashPrintServiceAttributeSet(); printServiceAttributes.add(new PrinterName(printerName, locale)); - + PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, printServiceAttributes); if (printServices.length > 0) { printer = printServices[0]; @@ -153,21 +153,21 @@ if (printer == null) { return ServiceUtil.returnError("No printer found with name: " + printerName); } - + } else { - + // if no printer name was supplied, try to get the default printer printer = PrintServiceLookup.lookupDefaultPrintService(); if (printer != null) { Debug.logInfo("No printer name supplied, using default printer: " + printer.getName(), module); } } - + if (printer == null) { return ServiceUtil.returnError("No printer available"); } - - + + PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet(); List printRequestAttributes = (List) serviceContext.remove("printRequestAttributes"); if (UtilValidate.isNotEmpty(printRequestAttributes)) { @@ -178,26 +178,26 @@ } DocPrintJob job = printer.createPrintJob(); job.print(myDoc, praset); - - + + } catch (Exception e) { String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - + return ServiceUtil.returnSuccess(); } - + public static Map<String, Object> createFileFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) { - + Locale locale = (Locale) serviceContext.get("locale"); String screenLocation = (String) serviceContext.remove("screenLocation"); Map screenContext = (Map) serviceContext.remove("screenContext"); String contentType = (String) serviceContext.remove("contentType"); String filePath = (String) serviceContext.remove("filePath"); String fileName = (String) serviceContext.remove("fileName"); - + if (UtilValidate.isEmpty(screenContext)) { screenContext = FastMap.newInstance(); } @@ -205,11 +205,11 @@ if (UtilValidate.isEmpty(contentType)) { contentType = "application/pdf"; } - + try { MapStack screenContextTmp = MapStack.create(); screenContextTmp.put("locale", locale); - + Writer writer = new StringWriter(); // substitute the freemarker variables... ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenRenderer); @@ -217,19 +217,19 @@ screenContextTmp.putAll(screenContext); screensAtt.getContext().put("formStringRenderer", foFormRenderer); screensAtt.render(screenLocation); - + // create the input stream for the generation StreamSource src = new StreamSource(new StringReader(writer.toString())); - + // create the output stream for the generation ByteArrayOutputStream baos = new ByteArrayOutputStream(); - + Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF); ApacheFopWorker.transform(src, null, fop); - + baos.flush(); baos.close(); - + fileName += UtilDateTime.nowAsString(); if ("application/pdf".equals(contentType)) { fileName += ".pdf"; @@ -242,18 +242,18 @@ filePath = UtilProperties.getPropertyValue("content.properties", "content.output.path", "/output"); } File file = new File(filePath, fileName); - + FileOutputStream fos = new FileOutputStream(file); fos.write(baos.toByteArray()); fos.close(); - + } catch (Exception e) { String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - + return ServiceUtil.returnSuccess(); } - + } Propchange: ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java?rev=778786&r1=778785&r2=778786&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java Tue May 26 16:11:43 2009 @@ -13,11 +13,11 @@ * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations + * specific language governing permissions and limitations * under the License. *******************************************************************************/ package org.ofbiz.product.image; - + import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; @@ -29,11 +29,11 @@ import java.util.List; import java.util.Locale; import java.util.Map; - + import javax.imageio.ImageIO; - + import javolution.util.FastMap; - + import org.jdom.JDOMException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; @@ -41,30 +41,30 @@ import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.service.ServiceUtil; import org.ofbiz.common.image.ImageTransform; - + /** - * ScaleImage Class + * ScaleImage Class * <p> * Scale the original image into 4 different size Types (small, medium, large, detail) */ public class ScaleImage { - + public static final String module = ScaleImage.class.getName(); public static final String resource = "ProductErrorUiLabels"; - + public ScaleImage() { } - + /** * scaleImageInAllSize * <p> * Scale the original image into all different size Types (small, medium, large, detail) * * @param context Context - * @param filenameToUse Filename of future image files + * @param filenameToUse Filename of future image files * @param viewType "Main" view or "additional" view * @param viewNumber If it's the main view, viewNumber = "0" - * @return URL images for all different size types + * @return URL images for all different size types * @throws IllegalArgumentException Any parameter is null * @throws ImagingOpException The transform is non-invertible * @throws IOException Error prevents the document from being fully parsed @@ -72,7 +72,7 @@ */ public static Map<String, Object> scaleImageInAllSize(Map<String, ? extends Object> context, String filenameToUse, String viewType, String viewNumber) throws IllegalArgumentException, ImagingOpException, IOException, JDOMException { - + /* VARIABLES */ Locale locale = (Locale) context.get("locale"); List<String> sizeTypeList = UtilMisc.toList("small", "medium", "large", "detail"); @@ -86,7 +86,7 @@ Map<String, Object> resultBufImgMap = FastMap.newInstance(); Map<String, Object> resultScaleImgMap = FastMap.newInstance(); Map<String, Object> result = FastMap.newInstance(); - + /* ImageProperties.xml */ String imgPropertyFullPath = System.getProperty("ofbiz.home") + "/applications/product/config/ImageProperties.xml"; resultXMLMap.putAll((Map<String, Object>) ImageTransform.getXMLValue(imgPropertyFullPath, locale)); @@ -98,17 +98,17 @@ result.put("errorMessage", errMsg); return result; } - + /* IMAGE */ // get Name and Extension index = filenameToUse.lastIndexOf("."); String imgName = filenameToUse.substring(0, index - 1); String imgExtension = filenameToUse.substring(index + 1); - // paths + // paths String mainFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format"); String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context); String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix"); - + String id = null; String type = null; if (viewType.toLowerCase().contains("main")) { @@ -126,15 +126,15 @@ if (fileLocation.lastIndexOf("/") != -1) { filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash } - - - + + + /* get original BUFFERED IMAGE */ resultBufImgMap.putAll(ImageTransform.getBufferedImage(imageServerPath + "/" + filePathPrefix + filenameToUse, locale)); - + if (resultBufImgMap.containsKey("responseMessage") && resultBufImgMap.get("responseMessage").equals("success")) { bufImg = (BufferedImage) resultBufImgMap.get("bufferedImage"); - + // get Dimensions imgHeight = (double) bufImg.getHeight(); imgWidth = (double) bufImg.getWidth(); @@ -144,26 +144,26 @@ result.put("errorMessage", errMsg); return result; } - + // new Filename Format FlexibleStringExpander addFilenameExpander = mainFilenameExpander; if (viewType.toLowerCase().contains("additional")) { String addFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.additionalviewsize.format"); addFilenameExpander = FlexibleStringExpander.getInstance(addFilenameFormat); } - + /* scale Image for each Size Type */ Iterator<String> sizeIter = sizeTypeList.iterator(); while (sizeIter.hasNext()) { String sizeType = sizeIter.next(); - + resultScaleImgMap.putAll(ImageTransform.scaleImage(bufImg, imgHeight, imgWidth, imgPropertyMap, sizeType, locale)); - + if (resultScaleImgMap.containsKey("responseMessage") && resultScaleImgMap.get("responseMessage").equals("success")) { bufNewImg = (BufferedImage) resultScaleImgMap.get("bufferedImage"); Double scaleFactorDb = (Double) resultScaleImgMap.get("scaleFactor"); scaleFactor = scaleFactorDb.doubleValue(); - + // define Interpolation Map<RenderingHints.Key, Object> rhMap = FastMap.newInstance(); rhMap.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); @@ -176,12 +176,12 @@ rhMap.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); rhMap.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); RenderingHints rh = new RenderingHints(rhMap); - + /* IMAGE TRANFORMATION */ AffineTransform tx = new AffineTransform(); tx.scale(scaleFactor, scaleFactor); - - + + try { op = new AffineTransformOp(tx, rh); } catch (ImagingOpException e) { @@ -190,7 +190,7 @@ result.put("errorMessage", errMsg); return result; } - + // write the New Scaled Image String newFileLocation = null; if (viewType.toLowerCase().contains("main")) { @@ -202,7 +202,7 @@ if (newFileLocation.lastIndexOf("/") != -1) { newFilePathPrefix = newFileLocation.substring(0, newFileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash } - + String targetDirectory = imageServerPath + "/" + newFilePathPrefix; File targetDir = new File(targetDirectory); if (!targetDir.exists()) { @@ -213,7 +213,7 @@ return ServiceUtil.returnError(errMsg); } } - + // write new image try { ImageIO.write(op.filter(bufImg, bufNewImg), imgExtension, new File(imageServerPath + "/" + newFilePathPrefix + filenameToUse)); @@ -228,19 +228,19 @@ result.put("errorMessage", errMsg); return result; } - + /* write Return Result */ String imageUrl = imageUrlPrefix + "/" + newFilePathPrefix + filenameToUse; imgUrlMap.put(sizeType, imageUrl); - + } // scaleImgMap } // sizeIter - + result.put("responseMessage", "success"); result.put("imageUrlMap", imgUrlMap); result.put("original", resultBufImgMap); return result; - + } else { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_scale_original_image", locale) + " : " + filenameToUse; Debug.logError(errMsg, module); Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java?rev=778786&r1=778785&r2=778786&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java Tue May 26 16:11:43 2009 @@ -13,11 +13,11 @@ * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations + * specific language governing permissions and limitations * under the License. *******************************************************************************/ package org.ofbiz.common.image; - + import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; @@ -25,12 +25,12 @@ import java.util.List; import java.util.Locale; import java.util.Map; - + import javax.imageio.ImageIO; import javax.xml.parsers.ParserConfigurationException; - + import javolution.util.FastMap; - + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilXml; @@ -40,21 +40,21 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; - - + + /** - * ImageTransform Class + * ImageTransform Class * <p> - * Services to apply transformation to images + * Services to apply transformation to images */ public class ImageTransform { - + public static final String module = ImageTransform.class.getName(); public static final String resource = "CommonErrorUiLabels"; - + public ImageTransform() { } - + /** * getBufferedImage * <p> @@ -62,17 +62,17 @@ * * @param context * @param fileLocation Full file Path or URL - * @return URL images for all different size types + * @return URL images for all different size types * @throws IOException Error prevents the document from being fully parsed * @throws JDOMException Errors occur in parsing */ public static Map<String, Object> getBufferedImage(String fileLocation, Locale locale) throws IllegalArgumentException, IOException { - + /* VARIABLES */ BufferedImage bufImg; Map<String, Object> result = FastMap.newInstance(); - + /* BUFFERED IMAGE */ try { bufImg = ImageIO.read(new File(fileLocation)); @@ -87,17 +87,17 @@ result.put("errorMessage", errMsg); return result; } - + result.put("responseMessage", "success"); result.put("bufferedImage", bufImg); return result; - + } - + /** * scaleImage * <p> - * scale original image related to the ImageProperties.xml dimensions + * scale original image related to the ImageProperties.xml dimensions * * @param bufImg Buffered image to scale * @param imgHeight Original image height @@ -107,12 +107,12 @@ * @return New scaled buffered image */ public static Map<String, Object> scaleImage(BufferedImage bufImg, double imgHeight, double imgWidth, Map<String, Map<String, String>> dimensionMap, String sizeType, Locale locale) { - + /* VARIABLES */ BufferedImage bufNewImg; double defaultHeight, defaultWidth, scaleFactor; Map<String, Object> result = FastMap.newInstance(); - + /* DIMENSIONS from ImageProperties */ defaultHeight = Double.parseDouble(dimensionMap.get(sizeType).get("height").toString()); defaultWidth = Double.parseDouble(dimensionMap.get(sizeType).get("width").toString()); @@ -122,9 +122,9 @@ result.put("errorMessage", errMsg); return result; } - + /* SCALE FACTOR */ - // find the right Scale Factor related to the Image Dimensions + // find the right Scale Factor related to the Image Dimensions if (imgHeight > imgWidth) { scaleFactor = defaultHeight / imgHeight; if (scaleFactor == 0.0) { @@ -150,7 +150,7 @@ scaleFactor = defaultHeight / imgHeight; } } - + if (scaleFactor == 0.0) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.final_scale_factor_is_null", locale) + " = " + scaleFactor; Debug.logError(errMsg, module); @@ -166,16 +166,16 @@ } else { bufImgType = bufImg.getType(); } - + bufNewImg = new BufferedImage( (int) (imgWidth * scaleFactor), (int) (imgHeight * scaleFactor), bufImgType); - + result.put("responseMessage", "success"); result.put("bufferedImage", bufNewImg); result.put("scaleFactor", scaleFactor); return result; - + } - + /** * getXMLValue * <p> @@ -186,13 +186,13 @@ */ public static Map<String, Object> getXMLValue(String fileFullPath, Locale locale) throws IllegalStateException, IOException { - + /* VARIABLES */ Document document; Element rootElt; Map<String, Map<String, String>> valueMap = FastMap.newInstance(); Map<String, Object> result = FastMap.newInstance(); - + /* PARSING */ try { document = UtilXml.readXmlDocument(new FileInputStream(fileFullPath), fileFullPath); @@ -221,7 +221,7 @@ result.put("errorMessage", "error"); return result; } - + /* get NAME and VALUE */ List<? extends Element> children = UtilXml.childElementList(rootElt); // FIXME : despite upgrading to jdom 1.1, it seems that getChildren is pre 1.5 java code (ie getChildren does not retun List<Element> but only List) for (Element currentElt : children) { @@ -239,10 +239,10 @@ valueMap.put(currentElt.getNodeName(), eltMap); } } - + result.put("responseMessage", "success"); result.put("xml", valueMap); return result; - + } } Propchange: ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ProtectViewWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ProtectViewWorker.java?rev=778786&r1=778785&r2=778786&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ProtectViewWorker.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ProtectViewWorker.java Tue May 26 16:11:43 2009 @@ -13,20 +13,20 @@ * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations + * specific language governing permissions and limitations * under the License. *******************************************************************************/ package org.ofbiz.webapp.control; - + import java.util.List; import java.util.Map; - + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; - + import javolution.util.FastMap; - + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; @@ -36,9 +36,9 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.service.ServiceUtil; - + /** - * Common Workers + * Common Workers */ public class ProtectViewWorker { @@ -110,7 +110,7 @@ tarpittedLoginView.set("userLoginId", userLoginId); tarpittedLoginView.set("viewNameId", viewNameId); tarpittedLoginView.set("tarpitReleaseDateTime", now + tarpitDuration); - + try { delegator.createOrStore(tarpittedLoginView); } catch (GenericEntityException e) { Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ProtectViewWorker.java ------------------------------------------------------------------------------ svn:eol-style = native |
Free forum by Nabble | Edit this page |