enhancements on new sharing policy

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@91444 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-02-12 11:49:07 +00:00
parent 7bc879acf9
commit c013b8c4a2
6 changed files with 67 additions and 7 deletions

View File

@ -168,6 +168,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private boolean selectRootItem;
private FileUploader fileUploader;
public static String myLogin;
public AppControllerExplorer() {
Registry.register(ConstantsExplorer.RPC_WORKSPACE_SERVICE, rpcWorkspaceService);
@ -2046,6 +2047,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
this.explorerPanel = new ExplorerPanel(true, true);
loadMyLogin();
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
// PollingWorkspace.pollBulkCreator(15000);
@ -2066,16 +2069,34 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
this.selectRootItem=selectRootItem;
loadMyLogin();
// if(instancingMessages)
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
// PollingWorkspace.pollBulkCreator(ConstantsExplorer.TIME_BULK_CREATOR_POLLING);
return this.explorerPanel;
}
private void loadMyLogin(){
rpcWorkspaceService.getMyLogin(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on loading my login is empty");
myLogin = "";
}
@Override
public void onSuccess(String result) {
GWT.log("My login is: "+result);
myLogin = result;
}
});
}
private void loadItemFromWorkspace(final String itemIdentifier){

View File

@ -199,4 +199,6 @@ public interface GWTWorkspaceService extends RemoteService{
void setACLs(String folderId, List<String> listLogins, String aclType)
throws Exception;
String getMyLogin();
}

View File

@ -177,4 +177,6 @@ public interface GWTWorkspaceServiceAsync {
void setACLs(String folderId, List<String> listLogins, String aclType,
AsyncCallback<Void> callback);
void getMyLogin(AsyncCallback<String> callback);
}

View File

@ -22,6 +22,7 @@ import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
@ -171,9 +172,11 @@ public class DialogShareFolder extends Dialog {
public void onSuccess(List<InfoContactModel> result) {
for (InfoContactModel infoContactModel : result) {
if(infoContactModel.getName()!=null){
listAlreadyShared.add(infoContactModel);
suggestPanel.addRecipient(infoContactModel.getName(),false);
}
}
lc.unmask();
}
@ -190,13 +193,13 @@ public class DialogShareFolder extends Dialog {
@Override
public void onFailure(Throwable caught) {
txtOwner.setValue("Error on retrieving Owner");
}
@Override
public void onSuccess(InfoContactModel result) {
txtOwner.setValue(result.getName());
permissionControl(result.getName(), true);
}
});
@ -205,10 +208,34 @@ public class DialogShareFolder extends Dialog {
add(txtOwner);
add(lc);
addListners();
enableFormDialog(false); //FORM IS DISABLED BY DEFAULT
this.show();
}
private void permissionControl(String owner, boolean showAlert){
GWT.log("Permission control compare between owner: "+owner +" and my login: "+AppControllerExplorer.myLogin);
if(AppControllerExplorer.myLogin.compareToIgnoreCase(owner)!=0){
enableFormDialog(false);
if(showAlert)
new MessageBoxAlert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null);
}else{
enableFormDialog(true);
}
}
private void enableFormDialog(boolean bool){
getButtonById(Dialog.OK).setEnabled(bool);
buttonMultiDrag.setEnabled(bool);
textAreaDescription.setEnabled(bool);
if(permission!=null)
permission.setEnabled(bool);
// setEnabled(bool);
}
public FileModel getParentFolder() {
return parentFolder;
}

View File

@ -2534,4 +2534,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception(error);
}
}
@Override
public String getMyLogin(){
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
return asl.getUsername();
}
}

View File

@ -103,10 +103,12 @@ public class WsUtil {
}else if(user.compareToIgnoreCase(TEST_USER)==0){
withoutPortal = true;
//COMMENT THIS IN PRODUCTION ENVIROMENT
// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){
//
// withoutPortal = true;
// //END UNCOMMENT
}else{
withoutPortal = false;