[kune-commits] r1643 - in trunk/src: main/java/cc/kune/core/server/utils main/resources test/java/cc/kune/core/server test/java/cc/kune/core/server/utils
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Wed Dec 21 10:02:04 CET 2011
Author: vjrj_
Date: 2011-12-21 10:02:04 +0100 (Wed, 21 Dec 2011)
New Revision: 1643
Added:
trunk/src/main/resources/assembly.xml
trunk/src/test/java/cc/kune/core/server/utils/
trunk/src/test/java/cc/kune/core/server/utils/FilenameUtilsTest.java
Modified:
trunk/src/main/java/cc/kune/core/server/utils/FilenameUtils.java
Log:
CLOSED - # 78: Rename don't fails with a name with only a space
http://kune.ourproject.org/issues/ticket/78
Modified: trunk/src/main/java/cc/kune/core/server/utils/FilenameUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/utils/FilenameUtils.java 2011-12-20 17:27:01 UTC (rev 1642)
+++ trunk/src/main/java/cc/kune/core/server/utils/FilenameUtils.java 2011-12-21 09:02:04 UTC (rev 1643)
@@ -21,22 +21,31 @@
import org.apache.commons.lang.StringUtils;
+import cc.kune.common.client.utils.TextUtils;
import cc.kune.core.client.errors.NameNotPermittedException;
public class FilenameUtils {
- /**
- * Check filename is not empty, or '.', or '..'
- *
- * @param filename
- */
- public static void checkBasicFilename(final String filename) {
- if (filename == null || filename.length() == 0 || filename.equals(".") || filename.equals("..")) {
- throw new NameNotPermittedException();
- }
+ /**
+ * Check filename is not empty, or '.', or '..'
+ *
+ * @param filename
+ */
+ public static void checkBasicFilename(final String filename) {
+ if (TextUtils.empty(StringUtils.trimToEmpty(filename)) || filename.equals(".")
+ || filename.equals("..")) {
+ throw new NameNotPermittedException();
}
+ }
- public static String chomp(final String filename) {
- return StringUtils.chomp(filename);
- }
+ /**
+ * Chomp the filename using {@link StringUtils.chomp}
+ *
+ * @param filename
+ * the filename
+ * @return the filename chomped
+ */
+ public static String chomp(final String filename) {
+ return StringUtils.chomp(filename);
+ }
}
Added: trunk/src/main/resources/assembly.xml
===================================================================
--- trunk/src/main/resources/assembly.xml (rev 0)
+++ trunk/src/main/resources/assembly.xml 2011-12-21 09:02:04 UTC (rev 1643)
@@ -0,0 +1,30 @@
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>complete</id>
+ <formats>
+ <format>jar</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/</outputDirectory>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>true</unpack>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <!-- ${module.groupId}-${module.artifactId}-${module.version}.${module.extension} -->
+ <directory>target/kune-0.1.0-SNAPSHOT/ws/</directory>
+ <outputDirectory>META-INF/resources/ws</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/src/main/webapp/</directory>
+ <outputDirectory>META-INF/resources/webapp</outputDirectory>
+ <filtered>true</filtered>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
Added: trunk/src/test/java/cc/kune/core/server/utils/FilenameUtilsTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/utils/FilenameUtilsTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/utils/FilenameUtilsTest.java 2011-12-21 09:02:04 UTC (rev 1643)
@@ -0,0 +1,38 @@
+package cc.kune.core.server.utils;
+
+import org.junit.Test;
+
+import cc.kune.core.client.errors.NameNotPermittedException;
+
+public class FilenameUtilsTest {
+
+ @Test(expected = NameNotPermittedException.class)
+ public void testNoDot() {
+ FilenameUtils.checkBasicFilename(".");
+ }
+
+ @Test(expected = NameNotPermittedException.class)
+ public void testNoDoubleDot() {
+ FilenameUtils.checkBasicFilename("..");
+ }
+
+ @Test(expected = NameNotPermittedException.class)
+ public void testNoEmpty() {
+ FilenameUtils.checkBasicFilename("");
+ }
+
+ @Test(expected = NameNotPermittedException.class)
+ public void testNoNull() {
+ FilenameUtils.checkBasicFilename(null);
+ }
+
+ @Test(expected = NameNotPermittedException.class)
+ public void testNoReturn() {
+ FilenameUtils.checkBasicFilename("\n");
+ }
+
+ @Test(expected = NameNotPermittedException.class)
+ public void testNoSpace() {
+ FilenameUtils.checkBasicFilename(" ");
+ }
+}
More information about the kune-commits
mailing list