[kune-commits] r885 - in trunk: . img/nav-icons
src/main/java/org/ourproject/kune/docs/client
src/main/java/org/ourproject/kune/platf/client/actions
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/public/images/nav
src/main/java/org/ourproject/kune/platf/server/domain
src/main/java/org/ourproject/kune/platf/server/manager/impl
src/main/java/org/ourproject/kune/platf/server/state
src/main/java/org/ourproject/kune/workspace/client/ctxnav
src/main/java/org/ourproject/kune/workspace/client/title
src/main/resources src/main/resources/META-INF
src/test/java/org/ourproject/kune/platf/client
src/test/java/org/ourproject/kune/platf/client/actions
src/test/java/org/ourproject/kune/platf/client/dto
src/test/java/org/ourproject/kune/platf/server/manager
src/test/java/org/ourproject/kune/platf/server/manager/impl
src/test/java/org/ourproject/kune/platf/server/mapper
vjrj
vjrj at ourproject.org
Fri Sep 26 03:40:50 CEST 2008
Author: vjrj
Date: 2008-09-26 03:40:25 +0200 (Fri, 26 Sep 2008)
New Revision: 885
Added:
trunk/img/nav-icons/folder.png
trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java
trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/folder.png
trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_excel.png
trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_pps.png
trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_word.png
trunk/src/main/java/org/ourproject/kune/platf/server/domain/BasicMimeType.java
trunk/src/test/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistryTest.java
trunk/src/test/java/org/ourproject/kune/platf/client/dto/
trunk/src/test/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTOTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java
Modified:
trunk/INSTALL
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java
trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java
trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java
trunk/src/main/resources/META-INF/persistence.xml
trunk/src/main/resources/dozerBeanMapping.xml
trunk/src/test/java/org/ourproject/kune/platf/server/manager/GroupManagerTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManagerTest.java
trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java
Log:
Incomplete - task 70: File uploaded client content part
Complete - task 71: Content Icon in EntityTitle
Server upload utf8 in names issue, mime-type of files support and registry of icons in client. UTF8 persist problems fixed.
Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/INSTALL 2008-09-26 01:40:25 UTC (rev 885)
@@ -16,8 +16,10 @@
(if you're using windows as dev plaftorm... you will have to write your own script ;). the idea is to
copy everything from target/kune-0.0.VERSIONHERE/org.ourproject.kune.app.Kune to src/main/webapp/gwt/org.ourproject.kune.app.Kune)
-- Make two databases in your mysql:
+- MYSQL configuration:
+Make two databases in your mysql:
+
CREATE DATABASE kune_dev;
GRANT ALL PRIVILEGES ON kune_dev.* TO kune at localhost IDENTIFIED BY 'db4kune';
FLUSH PRIVILEGES;
@@ -26,6 +28,15 @@
GRANT ALL PRIVILEGES ON kune_test.* TO kune at localhost IDENTIFIED BY 'db4kune';
FLUSH PRIVILEGES;
+You have to configure mysql to support UTF8 by editing your c:\Windows\my.ini or /etc/my.cnf (on Unix) file:
+[mysqld]
+default-character-set=utf8
+
+Or do it per table:
+
+ALTER DATABASE kune_dev CHARACTER SET utf8 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT COLLATE utf8_general_ci;
+ALTER DATABASE kune_test CHARACTER SET utf8 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT COLLATE utf8_general_ci;
+
- Configure upload directory:
sudo mkdir -p /var/lib/kune/uploads/
Added: trunk/img/nav-icons/folder.png
===================================================================
(Binary files differ)
Property changes on: trunk/img/nav-icons/folder.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -24,6 +24,7 @@
import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
+import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.tool.AbstractClientTool;
import org.ourproject.kune.platf.client.tool.ToolSelector;
@@ -61,7 +62,7 @@
this.dragDropContentRegistry = dragDropContentRegistry;
this.contentIconsRegistry = contentIconsRegistry;
registerDragDropTypes();
- registerImageTypes();
+ registerIcons();
}
public String getName() {
@@ -88,13 +89,32 @@
dragDropContentRegistry.registerDroppableType(TYPE_GALLERY);
}
- private void registerImageTypes() {
+ private void registerIcons() {
+ contentIconsRegistry.registerContentTypeIcon(TYPE_FOLDER, "images/nav/folder.png");
contentIconsRegistry.registerContentTypeIcon(TYPE_BLOG, "images/nav/blog.png");
contentIconsRegistry.registerContentTypeIcon(TYPE_GALLERY, "images/nav/gallery.png");
contentIconsRegistry.registerContentTypeIcon(TYPE_DOCUMENT, "images/nav/page.png");
contentIconsRegistry.registerContentTypeIcon(TYPE_POST, "images/nav/post.png");
contentIconsRegistry.registerContentTypeIcon(TYPE_WIKI, "images/nav/wiki.png");
contentIconsRegistry.registerContentTypeIcon(TYPE_WIKIPAGE, "images/nav/wikipage.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("image"),
+ "images/nav/picture.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("video"),
+ "images/nav/film.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("application", "pdf"),
+ "images/nav/page_pdf.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("application", "zip"),
+ "images/nav/page_zip.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("application", "zip"),
+ "images/nav/page_zip.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("text"),
+ "images/nav/page_text.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("application", "msword"),
+ "images/nav/page_word.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("application", "excel"),
+ "images/nav/page_excel.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, new BasicMimeTypeDTO("application",
+ "mspowerpoint"), "images/nav/page_pps.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_UPLOADEDFILE, "images/nav/page.png");
}
-
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -2,6 +2,8 @@
import java.util.HashMap;
+import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
+
public class ContentIconsRegistry {
private final HashMap<String, String> contentTypesIcons;
@@ -14,7 +16,44 @@
return icon == null ? "" : icon;
}
+ /**
+ * If there is a specific icon for a type/subtype pair or a generic type
+ * icon in defect
+ *
+ * @param typeId
+ * the kune typeId (see *ClientTool)
+ * @param mimeType
+ * @return
+ */
+ public String getContentTypeIcon(final String typeId, final BasicMimeTypeDTO mimeType) {
+ String icon = getContentTypeIcon(concatenate(typeId, mimeType));
+ if (icon.equals("")) {
+ if (mimeType == null) {
+ return getContentTypeIcon(typeId);
+ }
+ } else {
+ return icon;
+ }
+ final String subtype = mimeType.getSubtype();
+ if (subtype != null && subtype.length() > 0) {
+ icon = getContentTypeIcon(typeId, new BasicMimeTypeDTO(mimeType.getType()));
+ }
+ return icon.equals("") ? getContentTypeIcon(typeId) : icon;
+ }
+
+ public void registerContentTypeIcon(final String typeId, final BasicMimeTypeDTO mimeType, final String iconUrl) {
+ registerContentTypeIcon(concatenate(typeId, mimeType), iconUrl);
+ }
+
public void registerContentTypeIcon(final String contentTypeId, final String iconUrl) {
contentTypesIcons.put(contentTypeId, iconUrl);
}
+
+ private String concatenate(final String typeId, final BasicMimeTypeDTO mimeType) {
+ if (mimeType != null) {
+ return typeId + "|" + mimeType;
+ } else {
+ return typeId;
+ }
+ }
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTO.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -0,0 +1,49 @@
+package org.ourproject.kune.platf.client.dto;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+public class BasicMimeTypeDTO implements IsSerializable {
+
+ private String type;
+ private String subtype;
+
+ public BasicMimeTypeDTO() {
+ this(null, null);
+ }
+
+ public BasicMimeTypeDTO(final String mimetype) {
+ if (mimetype != null) {
+ final String[] split = mimetype.split("/", 2);
+ type = split[0];
+ if (split.length > 1 && split[1].length() > 0) {
+ subtype = split[1];
+ }
+ }
+ }
+
+ public BasicMimeTypeDTO(final String type, final String subtype) {
+ this.type = type;
+ this.subtype = subtype;
+ }
+
+ public String getSubtype() {
+ return subtype;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setSubtype(final String subtype) {
+ this.subtype = subtype;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return subtype == null ? type : type + "/" + subtype;
+ }
+
+}
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 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/ContentDTO.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -20,6 +20,7 @@
package org.ourproject.kune.platf.client.dto;
+
import com.google.gwt.user.client.rpc.IsSerializable;
public class ContentDTO implements IsSerializable {
@@ -30,13 +31,13 @@
private StateToken stateToken;
private ContentStatusDTO status;
private AccessRightsDTO rights;
- private String mimeType;
+ private BasicMimeTypeDTO mimeType;
public Long getId() {
return id;
}
- public String getMimeType() {
+ public BasicMimeTypeDTO getMimeType() {
return mimeType;
}
@@ -64,7 +65,7 @@
this.id = id;
}
- public void setMimeType(final String mimeType) {
+ public void setMimeType(final BasicMimeTypeDTO mimeType) {
this.mimeType = mimeType;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/dto/StateDTO.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -23,6 +23,7 @@
import java.util.Date;
import java.util.List;
+
import com.google.gwt.user.client.rpc.IsSerializable;
public class StateDTO implements IsSerializable {
@@ -45,6 +46,7 @@
private Integer rateByUsers;
private Double currentUserRate;
private String typeId;
+ private BasicMimeTypeDTO mimeType;
private LicenseDTO license;
private I18nLanguageDTO language;
private Date publishedOn;
@@ -77,6 +79,10 @@
return container;
}
+ public AccessRightsDTO getContainerRights() {
+ return containerRights;
+ }
+
public String getContent() {
return content;
}
@@ -93,10 +99,6 @@
return documentId;
}
- public AccessRightsDTO getContainerRights() {
- return containerRights;
- }
-
public GroupDTO getGroup() {
return this.group;
}
@@ -121,6 +123,10 @@
return license;
}
+ public BasicMimeTypeDTO getMimeType() {
+ return mimeType;
+ }
+
public ParticipationDataDTO getParticipation() {
return participation;
}
@@ -238,6 +244,10 @@
this.license = license;
}
+ public void setMimeType(final BasicMimeTypeDTO mimeType) {
+ this.mimeType = mimeType;
+ }
+
public void setParticipation(final ParticipationDataDTO participation) {
this.participation = participation;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneWorkspaceModule.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -1,5 +1,6 @@
package org.ourproject.kune.platf.client.services;
+import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
@@ -231,7 +232,7 @@
public EntityTitle create() {
final EntityTitlePresenter presenter = new EntityTitlePresenter($(I18nUITranslationService.class),
$(KuneErrorHandler.class), $(StateManager.class), $(Session.class),
- $$(ContentServiceAsync.class), $$(ContextNavigator.class));
+ $$(ContentServiceAsync.class), $$(ContextNavigator.class), $(ContentIconsRegistry.class));
final EntityTitlePanel panel = new EntityTitlePanel($(WorkspaceSkeleton.class), presenter);
presenter.init(panel);
return presenter;
@@ -259,21 +260,21 @@
}
});
- register(ApplicationComponentGroup.class, new Factory<RatePresenter>(RatePresenter.class) {
- public RatePresenter create() {
- final RatePresenter presenter = new RatePresenter($(StateManager.class));
- final RatePanel panel = new RatePanel(null, null, $(I18nUITranslationService.class),
+ register(ApplicationComponentGroup.class, new Factory<RateIt>(RateIt.class) {
+ public RateIt create() {
+ final RateItPresenter presenter = new RateItPresenter($(I18nUITranslationService.class),
+ $(Session.class), $$(ContentServiceAsync.class), $(StateManager.class));
+ final RateItPanel panel = new RateItPanel(presenter, $(I18nUITranslationService.class),
$(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
});
- register(ApplicationComponentGroup.class, new Factory<RateIt>(RateIt.class) {
- public RateIt create() {
- final RateItPresenter presenter = new RateItPresenter($(I18nUITranslationService.class),
- $(Session.class), $$(ContentServiceAsync.class), $(StateManager.class));
- final RateItPanel panel = new RateItPanel(presenter, $(I18nUITranslationService.class),
+ register(ApplicationComponentGroup.class, new Factory<RatePresenter>(RatePresenter.class) {
+ public RatePresenter create() {
+ final RatePresenter presenter = new RatePresenter($(StateManager.class));
+ final RatePanel panel = new RatePanel(null, null, $(I18nUITranslationService.class),
$(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 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -110,10 +110,13 @@
private void createDialog(final boolean show) {
dialog = new UploadDialog(i18n.t("File uploader"), false, true);
dialog.setId(SITE_FILE_UPLOADER);
- // dialog.setUploadAutostart(true);
+ dialog.setAllowCloseOnUpload(true);
dialog.setResetOnHide(false);
- dialog.setAllowCloseOnUpload(true);
+ dialog.setClosable(true);
dialog.setCloseAction(Window.HIDE);
+ dialog.setMinimizable(true);
+ dialog.setUploadAutostart(true);
+ // Here fails
dialog.addListener(new UploadDialogListenerAdapter() {
@Override
@@ -126,6 +129,11 @@
}
@Override
+ public void onMinimize(final Window source) {
+ dialog.hide();
+ }
+
+ @Override
public void onUploadComplete(final UploadDialog source) {
if (!dialog.isVisible()) {
Site.info(i18n.t("Upload completed"));
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/folder.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/folder.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_excel.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_excel.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_pps.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_pps.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_word.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/nav/page_word.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/server/domain/BasicMimeType.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/domain/BasicMimeType.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/BasicMimeType.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -0,0 +1,50 @@
+package org.ourproject.kune.platf.server.domain;
+
+import javax.persistence.Embeddable;
+
+ at Embeddable
+public class BasicMimeType {
+
+ private String type;
+ private String subtype;
+
+ public BasicMimeType() {
+ this(null, null);
+ }
+
+ public BasicMimeType(final String mimetype) {
+ if (mimetype != null) {
+ final String[] split = mimetype.split("/", 2);
+ type = split[0];
+ if (split.length > 1 && split[1].length() > 0) {
+ subtype = split[1];
+ }
+ }
+ }
+
+ public BasicMimeType(final String type, final String subtype) {
+ this.type = type;
+ this.subtype = subtype;
+ }
+
+ public String getSubtype() {
+ return subtype;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setSubtype(final String subtype) {
+ this.subtype = subtype;
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return subtype == null ? type : type + "/" + subtype;
+ }
+
+}
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 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/domain/Content.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -30,6 +30,7 @@
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -118,7 +119,8 @@
@Column(nullable = false)
private ContentStatus status;
- private String mimeType;
+ @Embedded
+ private BasicMimeType mimeType;
public Content() {
translations = new ArrayList<ContentTranslation>();
@@ -193,7 +195,7 @@
return license;
}
- public String getMimeType() {
+ public BasicMimeType getMimeType() {
return mimeType;
}
@@ -299,7 +301,7 @@
this.license = license;
}
- public void setMimeType(final String mimeType) {
+ public void setMimeType(final BasicMimeType mimeType) {
this.mimeType = mimeType;
}
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 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -3,7 +3,9 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.net.URLEncoder;
import java.util.Iterator;
import java.util.List;
@@ -12,7 +14,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import net.sf.jmimemagic.MagicException;
import net.sf.jmimemagic.MagicMatch;
+import net.sf.jmimemagic.MagicMatchNotFoundException;
+import net.sf.jmimemagic.MagicParseException;
import net.sf.json.JSONObject;
import org.apache.commons.fileupload.FileItem;
@@ -32,6 +37,7 @@
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.BasicMimeType;
import org.ourproject.kune.platf.server.domain.Container;
import org.ourproject.kune.platf.server.domain.Content;
import org.ourproject.kune.platf.server.domain.User;
@@ -48,6 +54,10 @@
public static final Log log = LogFactory.getLog(FileUploadManager.class);
+ private static final String SLASH = File.separator;
+
+ private static final String UTF8 = "UTF-8";
+
private static final long serialVersionUID = 1L;
@Inject
@@ -111,12 +121,10 @@
createFile(userHash, stateToken, fileName, file);
} catch (final FileUploadException e) {
jsonResponse = createJsonResponse(false, i18n.t("Error: File too large"));
-
} catch (final Exception e) {
- // SessionExpiredException,
- // UserMustBeLoggedException
jsonResponse = createJsonResponse(false, i18n.t("Error uploading file"));
- log.info(e.getCause());
+ log.info("Exception: " + e.getCause());
+ e.printStackTrace();
}
final Writer w = new OutputStreamWriter(resp.getOutputStream());
@@ -128,28 +136,46 @@
@Authenticated
@Authorizated(accessRolRequired = AccessRol.Editor, actionLevel = ActionLevel.container)
@Transactional(type = TransactionType.READ_WRITE)
- JSONObject createFile(final String userHash, final StateToken stateToken, final String fileName,
+ Content createFile(final String userHash, final StateToken stateToken, final String fileName,
final FileItem fileUploadItem) throws Exception {
- final String relDir = calculateUploadDirLocation(stateToken);
+ final String relDir = calculateUploadDirLocation(stateToken, false);
+ final String relDirEncoded = calculateUploadDirLocation(stateToken, true);
final String absDir = kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + relDir;
fileManager.mkdir(absDir);
- final File file = fileManager.createFileWithSequentialName(absDir, fileName);
+
+ final String filenameUTF8 = new String(fileName.getBytes(), UTF8);
+ final File file = fileManager.createFileWithSequentialName(absDir, filenameUTF8);
fileUploadItem.write(file);
- final MagicMatch magic = fileManager.getMimeType(file);
+ // FIXME remove file if not success
+ String mimetype = "unknown/unknown";
+ String extension = "";
+ try {
+ final MagicMatch magicMatch = fileManager.getMimeType(file);
+ extension = magicMatch.getExtension();
+ mimetype = magicMatch.getMimeType();
+ } catch (final MagicParseException e) {
+ log.info("Exception: " + e.getCause());
+ } catch (final MagicMatchNotFoundException e) {
+ log.info("Exception: " + e.getCause());
+ } catch (final MagicException e) {
+ log.info("Exception: " + e.getCause());
+ }
// 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);
+ extension), relDirEncoded + SLASH + URLEncoder.encode(filenameUTF8, UTF8), user, container);
content.setTypeId(DocumentServerTool.TYPE_UPLOADEDFILE);
- content.setMimeType(magic.getMimeType());
- return createSuccessResponse();
+ content.setMimeType(new BasicMimeType(mimetype));
+ return content;
}
- private String calculateUploadDirLocation(final StateToken stateToken) {
- return File.separator + stateToken.getGroup() + File.separator + stateToken.getTool() + File.separator
+ private String calculateUploadDirLocation(final StateToken stateToken, final boolean urlEncoded)
+ throws UnsupportedEncodingException {
+ final String group = stateToken.getGroup();
+ return SLASH + (urlEncoded ? URLEncoder.encode(group, UTF8) : group) + SLASH + stateToken.getTool() + SLASH
+ stateToken.getFolder();
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/state/State.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -27,6 +27,7 @@
import org.ourproject.kune.platf.server.ParticipationData;
import org.ourproject.kune.platf.server.access.AccessRights;
import org.ourproject.kune.platf.server.domain.AccessLists;
+import org.ourproject.kune.platf.server.domain.BasicMimeType;
import org.ourproject.kune.platf.server.domain.Container;
import org.ourproject.kune.platf.server.domain.ContentStatus;
import org.ourproject.kune.platf.server.domain.Group;
@@ -54,6 +55,7 @@
private Integer rateByUsers;
private Double currentUserRate;
private String typeId;
+ private BasicMimeType mimeType;
private License license;
private I18nLanguage language;
private List<User> authors;
@@ -123,6 +125,10 @@
return license;
}
+ public BasicMimeType getMimeType() {
+ return mimeType;
+ }
+
public ParticipationData getParticipation() {
return participation;
}
@@ -231,6 +237,10 @@
this.license = license;
}
+ public void setMimeType(final BasicMimeType mimeType) {
+ this.mimeType = mimeType;
+ }
+
public void setParticipation(final ParticipationData participation) {
this.participation = participation;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/state/StateServiceDefault.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -39,6 +39,7 @@
final Long documentId = content.getId();
if (documentId != null) {
state.setTypeId(content.getTypeId());
+ state.setMimeType(content.getMimeType());
state.setDocumentId(documentId.toString());
state.setIsRateable(true);
state.setLanguage(content.getLanguage());
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 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -30,6 +30,7 @@
import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
+import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
import org.ourproject.kune.platf.client.dto.ContainerDTO;
import org.ourproject.kune.platf.client.dto.ContainerSimpleDTO;
import org.ourproject.kune.platf.client.dto.ContentDTO;
@@ -204,11 +205,11 @@
// Process our current content/container
if (state.hasDocument()) {
rights = state.getContentRights();
- addItem(state.getTitle(), state.getTypeId(), state.getStatus(), stateToken, container.getStateToken(),
- rights, false);
+ addItem(state.getTitle(), state.getTypeId(), state.getMimeType(), state.getStatus(), stateToken, container
+ .getStateToken(), rights, false);
} else {
rights = containerRights;
- addItem(container.getName(), container.getTypeId(), ContentStatusDTO.publishedOnline, container
+ addItem(container.getName(), container.getTypeId(), null, ContentStatusDTO.publishedOnline, container
.getStateToken(), container.getStateToken().clone().setFolder(container.getParentFolderId()),
containerRights, false);
}
@@ -236,31 +237,32 @@
actionsByItem.clear();
}
- private void addItem(final String title, final String contentTypeId, final ContentStatusDTO status,
- final StateToken stateToken, final StateToken parentStateToken, final AccessRightsDTO rights,
- final boolean isNodeSelected) {
+ private void addItem(final String title, final String contentTypeId, final BasicMimeTypeDTO mimeType,
+ final ContentStatusDTO status, final StateToken stateToken, final StateToken parentStateToken,
+ final AccessRightsDTO rights, final boolean isNodeSelected) {
final ActionCollectionSet<StateToken> set = actionRegistry.selectCurrentActions(rights, contentTypeId);
toolbar.showActions(set.getToolbarActions(), isNodeSelected);
+ final String contentTypeIcon = contentIconsRegistry.getContentTypeIcon(contentTypeId, mimeType);
final ContextNavigatorItem item = new ContextNavigatorItem(genId(stateToken), genId(parentStateToken),
- contentIconsRegistry.getContentTypeIcon(contentTypeId), title, status, stateToken,
- dragDropContentRegistry.isDraggable(contentTypeId, rights.isAdministrable()), dragDropContentRegistry
- .isDroppable(contentTypeId, rights.isAdministrable()), set.getItemActions());
+ contentTypeIcon, title, status, stateToken, dragDropContentRegistry.isDraggable(contentTypeId, rights
+ .isAdministrable()), dragDropContentRegistry.isDroppable(contentTypeId, rights
+ .isAdministrable()), set.getItemActions());
view.addItem(item);
actionsByItem.put(stateToken, set.getToolbarActions());
}
private void createChildItems(final ContainerDTO container, final AccessRightsDTO containerRights) {
for (final ContentDTO content : container.getContents()) {
- addItem(content.getTitle(), content.getTypeId(), content.getStatus(), content.getStateToken(), content
- .getStateToken().clone().clearDocument(), content.getRights(), false);
+ addItem(content.getTitle(), content.getTypeId(), content.getMimeType(), content.getStatus(), content
+ .getStateToken(), content.getStateToken().clone().clearDocument(), content.getRights(), false);
}
for (final ContainerSimpleDTO siblingFolder : container.getChilds()) {
- addItem(siblingFolder.getName(), siblingFolder.getTypeId(), ContentStatusDTO.publishedOnline, siblingFolder
- .getStateToken(), siblingFolder.getStateToken().clone()
- .setFolder(siblingFolder.getParentFolderId()), containerRights, false);
+ addItem(siblingFolder.getName(), siblingFolder.getTypeId(), null, ContentStatusDTO.publishedOnline,
+ siblingFolder.getStateToken(), siblingFolder.getStateToken().clone().setFolder(
+ siblingFolder.getParentFolderId()), containerRights, false);
}
}
@@ -272,7 +274,7 @@
final StateToken parentStateToken = state.clone().clearDocument().setFolder(folder.getParentFolderId());
if (folder.getParentFolderId() != null) {
- addItem(folder.getName(), folder.getTypeId(), ContentStatusDTO.publishedOnline, folderStateToken,
+ addItem(folder.getName(), folder.getTypeId(), null, ContentStatusDTO.publishedOnline, folderStateToken,
parentStateToken, rights, false);
} else {
// Root must be already created
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePanel.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -25,13 +25,16 @@
import org.ourproject.kune.workspace.client.skel.TitleBar;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
public class EntityTitlePanel implements EntityTitleView {
private final EditableIconLabel titleLabel;
private final Label dateLabel;
+ private final Image icon;
public EntityTitlePanel(final WorkspaceSkeleton ws, final EntityTitlePresenter presenter) {
+ icon = new Image();
titleLabel = new EditableIconLabel(new EditableClickListener() {
public void onEdited(final String text) {
presenter.onTitleRename(text);
@@ -40,13 +43,17 @@
dateLabel = new Label();
final TitleBar wsTitle = ws.getEntityWorkspace().getTitle();
+ wsTitle.add(icon);
wsTitle.add(titleLabel);
wsTitle.addFill();
wsTitle.add(dateLabel);
- titleLabel.addStyleName("kune-Margin-Large-l");
+ icon.addStyleName("kune-Margin-Large-l");
+ titleLabel.addStyleName("kune-Margin-Medium-l");
titleLabel.addStyleName("kune-ft17px");
+ titleLabel.ensureDebugId("k-entity-title-title");
dateLabel.addStyleName("kune-Margin-Large-r");
dateLabel.addStyleName("kune-ft12px");
+ dateLabel.ensureDebugId("k-entity-title-date");
}
public void restoreOldTitle() {
@@ -57,6 +64,21 @@
dateLabel.setText(date);
}
+ public void setContentIcon(final String iconUrl) {
+ icon.setUrl(iconUrl);
+ }
+
+ public void setContentIconVisible(final boolean visible) {
+ icon.setVisible(visible);
+ if (visible) {
+ titleLabel.removeStyleName("kune-Margin-Large-l");
+ titleLabel.addStyleName("kune-Margin-Medium-l");
+ } else {
+ titleLabel.removeStyleName("kune-Margin-Medium-l");
+ titleLabel.addStyleName("kune-Margin-Large-l");
+ }
+ }
+
public void setContentTitle(final String title) {
titleLabel.setText(title);
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitlePresenter.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -23,6 +23,7 @@
import java.util.Date;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
import org.ourproject.kune.platf.client.dto.StateDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
@@ -46,16 +47,18 @@
private final Provider<ContentServiceAsync> contentServiceProvider;
private final Session session;
private final Provider<ContextNavigator> contextNavigatorProvider;
+ private final ContentIconsRegistry iconsRegistry;
public EntityTitlePresenter(final I18nTranslationService i18n, final KuneErrorHandler errorHandler,
final StateManager stateManager, final Session session,
final Provider<ContentServiceAsync> contentServiceProvider,
- final Provider<ContextNavigator> contextNavigatorProvider) {
+ final Provider<ContextNavigator> contextNavigatorProvider, final ContentIconsRegistry iconsRegistry) {
this.i18n = i18n;
this.errorHandler = errorHandler;
this.session = session;
this.contentServiceProvider = contentServiceProvider;
this.contextNavigatorProvider = contextNavigatorProvider;
+ this.iconsRegistry = iconsRegistry;
stateManager.onStateChanged(new Listener<StateDTO>() {
public void onEvent(final StateDTO state) {
setState(state);
@@ -130,6 +133,13 @@
}
setContentDateVisible(false);
}
+ final String contentTypeIcon = iconsRegistry.getContentTypeIcon(state.getTypeId(), state.getMimeType());
+ if (contentTypeIcon.length() > 0) {
+ view.setContentIcon(contentTypeIcon);
+ view.setContentIconVisible(true);
+ } else {
+ view.setContentIconVisible(false);
+ }
}
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/title/EntityTitleView.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -28,6 +28,10 @@
void setContentDate(String date);
+ void setContentIcon(String iconUrl);
+
+ void setContentIconVisible(boolean visible);
+
void setContentTitle(String title);
void setContentTitleEditable(boolean editable);
Modified: trunk/src/main/resources/META-INF/persistence.xml
===================================================================
--- trunk/src/main/resources/META-INF/persistence.xml 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/resources/META-INF/persistence.xml 2008-09-26 01:40:25 UTC (rev 885)
@@ -18,7 +18,7 @@
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url"
- value="jdbc:mysql://localhost/kune_dev?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8" />
+ value="jdbc:mysql://localhost/kune_dev?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8" />
<property name="hibernate.connection.username" value="kune" />
<property name="hibernate.connection.password" value="db4kune" />
<property name="hibernate.hbm2ddl.auto" value="update" />
@@ -47,7 +47,7 @@
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url"
- value="jdbc:mysql://localhost/kune_test?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8" />
+ value="jdbc:mysql://localhost/kune_test?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8" />
<property name="hibernate.connection.username" value="kune" />
<property name="hibernate.connection.password" value="db4kune" />
<property name="hibernate.hbm2ddl.auto" value="create" />
Modified: trunk/src/main/resources/dozerBeanMapping.xml
===================================================================
--- trunk/src/main/resources/dozerBeanMapping.xml 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/main/resources/dozerBeanMapping.xml 2008-09-26 01:40:25 UTC (rev 885)
@@ -2,330 +2,439 @@
<!DOCTYPE mappings PUBLIC "-//DOZER//DTD MAPPINGS//EN"
"http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtd">
<mappings>
- <configuration>
- <stop-on-errors>true</stop-on-errors>
- <date-format>dd/mm/yyyy</date-format>
- <wildcard>true</wildcard>
- </configuration>
+ <configuration>
+ <stop-on-errors>true</stop-on-errors>
+ <date-format>dd/mm/yyyy</date-format>
+ <wildcard>true</wildcard>
+ </configuration>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.InitDataDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.InitData</class-b>
- <field>
- <a>licenses</a>
- <b>licenses</b>
- <a-hint>org.ourproject.kune.platf.client.dto.LicenseDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.License</b-hint>
- </field>
- <field>
- <a>languages</a>
- <b>languages</b>
- <a-hint>
- org.ourproject.kune.platf.client.dto.I18nLanguageSimpleDTO
- </a-hint>
- <b-hint>
- org.ourproject.kune.platf.server.domain.I18nLanguage
- </b-hint>
- </field>
- <field>
- <a>countries</a>
- <b>countries</b>
- <a-hint>
- org.ourproject.kune.platf.client.dto.I18nCountryDTO
- </a-hint>
- <b-hint>
- org.ourproject.kune.platf.server.domain.I18nCountry
- </b-hint>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.InitDataDTO
+ </class-a>
+ <class-b>org.ourproject.kune.platf.server.InitData</class-b>
+ <field>
+ <a>licenses</a>
+ <b>licenses</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.LicenseDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.License
+ </b-hint>
+ </field>
+ <field>
+ <a>languages</a>
+ <b>languages</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.I18nLanguageSimpleDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.I18nLanguage
+ </b-hint>
+ </field>
+ <field>
+ <a>countries</a>
+ <b>countries</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.I18nCountryDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.I18nCountry
+ </b-hint>
+ </field>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.GroupDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.Group</class-b>
- </mapping>
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.GroupDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.Group</class-b>
+ </mapping>
+
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.GroupListDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.GroupList
+ </class-b>
+ <field>
+ <a>list</a>
+ <b>list</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.GroupDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.Group
+ </b-hint>
+ </field>
+ <field
+ custom-converter="org.ourproject.kune.platf.server.mapper.GroupListModeConverter">
+ <a>mode</a>
+ <b>mode</b>
+ </field>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.GroupListDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.GroupList</class-b>
- <field>
- <a>list</a>
- <b>list</b>
- <a-hint>org.ourproject.kune.platf.client.dto.GroupDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.Group</b-hint>
- </field>
- <field
- custom-converter="org.ourproject.kune.platf.server.mapper.GroupListModeConverter">
- <a>mode</a>
- <b>mode</b>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.AccessListsDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.AccessLists
+ </class-b>
+ <field>
+ <a>admins</a>
+ <b>admins</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.GroupListDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.GroupList
+ </b-hint>
+ </field>
+ <field>
+ <a>editors</a>
+ <b>editors</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.GroupListDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.GroupList
+ </b-hint>
+ </field>
+ <field>
+ <a>viewers</a>
+ <b>viewers</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.GroupListDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.GroupList
+ </b-hint>
+ </field>
+ </mapping>
- <mapping>
- <class-a>
- org.ourproject.kune.platf.client.dto.AccessListsDTO
- </class-a>
- <class-b>
- org.ourproject.kune.platf.server.domain.AccessLists
- </class-b>
- <field>
- <a>admins</a>
- <b>admins</b>
- <a-hint>org.ourproject.kune.platf.client.dto.GroupListDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.GroupList</b-hint>
- </field>
- <field>
- <a>editors</a>
- <b>editors</b>
- <a-hint>org.ourproject.kune.platf.client.dto.GroupListDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.GroupList</b-hint>
- </field>
- <field>
- <a>viewers</a>
- <b>viewers</b>
- <a-hint>org.ourproject.kune.platf.client.dto.GroupListDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.GroupList</b-hint>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.AccessRightsDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.access.AccessRights
+ </class-b>
+ </mapping>
- <mapping>
- <class-a>
- org.ourproject.kune.platf.client.dto.AccessRightsDTO
- </class-a>
- <class-b>
- org.ourproject.kune.platf.server.access.AccessRights
- </class-b>
- </mapping>
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.StateDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.state.State</class-b>
+ <field>
+ <a>authors</a>
+ <b>authors</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.UserSimpleDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.User
+ </b-hint>
+ </field>
+ <field>
+ <a>groupTags</a>
+ <b>groupTags</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.TagResultDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.TagResult
+ </b-hint>
+ </field>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.StateDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.state.State</class-b>
- <field>
- <a>authors</a>
- <b>authors</b>
- <a-hint>
- org.ourproject.kune.platf.client.dto.UserSimpleDTO
- </a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.User</b-hint>
- </field>
- <field>
- <a>groupTags</a>
- <b>groupTags</b>
- <a-hint>org.ourproject.kune.platf.client.dto.TagResultDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.TagResult</b-hint>
- </field>
- </mapping>
-
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.StateToken</class-a>
- <class-b>org.ourproject.kune.platf.client.dto.StateToken</class-b>
- <field>
- <a>encoded</a>
- <b>encoded</b>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.StateToken
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.client.dto.StateToken
+ </class-b>
+ <field>
+ <a>encoded</a>
+ <b>encoded</b>
+ </field>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.LicenseDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.License</class-b>
- </mapping>
-
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.ContainerSimpleDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.Container</class-b>
- <field>
- <a get-method="getStateToken">stateToken</a>
- <b>stateToken</b>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.BasicMimeType
+ </class-b>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.ContentDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.Content</class-b>
- <field>
- <a>title</a>
- <b>lastRevision.title</b>
- </field>
- <field>
- <a get-method="getStateToken">stateToken</a>
- <b>stateToken</b>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.LicenseDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.License
+ </class-b>
+ </mapping>
- <mapping type="one-way">
- <class-a>org.ourproject.kune.platf.server.domain.Content</class-a>
- <class-b>org.ourproject.kune.platf.client.dto.LinkDTO</class-b>
- <field>
- <a>lastRevision.title</a>
- <b>longName</b>
- </field>
- <field>
- <a>container.owner.shortName</a>
- <b>shortName</b>
- </field>
- <field>
- <a get-method="getStateTokenEncoded">link</a>
- <b>link</b>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.ContainerSimpleDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.Container
+ </class-b>
+ <field>
+ <a get-method="getStateToken">stateToken</a>
+ <b>stateToken</b>
+ </field>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.ContainerDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.Container</class-b>
- <field>
- <a>contents</a>
- <b>contents</b>
- <a-hint>org.ourproject.kune.platf.client.dto.ContentDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.Content</b-hint>
- </field>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.ContentDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.Content
+ </class-b>
+ <field>
+ <a>title</a>
+ <b>lastRevision.title</b>
+ </field>
+ <field>
+ <a get-method="getStateToken">stateToken</a>
+ <b>stateToken</b>
+ </field>
+ </mapping>
- <field>
- <a>absolutePath</a>
- <b>absolutePath</b>
- <a-hint>
- org.ourproject.kune.platf.client.dto.ContainerSimpleDTO
- </a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.Container</b-hint>
- </field>
+ <mapping type="one-way">
+ <class-a>
+ org.ourproject.kune.platf.server.domain.Content
+ </class-a>
+ <class-b>org.ourproject.kune.platf.client.dto.LinkDTO</class-b>
+ <field>
+ <a>lastRevision.title</a>
+ <b>longName</b>
+ </field>
+ <field>
+ <a>container.owner.shortName</a>
+ <b>shortName</b>
+ </field>
+ <field>
+ <a get-method="getStateTokenEncoded">link</a>
+ <b>link</b>
+ </field>
+ </mapping>
- <field>
- <a>childs</a>
- <b>childs</b>
- <a-hint>org.ourproject.kune.platf.client.dto.ContainerSimpleDTO</a-hint>
- <b-hint>org.ourproject.kune.platf.server.domain.Container</b-hint>
- </field>
-
- <field>
- <a get-method="getStateToken">stateToken</a>
- <b>stateToken</b>
- </field>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.ContainerDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.Container
+ </class-b>
+ <field>
+ <a>contents</a>
+ <b>contents</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.ContentDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.Content
+ </b-hint>
+ </field>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.UserInfoDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.users.UserInfo</class-b>
- <field>
- <a>language</a>
- <b>language</b>
- <a-hint>
- org.ourproject.kune.platf.client.dto.I18nLanguageDTO
- </a-hint>
- <b-hint>
- org.ourproject.kune.platf.server.domain.I18nLanguage
- </b-hint>
- </field>
- <field>
- <a>country</a>
- <b>country</b>
- <a-hint>
- org.ourproject.kune.platf.client.dto.I18nCountryDTO
- </a-hint>
- <b-hint>
- org.ourproject.kune.platf.server.domain.I18nCountry
- </b-hint>
- </field>
- </mapping>
+ <field>
+ <a>absolutePath</a>
+ <b>absolutePath</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.ContainerSimpleDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.Container
+ </b-hint>
+ </field>
- <mapping>
- <class-a>
- org.ourproject.kune.platf.client.dto.ParticipationDataDTO
- </class-a>
- <class-b>
- org.ourproject.kune.platf.server.ParticipationData
- </class-b>
- </mapping>
+ <field>
+ <a>childs</a>
+ <b>childs</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.ContainerSimpleDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.Container
+ </b-hint>
+ </field>
- <mapping>
- <class-a>
- org.ourproject.kune.platf.client.dto.I18nLanguageDTO
- </class-a>
- <class-b>
- org.ourproject.kune.platf.server.domain.I18nLanguage
- </class-b>
- </mapping>
+ <field>
+ <a get-method="getStateToken">stateToken</a>
+ <b>stateToken</b>
+ </field>
+ </mapping>
- <mapping>
- <class-a>
- org.ourproject.kune.platf.client.dto.I18nCountryDTO
- </class-a>
- <class-b>
- org.ourproject.kune.platf.server.domain.I18nCountry
- </class-b>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.UserInfoDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.users.UserInfo
+ </class-b>
+ <field>
+ <a>language</a>
+ <b>language</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.I18nLanguageDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.I18nLanguage
+ </b-hint>
+ </field>
+ <field>
+ <a>country</a>
+ <b>country</b>
+ <a-hint>
+ org.ourproject.kune.platf.client.dto.I18nCountryDTO
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.server.domain.I18nCountry
+ </b-hint>
+ </field>
+ </mapping>
- <mapping>
- <class-a>
- org.ourproject.kune.platf.client.dto.UserSimpleDTO
- </class-a>
- <class-b>org.ourproject.kune.platf.server.domain.User</class-b>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.ParticipationDataDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.ParticipationData
+ </class-b>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.TagDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.Tag</class-b>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.I18nLanguageDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.I18nLanguage
+ </class-b>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.TagResultDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.TagResult</class-b>
- </mapping>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.I18nCountryDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.I18nCountry
+ </class-b>
+ </mapping>
- <mapping>
- <class-a>org.ourproject.kune.platf.server.domain.Comment</class-a>
- <class-b>org.ourproject.kune.platf.client.dto.CommentDTO</class-b>
- <field>
- <a>author</a>
- <b>author</b>
- <a-hint>org.ourproject.kune.platf.server.domain.User</a-hint>
- <b-hint>
- org.ourproject.kune.platf.client.dto.UserSimpleDTO
- </b-hint>
- </field>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.UserSimpleDTO
+ </class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.User</class-b>
+ </mapping>
- <field>
- <a>childs</a>
- <b>childs</b>
- <a-hint>org.ourproject.kune.platf.server.domain.Comment</a-hint>
- <b-hint>org.ourproject.kune.platf.client.dto.CommentDTO</b-hint>
- </field>
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.TagDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.Tag</class-b>
+ </mapping>
- <field type="one-way">
- <a get-method="getPositiveVotersCount">positiveVotersCount</a>
- <b>positiveVotersCount</b>
- </field>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.TagResultDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.TagResult
+ </class-b>
+ </mapping>
- <field type="one-way">
- <a get-method="getNegativeVotersCount">negativeVotersCount</a>
- <b>negativeVotersCount</b>
- </field>
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.server.domain.Comment
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.client.dto.CommentDTO
+ </class-b>
+ <field>
+ <a>author</a>
+ <b>author</b>
+ <a-hint>
+ org.ourproject.kune.platf.server.domain.User
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.client.dto.UserSimpleDTO
+ </b-hint>
+ </field>
- <field type="one-way">
- <a get-method="getAbuseInformersCount">abuseInformersCount</a>
- <b>abuseInformersCount</b>
- </field>
- </mapping>
-
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.LinkDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.User</class-b>
- <field>
- <a>longName</a>
- <b>name</b>
- </field>
- </mapping>
-
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.ChatUserParamsDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.ChatUserParams</class-b>
- </mapping>
-
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.ContentStatusDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.domain.ContentStatus</class-b>
- </mapping>
-
- <mapping>
- <class-a>org.ourproject.kune.platf.client.dto.AccessRolDTO</class-a>
- <class-b>org.ourproject.kune.platf.server.access.AccessRol</class-b>
- </mapping>
-
+ <field>
+ <a>childs</a>
+ <b>childs</b>
+ <a-hint>
+ org.ourproject.kune.platf.server.domain.Comment
+ </a-hint>
+ <b-hint>
+ org.ourproject.kune.platf.client.dto.CommentDTO
+ </b-hint>
+ </field>
+
+ <field type="one-way">
+ <a get-method="getPositiveVotersCount">
+ positiveVotersCount
+ </a>
+ <b>positiveVotersCount</b>
+ </field>
+
+ <field type="one-way">
+ <a get-method="getNegativeVotersCount">
+ negativeVotersCount
+ </a>
+ <b>negativeVotersCount</b>
+ </field>
+
+ <field type="one-way">
+ <a get-method="getAbuseInformersCount">
+ abuseInformersCount
+ </a>
+ <b>abuseInformersCount</b>
+ </field>
+ </mapping>
+
+ <mapping>
+ <class-a>org.ourproject.kune.platf.client.dto.LinkDTO</class-a>
+ <class-b>org.ourproject.kune.platf.server.domain.User</class-b>
+ <field>
+ <a>longName</a>
+ <b>name</b>
+ </field>
+ </mapping>
+
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.ChatUserParamsDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.ChatUserParams
+ </class-b>
+ </mapping>
+
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.ContentStatusDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.domain.ContentStatus
+ </class-b>
+ </mapping>
+
+ <mapping>
+ <class-a>
+ org.ourproject.kune.platf.client.dto.AccessRolDTO
+ </class-a>
+ <class-b>
+ org.ourproject.kune.platf.server.access.AccessRol
+ </class-b>
+ </mapping>
+
</mappings>
\ No newline at end of file
Added: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistryTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistryTest.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistryTest.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -0,0 +1,81 @@
+package org.ourproject.kune.platf.client.actions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
+
+public class ContentIconsRegistryTest {
+
+ private static final String CONTENT_TYPE_TEST = "somecontenttype";
+ private static final String ICON = "someicon";
+ private static final String OTHERICON = "othericon";
+ private static final String JUSTANOTHERICON = "justanothericon";
+
+ private ContentIconsRegistry reg;
+
+ @Before
+ public void before() {
+ reg = new ContentIconsRegistry();
+ }
+
+ @Test
+ public void testBasic() {
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, ICON);
+ assertEquals(ICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST));
+ }
+
+ @Test
+ public void testBasicMimeType() {
+ final BasicMimeTypeDTO mimeType = new BasicMimeTypeDTO("image/png");
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, mimeType, ICON);
+ assertEquals(ICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, mimeType));
+ assertEquals("", reg.getContentTypeIcon(CONTENT_TYPE_TEST));
+ }
+
+ @Test
+ public void testBasicMimeTypeWithDef() {
+ final BasicMimeTypeDTO mimeType = new BasicMimeTypeDTO("image/png");
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, mimeType, ICON);
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, OTHERICON);
+ assertEquals(ICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, mimeType));
+ assertEquals(OTHERICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST));
+ }
+
+ @Test
+ public void testBasicMimeTypeWithDefType() {
+ final BasicMimeTypeDTO mimeType = new BasicMimeTypeDTO("image/png");
+ final BasicMimeTypeDTO genericMimeType = new BasicMimeTypeDTO("image");
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, mimeType, ICON);
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, genericMimeType, OTHERICON);
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, JUSTANOTHERICON);
+ assertEquals(ICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, mimeType));
+ assertEquals(OTHERICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, genericMimeType));
+ assertEquals(JUSTANOTHERICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST));
+ }
+
+ @Test
+ public void testBasicMimeTypeWithOnlyDefType() {
+ final BasicMimeTypeDTO mimeType = new BasicMimeTypeDTO("image/png");
+ final BasicMimeTypeDTO genericMimeType = new BasicMimeTypeDTO("image");
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, genericMimeType, OTHERICON);
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, JUSTANOTHERICON);
+ assertEquals(OTHERICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, mimeType));
+ assertEquals(OTHERICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, genericMimeType));
+ assertEquals(JUSTANOTHERICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST));
+ }
+
+ @Test
+ public void testNoResult() {
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, new BasicMimeTypeDTO("text", "plain"), ICON);
+ assertEquals("", reg.getContentTypeIcon(CONTENT_TYPE_TEST, new BasicMimeTypeDTO("text", "rtf")));
+ }
+
+ @Test
+ public void testNullBasicMimeType() {
+ final BasicMimeTypeDTO mimeType = null;
+ reg.registerContentTypeIcon(CONTENT_TYPE_TEST, ICON);
+ assertEquals(ICON, reg.getContentTypeIcon(CONTENT_TYPE_TEST, mimeType));
+ }
+}
Added: trunk/src/test/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTOTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTOTest.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/dto/BasicMimeTypeDTOTest.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -0,0 +1,47 @@
+package org.ourproject.kune.platf.client.dto;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class BasicMimeTypeDTOTest {
+
+ @Test
+ public void testNoSubtype() {
+ final BasicMimeTypeDTO mime = new BasicMimeTypeDTO("somesimplemime");
+ assertEquals("somesimplemime", mime.getType());
+ assertEquals(null, mime.getSubtype());
+ assertEquals("somesimplemime", mime.toString());
+ }
+
+ @Test
+ public void testNoSubtypeWithSlash() {
+ final BasicMimeTypeDTO mime = new BasicMimeTypeDTO("somesimplemime/");
+ assertEquals("somesimplemime", mime.getType());
+ assertEquals(null, mime.getSubtype());
+ assertEquals("somesimplemime", mime.toString());
+ }
+
+ @Test
+ public void testNull() {
+ final BasicMimeTypeDTO mime = new BasicMimeTypeDTO(null);
+ assertEquals(null, mime.getType());
+ assertEquals(null, mime.getSubtype());
+ }
+
+ @Test
+ public void testSeveralSlashs() {
+ final BasicMimeTypeDTO mime = new BasicMimeTypeDTO("somesimplemime/subtype/thisisposible?");
+ assertEquals("somesimplemime", mime.getType());
+ assertEquals("subtype/thisisposible?", mime.getSubtype());
+ assertEquals("somesimplemime/subtype/thisisposible?", mime.toString());
+ }
+
+ @Test
+ public void testSubtype() {
+ final BasicMimeTypeDTO mime = new BasicMimeTypeDTO("somesimplemime/subtype");
+ assertEquals("somesimplemime", mime.getType());
+ assertEquals("subtype", mime.getSubtype());
+ assertEquals("somesimplemime/subtype", mime.toString());
+ }
+}
Added: trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/manager/ContentManagerTest.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -0,0 +1,105 @@
+package org.ourproject.kune.platf.server.manager;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.ourproject.kune.platf.server.PersistenceTest;
+import org.ourproject.kune.platf.server.content.ContentManager;
+import org.ourproject.kune.platf.server.domain.BasicMimeType;
+import org.ourproject.kune.platf.server.domain.Container;
+import org.ourproject.kune.platf.server.domain.Content;
+import org.ourproject.kune.platf.server.domain.Group;
+import org.ourproject.kune.platf.server.domain.I18nCountry;
+import org.ourproject.kune.platf.server.domain.I18nLanguage;
+import org.ourproject.kune.platf.server.domain.License;
+import org.ourproject.kune.platf.server.domain.User;
+
+import com.google.inject.Inject;
+
+public class ContentManagerTest extends PersistenceTest {
+
+ @Inject
+ User userFinder;
+ @Inject
+ Group groupFinder;
+ @Inject
+ License licenseFinder;
+ @Inject
+ ContentManager contentManager;
+ @Inject
+ GroupManager groupManager;
+ @Inject
+ UserManager userManager;
+ @Inject
+ LicenseManager licenseManager;
+ @Inject
+ I18nLanguageManager languageManager;
+ @Inject
+ I18nCountryManager countryManager;
+ private User user;
+ private License defLicense;
+
+ public ContentManagerTest() {
+ super("test_db", "kune.properties");
+ }
+
+ @After
+ public void close() {
+ if (getTransaction().isActive()) {
+ getTransaction().rollback();
+ }
+ }
+
+ @Before
+ public void insertData() throws Exception {
+ openTransaction();
+ assertEquals(0, userFinder.getAll().size());
+ assertEquals(0, groupFinder.getAll().size());
+ assertEquals(0, licenseFinder.getAll().size());
+ final I18nLanguage english = new I18nLanguage(new Long(1819), "English", "English", "en");
+ languageManager.persist(english);
+ final I18nCountry gb = new I18nCountry(new Long(75), "GB", "GBP", ".", "£%n", "", ".", "United Kingdom",
+ "western", ",");
+ countryManager.persist(gb);
+ user = userManager.createUser("username", "the user name", "email at example.com", "userPassword", "en", "GB",
+ TimeZone.getDefault().getID());
+ defLicense = new License("by-sa", "Creative Commons Attribution-ShareAlike", "",
+ "http://creativecommons.org/licenses/by-sa/3.0/", true, true, false, "", "");
+ licenseManager.persist(defLicense);
+ groupManager.createUserGroup(user);
+ }
+
+ @Test
+ public void testBasicMimePersist() {
+ final String mimetype = "application/pdf";
+ createContentWithMime(mimetype);
+ }
+
+ @Test
+ public void testBasicMimePersistWithoutSubtype() {
+ final String mimetype = "application";
+ createContentWithMime(mimetype);
+ }
+
+ @Test
+ public void testUTF8Persist() {
+ final Container container = Mockito.mock(Container.class);
+ final Content cnt = contentManager.createContent("汉语/漢語", "汉语/漢語", user, container);
+ final Content newCnt = contentManager.find(cnt.getId());
+ assertEquals("汉语/漢語", newCnt.getTitle());
+ }
+
+ private void createContentWithMime(final String mimetype) {
+ final Container container = Mockito.mock(Container.class);
+ final Content cnt = contentManager.createContent("title", "body", user, container);
+ cnt.setMimeType(new BasicMimeType(mimetype));
+ persist(cnt);
+ final Content newCnt = contentManager.find(cnt.getId());
+ assertEquals(mimetype, newCnt.getMimeType().toString());
+ }
+}
Modified: trunk/src/test/java/org/ourproject/kune/platf/server/manager/GroupManagerTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/manager/GroupManagerTest.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/manager/GroupManagerTest.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -48,169 +48,168 @@
@After
public void close() {
- if (getTransaction().isActive()) {
- getTransaction().rollback();
- }
-
+ if (getTransaction().isActive()) {
+ getTransaction().rollback();
+ }
}
@Test
public void createdGroupShoudHaveValidSocialNetwork() throws Exception {
- final Group group = new Group("short", "longName", defLicense, GroupType.PROJECT);
- groupManager.createGroup(group, user);
- final SocialNetwork socialNetwork = group.getSocialNetwork();
- final AccessLists lists = socialNetwork.getAccessLists();
- assertTrue(lists.getAdmins().includes(user.getUserGroup()));
- assertTrue(lists.getEditors().isEmpty());
- assertTrue(lists.getViewers().isEmpty());
- closeTransaction();
+ final Group group = new Group("short", "longName", defLicense, GroupType.PROJECT);
+ groupManager.createGroup(group, user);
+ final SocialNetwork socialNetwork = group.getSocialNetwork();
+ final AccessLists lists = socialNetwork.getAccessLists();
+ assertTrue(lists.getAdmins().includes(user.getUserGroup()));
+ assertTrue(lists.getEditors().isEmpty());
+ assertTrue(lists.getViewers().isEmpty());
+ closeTransaction();
}
@Test
public void createGroup() throws Exception {
- final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
- GroupType.PROJECT);
- groupManager.createGroup(group, user);
- final Group otherGroup = groupManager.findByShortName("ysei");
+ final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+ GroupType.PROJECT);
+ groupManager.createGroup(group, user);
+ final Group otherGroup = groupManager.findByShortName("ysei");
- assertEquals(group.getLongName(), otherGroup.getLongName());
- assertEquals(group.getShortName(), otherGroup.getShortName());
- closeTransaction();
+ assertEquals(group.getLongName(), otherGroup.getLongName());
+ assertEquals(group.getShortName(), otherGroup.getShortName());
+ closeTransaction();
}
@Test
public void createGroupAndSearch() throws Exception, ParseException {
- final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
- GroupType.PROJECT);
- groupManager.createGroup(group, user);
- groupManager.reIndex();
- final SearchResult<Group> result = groupManager.search("ysei");
- assertEquals(1, (long) result.getSize());
- assertEquals("ysei", result.getList().get(0).getShortName());
- rollbackTransaction();
+ final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+ GroupType.PROJECT);
+ groupManager.createGroup(group, user);
+ groupManager.reIndex();
+ final SearchResult<Group> result = groupManager.search("ysei");
+ assertEquals(1, (long) result.getSize());
+ assertEquals("ysei", result.getList().get(0).getShortName());
+ rollbackTransaction();
}
@Test(expected = GroupNameInUseException.class)
public void createGroupWithExistingLongName() throws Exception {
- final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
- GroupType.PROJECT);
- groupManager.createGroup(group, user);
+ final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+ GroupType.PROJECT);
+ groupManager.createGroup(group, user);
- final Group group2 = new Group("ysei2", "Yellow Submarine Environmental Initiative", defLicense,
- GroupType.PROJECT);
- group2.setDefaultLicense(defLicense);
- groupManager.createGroup(group2, user);
+ final Group group2 = new Group("ysei2", "Yellow Submarine Environmental Initiative", defLicense,
+ GroupType.PROJECT);
+ group2.setDefaultLicense(defLicense);
+ groupManager.createGroup(group2, user);
- rollbackTransaction();
+ rollbackTransaction();
}
@Test(expected = GroupNameInUseException.class)
public void createGroupWithExistingShortName() throws Exception {
- final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
- GroupType.PROJECT);
- groupManager.createGroup(group, user);
+ final Group group = new Group("ysei", "Yellow Submarine Environmental Initiative", defLicense,
+ GroupType.PROJECT);
+ groupManager.createGroup(group, user);
- final Group group2 = new Group("ysei", "Yellow Submarine Environmental Initiative 2", defLicense,
- GroupType.PROJECT);
- groupManager.createGroup(group2, user);
+ final Group group2 = new Group("ysei", "Yellow Submarine Environmental Initiative 2", defLicense,
+ GroupType.PROJECT);
+ groupManager.createGroup(group2, user);
- rollbackTransaction();
+ rollbackTransaction();
}
@Test(expected = EmailAddressInUseException.class)
public void createUserExistingEmail() throws I18nNotFoundException, GroupNameInUseException,
- EmailAddressInUseException {
- final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
- "GB", "GMT");
- groupManager.createUserGroup(user1);
- final User user2 = userManager.createUser("test2", "test 2 name", "test1 at example.com", "some password", "en",
- "GB", "GMT");
- groupManager.createUserGroup(user2);
+ EmailAddressInUseException {
+ final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
+ "GB", "GMT");
+ groupManager.createUserGroup(user1);
+ final User user2 = userManager.createUser("test2", "test 2 name", "test1 at example.com", "some password", "en",
+ "GB", "GMT");
+ groupManager.createUserGroup(user2);
}
@Test(expected = GroupNameInUseException.class)
public void createUserExistingLongName() throws I18nNotFoundException, GroupNameInUseException,
- EmailAddressInUseException {
- final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
- "GB", "GMT");
- groupManager.createUserGroup(user1);
- final User user2 = userManager.createUser("test2", "test 1 name", "test2 at example.com", "some password", "en",
- "GB", "GMT");
- groupManager.createUserGroup(user2);
+ EmailAddressInUseException {
+ final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
+ "GB", "GMT");
+ groupManager.createUserGroup(user1);
+ final User user2 = userManager.createUser("test2", "test 1 name", "test2 at example.com", "some password", "en",
+ "GB", "GMT");
+ groupManager.createUserGroup(user2);
}
@Test(expected = GroupNameInUseException.class)
public void createUserExistingShortName() throws I18nNotFoundException, GroupNameInUseException,
- EmailAddressInUseException {
- final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
- "GB", "GMT");
- groupManager.createUserGroup(user1);
- final User user2 = userManager.createUser("test", "test 2 name", "test2 at example.com", "some password", "en",
- "GB", "GMT");
- groupManager.createUserGroup(user2);
+ EmailAddressInUseException {
+ final User user1 = userManager.createUser("test", "test 1 name", "test1 at example.com", "some password", "en",
+ "GB", "GMT");
+ groupManager.createUserGroup(user1);
+ final User user2 = userManager.createUser("test", "test 2 name", "test2 at example.com", "some password", "en",
+ "GB", "GMT");
+ groupManager.createUserGroup(user2);
}
@Test(expected = EmailAddressInUseException.class)
public void createUserWithExistingEmail() throws Exception {
- final User user2 = userManager.createUser("username2", "the user name 2", "email at example.com", "userPassword",
- "en", "GB", TimeZone.getDefault().getID());
- groupManager.createUserGroup(user2);
- rollbackTransaction();
+ final User user2 = userManager.createUser("username2", "the user name 2", "email at example.com", "userPassword",
+ "en", "GB", TimeZone.getDefault().getID());
+ groupManager.createUserGroup(user2);
+ rollbackTransaction();
}
@Test(expected = GroupNameInUseException.class)
public void createUserWithExistingLongName() throws Exception {
- final User user2 = userManager.createUser("username2", "the user name", "email2 at example.com", "userPassword",
- "en", "GB", TimeZone.getDefault().getID());
- groupManager.createUserGroup(user2);
- rollbackTransaction();
+ final User user2 = userManager.createUser("username2", "the user name", "email2 at example.com", "userPassword",
+ "en", "GB", TimeZone.getDefault().getID());
+ groupManager.createUserGroup(user2);
+ rollbackTransaction();
}
@Test(expected = GroupNameInUseException.class)
public void createUserWithExistingShortName() throws Exception {
- final User user2 = userManager.createUser("username", "the user name 2", "email2 at example.com", "userPassword",
- "en", "GB", TimeZone.getDefault().getID());
- groupManager.createUserGroup(user2);
- rollbackTransaction();
+ final User user2 = userManager.createUser("username", "the user name 2", "email2 at example.com", "userPassword",
+ "en", "GB", TimeZone.getDefault().getID());
+ groupManager.createUserGroup(user2);
+ rollbackTransaction();
}
@Test
public void groupSearchPagination() throws Exception, ParseException {
- for (int i = 1; i < 10; i++) {
- createTestGroup(i);
- }
- groupManager.reIndex();
- final SearchResult<Group> result = groupManager.search("Yellow", 0, 5);
- assertEquals(9, (long) result.getSize());
- assertEquals(5, result.getList().size());
- final SearchResult<Group> result2 = groupManager.search("Yellow", 5, 5);
- assertEquals(9, (long) result2.getSize());
- assertEquals(4, result2.getList().size());
- rollbackTransaction();
+ for (int i = 1; i < 10; i++) {
+ createTestGroup(i);
+ }
+ groupManager.reIndex();
+ final SearchResult<Group> result = groupManager.search("Yellow", 0, 5);
+ assertEquals(9, (long) result.getSize());
+ assertEquals(5, result.getList().size());
+ final SearchResult<Group> result2 = groupManager.search("Yellow", 5, 5);
+ assertEquals(9, (long) result2.getSize());
+ assertEquals(4, result2.getList().size());
+ rollbackTransaction();
}
@Before
public void insertData() throws Exception {
- openTransaction();
- assertEquals(0, userFinder.getAll().size());
- assertEquals(0, groupFinder.getAll().size());
- assertEquals(0, licenseFinder.getAll().size());
- final I18nLanguage english = new I18nLanguage(new Long(1819), "English", "English", "en");
- languageManager.persist(english);
- final I18nCountry gb = new I18nCountry(new Long(75), "GB", "GBP", ".", "£%n", "", ".", "United Kingdom",
- "western", ",");
- countryManager.persist(gb);
- user = userManager.createUser("username", "the user name", "email at example.com", "userPassword", "en", "GB",
- TimeZone.getDefault().getID());
- defLicense = new License("by-sa", "Creative Commons Attribution-ShareAlike", "",
- "http://creativecommons.org/licenses/by-sa/3.0/", true, true, false, "", "");
- licenseManager.persist(defLicense);
- groupManager.createUserGroup(user);
+ openTransaction();
+ assertEquals(0, userFinder.getAll().size());
+ assertEquals(0, groupFinder.getAll().size());
+ assertEquals(0, licenseFinder.getAll().size());
+ final I18nLanguage english = new I18nLanguage(new Long(1819), "English", "English", "en");
+ languageManager.persist(english);
+ final I18nCountry gb = new I18nCountry(new Long(75), "GB", "GBP", ".", "£%n", "", ".", "United Kingdom",
+ "western", ",");
+ countryManager.persist(gb);
+ user = userManager.createUser("username", "the user name", "email at example.com", "userPassword", "en", "GB",
+ TimeZone.getDefault().getID());
+ defLicense = new License("by-sa", "Creative Commons Attribution-ShareAlike", "",
+ "http://creativecommons.org/licenses/by-sa/3.0/", true, true, false, "", "");
+ licenseManager.persist(defLicense);
+ groupManager.createUserGroup(user);
}
private void createTestGroup(final int number) throws Exception {
- final Group g = new Group("ysei" + number, "Yellow Submarine Environmental Initiative " + number, defLicense,
- GroupType.PROJECT);
- groupManager.createGroup(g, user);
+ final Group g = new Group("ysei" + number, "Yellow Submarine Environmental Initiative " + number, defLicense,
+ GroupType.PROJECT);
+ groupManager.createGroup(g, user);
}
}
Modified: trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManagerTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManagerTest.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManagerTest.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -4,12 +4,12 @@
import org.junit.Test;
import org.ourproject.kune.platf.client.errors.SessionExpiredException;
import org.ourproject.kune.platf.client.errors.UserMustBeLoggedException;
-import org.ourproject.kune.platf.integration.IntegrationTest;
import org.ourproject.kune.platf.integration.IntegrationTestHelper;
+import org.ourproject.kune.platf.integration.content.ContentServiceIntegrationTest;
import com.google.inject.Inject;
-public class FileUploadManagerTest extends IntegrationTest {
+public class FileUploadManagerTest extends ContentServiceIntegrationTest {
@Inject
FileUploadManager fileUploadManager;
@@ -19,6 +19,18 @@
new IntegrationTestHelper(this);
}
+ // @Test
+ public void testMimeTypePersist() throws Exception {
+ // doLogin();
+ // final FileItem fileItem = Mockito.mock(FileItem.class);
+ // file = File.createTempFile("test", ".txt");
+ // final Content cnt = fileUploadManager.createFile(super.getHash(),
+ // getDefaultContent().getContainer()
+ // .getStateToken(), "somefilename", fileItem);
+ // final StateDTO state = contentService.getContent(getHash(),
+ // cnt.getStateToken());
+ }
+
@Test(expected = SessionExpiredException.class)
public void testSessionExp() throws Exception {
fileUploadManager.createFile("otherhash", null, null, null);
Modified: trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java 2008-09-24 22:54:07 UTC (rev 884)
+++ trunk/src/test/java/org/ourproject/kune/platf/server/mapper/MapperTest.java 2008-09-26 01:40:25 UTC (rev 885)
@@ -23,6 +23,7 @@
import org.ourproject.kune.platf.server.TestDomainHelper;
import org.ourproject.kune.platf.server.TestHelper;
import org.ourproject.kune.platf.server.access.AccessRights;
+import org.ourproject.kune.platf.server.domain.BasicMimeType;
import org.ourproject.kune.platf.server.domain.Comment;
import org.ourproject.kune.platf.server.domain.Container;
import org.ourproject.kune.platf.server.domain.Content;
@@ -208,6 +209,14 @@
}
@Test
+ public void testMimeMapping() {
+ final Content d = createDefContent();
+ d.setMimeType(new BasicMimeType("application/pdf"));
+ final ContentDTO contentDTO = mapper.map(d, ContentDTO.class);
+ assertEquals("application/pdf", contentDTO.getMimeType().toString());
+ }
+
+ @Test
public void testStateTokenInStateMap() {
final StateToken stateToken = new StateToken(TESTGROUPSHORTNAME, TESTTOOL, "1", "2");
final StateToken stateTokenMapped = mapper.map(stateToken, StateToken.class);
More information about the kune-commits
mailing list