User: kz Date: 2008-03-05 17:28:42+0000 Modified: dba/reportdesign/java/com/sun/star/report/pentaho/DefaultNameGenerator.java
Log: INTEGRATION: CWS rptchart01_DEV300 (1.2.70); FILE MERGED 2008/02/21 09:57:23 oj 1.2.70.2: #i85225# fixes found with PMD 2008/02/13 07:04:22 oj 1.2.70.1: #i85225# impl chart readhandler and oleproducer File Changes: Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/ ============================================================== File [changed]: DefaultNameGenerator.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/DefaultNameGenerator.java?r1=1.2&r2=1.3 Delta lines: +109 -72 ---------------------- --- DefaultNameGenerator.java 2007-07-09 11:56:04+0000 1.2 +++ DefaultNameGenerator.java 2008-03-05 17:28:39+0000 1.3 @@ -33,8 +33,6 @@ * MA 02111-1307 USA * ************************************************************************/ - - package com.sun.star.report.pentaho; import java.io.IOException; @@ -43,6 +41,7 @@ public class DefaultNameGenerator { + private OutputRepository outputRepository; public DefaultNameGenerator(final OutputRepository outputRepository) @@ -54,6 +53,18 @@ this.outputRepository = outputRepository; } + public String generateName(final String namePrefix, final String mimeType) + throws IOException + { + return generateName(namePrefix, mimeType, true); + } + + public String generateStorageName(final String namePrefix, final String mimeType) + throws IOException + { + return generateName(namePrefix, mimeType, false); + } + /** * Generates a new, unique name for storing resources in the output repository. Assuming that proper synchronization * has been applied, the generated name will be unique within that repository. @@ -62,7 +73,7 @@ * @param mimeType the mime type of the resource to be stored in the repository. * @return the generated, fully qualified name. */ - public String generateName(final String namePrefix, final String mimeType) + private String generateName(final String namePrefix, final String mimeType, boolean isStream) throws IOException { final String name; @@ -75,9 +86,23 @@ name = "file"; } - final String suffix = getSuffixForType(mimeType); - final String firstFileName = name + "." + suffix; - if (outputRepository.exists(firstFileName) == false) + String firstFileName = name; + String suffix = null; + if (mimeType != null) + { + suffix = getSuffixForType(mimeType); + firstFileName += "." + suffix; + } + boolean exists = false; + if (isStream) + { + exists = outputRepository.exists(firstFileName); + } + else + { + exists = outputRepository.existsStorage(firstFileName); + } + if (exists == false) { return firstFileName; } @@ -88,8 +113,20 @@ { throw new IOException(); } - final String filename = name + counter + "." + suffix; - if (outputRepository.exists(filename) == false) + String filename = name + counter; + if (suffix != null) + { + filename += "." + suffix; + } + if (isStream) + { + exists = outputRepository.exists(filename); + } + else + { + exists = outputRepository.existsStorage(filename); + } + if (exists == false) { return filename; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
