[kune-commits] r884 - in trunk: . src/main/java/org/ourproject/kune/docs/client/ctx src/main/java/org/ourproject/kune/platf/client/dto src/main/java/org/ourproject/kune/platf/client/services src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload src/main/java/org/ourproject/kune/platf/server/domain src/main/java/org/ourproject/kune/platf/server/manager src/main/java/org/ourproject/kune/platf/server/manager/impl src/main/java/org/ourproject/kune/workspace/client/ctxnav src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload src/test/java/org/ourproject/kune/platf/server/manager/impl

vjrj vjrj at ourproject.org
Thu Sep 25 00:54:17 CEST 2008


Author: vjrj
Date: 2008-09-25 00:54:07 +0200 (Thu, 25 Sep 2008)
New Revision: 884

Modified:
   trunk/pom.xml
   trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java
   trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java
   trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java
   trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java
   trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUtils.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
   trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java
   trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUtilsTest.java
Log:
Complete - task 68: File upload content persist 


Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/pom.xml	2008-09-24 22:54:07 UTC (rev 884)
@@ -247,6 +247,11 @@
 			<version>2.4</version>
 			<scope>provided</scope>
 		</dependency>
+		<dependency>
+			<groupId>jmimemagic</groupId>
+			<artifactId>jmimemagic</artifactId>
+			<version>0.1.2</version>
+		</dependency>
 
 		<!-- testing dependencies -->
 		<dependency>
@@ -283,7 +288,6 @@
 		</dependency>
 	</dependencies>
 
-
 	<!-- http://gwt-maven.googlecode.com/svn/docs/maven-googlewebtoolkit2-plugin/index.html -->
 	<repositories>
 		<repository>

Modified: trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/ctx/DocumentContextPresenter.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -61,7 +61,7 @@
     }
 
     private void setState(final StateDTO state) {
-	contextNavigatorProvider.get().setState(state);
+	contextNavigatorProvider.get().setState(state, true);
 	adminContextProvider.get().setState(state);
 	showFolders();
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -30,11 +30,16 @@
     private StateToken stateToken;
     private ContentStatusDTO status;
     private AccessRightsDTO rights;
+    private String mimeType;
 
     public Long getId() {
 	return id;
     }
 
+    public String getMimeType() {
+	return mimeType;
+    }
+
     public AccessRightsDTO getRights() {
 	return rights;
     }
@@ -59,6 +64,10 @@
 	this.id = id;
     }
 
+    public void setMimeType(final String mimeType) {
+	this.mimeType = mimeType;
+    }
+
     public void setRights(final AccessRightsDTO rights) {
 	this.rights = rights;
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -349,7 +349,8 @@
 
 	register(Singleton.class, new Factory<FileUploader>(FileUploader.class) {
 	    public FileUploader create() {
-		final FileUploaderPresenter presenter = new FileUploaderPresenter($(Session.class));
+		final FileUploaderPresenter presenter = new FileUploaderPresenter($(Session.class),
+			$$(ContextNavigator.class));
 		final FileUploaderDialog panel = new FileUploaderDialog(presenter, i18n, $(WorkspaceSkeleton.class));
 		presenter.init(panel);
 		return presenter;

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -13,6 +13,7 @@
 import com.gwtext.client.core.UrlParam;
 import com.gwtext.client.widgets.Button;
 import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.Window;
 import com.gwtext.client.widgets.event.ButtonListenerAdapter;
 import com.gwtextux.client.widgets.upload.UploadDialog;
 import com.gwtextux.client.widgets.upload.UploadDialogListenerAdapter;
@@ -111,6 +112,9 @@
 	dialog.setId(SITE_FILE_UPLOADER);
 	// dialog.setUploadAutostart(true);
 	dialog.setResetOnHide(false);
+	dialog.setAllowCloseOnUpload(true);
+	dialog.setCloseAction(Window.HIDE);
+
 	dialog.addListener(new UploadDialogListenerAdapter() {
 	    @Override
 	    public boolean onBeforeAdd(final UploadDialog source, final String filename) {
@@ -128,6 +132,7 @@
 		    traybarButton.destroy();
 		    traybarButton = null;
 		}
+		presenter.onUploadComplete();
 	    }
 
 	    @Override

Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -2,7 +2,9 @@
 
 import org.ourproject.kune.platf.client.dto.StateToken;
 import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
 
+import com.calclab.suco.client.ioc.Provider;
 import com.calclab.suco.client.listener.Listener0;
 
 public class FileUploaderPresenter implements FileUploader {
@@ -10,9 +12,11 @@
     private FileUploaderView view;
     private final Session session;
     private StateToken currentUploadStateToken;
+    private final Provider<ContextNavigator> navProvider;
 
-    public FileUploaderPresenter(final Session session) {
+    public FileUploaderPresenter(final Session session, final Provider<ContextNavigator> navProvider) {
 	this.session = session;
+	this.navProvider = navProvider;
     }
 
     public boolean checkFolderChange() {
@@ -47,6 +51,10 @@
 	});
     }
 
+    public void onUploadComplete() {
+	navProvider.get().refresh(currentUploadStateToken);
+    }
+
     public void resetPermittedExtensions() {
 	view.resetPermittedExtensions();
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -118,6 +118,8 @@
     @Column(nullable = false)
     private ContentStatus status;
 
+    private String mimeType;
+
     public Content() {
 	translations = new ArrayList<ContentTranslation>();
 	authors = new ArrayList<User>();
@@ -191,6 +193,10 @@
 	return license;
     }
 
+    public String getMimeType() {
+	return mimeType;
+    }
+
     public Group getOwner(final Group group) {
 	return container.getOwner();
     }
@@ -293,6 +299,10 @@
 	this.license = license;
     }
 
+    public void setMimeType(final String mimeType) {
+	this.mimeType = mimeType;
+    }
+
     public void setPublishedOn(final Date publishedOn) {
 	this.publishedOn = publishedOn;
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -3,6 +3,11 @@
 import java.io.File;
 import java.io.IOException;
 
+import net.sf.jmimemagic.MagicException;
+import net.sf.jmimemagic.MagicMatch;
+import net.sf.jmimemagic.MagicMatchNotFoundException;
+import net.sf.jmimemagic.MagicParseException;
+
 public interface FileManager {
 
     /**
@@ -18,6 +23,8 @@
      */
     File createFileWithSequentialName(String dir, String fileName) throws IOException;
 
+    MagicMatch getMimeType(File file) throws MagicParseException, MagicMatchNotFoundException, MagicException;
+
     /**
      * @param dir
      *                the directory (use File.separator for dir delimiters)

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -3,6 +3,12 @@
 import java.io.File;
 import java.io.IOException;
 
+import net.sf.jmimemagic.Magic;
+import net.sf.jmimemagic.MagicException;
+import net.sf.jmimemagic.MagicMatch;
+import net.sf.jmimemagic.MagicMatchNotFoundException;
+import net.sf.jmimemagic.MagicParseException;
+
 import org.ourproject.kune.platf.server.manager.FileManager;
 
 import com.google.inject.Singleton;
@@ -21,6 +27,11 @@
 	return file;
     }
 
+    public MagicMatch getMimeType(final File file) throws MagicParseException, MagicMatchNotFoundException,
+	    MagicException {
+	return Magic.getMagicMatch(file, true);
+    }
+
     public boolean mkdir(final String dir) {
 	return (new File(dir)).mkdirs();
     }

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -12,6 +12,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import net.sf.jmimemagic.MagicMatch;
 import net.sf.json.JSONObject;
 
 import org.apache.commons.fileupload.FileItem;
@@ -20,19 +21,27 @@
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.ourproject.kune.docs.server.DocumentServerTool;
 import org.ourproject.kune.platf.client.dto.StateToken;
 import org.ourproject.kune.platf.client.services.I18nTranslationService;
 import org.ourproject.kune.platf.client.ui.dialogs.upload.FileUploader;
+import org.ourproject.kune.platf.server.UserSession;
 import org.ourproject.kune.platf.server.access.AccessRol;
+import org.ourproject.kune.platf.server.access.AccessService;
 import org.ourproject.kune.platf.server.auth.ActionLevel;
 import org.ourproject.kune.platf.server.auth.Authenticated;
 import org.ourproject.kune.platf.server.auth.Authorizated;
 import org.ourproject.kune.platf.server.content.ContentManager;
+import org.ourproject.kune.platf.server.domain.Container;
+import org.ourproject.kune.platf.server.domain.Content;
+import org.ourproject.kune.platf.server.domain.User;
 import org.ourproject.kune.platf.server.manager.FileManager;
 import org.ourproject.kune.platf.server.properties.KuneProperties;
 
 import com.google.inject.Inject;
 import com.google.inject.servlet.RequestScoped;
+import com.wideplay.warp.persist.TransactionType;
+import com.wideplay.warp.persist.Transactional;
 
 @RequestScoped
 public class FileUploadManager extends HttpServlet {
@@ -44,8 +53,12 @@
     @Inject
     KuneProperties kuneProperties;
     @Inject
+    UserSession userSession;
+    @Inject
     ContentManager contentManager;
     @Inject
+    AccessService accessService;
+    @Inject
     FileManager fileManager;
     @Inject
     I18nTranslationService i18n;
@@ -114,20 +127,30 @@
 
     @Authenticated
     @Authorizated(accessRolRequired = AccessRol.Editor, actionLevel = ActionLevel.container)
+    @Transactional(type = TransactionType.READ_WRITE)
     JSONObject createFile(final String userHash, final StateToken stateToken, final String fileName,
 	    final FileItem fileUploadItem) throws Exception {
-	final String destDir = calculateUploadDirLocation(stateToken);
-	fileManager.mkdir(destDir);
-	final File file = fileManager.createFileWithSequentialName(destDir, fileName);
+	final String relDir = calculateUploadDirLocation(stateToken);
+	final String absDir = kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + relDir;
+	fileManager.mkdir(absDir);
+	final File file = fileManager.createFileWithSequentialName(absDir, fileName);
 	fileUploadItem.write(file);
-	fileUploadItem.getContentType();
-	// here ContentManager code
+	final MagicMatch magic = fileManager.getMimeType(file);
+
+	// Persist
+	final User user = userSession.getUser();
+	final Container container = accessService.accessToContainer(new Long(stateToken.getFolder()), user,
+		AccessRol.Editor);
+	final Content content = contentManager.createContent(FileUtils.getFileNameWithoutExtension(file.getName(),
+		magic.getExtension()), relDir + File.separator + file.getName(), user, container);
+	content.setTypeId(DocumentServerTool.TYPE_UPLOADEDFILE);
+	content.setMimeType(magic.getMimeType());
 	return createSuccessResponse();
     }
 
     private String calculateUploadDirLocation(final StateToken stateToken) {
-	return kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + File.separator + stateToken.getGroup()
-		+ File.separator + stateToken.getTool() + File.separator + stateToken.getFolder();
+	return File.separator + stateToken.getGroup() + File.separator + stateToken.getTool() + File.separator
+		+ stateToken.getFolder();
     }
 
     private JSONObject createJsonResponse(final boolean success, final String message) {

Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUtils.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUtils.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUtils.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -2,6 +2,15 @@
 
 public class FileUtils {
 
+    public static String getFileNameWithoutExtension(final String fileName, final String extension) {
+	final int extlength = extension.length();
+	if (extlength > 0) {
+	    return fileName.substring(0, fileName.length() - extlength - 1);
+	} else {
+	    return fileName;
+	}
+    }
+
     public static String getNextSequentialFileName(final String fileName) {
 	final int lastSpace = fileName.lastIndexOf(" ");
 	if (lastSpace != -1) {

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -32,12 +32,14 @@
 
     boolean isSelected(StateToken stateToken);
 
+    void refresh(StateToken stateToken);
+
     void selectItem(StateToken stateToken);
 
     void setEditOnNextStateChange(boolean edit);
 
     void setItemText(StateToken stateToken, String name);
 
-    void setState(StateDTO state);
+    void setState(StateDTO state, boolean selectItem);
 
 }

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -37,7 +37,8 @@
 import com.gwtext.client.core.EventObject;
 import com.gwtext.client.core.ExtElement;
 import com.gwtext.client.data.Node;
-import com.gwtext.client.data.Tree;
+import com.gwtext.client.dd.DragData;
+import com.gwtext.client.dd.DragDrop;
 import com.gwtext.client.widgets.Editor;
 import com.gwtext.client.widgets.event.EditorListenerAdapter;
 import com.gwtext.client.widgets.form.TextField;
@@ -45,6 +46,7 @@
 import com.gwtext.client.widgets.menu.Item;
 import com.gwtext.client.widgets.menu.Menu;
 import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
+import com.gwtext.client.widgets.tree.DropNodeCallback;
 import com.gwtext.client.widgets.tree.TreeEditor;
 import com.gwtext.client.widgets.tree.TreeNode;
 import com.gwtext.client.widgets.tree.TreePanel;
@@ -238,6 +240,13 @@
 	root.expand();
 	createItemMenu(rootId, actions, stateToken);
 	treePanel.addListener(new TreePanelListenerAdapter() {
+	    public boolean doBeforeNodeDrop(final TreePanel treePanel, final TreeNode target, final DragData dragData,
+		    final String point, final DragDrop source, final TreeNode dropNode,
+		    final DropNodeCallback dropNodeCallback) {
+		Site.info("Drag & drop of contents in development");
+		return false;
+	    }
+
 	    public void onContextMenu(final TreeNode node, final EventObject e) {
 		final Menu menu = contextMenus.get(node.getId());
 		if (menu != null && menu.getItems().length > 0) {
@@ -246,14 +255,6 @@
 		    Log.info("Empty item menu");
 		}
 	    }
-
-	    @Override
-	    public void onMoveNode(final Tree treePanel, final TreeNode node, final TreeNode oldParent,
-		    final TreeNode newParent, final int index) {
-		newParent.removeChild(node);
-		oldParent.appendChild(node);
-		Site.info("Drag & drop of contents in development");
-	    }
 	});
 	treePanel.setLines(false);
 	treePanel.setEnableDD(isEditable);

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -37,6 +37,7 @@
 import org.ourproject.kune.platf.client.dto.StateDTO;
 import org.ourproject.kune.platf.client.dto.StateToken;
 import org.ourproject.kune.platf.client.dto.UserInfoDTO;
+import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
 import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.state.StateManager;
@@ -149,6 +150,14 @@
 	}
     }
 
+    public void refresh(final StateToken stateToken) {
+	contentServiceProvider.get().getContent(session.getUserHash(), stateToken, new AsyncCallbackSimple<StateDTO>() {
+	    public void onSuccess(final StateDTO result) {
+		setState(result, false);
+	    }
+	});
+    }
+
     public void selectItem(final StateToken stateToken) {
 	view.selectItem(genId(stateToken));
 	toolbar.disableMenusAndClearButtons();
@@ -163,7 +172,7 @@
 	view.setItemText(genId(stateToken), name);
     }
 
-    public void setState(final StateDTO state) {
+    public void setState(final StateDTO state, final boolean select) {
 	final ContainerDTO container = state.getContainer();
 	final StateToken stateToken = state.getStateToken();
 	final AccessRightsDTO containerRights = state.getContainerRights();
@@ -209,11 +218,14 @@
 
 	// Finaly
 	if (mustEditOnNextStateChange()) {
+	    // Code smell
 	    selectItem(stateToken);
 	    editItem(stateToken);
 	    setEditOnNextStateChange(false);
 	} else {
-	    selectItem(stateToken);
+	    if (select) {
+		selectItem(stateToken);
+	    }
 
 	}
     }

Modified: trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -20,7 +20,7 @@
     public void before() {
 	session = Mockito.mock(Session.class);
 	view = Mockito.mock(FileUploaderView.class);
-	presenter = new FileUploaderPresenter(session);
+	presenter = new FileUploaderPresenter(session, null);
 	presenter.init(view);
 	Mockito.stub(session.getUserHash()).toReturn(SOMEUSER_HASH);
     }

Modified: trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUtilsTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUtilsTest.java	2008-09-24 20:16:24 UTC (rev 883)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUtilsTest.java	2008-09-24 22:54:07 UTC (rev 884)
@@ -20,6 +20,16 @@
     }
 
     @Test
+    public void testFileNameWExtensionSimple() {
+	assertEquals("test", FileUtils.getFileNameWithoutExtension("test.txt", "txt"));
+    }
+
+    @Test
+    public void testFileNameWithoutExtension() {
+	assertEquals("test", FileUtils.getFileNameWithoutExtension("test", ""));
+    }
+
+    @Test
     public void testIfSeq101return102() {
 	assertEquals(SIMPLE_FILE_NAME + " 102", FileUtils.getNextSequentialFileName(SIMPLE_FILE_NAME + " 101"));
     }




More information about the kune-commits mailing list