Implemented Feature #5110

Add Enabled/Disabled Public Access to workspace history


git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@131999 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-09-28 14:58:57 +00:00
parent 24565db7ff
commit 9f804215bd
4 changed files with 137 additions and 20 deletions

View File

@ -36,14 +36,21 @@ import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter;
import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
/**
* The Class AccoutingInfoContainer.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 28, 2016
*/
public class AccoutingInfoContainer extends LayoutContainer { public class AccoutingInfoContainer extends LayoutContainer {
/** /**
* *
*/ */
private static final String OPERATION_NAME = "OperationName"; private static final String OPERATION_NAME = "OperationName";
/** /**
* *
*/ */
private static final String TYPEOPERATION = "typeoperation"; private static final String TYPEOPERATION = "typeoperation";
protected static final String DATE = "Date"; protected static final String DATE = "Date";
@ -57,12 +64,18 @@ public class AccoutingInfoContainer extends LayoutContainer {
private boolean groupingEnabled; private boolean groupingEnabled;
private ListStore<ModelData> typeStoreOperation = new ListStore<ModelData>(); private ListStore<ModelData> typeStoreOperation = new ListStore<ModelData>();
/**
* Instantiates a new accouting info container.
*/
public AccoutingInfoContainer() { public AccoutingInfoContainer() {
initContentPanel(); initContentPanel();
initGrid(); initGrid();
createToolBar(); createToolBar();
} }
/**
* Inits the content panel.
*/
private void initContentPanel() { private void initContentPanel() {
setLayout(new FitLayout()); setLayout(new FitLayout());
getAriaSupport().setPresentation(true); getAriaSupport().setPresentation(true);
@ -76,6 +89,9 @@ public class AccoutingInfoContainer extends LayoutContainer {
add(cp); add(cp);
} }
/**
* Creates the tool bar.
*/
private void createToolBar() { private void createToolBar() {
ToolBar bar = new ToolBar(); ToolBar bar = new ToolBar();
@ -103,6 +119,9 @@ public class AccoutingInfoContainer extends LayoutContainer {
} }
/**
* Inits the grid.
*/
public void initGrid() { public void initGrid() {
store.groupBy(OPERATION_NAME); store.groupBy(OPERATION_NAME);
@ -152,6 +171,12 @@ public class AccoutingInfoContainer extends LayoutContainer {
else if (model.get(OPERATION).equals( else if (model.get(OPERATION).equals(
GxtAccountingEntryType.RESTORE)) GxtAccountingEntryType.RESTORE))
return Resources.getIconUndo().createImage(); return Resources.getIconUndo().createImage();
else if (model.get(OPERATION).equals(
GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS))
return Resources.getIconFolderPublicRemove().createImage();
else if (model.get(OPERATION).equals(
GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS))
return Resources.getIconFolderPublic().createImage();
} }
return null; return null;
} }
@ -166,11 +191,9 @@ public class AccoutingInfoContainer extends LayoutContainer {
public Object render(ModelData model, String property, public Object render(ModelData model, String property,
ColumnData config, int rowIndex, int colIndex, ColumnData config, int rowIndex, int colIndex,
ListStore<ModelData> store, Grid<ModelData> grid) { ListStore<ModelData> store, Grid<ModelData> grid) {
// if(model.get(OPERATION).equals(GxtAccountingEntryType.READ)) // if(model.get(OPERATION).equals(GxtAccountingEntryType.READ))
// return "<b><p style=\"color: red;\">" // return "<b><p style=\"color: red;\">"
// + model.get(DESCRIPTION)+ "</p></b>"; // + model.get(DESCRIPTION)+ "</p></b>";
return model.get(DESCRIPTION); return model.get(DESCRIPTION);
} }
@ -209,16 +232,16 @@ public class AccoutingInfoContainer extends LayoutContainer {
DateFilter dateFilter = new DateFilter(DATE); DateFilter dateFilter = new DateFilter(DATE);
filters.addFilter(dateFilter); filters.addFilter(dateFilter);
StringFilter descrFilter = new StringFilter(DESCRIPTION); StringFilter descrFilter = new StringFilter(DESCRIPTION);
filters.addFilter(descrFilter); filters.addFilter(descrFilter);
StringFilter authorFilter = new StringFilter(AUTHOR); StringFilter authorFilter = new StringFilter(AUTHOR);
filters.addFilter(authorFilter); filters.addFilter(authorFilter);
ListFilter listFilter = new ListFilter(OPERATION_NAME, typeStoreOperation); ListFilter listFilter = new ListFilter(OPERATION_NAME, typeStoreOperation);
listFilter.setDisplayProperty(TYPEOPERATION); listFilter.setDisplayProperty(TYPEOPERATION);
filters.addFilter(listFilter); filters.addFilter(listFilter);
grid.addPlugin(filters); grid.addPlugin(filters);
@ -233,8 +256,14 @@ public class AccoutingInfoContainer extends LayoutContainer {
cp.add(grid); cp.add(grid);
} }
/**
* Sets the panel size.
*
* @param width the width
* @param height the height
*/
public void setPanelSize(int width, int height) { public void setPanelSize(int width, int height) {
if (width > 0 && height > 0 && grid != null) { if (width > 0 && height > 0 && grid != null) {
@ -243,6 +272,11 @@ public class AccoutingInfoContainer extends LayoutContainer {
} }
} }
/**
* Instantiates a new accouting info container.
*
* @param accountings the accountings
*/
public AccoutingInfoContainer(List<GxtAccountingField> accountings) { public AccoutingInfoContainer(List<GxtAccountingField> accountings) {
initContentPanel(); initContentPanel();
@ -250,10 +284,13 @@ public class AccoutingInfoContainer extends LayoutContainer {
updateListAccounting(accountings); updateListAccounting(accountings);
} }
/**
* Disable grouping.
*/
public void disableGrouping() { public void disableGrouping() {
GroupingStore<ModelData> groupingStore = null; GroupingStore<ModelData> groupingStore = null;
if (store instanceof GroupingStore) { if (store instanceof GroupingStore) {
groupingStore = (GroupingStore<ModelData>) store; groupingStore = store;
if (groupingStore != null) { if (groupingStore != null) {
groupingStore.clearGrouping(); groupingStore.clearGrouping();
} }
@ -261,10 +298,13 @@ public class AccoutingInfoContainer extends LayoutContainer {
} }
} }
/**
* Enable grouping.
*/
public void enableGrouping() { public void enableGrouping() {
GroupingStore<ModelData> groupingStore = null; GroupingStore<ModelData> groupingStore = null;
if (store instanceof GroupingStore) { if (store instanceof GroupingStore) {
groupingStore = (GroupingStore<ModelData>) store; groupingStore = store;
if (groupingStore != null) { if (groupingStore != null) {
groupingStore.groupBy(OPERATION_NAME); groupingStore.groupBy(OPERATION_NAME);
} }
@ -272,23 +312,28 @@ public class AccoutingInfoContainer extends LayoutContainer {
} }
} }
/**
* Update list accounting.
*
* @param accountings the accountings
*/
public void updateListAccounting(List<GxtAccountingField> accountings) { public void updateListAccounting(List<GxtAccountingField> accountings) {
List<BaseModelData> listModelData = new ArrayList<BaseModelData>(); List<BaseModelData> listModelData = new ArrayList<BaseModelData>();
store.removeAll(); store.removeAll();
//Used for list store filters //Used for list store filters
Map<String, String> hashOperation = new HashMap<String, String>(); Map<String, String> hashOperation = new HashMap<String, String>();
typeStoreOperation.removeAll(); typeStoreOperation.removeAll();
for (GxtAccountingField gxtAccountingField : accountings) { for (GxtAccountingField gxtAccountingField : accountings) {
BaseModelData baseModel = new BaseModelData(); BaseModelData baseModel = new BaseModelData();
baseModel.set(DESCRIPTION, gxtAccountingField.getDescription()); baseModel.set(DESCRIPTION, gxtAccountingField.getDescription());
baseModel.set(OPERATION, gxtAccountingField.getOperation()); baseModel.set(OPERATION, gxtAccountingField.getOperation());
baseModel.set(OPERATION_NAME, gxtAccountingField.getOperation().getId()); baseModel.set(OPERATION_NAME, gxtAccountingField.getOperation().getId());
if(hashOperation.get(gxtAccountingField.getOperation().getId())==null){ if(hashOperation.get(gxtAccountingField.getOperation().getId())==null){
hashOperation.put(gxtAccountingField.getOperation().getId(), ""); hashOperation.put(gxtAccountingField.getOperation().getId(), "");
// typeStoreOperation.add(type((gxtAccountingField.getOperation().getId()))); // typeStoreOperation.add(type((gxtAccountingField.getOperation().getId())));
@ -299,7 +344,7 @@ public class AccoutingInfoContainer extends LayoutContainer {
listModelData.add(baseModel); listModelData.add(baseModel);
} }
List<String> operationKeys = new ArrayList<String>(hashOperation.keySet()); List<String> operationKeys = new ArrayList<String>(hashOperation.keySet());
Collections.sort(operationKeys); Collections.sort(operationKeys);
for (String key : operationKeys) { for (String key : operationKeys) {
@ -308,7 +353,13 @@ public class AccoutingInfoContainer extends LayoutContainer {
store.add(listModelData); store.add(listModelData);
} }
/**
* Type.
*
* @param type the type
* @return the model data
*/
private ModelData type(String type) { private ModelData type(String type) {
ModelData model = new BaseModelData(); ModelData model = new BaseModelData();
model.set(TYPEOPERATION, type); model.set(TYPEOPERATION, type);
@ -316,6 +367,11 @@ public class AccoutingInfoContainer extends LayoutContainer {
} }
/**
* Update store.
*
* @param store the store
*/
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void updateStore(ListStore<ModelData> store) { private void updateStore(ListStore<ModelData> store) {
@ -323,10 +379,21 @@ public class AccoutingInfoContainer extends LayoutContainer {
this.grid.getStore().add(store.getModels()); this.grid.getStore().add(store.getModels());
} }
/**
* Reset store.
*/
public void resetStore() { public void resetStore() {
this.grid.getStore().removeAll(); this.grid.getStore().removeAll();
} }
/**
* Creates the sortable column config.
*
* @param id the id
* @param name the name
* @param width the width
* @return the column config
*/
public ColumnConfig createSortableColumnConfig(String id, String name, public ColumnConfig createSortableColumnConfig(String id, String name,
int width) { int width) {
ColumnConfig columnConfig = new ColumnConfig(id, name, width); ColumnConfig columnConfig = new ColumnConfig(id, name, width);
@ -335,15 +402,30 @@ public class AccoutingInfoContainer extends LayoutContainer {
return columnConfig; return columnConfig;
} }
/**
* Sets the header title.
*
* @param title the new header title
*/
public void setHeaderTitle(String title) { public void setHeaderTitle(String title) {
cp.setHeading(title); cp.setHeading(title);
// cp.layout(); // cp.layout();
} }
/**
* Checks if is grouping enabled.
*
* @return true, if is grouping enabled
*/
public boolean isGroupingEnabled() { public boolean isGroupingEnabled() {
return groupingEnabled; return groupingEnabled;
} }
/**
* Sets the grouping enabled.
*
* @param groupingEnabled the new grouping enabled
*/
public void setGroupingEnabled(boolean groupingEnabled) { public void setGroupingEnabled(boolean groupingEnabled) {
this.groupingEnabled = groupingEnabled; this.groupingEnabled = groupingEnabled;
} }

View File

@ -17,7 +17,6 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty; import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
import org.gcube.portlets.user.workspace.server.util.WsUtil; import org.gcube.portlets.user.workspace.server.util.WsUtil;

View File

@ -1854,6 +1854,38 @@ public class GWTWorkspaceBuilder {
af.setDescription(msg); af.setDescription(msg);
} }
break; break;
case DISABLED_PUBLIC_ACCESS:
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)){
af.setOperation(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS);
AccountingEntryRestore acc = (AccountingEntryRestore) accountingEntry;
String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
msg+=GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName()+" by "+user.getName();
af.setDescription(msg);
}
break;
case ENABLED_PUBLIC_ACCESS:
if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)){
af.setOperation(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS);
AccountingEntryRestore acc = (AccountingEntryRestore) accountingEntry;
String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
msg+=GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName()+" by "+user.getName();
af.setDescription(msg);
}
break;
default:
break;
} }
listAccFields.add(af); listAccFields.add(af);
} }

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.workspace.shared.accounting; package org.gcube.portlets.user.workspace.shared.accounting;
@ -8,7 +8,7 @@ package org.gcube.portlets.user.workspace.shared.accounting;
* The Enum GxtAccountingEntryType. * The Enum GxtAccountingEntryType.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 10, 2015 * Sep 28, 2016
*/ */
public enum GxtAccountingEntryType { public enum GxtAccountingEntryType {
@ -36,6 +36,10 @@ public enum GxtAccountingEntryType {
RESTORE("Restored", "restored"), RESTORE("Restored", "restored"),
DISABLED_PUBLIC_ACCESS("DisabledPublicAccess","disabled public access"),
ENABLED_PUBLIC_ACCESS("EnabledPublicAccess","enabled public access"),
ALLWITHOUTREAD("allwithoutread", "allwithoutread"); ALLWITHOUTREAD("allwithoutread", "allwithoutread");
private String id; private String id;