update to support links

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-widget-portlet@167711 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2018-05-23 15:06:09 +00:00
parent bc9b5fbccb
commit 8b3f6b5c25
4 changed files with 29 additions and 112 deletions

View File

@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="storagehub-icons-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/storagehub-icons-library/storagehub-icons-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="workspace-widget-portlet"/>
<property name="java-output-path" value="/workspace-widget-portlet/target/classes"/>
</wb-module>

View File

@ -54,6 +54,11 @@
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>storagehub-icons-library</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>

View File

@ -8,10 +8,13 @@ import java.util.Date;
import java.util.List;
import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.gcube.common.storagehub.model.items.VreFolder;
import org.gcube.portal.stohubicons.IconsManager;
import org.gcube.portal.stohubicons.shared.MDIcon;
import org.gcube.portlets.user.wswidget.shared.ItemType;
import org.gcube.portlets.user.wswidget.shared.WSItem;
import org.gcube.vomanagement.usermanagement.UserManager;
@ -39,7 +42,6 @@ public class ItemBuilder {
boolean isSharedFolder = (type.equals(ItemType.SHARED_FOLDER) || type.equals(ItemType.VRE_FOLDER )) ? true : false;
String itemName = workspaceItem.getName();
if(isSharedFolder){
_log.info("Is shared folder: "+workspaceItem.getTitle());
SharedFolder shared = (SharedFolder) workspaceItem;
@ -66,15 +68,24 @@ public class ItemBuilder {
} else if (isFolder) {
item.setIconNameAndColor("folder", "#8F8F8F");// #gray
}
else { //is a file
String[] splits = item.getName().split("\\.");
String extension = "";
if (splits.length > 0) {
extension = splits[splits.length-1];
else { //is a file, a Link or an XML
MDIcon mdIcon = IconsManager.getDefault();
if (workspaceItem instanceof ExternalURL) {
mdIcon = IconsManager.getIconTypeLink();
} else {
AbstractFileItem aItem = (AbstractFileItem) workspaceItem;
if (aItem.getContent().getMimeType().compareTo("application/xml") == 0) {
mdIcon = IconsManager.getXMLTypeLink();
} else {
String[] splits = item.getName().split("\\.");
String extension = "";
if (splits.length > 0) {
extension = splits[splits.length-1];
}
mdIcon = IconsManager.getMDIconTextualName(extension);
}
}
String iconURL = Utils.getIconImage(Utils.getFileIconImageType(extension).toString());
String iconColor = Utils.getIconColor(Utils.getFileIconImageType(extension).toString());
item.setIconNameAndColor(iconURL, iconColor);
item.setIconNameAndColor(mdIcon.getTextualName(), mdIcon.getColor());
}
} catch(Exception e){
_log.error("Error on getting item: "+itemName+" with id: "+workspaceItem.getId()+", from HL, so skipping item " + e.getMessage());

View File

@ -14,7 +14,6 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.wswidget.shared.ImageType;
import org.gcube.portlets.user.wswidget.shared.ItemType;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
@ -46,60 +45,7 @@ public class Utils {
return true;
return false;
}
public static String getIconImage(String type) {
switch (type) {
case "DOC":
return "description";
case "XLS":
return "description";
case "PPT":
return "description";
case "PDF":
return "picture_as_pdf";
case "IMAGE":
return "panorama";
case "MOVIE":
return "movie_creation";
case "HTML":
return "web";
case "RAR":
return "archive";
case "ZIP":
return "archive";
case "TXT":
return "description";
default:
return "insert_drive_file";
}
}
public static String getIconColor(String type) {
switch (type) {
case "DOC":
return "#0277bd"; // light-blue darken-3
case "XLS":
return "#4caf50"; //green
case "PPT":
return "#fb8c00"; //orange
case "PDF":
return "#f44336"; //red
case "IMAGE":
return "#d81b60"; //light blue
case "MOVIE":
return "#90caf9";
case "HTML":
return "#0277bd";
case "RAR":
return "#ffc107";
case "ZIP":
return "#ffc107";//amber
case "TXT":
return "#CCC"; // gray
default:
return "#CCC"; // gray
}
}
public static GCubeUser getCurrentUser(RenderRequest request) {
long userId;
try {
@ -235,52 +181,4 @@ public class Utils {
return token;
}
public static ImageType getFileIconImageType(String extension) {
if (extension == null || extension.compareTo("") == 0)
return ImageType.NONE;
extension = extension.toLowerCase();
switch (extension) {
case "doc":
case "docx":
return ImageType.DOC;
case "rtf":
case "txt":
return ImageType.TXT;
case "xls":
case "xlsx":
return ImageType.XLS;
case "ppt":
case "pptx":
return ImageType.PPT;
case "pdf":
return ImageType.PDF;
case "jpg":
case "jpeg":
case "gif":
case "bmp":
case "png":
case "tif":
case "tiff":
return ImageType.IMAGE;
case "avi":
case "mp4":
case "mpeg":
return ImageType.MOVIE;
case "html":
case "htm":
case "jsp":
return ImageType.HTML;
case "rar":
return ImageType.RAR;
case "zip":
case "tar":
case "tar.gz":
case ".cpgz":
case ".gz":
return ImageType.ZIP;
default:
return ImageType.NONE;
}
}
}