ref 13226:StorageHub - Update workspace-sharing-widget to SH
https://support.d4science.org/issues/13226 Updated to StorageHub git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@177242 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6cb6d82820
commit
22074fee73
|
@ -27,16 +27,12 @@ public class ExtendedInfoContactModel extends InfoContactModel {
|
|||
super(id, login, fullName, isGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return use this client side
|
||||
*/
|
||||
|
||||
public void setIcon() {
|
||||
set(ICON, getIcon());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return use this client side
|
||||
*/
|
||||
|
||||
public Image getIcon() {
|
||||
|
||||
if (!this.isGroup()) // NOT IS GROUP
|
||||
|
|
|
@ -7,12 +7,11 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel
|
|||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||
* May 12, 2014
|
||||
* May 12, 2014
|
||||
*
|
||||
*/
|
||||
public class FileTrashedModel extends FileGridModel {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -22,34 +21,18 @@ public class FileTrashedModel extends FileGridModel {
|
|||
private Date deleteDate;
|
||||
private InfoContactModel deletedBy;
|
||||
|
||||
public static enum STOREINFO {ORIGINALPATH, DELETEDATE, DELETEUSER}
|
||||
|
||||
|
||||
public static enum STOREINFO {
|
||||
ORIGINALPATH, DELETEDATE, DELETEUSER
|
||||
}
|
||||
|
||||
public FileTrashedModel() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param identifier
|
||||
* @param name
|
||||
* @param path
|
||||
* @param creationDate
|
||||
* @param parent
|
||||
* @param size
|
||||
* @param isDirectory
|
||||
* @param isShared
|
||||
*/
|
||||
public FileTrashedModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
|
||||
|
||||
public FileTrashedModel(String identifier, String name, String path, Date creationDate, FileModel parent, long size,
|
||||
boolean isDirectory, boolean isShared) {
|
||||
super(identifier, name, path, creationDate, parent, size, isDirectory, isShared);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param orginalPath
|
||||
* @param deleteDate
|
||||
* @param deleteUser
|
||||
*/
|
||||
|
||||
public FileTrashedModel(String orginalPath, Date deleteDate, InfoContactModel deleteUser) {
|
||||
super();
|
||||
this.orginalPath = orginalPath;
|
||||
|
@ -57,18 +40,8 @@ public class FileTrashedModel extends FileGridModel {
|
|||
this.deletedBy = deleteUser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param identifier
|
||||
* @param name
|
||||
* @param creationDate
|
||||
* @param parent
|
||||
* @param size
|
||||
* @param isDirectory
|
||||
* @param isShared
|
||||
*/
|
||||
public FileTrashedModel(String identifier, String name, Date creationDate, FileModel parent, long size, boolean isDirectory, boolean isShared) {
|
||||
public FileTrashedModel(String identifier, String name, Date creationDate, FileModel parent, long size,
|
||||
boolean isDirectory, boolean isShared) {
|
||||
super(identifier, name, creationDate, parent, size, isDirectory, isShared);
|
||||
}
|
||||
|
||||
|
@ -99,7 +72,6 @@ public class FileTrashedModel extends FileGridModel {
|
|||
set(STOREINFO.DELETEUSER.toString(), deleteUser.getName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -29,10 +29,7 @@ public class GcubeVRE extends BaseModelData implements IsSerializable{
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vreName
|
||||
* @param vreScope
|
||||
*/
|
||||
|
||||
public GcubeVRE(String vreName, String vreScope) {
|
||||
|
||||
super();
|
||||
|
|
|
@ -15,61 +15,96 @@ import com.extjs.gxt.ui.client.data.BaseModelData;
|
|||
*/
|
||||
public class MessageModel extends BaseModelData implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MessageModel() {}
|
||||
public MessageModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* USED IN OPEN MESSAGE
|
||||
* USED IN OPEN MESSAGE
|
||||
*
|
||||
* @param id
|
||||
* id
|
||||
* @param subject
|
||||
* subject
|
||||
* @param sender
|
||||
* sender
|
||||
* @param date
|
||||
* date
|
||||
* @param text
|
||||
* text
|
||||
* @param attachs
|
||||
* attachs
|
||||
* @param listContactsToString
|
||||
* contacts
|
||||
* @param messageType
|
||||
* message type
|
||||
* @param isRead
|
||||
* is read
|
||||
*/
|
||||
public MessageModel(String id, String subject, InfoContactModel sender, Date date, String text, List<FileModel> attachs, List<String> listContactsToString, String messageType, boolean isRead) {
|
||||
this(id,subject,sender,date,attachs.size(),isRead, messageType);
|
||||
public MessageModel(String id, String subject, InfoContactModel sender, Date date, String text,
|
||||
List<FileModel> attachs, List<String> listContactsToString, String messageType, boolean isRead) {
|
||||
this(id, subject, sender, date, attachs.size(), isRead, messageType);
|
||||
setListContactsToString(listContactsToString);
|
||||
setListAttachments(attachs);
|
||||
setText(text);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* BASIC CONSTRUCTOR
|
||||
*
|
||||
* @param id
|
||||
* id
|
||||
* @param subject
|
||||
* subject
|
||||
* @param sender
|
||||
* sender
|
||||
* @param date
|
||||
* date
|
||||
* @param numAttachs
|
||||
* attachs num
|
||||
* @param isRead
|
||||
* is read
|
||||
* @param messageType
|
||||
* message type
|
||||
*/
|
||||
public MessageModel(String id, String subject, InfoContactModel sender, Date date, int numAttachs, boolean isRead, String messageType) {
|
||||
public MessageModel(String id, String subject, InfoContactModel sender, Date date, int numAttachs, boolean isRead,
|
||||
String messageType) {
|
||||
setId(id);
|
||||
setSubject(subject);
|
||||
setFromContact(sender);
|
||||
setDate(date);
|
||||
setFromLogin(sender.getLogin());
|
||||
setNumAttachments(numAttachs);
|
||||
setRead(""+isRead);
|
||||
setRead("" + isRead);
|
||||
setMessageType(messageType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* USED TO VIEW MESSAGE IN GRID
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* id
|
||||
* @param subject
|
||||
* subject
|
||||
* @param sender
|
||||
* sender
|
||||
* @param date
|
||||
* date
|
||||
* @param attachsNames
|
||||
* attachs names
|
||||
* @param messageType
|
||||
* message type
|
||||
* @param isRead
|
||||
* is read
|
||||
*/
|
||||
public MessageModel(String id, String subject, InfoContactModel sender, Date date, List<String> attachsNames, String messageType, boolean isRead) {
|
||||
public MessageModel(String id, String subject, InfoContactModel sender, Date date, List<String> attachsNames,
|
||||
String messageType, boolean isRead) {
|
||||
setId(id);
|
||||
setSubject(subject);
|
||||
setFromContact(sender);
|
||||
|
@ -77,63 +112,60 @@ public class MessageModel extends BaseModelData implements Serializable {
|
|||
setFromLogin(sender.getLogin());
|
||||
setNumAttachments(attachsNames.size());
|
||||
setMessageType(messageType);
|
||||
setRead(""+isRead);
|
||||
// System.out.println("##################IN CONSTRUCTROR Attach size: " + attachsNames.size());
|
||||
setAttachmentsNames(attachsNames);
|
||||
// System.out.println("##########START MESSAGE: " + id);
|
||||
//
|
||||
// for(String mess: attachsNames){
|
||||
// System.out.println("##################IN CONSTRUCTROR Attach: " + mess);
|
||||
// }
|
||||
//
|
||||
// System.out.println("##########END MESSAGE: " + id);
|
||||
setRead("" + isRead);
|
||||
// System.out.println("##################IN CONSTRUCTROR Attach size: "
|
||||
// + attachsNames.size());
|
||||
setAttachmentsNames(attachsNames);
|
||||
// System.out.println("##########START MESSAGE: " + id);
|
||||
//
|
||||
// for(String mess: attachsNames){
|
||||
// System.out.println("##################IN CONSTRUCTROR Attach: " +
|
||||
// mess);
|
||||
// }
|
||||
//
|
||||
// System.out.println("##########END MESSAGE: " + id);
|
||||
setAttachmentsNamesView(attachsNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set string with first attach name and the numbers of attachs
|
||||
* @param attachsNames
|
||||
*/
|
||||
|
||||
private void setAttachmentsNamesView(List<String> attachsNames) {
|
||||
if(attachsNames.size()==0){
|
||||
set(ConstantsExplorer.ATTACHS, "");
|
||||
}else if(attachsNames.size() == 1){
|
||||
set(ConstantsExplorer.ATTACHS, attachsNames.get(0));
|
||||
}else if(attachsNames.size() > 1)
|
||||
set(ConstantsExplorer.ATTACHS, attachsNames.get(0) + " [+"+attachsNames.size() + "]");
|
||||
if (attachsNames.size() == 0) {
|
||||
set(ConstantsExplorer.ATTACHS, "");
|
||||
} else if (attachsNames.size() == 1) {
|
||||
set(ConstantsExplorer.ATTACHS, attachsNames.get(0));
|
||||
} else if (attachsNames.size() > 1)
|
||||
set(ConstantsExplorer.ATTACHS, attachsNames.get(0) + " [+" + attachsNames.size() + "]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setMessageType(String messageType) {
|
||||
set(ConstantsExplorer.MESSAGETYPE, messageType);
|
||||
set(ConstantsExplorer.MESSAGETYPE, messageType);
|
||||
}
|
||||
|
||||
private void setAttachmentsNames(List<String> attachsNames) {
|
||||
set(ConstantsExplorer.LISTATTACHMENTSNAMES, attachsNames);
|
||||
set(ConstantsExplorer.LISTATTACHMENTSNAMES, attachsNames);
|
||||
}
|
||||
|
||||
|
||||
private void setListContactsToString(List<String> listContactsToString) {
|
||||
set(ConstantsExplorer.LISTCONTACTSTOSTRING, listContactsToString);
|
||||
set(ConstantsExplorer.LISTCONTACTSTOSTRING, listContactsToString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setRead(String isRead) {
|
||||
set(ConstantsExplorer.ISREAD, isRead);
|
||||
|
||||
set(ConstantsExplorer.ISREAD, isRead);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getIsRead() {
|
||||
return get(ConstantsExplorer.ISREAD);
|
||||
}
|
||||
|
||||
private void setListContactsTo(List<InfoContactModel> listContactsTo) {
|
||||
set(ConstantsExplorer.LISTCONTACTSTO, listContactsTo);
|
||||
set(ConstantsExplorer.LISTCONTACTSTO, listContactsTo);
|
||||
}
|
||||
|
||||
|
||||
private void setListAttachments(List<FileModel> listAttachs) {
|
||||
set(ConstantsExplorer.LISTATTACHS, listAttachs);
|
||||
set(ConstantsExplorer.LISTATTACHS, listAttachs);
|
||||
}
|
||||
|
||||
|
||||
private void setDate(Date date) {
|
||||
set(ConstantsExplorer.DATE, date);
|
||||
}
|
||||
|
@ -145,21 +177,20 @@ public class MessageModel extends BaseModelData implements Serializable {
|
|||
public void setId(String id) {
|
||||
set(ConstantsExplorer.ID, id);
|
||||
}
|
||||
|
||||
|
||||
private void setText(String text) {
|
||||
set(ConstantsExplorer.TEXTMESS, text);
|
||||
set(ConstantsExplorer.TEXTMESS, text);
|
||||
}
|
||||
|
||||
|
||||
private void setFromContact(InfoContactModel contact) {
|
||||
set(ConstantsExplorer.FROM, contact);
|
||||
set(ConstantsExplorer.FROM, contact);
|
||||
}
|
||||
|
||||
private void setSubject(String subject) {
|
||||
set(ConstantsExplorer.SUBJECT, subject);
|
||||
}
|
||||
|
||||
private void setFromLogin(String login){
|
||||
|
||||
private void setFromLogin(String login) {
|
||||
set(ConstantsExplorer.FROMLOGIN, login);
|
||||
}
|
||||
|
||||
|
@ -170,49 +201,45 @@ public class MessageModel extends BaseModelData implements Serializable {
|
|||
public String getSubject() {
|
||||
return get(ConstantsExplorer.SUBJECT);
|
||||
}
|
||||
|
||||
|
||||
public Date getDate() {
|
||||
return (Date) get(ConstantsExplorer.DATE);
|
||||
}
|
||||
|
||||
|
||||
public int getNumAttchments() {
|
||||
return (Integer) get(ConstantsExplorer.NUMATTACHS);
|
||||
}
|
||||
|
||||
|
||||
public InfoContactModel getFromContact() {
|
||||
return (InfoContactModel) get(ConstantsExplorer.FROM);
|
||||
}
|
||||
|
||||
|
||||
public String getFromLogin() {
|
||||
return get(ConstantsExplorer.FROMLOGIN);
|
||||
}
|
||||
|
||||
|
||||
public String getTextMessage() {
|
||||
return get(ConstantsExplorer.TEXTMESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* used in grid
|
||||
* @return
|
||||
*/
|
||||
public String getAttachmentsNamesView() {
|
||||
return get(ConstantsExplorer.ATTACHS);
|
||||
}
|
||||
|
||||
|
||||
public List<InfoContactModel> getListContactsTo() {
|
||||
return get(ConstantsExplorer.LISTCONTACTSTO);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getListContactsToString() {
|
||||
return get(ConstantsExplorer.LISTCONTACTSTOSTRING);
|
||||
}
|
||||
|
||||
|
||||
public List<FileModel> getListAttachments() {
|
||||
return get(ConstantsExplorer.LISTATTACHS);
|
||||
}
|
||||
|
||||
public String getMessageType(){
|
||||
|
||||
public String getMessageType() {
|
||||
return get(ConstantsExplorer.MESSAGETYPE);
|
||||
}
|
||||
|
||||
|
@ -248,5 +275,5 @@ public class MessageModel extends BaseModelData implements Serializable {
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,7 +2,8 @@ package org.gcube.portlets.user.workspace.client.util;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it May 8, 2014
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||
* May 8, 2014
|
||||
*
|
||||
*/
|
||||
public class GroupNameUtilSeparator {
|
||||
|
@ -24,6 +25,7 @@ public class GroupNameUtilSeparator {
|
|||
* name
|
||||
* @param separatorStartIndex
|
||||
* start
|
||||
* @return sub sequence
|
||||
* @throws Exception
|
||||
* error
|
||||
*/
|
||||
|
@ -58,7 +60,6 @@ public class GroupNameUtilSeparator {
|
|||
return displayName;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
GroupNameUtilSeparator filter = new GroupNameUtilSeparator("/");
|
||||
|
|
|
@ -132,15 +132,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
* @return the workspace
|
||||
*
|
||||
* @return Workspace
|
||||
* @throws InternalErrorException
|
||||
* the internal error exception
|
||||
* @throws InternalErrorException
|
||||
* the internal error exception
|
||||
* Internal error
|
||||
* @throws HomeNotFoundException
|
||||
* the home not found exception
|
||||
* Home not found error
|
||||
* @throws WorkspaceFolderNotFoundException
|
||||
* the workspace folder not found exception
|
||||
* Folder not found error
|
||||
* @throws org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException
|
||||
* StorageHub Internal error
|
||||
*/
|
||||
protected Workspace getWorkspace()
|
||||
throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException,
|
||||
|
@ -1084,9 +1085,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
// workspaceLogger.trace("######### SEND TO: ");
|
||||
// workspaceLogger.trace("subject " + subject);
|
||||
// workspaceLogger.trace("body " + body);
|
||||
// workspaceLogger.trace("######### SEND TO: ");
|
||||
// workspaceLogger.trace("subject " + subject);
|
||||
// workspaceLogger.trace("body " + body);
|
||||
|
||||
// DEBUG
|
||||
for (String contactId : listContactsId)
|
||||
|
@ -1168,8 +1169,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/** Gets the list parents by item identifier.
|
||||
/**
|
||||
* Gets the list parents by item identifier.
|
||||
*
|
||||
* @param itemIdentifier
|
||||
* the item identifier
|
||||
|
@ -2653,7 +2654,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
org.gcube.common.storagehub.model.items.FolderItem.class);
|
||||
|
||||
for (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem workspaceItem : children) {
|
||||
workspaceLogger.trace("The ITEM: "+workspaceItem.getName() + ", is shared: "+workspaceItem.isShared() + ", is folder: "+workspaceItem.isFolder() +" the id: "+workspaceItem.getId());
|
||||
workspaceLogger
|
||||
.trace("The ITEM: " + workspaceItem.getName() + ", is shared: " + workspaceItem.isShared()
|
||||
+ ", is folder: " + workspaceItem.isFolder() + " the id: " + workspaceItem.getId());
|
||||
}
|
||||
|
||||
StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter();
|
||||
|
@ -2709,10 +2712,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
* System.out.println(i++ +")"+fileModel); }
|
||||
*/
|
||||
|
||||
// if(!WsUtil.isWithinPortal()){
|
||||
// workspaceLogger.trace("Sleeping 4 sec...");
|
||||
// Thread.sleep(4000);
|
||||
// }
|
||||
// if(!WsUtil.isWithinPortal()){
|
||||
// workspaceLogger.trace("Sleeping 4 sec...");
|
||||
// Thread.sleep(4000);
|
||||
// }
|
||||
return listFileModels;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -147,7 +147,6 @@ public class ObjectStorageHubToWorkpaceMapper {
|
|||
*
|
||||
* @param wrappedItem the wrapped item
|
||||
* @param parentFolderModel the parent folder model
|
||||
* @param isParentShared the is parent shared
|
||||
* @param loggedUser the logged user
|
||||
* @return the file grid model
|
||||
* @throws InternalErrorException the internal error exception
|
||||
|
|
|
@ -142,7 +142,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{
|
|||
* Sets the synched thredds state for.
|
||||
*
|
||||
* @param fileModel the file model
|
||||
* @param wrappedItem
|
||||
* @param wrappedItem item
|
||||
* @return the file model
|
||||
*/
|
||||
protected FileModel setSynchedThreddsStateFor(FileModel fileModel, WorkspaceItem wrappedItem) {
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||
* @Apr 26, 2013
|
||||
* Apr 26, 2013
|
||||
*
|
||||
*/
|
||||
public class HttpRequestUtil {
|
||||
|
|
|
@ -21,51 +21,51 @@ import javax.imageio.ImageIO;
|
|||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
|
||||
/**
|
||||
* The Class ThumbnailGenerator.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||
* Oct 18, 2018
|
||||
* Oct 18, 2018
|
||||
*/
|
||||
public class ThumbnailGenerator {
|
||||
|
||||
|
||||
/**
|
||||
* Creates the thumbnail.
|
||||
*
|
||||
* @param originalFile the original file
|
||||
* @param thumbWidth the thumb width
|
||||
* @param thumbHeight the thumb height
|
||||
* @param originalFile
|
||||
* the original file
|
||||
* @param thumbWidth
|
||||
* the thumb width
|
||||
* @param thumbHeight
|
||||
* the thumb height
|
||||
* @return the input stream
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public static InputStream generateThumbnail(
|
||||
String originalFile, int thumbWidth,
|
||||
int thumbHeight)
|
||||
throws Exception {
|
||||
public static InputStream generateThumbnail(String originalFile, int thumbWidth, int thumbHeight) throws Exception {
|
||||
|
||||
String baseName = FilenameUtils.getBaseName(originalFile);
|
||||
Image image = ImageIO.read(new File(originalFile));
|
||||
return createThumb(image, baseName, thumbWidth, thumbHeight);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate thumbnail.
|
||||
*
|
||||
* @param originalFile the original file
|
||||
* @param fileName the file name
|
||||
* @param thumbWidth the thumb width
|
||||
* @param thumbHeight the thumb height
|
||||
* @param originalFile
|
||||
* the original file
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param thumbWidth
|
||||
* the thumb width
|
||||
* @param thumbHeight
|
||||
* the thumb height
|
||||
* @return the input stream
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public static InputStream generateThumbnail(
|
||||
InputStream originalFile, String fileName, int thumbWidth,
|
||||
int thumbHeight)
|
||||
throws Exception {
|
||||
public static InputStream generateThumbnail(InputStream originalFile, String fileName, int thumbWidth,
|
||||
int thumbHeight) throws Exception {
|
||||
Image image = ImageIO.read(originalFile);
|
||||
return createThumb(image, fileName, thumbWidth, thumbHeight);
|
||||
}
|
||||
|
@ -73,30 +73,33 @@ public class ThumbnailGenerator {
|
|||
/**
|
||||
* Creates the thumb.
|
||||
*
|
||||
* @param image the image
|
||||
* @param imageName the image name
|
||||
* @param thumbWidth the thumb width
|
||||
* @param thumbHeight the thumb height
|
||||
* @param image
|
||||
* the image
|
||||
* @param imageName
|
||||
* the image name
|
||||
* @param thumbWidth
|
||||
* the thumb width
|
||||
* @param thumbHeight
|
||||
* the thumb height
|
||||
* @return the input stream
|
||||
* @throws IOException
|
||||
* error
|
||||
*/
|
||||
public static InputStream createThumb(Image image, String imageName, int thumbWidth,
|
||||
int thumbHeight) throws IOException{
|
||||
public static InputStream createThumb(Image image, String imageName, int thumbWidth, int thumbHeight)
|
||||
throws IOException {
|
||||
double thumbRatio = (double) thumbWidth / (double) thumbHeight;
|
||||
int imageWidth = image.getWidth(null);
|
||||
int imageHeight = image.getHeight(null);
|
||||
double imageRatio = (double) imageWidth / (double) imageHeight;
|
||||
if (thumbRatio < imageRatio) {
|
||||
thumbHeight = (int) (thumbWidth / imageRatio);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
thumbWidth = (int) (thumbHeight * imageRatio);
|
||||
}
|
||||
if (imageWidth < thumbWidth && imageHeight < thumbHeight) {
|
||||
thumbWidth = imageWidth;
|
||||
thumbHeight = imageHeight;
|
||||
}
|
||||
else if (imageWidth < thumbWidth)
|
||||
} else if (imageWidth < thumbWidth)
|
||||
thumbWidth = imageWidth;
|
||||
else if (imageHeight < thumbHeight)
|
||||
thumbHeight = imageHeight;
|
||||
|
@ -107,52 +110,55 @@ public class ThumbnailGenerator {
|
|||
graphics2D.setBackground(Color.WHITE);
|
||||
graphics2D.setPaint(Color.WHITE);
|
||||
graphics2D.fillRect(0, 0, thumbWidth, thumbHeight);
|
||||
graphics2D.setRenderingHint(
|
||||
RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
|
||||
|
||||
String ext = FilenameUtils.getExtension(imageName);
|
||||
// String baseName = FilenameUtils.getBaseName(originalFile);
|
||||
// String baseName = FilenameUtils.getBaseName(originalFile);
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
ImageIO.write(thumbImage, ext, os);
|
||||
return new ByteArrayInputStream(os.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream2file.
|
||||
*
|
||||
* @param in the in
|
||||
* @param filename the filename
|
||||
* @param extension the extension
|
||||
* @return the file
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static File stream2file (InputStream in, String filename, String extension) throws IOException {
|
||||
/**
|
||||
* Stream2file.
|
||||
*
|
||||
* @param in
|
||||
* the in
|
||||
* @param filename
|
||||
* the filename
|
||||
* @param extension
|
||||
* the extension
|
||||
* @return the file
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static File stream2file(InputStream in, String filename, String extension) throws IOException {
|
||||
|
||||
extension = extension.startsWith(".")?extension:"."+extension;
|
||||
final File tempFile = File.createTempFile(filename, extension);
|
||||
//tempFile.deleteOnExit();
|
||||
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
||||
IOUtils.copy(in, out);
|
||||
}
|
||||
return tempFile;
|
||||
}
|
||||
extension = extension.startsWith(".") ? extension : "." + extension;
|
||||
final File tempFile = File.createTempFile(filename, extension);
|
||||
// tempFile.deleteOnExit();
|
||||
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
||||
IOUtils.copy(in, out);
|
||||
}
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * The main method.
|
||||
// *
|
||||
// * @param args the arguments
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// public static void main(String[] args) throws Exception {
|
||||
//
|
||||
// String originalFile = "/home/francesco-mangiacrapa/Pictures/Screenshot from 2016-04-11 10:20:43.png";
|
||||
// int thumbWidth = 200;
|
||||
// int thumbHeight = 200;
|
||||
//
|
||||
// createThumbnail(originalFile, thumbWidth, thumbHeight);
|
||||
//
|
||||
// }
|
||||
// /**
|
||||
// * The main method.
|
||||
// *
|
||||
// * @param args the arguments
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// public static void main(String[] args) throws Exception {
|
||||
//
|
||||
// String originalFile = "/home/francesco-mangiacrapa/Pictures/Screenshot
|
||||
// from 2016-04-11 10:20:43.png";
|
||||
// int thumbWidth = 200;
|
||||
// int thumbHeight = 200;
|
||||
//
|
||||
// createThumbnail(originalFile, thumbWidth, thumbHeight);
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -34,18 +34,14 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
|||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
|
||||
/**
|
||||
* The Class WsUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||
* Nov 25, 2016
|
||||
* Nov 25, 2016
|
||||
*/
|
||||
public class WsUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String FOLDER_PUBLISHING_ON_THREDDS = "FolderPublishingOnThredds";
|
||||
|
||||
protected static Logger logger = Logger.getLogger(WsUtil.class);
|
||||
|
@ -56,7 +52,8 @@ public class WsUtil {
|
|||
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
|
||||
public static final String NOTIFICATION_MANAGER = "NOTIFICATION_MANAGER";
|
||||
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_PRODUCER";
|
||||
//public static final String NOTIFICATION_MANAGER_TO_STORAGEHUB = "NOTIFICATION_MANAGER_TO_STORAGEHUB";
|
||||
// public static final String NOTIFICATION_MANAGER_TO_STORAGEHUB =
|
||||
// "NOTIFICATION_MANAGER_TO_STORAGEHUB";
|
||||
public static final String NOTIFICATION_PRODUCER_TO_STORAGEHUB = "NOTIFICATION_PRODUCER_TO_STORAGEHUB";
|
||||
public static final String WS_RUN_IN_TEST_MODE = "WS_RUN_IN_TEST_MODE";
|
||||
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SCOPE_UTIL";
|
||||
|
@ -64,7 +61,8 @@ public class WsUtil {
|
|||
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
|
||||
public static final String URI_RESOLVER_SERVICE = "URI_RESOLVER_SERVICE";
|
||||
public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
|
||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
|
||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; // IN
|
||||
// DEV
|
||||
|
||||
/**
|
||||
* Checks if is within portal.
|
||||
|
@ -75,82 +73,86 @@ public class WsUtil {
|
|||
try {
|
||||
UserLocalServiceUtil.getService();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
logger.trace("Development Mode ON");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the portal context.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the portal context
|
||||
*/
|
||||
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest){
|
||||
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest) {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
//USER
|
||||
// USER
|
||||
GCubeUser user = pContext.getCurrentUser(httpServletRequest);
|
||||
String username = user.getUsername();
|
||||
String fullName = user.getFullname();
|
||||
String email = user.getEmail();
|
||||
String avatarID = user.getUserAvatarId();
|
||||
String avatarURL = user.getUserAvatarURL();
|
||||
//SESSION
|
||||
// SESSION
|
||||
String currentScope = pContext.getCurrentScope(httpServletRequest);
|
||||
String userToken = pContext.getCurrentUserToken(httpServletRequest);
|
||||
long currGroupId = pContext.getCurrentGroupId(httpServletRequest);
|
||||
|
||||
return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken, currGroupId);
|
||||
return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken,
|
||||
currGroupId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the portal context.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param overrideScope the override scope
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @param overrideScope
|
||||
* the override scope
|
||||
* @return the portal context
|
||||
*/
|
||||
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope){
|
||||
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope) {
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
info.setCurrentScope(overrideScope);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is session expired.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return true, if is session expired
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
|
||||
logger.trace("workspace session validating...");
|
||||
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest)==null;
|
||||
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @return the workspace
|
||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||
* @throws InternalErrorException the internal error exception
|
||||
* @throws HomeNotFoundException the home not found exception
|
||||
* @param httpServletRequest
|
||||
* Servlet request
|
||||
* @return Workspace
|
||||
* @throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException
|
||||
* Folder not found error
|
||||
* @throws org.gcube.common.homelibrary.home.exceptions.InternalErrorException
|
||||
* Internal error
|
||||
* @throws HomeNotFoundException
|
||||
* Home not found error
|
||||
*/
|
||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest) throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException, org.gcube.common.homelibrary.home.exceptions.InternalErrorException, HomeNotFoundException
|
||||
{
|
||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest)
|
||||
throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException,
|
||||
org.gcube.common.homelibrary.home.exceptions.InternalErrorException, HomeNotFoundException {
|
||||
|
||||
logger.trace("Get Workspace");
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
logger.trace("PortalContextInfo: "+info);
|
||||
logger.trace("PortalContextInfo: " + info);
|
||||
|
||||
ScopeProvider.instance.set(info.getCurrentScope());
|
||||
logger.trace("Scope provider instancied");
|
||||
|
@ -159,43 +161,54 @@ public class WsUtil {
|
|||
return workspace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param contextID the context id
|
||||
* @param user the user
|
||||
* @return the workspace
|
||||
* @throws InternalErrorException the internal error exception
|
||||
* @throws InternalErrorException the internal error exception
|
||||
* @throws HomeNotFoundException the home not found exception
|
||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||
*
|
||||
* @param httpServletRequest
|
||||
* Workspace
|
||||
* @param contextID
|
||||
* contexId
|
||||
* @param user
|
||||
* user
|
||||
* @return Workspace
|
||||
* @throws InternalErrorException
|
||||
* Internal error
|
||||
* @throws HomeNotFoundException
|
||||
* Home not found error
|
||||
* @throws WorkspaceFolderNotFoundException
|
||||
* Folder not found error
|
||||
* @throws org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException
|
||||
* folder not found error
|
||||
* @throws org.gcube.common.homelibrary.home.exceptions.InternalErrorException
|
||||
* internal error
|
||||
*/
|
||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException, org.gcube.common.homelibrary.home.exceptions.InternalErrorException
|
||||
{
|
||||
logger.info("Get workspace using contextID: "+contextID +", current user: "+user.getUsername());
|
||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user)
|
||||
throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException,
|
||||
org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException,
|
||||
org.gcube.common.homelibrary.home.exceptions.InternalErrorException {
|
||||
logger.info("Get workspace using contextID: " + contextID + ", current user: " + user.getUsername());
|
||||
String currentScope;
|
||||
|
||||
if(isWithinPortal())
|
||||
if (isWithinPortal())
|
||||
currentScope = PortalContext.getConfiguration().getCurrentScope(contextID);
|
||||
else{
|
||||
else {
|
||||
currentScope = PortalContext.getConfiguration().getCurrentScope(httpServletRequest);
|
||||
logger.warn("STARTING IN TEST MODE!!!! USING SCOPE: "+currentScope);
|
||||
logger.warn("STARTING IN TEST MODE!!!! USING SCOPE: " + currentScope);
|
||||
}
|
||||
|
||||
logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
|
||||
logger.info("For ContextID: " + contextID + ", read scope from Portal Context: " + currentScope);
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest, currentScope);
|
||||
logger.trace("PortalContextInfo: "+info);
|
||||
logger.trace("PortalContextInfo: " + info);
|
||||
|
||||
ScopeProvider.instance.set(info.getCurrentScope());
|
||||
logger.trace("Scope provider instancied");
|
||||
|
||||
String username = null;
|
||||
try {
|
||||
if(user.getUsername().compareTo(info.getUsername())!=0){
|
||||
logger.debug("Gcube user read from Portal Context "+user.getUsername()+" is different by GCubeUser passed, using the second one: "+info.getUsername());
|
||||
if (user.getUsername().compareTo(info.getUsername()) != 0) {
|
||||
logger.debug("Gcube user read from Portal Context " + user.getUsername()
|
||||
+ " is different by GCubeUser passed, using the second one: " + info.getUsername());
|
||||
username = user.getUsername();
|
||||
}
|
||||
|
||||
|
@ -203,7 +216,7 @@ public class WsUtil {
|
|||
logger.error("Error comparing username read from input parameter and Portal context");
|
||||
}
|
||||
|
||||
if(username!=null)
|
||||
if (username != null)
|
||||
info.setUsername(username);
|
||||
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
|
||||
|
@ -214,83 +227,88 @@ public class WsUtil {
|
|||
/**
|
||||
* Gets the GWT workspace builder.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the GWT workspace builder
|
||||
*/
|
||||
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpServletRequest httpServletRequest)
|
||||
{
|
||||
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpServletRequest httpServletRequest) {
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
logger.trace("PortalContextInfo: "+info);
|
||||
logger.trace("PortalContextInfo: " + info);
|
||||
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
|
||||
GWTWorkspaceBuilder builder = (GWTWorkspaceBuilder) session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE);
|
||||
if (builder == null){
|
||||
if (builder == null) {
|
||||
logger.info("Initializing the workspace area builder");
|
||||
builder = new GWTWorkspaceBuilder();
|
||||
//ADDED 03/09/2013
|
||||
builder.setContexInfo(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false), info.getCurrentScope());
|
||||
// ADDED 03/09/2013
|
||||
builder.setContexInfo(
|
||||
new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false),
|
||||
info.getCurrentScope());
|
||||
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the notification manager.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the notification manager
|
||||
*/
|
||||
public static NotificationsManager getNotificationManager(HttpServletRequest httpServletRequest)
|
||||
{
|
||||
public static NotificationsManager getNotificationManager(HttpServletRequest httpServletRequest) {
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
|
||||
|
||||
if (notifMng == null) {
|
||||
try{
|
||||
logger.trace("Create new NotificationsManager for user: "+info.getUsername());
|
||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
||||
try {
|
||||
logger.trace("Create new NotificationsManager for user: " + info.getUsername());
|
||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "
|
||||
+ NOTIFICATION_PORTLET_CLASS_ID);
|
||||
SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(), info.getUserFullName(), info.getUserAvatarID());
|
||||
notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(),
|
||||
info.getUserFullName(), info.getUserAvatarID());
|
||||
notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser,
|
||||
NOTIFICATION_PORTLET_CLASS_ID);
|
||||
session.setAttribute(NOTIFICATION_MANAGER, notifMng);
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"An error occurred instancing ApplicationNotificationsManager for user: " + info.getUsername(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
return notifMng;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the notification producer.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the notification producer
|
||||
*/
|
||||
public static NotificationsProducer getNotificationProducer(HttpServletRequest httpServletRequest)
|
||||
{
|
||||
public static NotificationsProducer getNotificationProducer(HttpServletRequest httpServletRequest) {
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||
|
||||
if (notifProducer == null) {
|
||||
logger.trace("Create new Notification Producer for user: "+info.getUsername());
|
||||
logger.trace("Create new Notification Producer for user: " + info.getUsername());
|
||||
notifProducer = new NotificationsProducer(httpServletRequest);
|
||||
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||
}
|
||||
return notifProducer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the user id.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the user id
|
||||
*/
|
||||
public static String getUserId(HttpServletRequest httpServletRequest) {
|
||||
|
@ -302,14 +320,15 @@ public class WsUtil {
|
|||
/**
|
||||
* Checks if is vre.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param scope
|
||||
* the scope
|
||||
* @return true, if is vre
|
||||
*/
|
||||
public static boolean isVRE(String scope){
|
||||
public static boolean isVRE(String scope) {
|
||||
|
||||
int slashCount = StringUtils.countMatches(scope, "/");
|
||||
|
||||
if(slashCount < 3){
|
||||
if (slashCount < 3) {
|
||||
logger.trace("currentScope is not VRE");
|
||||
return false;
|
||||
}
|
||||
|
@ -322,33 +341,34 @@ public class WsUtil {
|
|||
/**
|
||||
* Gets the scope util filter.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the scope util filter
|
||||
*/
|
||||
public static ScopeUtilFilter getScopeUtilFilter(HttpServletRequest httpServletRequest){
|
||||
public static ScopeUtilFilter getScopeUtilFilter(HttpServletRequest httpServletRequest) {
|
||||
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
ScopeUtilFilter scopeUtil = null;
|
||||
try{
|
||||
try {
|
||||
scopeUtil = (ScopeUtilFilter) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
|
||||
|
||||
if(scopeUtil==null){
|
||||
scopeUtil = new ScopeUtilFilter(info.getCurrentScope(),true);
|
||||
if (scopeUtil == null) {
|
||||
scopeUtil = new ScopeUtilFilter(info.getCurrentScope(), true);
|
||||
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("an error occurred in getscope filter "+e);
|
||||
} catch (Exception e) {
|
||||
logger.error("an error occurred in getscope filter " + e);
|
||||
}
|
||||
|
||||
return scopeUtil;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the url shortener.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the url shortener
|
||||
*/
|
||||
public static UrlShortener getUrlShortener(HttpServletRequest httpServletRequest) {
|
||||
|
@ -356,26 +376,26 @@ public class WsUtil {
|
|||
HttpSession session = httpServletRequest.getSession();
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
UrlShortener shortener = null;
|
||||
try{
|
||||
try {
|
||||
shortener = (UrlShortener) session.getAttribute(WsUtil.URL_SHORTENER_SERVICE);
|
||||
|
||||
if(shortener==null){
|
||||
if (shortener == null) {
|
||||
shortener = new UrlShortener();
|
||||
session.setAttribute(URL_SHORTENER_SERVICE, shortener);
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("an error occurred in instancing url shortener ",e);
|
||||
} catch (Exception e) {
|
||||
logger.error("an error occurred in instancing url shortener ", e);
|
||||
}
|
||||
|
||||
return shortener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the uri resolver.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the uri resolver
|
||||
*/
|
||||
public static UriResolverReaderParameterForResolverIndex getUriResolver(HttpServletRequest httpServletRequest) {
|
||||
|
@ -383,16 +403,18 @@ public class WsUtil {
|
|||
HttpSession session = httpServletRequest.getSession();
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
UriResolverReaderParameterForResolverIndex uriResolver = null;
|
||||
try{
|
||||
uriResolver = (UriResolverReaderParameterForResolverIndex) session.getAttribute(WsUtil.URI_RESOLVER_SERVICE);
|
||||
try {
|
||||
uriResolver = (UriResolverReaderParameterForResolverIndex) session
|
||||
.getAttribute(WsUtil.URI_RESOLVER_SERVICE);
|
||||
|
||||
if(uriResolver==null){
|
||||
uriResolver = new UriResolverReaderParameterForResolverIndex(info.getCurrentScope(),RESOLVER_TYPE.SMP_ID);
|
||||
if (uriResolver == null) {
|
||||
uriResolver = new UriResolverReaderParameterForResolverIndex(info.getCurrentScope(),
|
||||
RESOLVER_TYPE.SMP_ID);
|
||||
session.setAttribute(URI_RESOLVER_SERVICE, uriResolver);
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("an error occurred instancing URI Resolver ",e);
|
||||
} catch (Exception e) {
|
||||
logger.error("an error occurred instancing URI Resolver ", e);
|
||||
}
|
||||
|
||||
return uriResolver;
|
||||
|
@ -401,24 +423,27 @@ public class WsUtil {
|
|||
/**
|
||||
* Gets the property special folder reader.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param pathProperty the path property
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @param pathProperty
|
||||
* the path property
|
||||
* @return the property special folder reader
|
||||
*/
|
||||
public static PropertySpecialFolderReader getPropertySpecialFolderReader(HttpServletRequest httpServletRequest, String pathProperty) {
|
||||
public static PropertySpecialFolderReader getPropertySpecialFolderReader(HttpServletRequest httpServletRequest,
|
||||
String pathProperty) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
|
||||
PropertySpecialFolderReader psFolderReader = null;
|
||||
try{
|
||||
try {
|
||||
psFolderReader = (PropertySpecialFolderReader) session.getAttribute(WsUtil.PROPERTY_SPECIAL_FOLDER);
|
||||
|
||||
if(psFolderReader==null){
|
||||
if (psFolderReader == null) {
|
||||
psFolderReader = new PropertySpecialFolderReader(pathProperty);
|
||||
session.setAttribute(PROPERTY_SPECIAL_FOLDER, psFolderReader);
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("an error occurred instancing PropertySpecialFolderReader ",e);
|
||||
} catch (Exception e) {
|
||||
logger.error("an error occurred instancing PropertySpecialFolderReader ", e);
|
||||
}
|
||||
|
||||
return psFolderReader;
|
||||
|
@ -427,66 +452,75 @@ public class WsUtil {
|
|||
/**
|
||||
* Gets the storage hub wrapper.
|
||||
*
|
||||
* @param request the request
|
||||
* @param scopeGroupId the scope group id. If scopeGroupId is null the scope is read by using the request else by using the scopeGroupId
|
||||
* @param user the user
|
||||
* @param request
|
||||
* the request
|
||||
* @param scopeGroupId
|
||||
* the scope group id. If scopeGroupId is null the scope is read
|
||||
* by using the request else by using the scopeGroupId
|
||||
* @param user
|
||||
* the user
|
||||
* @return the storage hub wrapper
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public static StorageHubWrapper getStorageHubWrapper(final HttpServletRequest request, String scopeGroupId, GCubeUser user) throws Exception{
|
||||
public static StorageHubWrapper getStorageHubWrapper(final HttpServletRequest request, String scopeGroupId,
|
||||
GCubeUser user) throws Exception {
|
||||
|
||||
if(user==null || user.getUsername().isEmpty())
|
||||
if (user == null || user.getUsername().isEmpty())
|
||||
throw new Exception("Session expired");
|
||||
|
||||
try {
|
||||
String scope;
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
if(WsUtil.isWithinPortal() && scopeGroupId!=null){
|
||||
if (WsUtil.isWithinPortal() && scopeGroupId != null) {
|
||||
scope = pContext.getCurrentScope(scopeGroupId);
|
||||
logger.debug(scope+" has retrieved by using the scopeGroupId="+scopeGroupId);
|
||||
}
|
||||
else
|
||||
logger.debug(scope + " has retrieved by using the scopeGroupId=" + scopeGroupId);
|
||||
} else
|
||||
scope = pContext.getCurrentScope(request);
|
||||
|
||||
logger.debug("Getting "+StorageHubWrapper.class.getSimpleName()+" for user: "+user.getUsername() +" by using the scope: "+scope);
|
||||
logger.debug("Getting " + StorageHubWrapper.class.getSimpleName() + " for user: " + user.getUsername()
|
||||
+ " by using the scope: " + scope);
|
||||
String token = pContext.getCurrentUserToken(scope, user.getUsername());
|
||||
return new StorageHubWrapper(scope, token, false, false, true);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during getting storageHub wrapper", e);
|
||||
throw new Exception("Error on gettig the StorageHub wrapper for userId: "+user);
|
||||
throw new Exception("Error on gettig the StorageHub wrapper for userId: " + user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the storage hub to workpace converter.
|
||||
*
|
||||
* @param request the request
|
||||
* @param scopeGroupId the scope group id
|
||||
* @param user the user
|
||||
* @param request
|
||||
* the request
|
||||
* @param scopeGroupId
|
||||
* the scope group id
|
||||
* @param user
|
||||
* the user
|
||||
* @return the storage hub to workpace converter
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
public static StorageHubToWorkpaceConverter getStorageHubToWorkpaceConverter(final HttpServletRequest request, String scopeGroupId, GCubeUser user) throws Exception {
|
||||
public static StorageHubToWorkpaceConverter getStorageHubToWorkpaceConverter(final HttpServletRequest request,
|
||||
String scopeGroupId, GCubeUser user) throws Exception {
|
||||
|
||||
if(user==null || user.getUsername().isEmpty())
|
||||
if (user == null || user.getUsername().isEmpty())
|
||||
throw new Exception("Session expired");
|
||||
|
||||
try {
|
||||
HttpSession session = request.getSession();
|
||||
StorageHubToWorkpaceConverter converter = (StorageHubToWorkpaceConverter) session.getAttribute(WORKSPACE_STORAGE_HUB_CONVERTER);
|
||||
StorageHubToWorkpaceConverter converter = (StorageHubToWorkpaceConverter) session
|
||||
.getAttribute(WORKSPACE_STORAGE_HUB_CONVERTER);
|
||||
|
||||
String scope;
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
if(WsUtil.isWithinPortal() && scopeGroupId!=null){
|
||||
if (WsUtil.isWithinPortal() && scopeGroupId != null) {
|
||||
scope = pContext.getCurrentScope(scopeGroupId);
|
||||
logger.debug(scope+" has retrieved by using the scopeGroupId="+scopeGroupId);
|
||||
}
|
||||
else
|
||||
logger.debug(scope + " has retrieved by using the scopeGroupId=" + scopeGroupId);
|
||||
} else
|
||||
scope = pContext.getCurrentScope(request);
|
||||
|
||||
if(converter==null){
|
||||
if (converter == null) {
|
||||
converter = new StorageHubToWorkpaceConverter(scope, user);
|
||||
session.setAttribute(WORKSPACE_STORAGE_HUB_CONVERTER, converter);
|
||||
}
|
||||
|
@ -494,79 +528,87 @@ public class WsUtil {
|
|||
return converter;
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during getting storageHub conveter", e);
|
||||
throw new Exception("Error on gettig the StorageHub conveter for user: "+user);
|
||||
throw new Exception("Error on gettig the StorageHub conveter for user: " + user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is root folder.
|
||||
*
|
||||
* @param folder the folder
|
||||
* @param converter the converter
|
||||
* @param folder
|
||||
* the folder
|
||||
* @param converter
|
||||
* the converter
|
||||
* @return true, if is root folder
|
||||
*/
|
||||
public static boolean isRootFolder(FileModel folder, StorageHubToWorkpaceConverter converter){
|
||||
public static boolean isRootFolder(FileModel folder, StorageHubToWorkpaceConverter converter) {
|
||||
|
||||
if(folder==null)
|
||||
if (folder == null)
|
||||
return false;
|
||||
|
||||
if(folder.getIdentifier().compareTo(converter.getWorkspaceRootId())==0)
|
||||
if (folder.getIdentifier().compareTo(converter.getWorkspaceRootId()) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Gets the notification manager to storage hub.
|
||||
// *
|
||||
// * @param httpServletRequest the http servlet request
|
||||
// * @return the notification manager to storage hub
|
||||
// */
|
||||
// public static NotificationsManager getNotificationManagerToStorageHub(HttpServletRequest httpServletRequest)
|
||||
// {
|
||||
// PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
// HttpSession session = httpServletRequest.getSession();
|
||||
// NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB);
|
||||
//
|
||||
// if (notifMng == null) {
|
||||
// try{
|
||||
// logger.trace("Create new NotificationsManager for user: "+info.getUsername());
|
||||
// logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
||||
// SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
||||
// SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(), info.getUserFullName(), info.getUserAvatarID());
|
||||
// notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
||||
// session.setAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB, notifMng);
|
||||
// }catch (Exception e) {
|
||||
// logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return notifMng;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Gets the notification manager to storage hub.
|
||||
// *
|
||||
// * @param httpServletRequest the http servlet request
|
||||
// * @return the notification manager to storage hub
|
||||
// */
|
||||
// public static NotificationsManager
|
||||
// getNotificationManagerToStorageHub(HttpServletRequest httpServletRequest)
|
||||
// {
|
||||
// PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
// HttpSession session = httpServletRequest.getSession();
|
||||
// NotificationsManager notifMng = (NotificationsManager)
|
||||
// session.getAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB);
|
||||
//
|
||||
// if (notifMng == null) {
|
||||
// try{
|
||||
// logger.trace("Create new NotificationsManager for user:
|
||||
// "+info.getUsername());
|
||||
// logger.trace("New ApplicationNotificationsManager with portlet class
|
||||
// name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
||||
// SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
||||
// SocialNetworkingUser curser = new
|
||||
// SocialNetworkingUser(info.getUsername(), info.getUserEmail(),
|
||||
// info.getUserFullName(), info.getUserAvatarID());
|
||||
// notifMng = new ApplicationNotificationsManager(site,
|
||||
// info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
||||
// session.setAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB, notifMng);
|
||||
// }catch (Exception e) {
|
||||
// logger.error("An error occurred instancing
|
||||
// ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return notifMng;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the notification producer to storage hub.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @return the notification producer to storage hub
|
||||
*/
|
||||
public static NotificationsProducerToStorageHub getNotificationProducerToStorageHub(HttpServletRequest httpServletRequest)
|
||||
{
|
||||
* Gets the notification producer to storage hub.
|
||||
*
|
||||
* @param httpServletRequest
|
||||
* the http servlet request
|
||||
* @return the notification producer to storage hub
|
||||
*/
|
||||
public static NotificationsProducerToStorageHub getNotificationProducerToStorageHub(
|
||||
HttpServletRequest httpServletRequest) {
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
NotificationsProducerToStorageHub notifProducer = (NotificationsProducerToStorageHub) session.getAttribute(NOTIFICATION_PRODUCER_TO_STORAGEHUB);
|
||||
NotificationsProducerToStorageHub notifProducer = (NotificationsProducerToStorageHub) session
|
||||
.getAttribute(NOTIFICATION_PRODUCER_TO_STORAGEHUB);
|
||||
|
||||
if (notifProducer == null) {
|
||||
logger.trace("Create new Notification Producer for user: "+info.getUsername());
|
||||
logger.trace("Create new Notification Producer for user: " + info.getUsername());
|
||||
notifProducer = new NotificationsProducerToStorageHub(httpServletRequest);
|
||||
session.setAttribute(NOTIFICATION_PRODUCER_TO_STORAGEHUB, notifProducer);
|
||||
}
|
||||
return notifProducer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,146 +8,143 @@ import java.util.Map;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
public class ScopeUtilFilter {
|
||||
|
||||
|
||||
private static final String SCOPE_SEPARATOR = "/";
|
||||
private String scopeRoot = null;
|
||||
public static Logger logger = Logger.getLogger(ScopeUtilFilter.class);
|
||||
public Map<String, String> hashScopesFiltered = new HashMap<String, String>();
|
||||
|
||||
|
||||
public static final String ALLSCOPE = "All spaces";
|
||||
public static final String IDALLSCOPE = "ID All spaces";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param scopeName
|
||||
* @param addIdAllSpaces if true add "ID All spaces" - "All spaces" pair into map
|
||||
* scope name
|
||||
* @param addIdAllSpaces
|
||||
* if true add "ID All spaces" - "All spaces" pair into map
|
||||
*/
|
||||
public ScopeUtilFilter(String scopeName, boolean addIdAllSpaces) {
|
||||
|
||||
if(scopeName!=null){
|
||||
if (scopeName != null) {
|
||||
String[] scopes = scopeName.split(SCOPE_SEPARATOR);
|
||||
|
||||
if(scopes!=null && scopes.length>1){
|
||||
scopeRoot = SCOPE_SEPARATOR+scopes[1];
|
||||
logger.trace("found root "+scopeRoot);
|
||||
}
|
||||
else{
|
||||
|
||||
if (scopes != null && scopes.length > 1) {
|
||||
scopeRoot = SCOPE_SEPARATOR + scopes[1];
|
||||
logger.trace("found root " + scopeRoot);
|
||||
} else {
|
||||
logger.warn("root scope not found!");
|
||||
scopeRoot = SCOPE_SEPARATOR;
|
||||
}
|
||||
|
||||
if(addIdAllSpaces)
|
||||
hashScopesFiltered.put(ALLSCOPE, IDALLSCOPE); //PUT DEFAULT ID ALL SCOPE
|
||||
|
||||
|
||||
if (addIdAllSpaces)
|
||||
hashScopesFiltered.put(ALLSCOPE, IDALLSCOPE); // PUT DEFAULT ID
|
||||
// ALL SCOPE
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> convertListScopeToPortlet(List<String> listScopes){
|
||||
|
||||
logger.trace("List Scope converting..."+listScopes);
|
||||
|
||||
|
||||
public List<String> convertListScopeToPortlet(List<String> listScopes) {
|
||||
|
||||
logger.trace("List Scope converting..." + listScopes);
|
||||
|
||||
List<String> scopesConverted = new ArrayList<String>();
|
||||
scopesConverted.add(ALLSCOPE);
|
||||
|
||||
if(scopeRoot.compareTo(SCOPE_SEPARATOR)==0){
|
||||
|
||||
logger.warn("root scope is '"+SCOPE_SEPARATOR+"' return list scopes passed in input");
|
||||
|
||||
if (scopeRoot.compareTo(SCOPE_SEPARATOR) == 0) {
|
||||
|
||||
logger.warn("root scope is '" + SCOPE_SEPARATOR + "' return list scopes passed in input");
|
||||
return listScopes;
|
||||
}
|
||||
|
||||
|
||||
for (String scope : listScopes) {
|
||||
|
||||
if(scope.compareTo(scopeRoot)==0){ //CASE SCOPE IS ROOT
|
||||
logger.trace("found scope root "+scope+" added to list without converting");
|
||||
|
||||
if (scope.compareTo(scopeRoot) == 0) { // CASE SCOPE IS ROOT
|
||||
logger.trace("found scope root " + scope + " added to list without converting");
|
||||
hashScopesFiltered.put(scopeRoot, scopeRoot);
|
||||
scopesConverted.add(scopeRoot);
|
||||
|
||||
} else{
|
||||
|
||||
int index = scope.indexOf(scopeRoot,0);
|
||||
int start = index+scopeRoot.length();
|
||||
|
||||
} else {
|
||||
|
||||
int index = scope.indexOf(scopeRoot, 0);
|
||||
int start = index + scopeRoot.length();
|
||||
int end = scope.length();
|
||||
//DEBUG
|
||||
// System.out.println("\n\n ");
|
||||
// System.out.println("index "+index);
|
||||
// System.out.println("start "+start);
|
||||
// System.out.println("end "+end);
|
||||
|
||||
if(index!=-1){ //CASE SCOPE ROOT IS FOUND
|
||||
String filerString = scope.substring(index+start, scope.length());
|
||||
// DEBUG
|
||||
// System.out.println("\n\n ");
|
||||
// System.out.println("index "+index);
|
||||
// System.out.println("start "+start);
|
||||
// System.out.println("end "+end);
|
||||
|
||||
if (index != -1) { // CASE SCOPE ROOT IS FOUND
|
||||
String filerString = scope.substring(index + start, scope.length());
|
||||
hashScopesFiltered.put(filerString, scope);
|
||||
scopesConverted.add(filerString);
|
||||
logger.trace("scope "+scope+ " is converted in: "+filerString);
|
||||
|
||||
}else{ //CASE SCOPE ROOT NOT IS FOUND
|
||||
logger.warn("scope "+scope + " was reject from filter");
|
||||
scopesConverted.add(filerString);
|
||||
logger.trace("scope " + scope + " is converted in: " + filerString);
|
||||
|
||||
} else { // CASE SCOPE ROOT NOT IS FOUND
|
||||
logger.warn("scope " + scope + " was reject from filter");
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.trace("Scope converting was completed");
|
||||
return scopesConverted;
|
||||
}
|
||||
|
||||
|
||||
public String getPortalScopeFromFilteredScope(String scope){
|
||||
|
||||
|
||||
public String getPortalScopeFromFilteredScope(String scope) {
|
||||
|
||||
String portalScope = hashScopesFiltered.get(scope);
|
||||
|
||||
if(portalScope==null){
|
||||
logger.warn("scope not found in scope fiter, return root scope "+scopeRoot);
|
||||
|
||||
if (portalScope == null) {
|
||||
logger.warn("scope not found in scope fiter, return root scope " + scopeRoot);
|
||||
return scopeRoot;
|
||||
}
|
||||
|
||||
|
||||
return portalScope;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getHashScopesFiltered() {
|
||||
return hashScopesFiltered;
|
||||
}
|
||||
|
||||
|
||||
//TEST
|
||||
private void printScopeName(String scopeName){
|
||||
|
||||
|
||||
// TEST
|
||||
private void printScopeName(String scopeName) {
|
||||
|
||||
String[] scopes = scopeName.split(SCOPE_SEPARATOR);
|
||||
|
||||
|
||||
for (String scope : scopes) {
|
||||
System.out.println("scope split: "+scope);
|
||||
System.out.println("scope split: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void printScopes(){
|
||||
|
||||
|
||||
private void printScopes() {
|
||||
|
||||
for (String key : hashScopesFiltered.keySet()) {
|
||||
|
||||
System.out.println("Scope found: "+ hashScopesFiltered.get(key) +" with key: "+ key);
|
||||
|
||||
System.out.println("Scope found: " + hashScopesFiltered.get(key) + " with key: " + key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getScopeRoot() {
|
||||
return scopeRoot;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String scope = "/gcube";
|
||||
|
||||
List<String> listTest = Arrays.asList(new String[]{"/gcube/devsec/devre", "/gcube/devsec","/gcube/devsec/devNEXT", "/", "/gcub", "/gcube"});
|
||||
|
||||
|
||||
List<String> listTest = Arrays.asList(new String[] { "/gcube/devsec/devre", "/gcube/devsec",
|
||||
"/gcube/devsec/devNEXT", "/", "/gcub", "/gcube" });
|
||||
|
||||
ScopeUtilFilter filter = new ScopeUtilFilter(scope, false);
|
||||
|
||||
System.out.println("scope root is: "+filter.getScopeRoot());
|
||||
|
||||
|
||||
System.out.println("scope root is: " + filter.getScopeRoot());
|
||||
|
||||
filter.convertListScopeToPortlet(listTest);
|
||||
|
||||
|
||||
System.out.println("get portal scope for /devsec: "+filter.getPortalScopeFromFilteredScope("/devsec"));
|
||||
|
||||
|
||||
System.out.println("get portal scope for /devsec: " + filter.getPortalScopeFromFilteredScope("/devsec"));
|
||||
|
||||
filter.printScopes();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,25 +15,16 @@ import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
|||
*/
|
||||
public class TrashContent implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = -7428752149892396573L;
|
||||
|
||||
|
||||
List<FileTrashedModel> trashContent;
|
||||
List<FileTrashedModel> listErrors;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TrashContent() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trashContent
|
||||
* @param listErrors
|
||||
*/
|
||||
public TrashContent(List<FileTrashedModel> trashContent, List<FileTrashedModel> listErrors) {
|
||||
this.trashContent = trashContent;
|
||||
this.listErrors = listErrors;
|
||||
|
|
|
@ -12,25 +12,14 @@ import java.util.List;
|
|||
*/
|
||||
public class TrashOperationContent extends TrashContent{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3089944053784656200L;
|
||||
|
||||
private List<String> listTrashIds;
|
||||
private WorkspaceTrashOperation operation;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TrashOperationContent() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trashContent
|
||||
* @param listErrors
|
||||
*/
|
||||
public TrashOperationContent(WorkspaceTrashOperation operation, List<String> listTrashIds) {
|
||||
this.listTrashIds = listTrashIds;
|
||||
this.operation = operation;
|
||||
|
|
|
@ -4,9 +4,7 @@ import java.io.Serializable;
|
|||
|
||||
public class UserBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 6779963164440480883L;
|
||||
|
||||
private String username;
|
||||
|
@ -25,36 +23,25 @@ public class UserBean implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the firstName
|
||||
*/
|
||||
public String getFirstName() {
|
||||
|
||||
return firstName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the lastName
|
||||
*/
|
||||
public String getLastName() {
|
||||
public String getLastName() {
|
||||
|
||||
return lastName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the email
|
||||
*/
|
||||
|
||||
public String getEmail() {
|
||||
|
||||
return email;
|
||||
|
|
|
@ -12,10 +12,6 @@ import java.io.Serializable;
|
|||
*/
|
||||
public class WorkspaceUserQuote implements Serializable{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5363340286390074157L;
|
||||
|
||||
|
||||
|
@ -28,11 +24,6 @@ public class WorkspaceUserQuote implements Serializable{
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @param diskSpace
|
||||
* @param diskSpaceFormatted
|
||||
* @param totalItems
|
||||
*/
|
||||
public WorkspaceUserQuote(Long diskSpace, String diskSpaceFormatted,
|
||||
Long totalItems) {
|
||||
this.diskSpace = diskSpace;
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.workspace.shared.accounting;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum GxtAccountingEntryType.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
||||
* Sep 28, 2016
|
||||
* Sep 28, 2016
|
||||
*/
|
||||
public enum GxtAccountingEntryType {
|
||||
|
||||
|
@ -36,9 +35,9 @@ public enum GxtAccountingEntryType {
|
|||
|
||||
RESTORE("Restored", "restored"),
|
||||
|
||||
DISABLED_PUBLIC_ACCESS("DisabledPublicAccess","disabled public access"),
|
||||
DISABLED_PUBLIC_ACCESS("DisabledPublicAccess", "disabled public access"),
|
||||
|
||||
ENABLED_PUBLIC_ACCESS("EnabledPublicAccess","enabled public access"),
|
||||
ENABLED_PUBLIC_ACCESS("EnabledPublicAccess", "enabled public access"),
|
||||
|
||||
ALLWITHOUTREAD("allwithoutread", "allwithoutread");
|
||||
|
||||
|
@ -48,8 +47,10 @@ public enum GxtAccountingEntryType {
|
|||
/**
|
||||
* Instantiates a new gxt accounting entry type.
|
||||
*
|
||||
* @param id the id
|
||||
* @param name the name
|
||||
* @param id
|
||||
* the id
|
||||
* @param name
|
||||
* the name
|
||||
*/
|
||||
GxtAccountingEntryType(String id, String name) {
|
||||
this.id = id;
|
||||
|
@ -69,7 +70,8 @@ public enum GxtAccountingEntryType {
|
|||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
* @param id
|
||||
* the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
|
@ -87,7 +89,8 @@ public enum GxtAccountingEntryType {
|
|||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
* @param name
|
||||
* the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
|
|
|
@ -15,9 +15,6 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel
|
|||
*/
|
||||
public class GxtAccountingField implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2114527164447302004L;
|
||||
|
||||
private InfoContactModel user;
|
||||
|
@ -29,12 +26,6 @@ public class GxtAccountingField implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* @param user
|
||||
* @param date
|
||||
* @param operation
|
||||
*/
|
||||
public GxtAccountingField(String description, InfoContactModel user,
|
||||
Date date, GxtAccountingEntryType operation) {
|
||||
setUser(user);
|
||||
|
|
Loading…
Reference in New Issue