fix image preview and download

fix on share user by admin

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@149320 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-06-06 16:12:44 +00:00
parent 6c2e402ed5
commit 3c6a33ef25
4 changed files with 163 additions and 26 deletions

View File

@ -34,11 +34,12 @@ import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
/** /**
* The Class DialogShareFolder. * The Class DialogShareFolder.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 4, 2015 * Jun 6, 2017
*/ */
public class DialogShareFolder extends Dialog { public class DialogShareFolder extends Dialog {
@ -62,6 +63,7 @@ public class DialogShareFolder extends Dialog {
* @param folderParentName the folder parent name * @param folderParentName the folder parent name
* @param folder the folder * @param folder the folder
* @param eventBus the event bus * @param eventBus the event bus
* @param userStore the user store
*/ */
public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus, UserStore userStore) { public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus, UserStore userStore) {
initUserStore(userStore); initUserStore(userStore);
@ -143,6 +145,7 @@ public class DialogShareFolder extends Dialog {
lc.add(flexTable); lc.add(flexTable);
if(hpPermission!=null) if(hpPermission!=null)
lc.add(hpPermission); lc.add(hpPermission);
lc.mask(); lc.mask();
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() { userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
@ -156,12 +159,29 @@ public class DialogShareFolder extends Dialog {
public void onSuccess(InfoContactModel result) { public void onSuccess(InfoContactModel result) {
shareOwner = result; shareOwner = result;
txtOwner.setValue(result.getName()); txtOwner.setValue(result.getName());
permissionControl(result.getLogin(), true); //permissionControl(result.getLogin(), true);
fillRecipientAlreadyShared(folder.getIdentifier(), lc); fillRecipientAlreadyShared(folder.getIdentifier(), lc);
} }
}); });
AsyncCallback<List<InfoContactModel>> callback = new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Alert", "Sorry, an error occurred during on getting Managers from server",null);
hpPermission.unmask();
}
@Override
public void onSuccess(List<InfoContactModel> listManagers) {
permissionControl(listManagers, true, folder);
hpPermission.unmask();
}
};
getUsersManagers(folder.getIdentifier(), callback);
setFocusWidget(suggestPanel.getBox()); setFocusWidget(suggestPanel.getBox());
add(txtName); add(txtName);
add(txtOwner); add(txtOwner);
@ -172,6 +192,11 @@ public class DialogShareFolder extends Dialog {
this.show(); this.show();
} }
/**
* Inits the user store.
*
* @param userStore the user store
*/
private void initUserStore(UserStore userStore){ private void initUserStore(UserStore userStore){
this.userStore = userStore; this.userStore = userStore;
this.suggestPanel = new MultiValuePanel(userStore); this.suggestPanel = new MultiValuePanel(userStore);
@ -581,4 +606,61 @@ public class DialogShareFolder extends Dialog {
} }
/**
* Gets the users managers.
*
* @param sharedFolderId the shared folder id
* @param callback the callback
* @return the users managers
*/
public void getUsersManagers(final String sharedFolderId,final AsyncCallback<List<InfoContactModel>> callback) {
AppControllerExplorer.rpcWorkspaceService.getUsersManagerToSharedFolder(sharedFolderId, new AsyncCallback<List<InfoContactModel>>() {
@Override
public void onFailure(Throwable arg0) {
GWT.log("an error occured in getting user managers by Id "+sharedFolderId + " "+arg0.getMessage());
new MessageBoxAlert("Alert", "Sorry, an error occurred on getting users managers, try again later",null);
}
@Override
public void onSuccess(List<InfoContactModel> listManagers) {
callback.onSuccess(listManagers);
}
});
}
/**
* Permission control.
*
* @param listManagers the list managers
* @param showAlert the show alert
* @param folder the folder
*/
private void permissionControl(List<InfoContactModel> listManagers, boolean showAlert, FileModel folder){
boolean permissionsOk = false;
for (InfoContactModel infoContactModel : listManagers) {
GWT.log("DialogPermission control compare between : "+infoContactModel.getLogin() +" and my login: "+AppControllerExplorer.myLogin);
if(AppControllerExplorer.myLogin.compareToIgnoreCase(infoContactModel.getLogin())==0){
permissionsOk = true;
break;
}
}
if(permissionsOk){
enableFormDialog(true);
}else{
enableFormDialog(false);
if(showAlert)
new MessageBoxAlert("Permission denied", "You have no permissions to change sharing. You are not manager of \""+folder.getName()+"\"", null);
}
}
} }

View File

@ -103,9 +103,11 @@ public class ImagesPreviewController {
private EnhancedImage toEnhancedImage(GWTWorkspaceItem wi){ private EnhancedImage toEnhancedImage(GWTWorkspaceItem wi){
if(wi instanceof GWTImageDocument){ if(wi instanceof GWTImageDocument){
GWTImageDocument image = (GWTImageDocument) wi; GWTImageDocument image = (GWTImageDocument) wi;
return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl()); GWT.log("GWTImageDocument image: "+image);
return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl());
}else if(wi instanceof GWTExternalImage){ }else if(wi instanceof GWTExternalImage){
GWTExternalImage image = (GWTExternalImage) wi; GWTExternalImage image = (GWTExternalImage) wi;
GWT.log("GWTExternalImage image: "+image);
return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl()); return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl());
} }
@ -157,18 +159,13 @@ public class ImagesPreviewController {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
parentImages = null; parentImages = null;
} }
@Override @Override
public void onSuccess(List<GWTWorkspaceItem> result) { public void onSuccess(List<GWTWorkspaceItem> result) {
GWT.log("Preloaded: "+result +" image/s"); GWT.log("Preloaded: "+result +" image/s");
parentImages = result; parentImages = result;
if(parentImages.size()>0) if(parentImages.size()>0)
carousel.showArrows(true); carousel.showArrows(true);
@ -186,8 +183,8 @@ public class ImagesPreviewController {
*/ */
private void showCarousel(String imageTitle, String thumbnailURL, String imageURL) { private void showCarousel(String imageTitle, String thumbnailURL, String imageURL) {
List<EnhancedImage> list = new ArrayList<EnhancedImage>(); List<EnhancedImage> list = new ArrayList<EnhancedImage>();
GWT.log("Generating imageURL: "+thumbnailURL); GWT.log("Generating thumbnailURL: "+thumbnailURL +"\n imageURL: "+imageURL);
EnhancedImage myimg = new EnhancedImage(thumbnailURL, imageTitle, imageTitle); EnhancedImage myimg = new EnhancedImage(thumbnailURL, imageTitle, imageTitle, imageURL);
list.add(myimg); list.add(myimg);
carousel.updateImages(list); carousel.updateImages(list);
carousel.showArrows(false); carousel.showArrows(false);

View File

@ -173,4 +173,33 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G
public long getThumbnailLenght() { public long getThumbnailLenght() {
return thumbnailLenght; return thumbnailLenght;
} }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GWTExternalImage [imageUrl=");
builder.append(imageUrl);
builder.append(", thumbnailUrl=");
builder.append(thumbnailUrl);
builder.append(", thumbnailWidth=");
builder.append(thumbnailWidth);
builder.append(", thumbnailHeight=");
builder.append(thumbnailHeight);
builder.append(", thumbnailLenght=");
builder.append(thumbnailLenght);
builder.append(", width=");
builder.append(width);
builder.append(", height=");
builder.append(height);
builder.append(", mimeType=");
builder.append(mimeType);
builder.append("]");
return builder.toString();
}
} }

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube; package org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube;
@ -21,48 +21,48 @@ import com.google.gwt.user.client.rpc.IsSerializable;
* *
*/ */
public class GWTImageDocument extends GWTDocument implements IsSerializable, GWTImage{ public class GWTImageDocument extends GWTDocument implements IsSerializable, GWTImage{
protected String imageUrl; protected String imageUrl;
protected String thumbnailUrl; protected String thumbnailUrl;
protected int thumbnailWidth; protected int thumbnailWidth;
protected int thumbnailHeight; protected int thumbnailHeight;
protected long thumbnailLenght; protected long thumbnailLenght;
protected int width; protected int width;
protected int height; protected int height;
protected long lenght; protected long lenght;
protected GWTImageDocument() protected GWTImageDocument()
{} {}
public GWTImageDocument(Date creationTime, String id, GWTProperties properties, String name, String owner, public GWTImageDocument(Date creationTime, String id, GWTProperties properties, String name, String owner,
String description, Date lastModificationTime, GWTWorkspaceItemAction lastAction, String description, Date lastModificationTime, GWTWorkspaceItemAction lastAction,
GWTWorkspaceFolder parent, GWTWorkspaceFolder parent,
String imageUrl, String thumbnailUrl, int width, int height, int thumbnailWidth, int thumbnailHeight, long thumbnailLenght, String imageUrl, String thumbnailUrl, int width, int height, int thumbnailWidth, int thumbnailHeight, long thumbnailLenght,
long length, String mimeType, String oid, Map<String, GWTDocumentMetadata> metadata, Map<String,String> annotation, long length, String mimeType, String oid, Map<String, GWTDocumentMetadata> metadata, Map<String,String> annotation,
String collection, int numberOfAlternatives, int numberOfParts) { String collection, int numberOfAlternatives, int numberOfParts) {
super(creationTime, id, properties, name, owner, description, lastModificationTime, lastAction, parent, length, oid, super(creationTime, id, properties, name, owner, description, lastModificationTime, lastAction, parent, length, oid,
mimeType, metadata, annotation, collection, numberOfAlternatives, numberOfParts); mimeType, metadata, annotation, collection, numberOfAlternatives, numberOfParts);
this.imageUrl = imageUrl; this.imageUrl = imageUrl;
this.thumbnailUrl = thumbnailUrl; this.thumbnailUrl = thumbnailUrl;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.lenght = length; this.lenght = length;
this.thumbnailHeight = thumbnailHeight; this.thumbnailHeight = thumbnailHeight;
this.thumbnailWidth = thumbnailWidth; this.thumbnailWidth = thumbnailWidth;
this.thumbnailLenght = thumbnailLenght; this.thumbnailLenght = thumbnailLenght;
this.mimeType = mimeType; this.mimeType = mimeType;
} }
public String getThumbnailUrl(){ public String getThumbnailUrl(){
return GWT.getModuleBaseURL()+thumbnailUrl; return GWT.getModuleBaseURL()+thumbnailUrl;
} }
public String getImageUrl(){ public String getImageUrl(){
return GWT.getModuleBaseURL()+imageUrl; return GWT.getModuleBaseURL()+imageUrl;
} }
@ -87,7 +87,7 @@ public class GWTImageDocument extends GWTDocument implements IsSerializable, GWT
public long getLength() { public long getLength() {
return lenght; return lenght;
} }
/** /**
* @return the thumbnailWidth * @return the thumbnailWidth
@ -118,4 +118,33 @@ public class GWTImageDocument extends GWTDocument implements IsSerializable, GWT
return GWTFolderItemType.IMAGE_DOCUMENT; return GWTFolderItemType.IMAGE_DOCUMENT;
} }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GWTImageDocument [imageUrl=");
builder.append(imageUrl);
builder.append(", thumbnailUrl=");
builder.append(thumbnailUrl);
builder.append(", thumbnailWidth=");
builder.append(thumbnailWidth);
builder.append(", thumbnailHeight=");
builder.append(thumbnailHeight);
builder.append(", thumbnailLenght=");
builder.append(thumbnailLenght);
builder.append(", width=");
builder.append(width);
builder.append(", height=");
builder.append(height);
builder.append(", lenght=");
builder.append(lenght);
builder.append("]");
return builder.toString();
}
} }