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;
/**
* The Class DialogShareFolder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 4, 2015
* Jun 6, 2017
*/
public class DialogShareFolder extends Dialog {
@ -62,6 +63,7 @@ public class DialogShareFolder extends Dialog {
* @param folderParentName the folder parent name
* @param folder the folder
* @param eventBus the event bus
* @param userStore the user store
*/
public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus, UserStore userStore) {
initUserStore(userStore);
@ -143,6 +145,7 @@ public class DialogShareFolder extends Dialog {
lc.add(flexTable);
if(hpPermission!=null)
lc.add(hpPermission);
lc.mask();
userStore.getOwner(folder.getIdentifier(), new AsyncCallback<InfoContactModel>() {
@ -156,12 +159,29 @@ public class DialogShareFolder extends Dialog {
public void onSuccess(InfoContactModel result) {
shareOwner = result;
txtOwner.setValue(result.getName());
permissionControl(result.getLogin(), true);
//permissionControl(result.getLogin(), true);
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());
add(txtName);
add(txtOwner);
@ -172,6 +192,11 @@ public class DialogShareFolder extends Dialog {
this.show();
}
/**
* Inits the user store.
*
* @param userStore the user store
*/
private void initUserStore(UserStore userStore){
this.userStore = 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){
if(wi instanceof GWTImageDocument){
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){
GWTExternalImage image = (GWTExternalImage) wi;
GWT.log("GWTExternalImage image: "+image);
return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl());
}
@ -157,18 +159,13 @@ public class ImagesPreviewController {
@Override
public void onFailure(Throwable caught) {
parentImages = null;
}
@Override
public void onSuccess(List<GWTWorkspaceItem> result) {
GWT.log("Preloaded: "+result +" image/s");
parentImages = result;
if(parentImages.size()>0)
carousel.showArrows(true);
@ -186,8 +183,8 @@ public class ImagesPreviewController {
*/
private void showCarousel(String imageTitle, String thumbnailURL, String imageURL) {
List<EnhancedImage> list = new ArrayList<EnhancedImage>();
GWT.log("Generating imageURL: "+thumbnailURL);
EnhancedImage myimg = new EnhancedImage(thumbnailURL, imageTitle, imageTitle);
GWT.log("Generating thumbnailURL: "+thumbnailURL +"\n imageURL: "+imageURL);
EnhancedImage myimg = new EnhancedImage(thumbnailURL, imageTitle, imageTitle, imageURL);
list.add(myimg);
carousel.updateImages(list);
carousel.showArrows(false);

View File

@ -173,4 +173,33 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G
public long getThumbnailLenght() {
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;
@ -21,48 +21,48 @@ import com.google.gwt.user.client.rpc.IsSerializable;
*
*/
public class GWTImageDocument extends GWTDocument implements IsSerializable, GWTImage{
protected String imageUrl;
protected String thumbnailUrl;
protected int thumbnailWidth;
protected int thumbnailHeight;
protected long thumbnailLenght;
protected int width;
protected int height;
protected long lenght;
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,
GWTWorkspaceFolder parent,
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,
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,
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);
this.imageUrl = imageUrl;
this.thumbnailUrl = thumbnailUrl;
this.width = width;
this.height = height;
this.lenght = length;
this.thumbnailHeight = thumbnailHeight;
this.thumbnailWidth = thumbnailWidth;
this.thumbnailLenght = thumbnailLenght;
this.mimeType = mimeType;
}
public String getThumbnailUrl(){
return GWT.getModuleBaseURL()+thumbnailUrl;
}
public String getImageUrl(){
return GWT.getModuleBaseURL()+imageUrl;
}
@ -87,7 +87,7 @@ public class GWTImageDocument extends GWTDocument implements IsSerializable, GWT
public long getLength() {
return lenght;
}
/**
* @return the thumbnailWidth
@ -118,4 +118,33 @@ public class GWTImageDocument extends GWTDocument implements IsSerializable, GWT
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();
}
}