filters updated
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@86974 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8e1f0fba14
commit
c0a389a9ef
|
@ -100,7 +100,6 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
||||
import org.gcube.portlets.user.workspace.client.util.PollingWorkspace;
|
||||
import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceValidateItem;
|
||||
import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter;
|
||||
import org.gcube.portlets.user.workspace.client.view.BasicDNDExample;
|
||||
|
|
|
@ -2,15 +2,11 @@ package org.gcube.portlets.user.workspace.client.util;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.event.BulkCreatorEvent;
|
||||
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.MessageModel;
|
||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
||||
|
||||
import com.extjs.gxt.ui.client.Registry;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows.accounting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
|
||||
|
@ -28,12 +30,21 @@ import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
|
|||
import com.extjs.gxt.ui.client.widget.grid.GroupingView;
|
||||
import com.extjs.gxt.ui.client.widget.grid.filters.DateFilter;
|
||||
import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters;
|
||||
import com.extjs.gxt.ui.client.widget.grid.filters.ListFilter;
|
||||
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.toolbar.ToolBar;
|
||||
|
||||
public class AccoutingInfoContainer extends LayoutContainer {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String OPERATION_NAME = "OperationName";
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final String TYPEOPERATION = "typeoperation";
|
||||
protected static final String DATE = "Date";
|
||||
protected static final String AUTHOR = "Author";
|
||||
protected static final String OPERATION = "Operation";
|
||||
|
@ -43,13 +54,14 @@ public class AccoutingInfoContainer extends LayoutContainer {
|
|||
private ContentPanel cp;
|
||||
private GroupingStore<ModelData> store = new GroupingStore<ModelData>();
|
||||
private boolean groupingEnabled;
|
||||
|
||||
public AccoutingInfoContainer(){
|
||||
private ListStore<ModelData> typeStoreOperation = new ListStore<ModelData>();
|
||||
|
||||
public AccoutingInfoContainer() {
|
||||
initContentPanel();
|
||||
initGrid();
|
||||
createToolBar();
|
||||
}
|
||||
|
||||
|
||||
private void initContentPanel() {
|
||||
setLayout(new FitLayout());
|
||||
getAriaSupport().setPresentation(true);
|
||||
|
@ -58,149 +70,172 @@ public class AccoutingInfoContainer extends LayoutContainer {
|
|||
cp.setBodyBorder(true);
|
||||
cp.setLayout(new FitLayout());
|
||||
cp.setButtonAlign(HorizontalAlignment.CENTER);
|
||||
// cp.getHeader().setIconAltText("Grid Icon");
|
||||
// cp.setSize(550, 280);
|
||||
// cp.getHeader().setIconAltText("Grid Icon");
|
||||
// cp.setSize(550, 280);
|
||||
add(cp);
|
||||
}
|
||||
|
||||
private void createToolBar(){
|
||||
|
||||
|
||||
private void createToolBar() {
|
||||
|
||||
ToolBar bar = new ToolBar();
|
||||
final ToggleButton buttonGrouping = new ToggleButton("", Resources.getIconGridView());
|
||||
final ToggleButton buttonGrouping = new ToggleButton("",
|
||||
Resources.getIconGridView());
|
||||
buttonGrouping.setToolTip("Grouping by operation");
|
||||
buttonGrouping.setScale(ButtonScale.SMALL);
|
||||
buttonGrouping.setScale(ButtonScale.SMALL);
|
||||
buttonGrouping.toggle(true);
|
||||
|
||||
buttonGrouping.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
if(buttonGrouping.isPressed())
|
||||
enableGrouping();
|
||||
else
|
||||
disableGrouping();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
buttonGrouping
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
if (buttonGrouping.isPressed())
|
||||
enableGrouping();
|
||||
else
|
||||
disableGrouping();
|
||||
}
|
||||
});
|
||||
|
||||
bar.add(buttonGrouping);
|
||||
cp.setTopComponent(bar);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void initGrid() {
|
||||
|
||||
store.groupBy(OPERATION);
|
||||
|
||||
|
||||
store.groupBy(OPERATION_NAME);
|
||||
|
||||
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
|
||||
|
||||
|
||||
ColumnConfig icon = createSortableColumnConfig("Type", "", 20);
|
||||
columns.add(icon);
|
||||
|
||||
icon.setRenderer(new GridCellRenderer<ModelData>() {
|
||||
|
||||
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||
ListStore<ModelData> store, Grid<ModelData> grid) {
|
||||
|
||||
if(model.get(OPERATION)!=null){
|
||||
if(model.get(OPERATION).equals(GxtAccountingEntryType.CREATE))
|
||||
return Resources.getIconCreateNew().createImage();
|
||||
if(model.get(OPERATION).equals(GxtAccountingEntryType.READ))
|
||||
return Resources.getIconRead().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.CUT))
|
||||
return Resources.getIconCut().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.PASTE))
|
||||
return Resources.getIconPaste().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.REMOVE))
|
||||
return Resources.getIconCancel().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.RENAME))
|
||||
return Resources.getIconRenameItem().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.UPDATE))
|
||||
return Resources.getIconRefresh().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.ADD))
|
||||
return Resources.getIconFileUpload().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.SHARE))
|
||||
return Resources.getIconShareFolder().createImage();
|
||||
else if(model.get(OPERATION).equals(GxtAccountingEntryType.UNSHARE))
|
||||
return Resources.getIconUnShareFolder().createImage();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
icon.setRenderer(new GridCellRenderer<ModelData>() {
|
||||
|
||||
public Object render(ModelData model, String property,
|
||||
ColumnData config, int rowIndex, int colIndex,
|
||||
ListStore<ModelData> store, Grid<ModelData> grid) {
|
||||
|
||||
if (model.get(OPERATION) != null) {
|
||||
if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.CREATE))
|
||||
return Resources.getIconCreateNew().createImage();
|
||||
if (model.get(OPERATION)
|
||||
.equals(GxtAccountingEntryType.READ))
|
||||
return Resources.getIconRead().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.CUT))
|
||||
return Resources.getIconCut().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.PASTE))
|
||||
return Resources.getIconPaste().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.REMOVE))
|
||||
return Resources.getIconCancel().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.RENAME))
|
||||
return Resources.getIconRenameItem().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.UPDATE))
|
||||
return Resources.getIconRefresh().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.ADD))
|
||||
return Resources.getIconFileUpload().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.SHARE))
|
||||
return Resources.getIconShareFolder().createImage();
|
||||
else if (model.get(OPERATION).equals(
|
||||
GxtAccountingEntryType.UNSHARE))
|
||||
return Resources.getIconUnShareFolder().createImage();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
ColumnConfig descr = createSortableColumnConfig(DESCRIPTION, DESCRIPTION, 230);
|
||||
columns.add(descr);
|
||||
|
||||
descr.setRenderer(new GridCellRenderer<ModelData>() {
|
||||
|
||||
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||
ListStore<ModelData> store, Grid<ModelData> grid) {
|
||||
|
||||
// if(model.get(OPERATION).equals(GxtAccountingEntryType.READ))
|
||||
// return "<b><p style=\"color: red;\">"
|
||||
// + model.get(DESCRIPTION)+ "</p></b>";
|
||||
|
||||
return model.get(DESCRIPTION);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ColumnConfig oper = createSortableColumnConfig(OPERATION, OPERATION, 70);
|
||||
descr.setRenderer(new GridCellRenderer<ModelData>() {
|
||||
|
||||
public Object render(ModelData model, String property,
|
||||
ColumnData config, int rowIndex, int colIndex,
|
||||
ListStore<ModelData> store, Grid<ModelData> grid) {
|
||||
|
||||
// if(model.get(OPERATION).equals(GxtAccountingEntryType.READ))
|
||||
// return "<b><p style=\"color: red;\">"
|
||||
// + model.get(DESCRIPTION)+ "</p></b>";
|
||||
|
||||
return model.get(DESCRIPTION);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ColumnConfig oper = createSortableColumnConfig(OPERATION_NAME, OPERATION, 70);
|
||||
columns.add(oper);
|
||||
|
||||
|
||||
ColumnConfig auth = createSortableColumnConfig(AUTHOR, AUTHOR, 120);
|
||||
columns.add(auth);
|
||||
|
||||
|
||||
ColumnConfig date = createSortableColumnConfig(DATE, DATE, 140);
|
||||
columns.add(date);
|
||||
|
||||
cm = new ColumnModel(columns);
|
||||
|
||||
|
||||
final ColumnModel columnModel = cm;
|
||||
|
||||
grid = new Grid<ModelData>(this.store, cm);
|
||||
|
||||
GroupingView view = new GroupingView();
|
||||
view.setShowGroupedColumn(true);
|
||||
this.grid.setView(view);
|
||||
|
||||
view.setGroupRenderer(new GridGroupRenderer() {
|
||||
public String render(GroupColumnData data) {
|
||||
String f = columnModel.getColumnById(data.field).getHeader();
|
||||
String l = data.models.size() == 1 ? "Item" : "Items";
|
||||
return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
GroupingView view = new GroupingView();
|
||||
view.setShowGroupedColumn(true);
|
||||
this.grid.setView(view);
|
||||
|
||||
view.setGroupRenderer(new GridGroupRenderer() {
|
||||
public String render(GroupColumnData data) {
|
||||
String f = columnModel.getColumnById(data.field).getHeader();
|
||||
String l = data.models.size() == 1 ? "Item" : "Items";
|
||||
return f + ": " + data.group + " (" + data.models.size() + " "
|
||||
+ l + ")";
|
||||
}
|
||||
});
|
||||
|
||||
GridFilters filters = new GridFilters();
|
||||
filters.setLocal(true);
|
||||
|
||||
|
||||
DateFilter dateFilter = new DateFilter(DATE);
|
||||
filters.addFilter(dateFilter);
|
||||
|
||||
StringFilter descrFilter = new StringFilter(DESCRIPTION);
|
||||
filters.addFilter(descrFilter);
|
||||
|
||||
StringFilter authorFilter = new StringFilter(AUTHOR);
|
||||
filters.addFilter(authorFilter);
|
||||
|
||||
ListFilter listFilter = new ListFilter(OPERATION_NAME, typeStoreOperation);
|
||||
listFilter.setDisplayProperty(TYPEOPERATION);
|
||||
|
||||
filters.addFilter(listFilter);
|
||||
|
||||
grid.addPlugin(filters);
|
||||
|
||||
|
||||
|
||||
grid.setBorders(true);
|
||||
grid.setStripeRows(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
grid.setColumnLines(true);
|
||||
grid.setColumnReordering(true);
|
||||
grid.setStyleAttribute("borderTop", "none");
|
||||
// grid.setLoadMask(true);
|
||||
// grid.setLoadMask(true);
|
||||
cp.add(grid);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setPanelSize(int width, int height){
|
||||
|
||||
if(width>0 && height>0 && grid!=null){
|
||||
|
||||
public void setPanelSize(int width, int height) {
|
||||
|
||||
if (width > 0 && height > 0 && grid != null) {
|
||||
cp.setSize(width, height);
|
||||
// grid.setSize(width, height);
|
||||
// grid.setSize(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +245,7 @@ public class AccoutingInfoContainer extends LayoutContainer {
|
|||
initGrid();
|
||||
updateListAccounting(accountings);
|
||||
}
|
||||
|
||||
|
||||
public void disableGrouping() {
|
||||
GroupingStore<ModelData> groupingStore = null;
|
||||
if (store instanceof GroupingStore) {
|
||||
|
@ -227,56 +262,72 @@ public class AccoutingInfoContainer extends LayoutContainer {
|
|||
if (store instanceof GroupingStore) {
|
||||
groupingStore = (GroupingStore<ModelData>) store;
|
||||
if (groupingStore != null) {
|
||||
groupingStore.groupBy(OPERATION);
|
||||
groupingStore.groupBy(OPERATION_NAME);
|
||||
}
|
||||
this.groupingEnabled = true;
|
||||
this.groupingEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateListAccounting(List<GxtAccountingField> accountings){
|
||||
|
||||
|
||||
public void updateListAccounting(List<GxtAccountingField> accountings) {
|
||||
|
||||
List<BaseModelData> listModelData = new ArrayList<BaseModelData>();
|
||||
|
||||
|
||||
store.removeAll();
|
||||
|
||||
//Used for list store filters
|
||||
Map<String, String> hashOperation = new HashMap<String, String>();
|
||||
typeStoreOperation.removeAll();
|
||||
|
||||
for (GxtAccountingField gxtAccountingField : accountings) {
|
||||
BaseModelData baseModel = new BaseModelData();
|
||||
|
||||
|
||||
baseModel.set(DESCRIPTION, gxtAccountingField.getDescription());
|
||||
baseModel.set(OPERATION, gxtAccountingField.getOperation());
|
||||
baseModel.set(OPERATION_NAME, gxtAccountingField.getOperation().getId());
|
||||
|
||||
if(hashOperation.get(gxtAccountingField.getOperation().getId())==null){
|
||||
hashOperation.put(gxtAccountingField.getOperation().getId(), "");
|
||||
typeStoreOperation.add(type((gxtAccountingField.getOperation().getId())));
|
||||
}
|
||||
|
||||
baseModel.set(AUTHOR, gxtAccountingField.getUser().getName());
|
||||
baseModel.set(DATE, gxtAccountingField.getDate());
|
||||
|
||||
|
||||
listModelData.add(baseModel);
|
||||
}
|
||||
|
||||
|
||||
store.add(listModelData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ModelData type(String type) {
|
||||
ModelData model = new BaseModelData();
|
||||
model.set(TYPEOPERATION, type);
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void updateStore(ListStore<ModelData> store){
|
||||
|
||||
private void updateStore(ListStore<ModelData> store) {
|
||||
|
||||
resetStore();
|
||||
this.grid.getStore().add(store.getModels());
|
||||
}
|
||||
|
||||
public void resetStore(){
|
||||
|
||||
public void resetStore() {
|
||||
this.grid.getStore().removeAll();
|
||||
}
|
||||
|
||||
public ColumnConfig createSortableColumnConfig(String id, String name, int width)
|
||||
{
|
||||
|
||||
public ColumnConfig createSortableColumnConfig(String id, String name,
|
||||
int width) {
|
||||
ColumnConfig columnConfig = new ColumnConfig(id, name, width);
|
||||
columnConfig.setSortable(true);
|
||||
|
||||
|
||||
return columnConfig;
|
||||
}
|
||||
|
||||
public void setHeaderTitle(String title) {
|
||||
cp.setHeading(title);
|
||||
// cp.layout();
|
||||
// cp.layout();
|
||||
}
|
||||
|
||||
public boolean isGroupingEnabled() {
|
||||
|
@ -286,7 +337,5 @@ public class AccoutingInfoContainer extends LayoutContainer {
|
|||
public void setGroupingEnabled(boolean groupingEnabled) {
|
||||
this.groupingEnabled = groupingEnabled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1083,7 +1083,7 @@ public class GWTWorkspaceBuilder {
|
|||
return listFileGridModel;
|
||||
}
|
||||
|
||||
protected FileGridModel buildGXTFileGridModelItem(WorkspaceItem item, FileModel parentFileModel) throws InternalErrorException{
|
||||
public FileGridModel buildGXTFileGridModelItem(WorkspaceItem item, FileModel parentFileModel) throws InternalErrorException{
|
||||
|
||||
|
||||
FileGridModel fileGridModel = null;
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistEx
|
|||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderBulkCreator;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItemType;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl;
|
||||
|
|
|
@ -3,17 +3,37 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.workspace;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.common.homelibrary.home.workspace.search.SearchFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.search.SearchFolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl;
|
||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter;
|
||||
import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
||||
import org.yaml.snakeyaml.reader.StreamReader;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
|
@ -25,25 +45,72 @@ public class SearchTextTest {
|
|||
|
||||
protected static Logger logger = Logger.getLogger(SearchTextTest.class);
|
||||
private static String text = "test";
|
||||
public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling"; //PRODUCTION
|
||||
|
||||
public static String USER = "pasquale.pagano"; //PRODUCTION
|
||||
|
||||
static GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||
static GWTWorkspaceServiceImpl serviceImpl = new GWTWorkspaceServiceImpl();
|
||||
static Workspace workspace;
|
||||
|
||||
static final String itemID = "8253f5c5-def6-41fd-a3f2-c614855a8b0b";
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
|
||||
ScopeBean scope = new ScopeBean("/gcube/devsec");
|
||||
// DEFAULT_SCOPE = "/gcube/devsec";
|
||||
|
||||
|
||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
|
||||
Workspace ws = HomeLibrary
|
||||
System.out.println("start get workspace\n");
|
||||
|
||||
workspace = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome("francesco.mangiacrapa")
|
||||
.getHome(USER)
|
||||
.getWorkspace();
|
||||
//
|
||||
|
||||
List<SearchItem> listSearchItems = ws.searchByName(text);
|
||||
// List<SearchItem> listSearchItems = ws.searchByName(text);
|
||||
|
||||
System.out.println("Total item founds: "+listSearchItems.size());
|
||||
|
||||
WorkspaceItem item = workspace.getItem(itemID);
|
||||
|
||||
|
||||
FileGridModel wsItem = builder.buildGXTFileGridModelItem(item, null);
|
||||
System.out.println("Item is: "+wsItem.getName() + "; ID: "+wsItem.getIdentifier() + " Last Update: "+wsItem.getLastModification());
|
||||
|
||||
int i = 1;
|
||||
while(item.getParent()!=null){
|
||||
|
||||
item = item.getParent();
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) item;
|
||||
|
||||
|
||||
FolderModel parent = builder.buildGXTFolderModelItem(folder, null);
|
||||
|
||||
|
||||
System.out.println("Parent "+i+" is: "+parent.getName() + "; ID: "+parent.getIdentifier());
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// if(item.getParent()!=null){
|
||||
//
|
||||
//// System.out.println("Parent is: "+item.getParent().getName());
|
||||
// System.out.println("Parent is: "+builder.buildGXTFolderModelItem(item.getParent(), null));
|
||||
// }else
|
||||
// System.out.println("parent is null");
|
||||
//
|
||||
//
|
||||
|
||||
// System.out.println(item.toString());
|
||||
|
||||
// System.out.println("Total item founds: "+listSearchItems.size());
|
||||
/*
|
||||
int i=0;
|
||||
for (SearchItem searchItem : listSearchItems) {
|
||||
|
||||
|
@ -64,13 +131,54 @@ public class SearchTextTest {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
System.out.println("end");
|
||||
}*/
|
||||
|
||||
// downloadFile(workspace.getItem(itemID));
|
||||
|
||||
System.out.println("\nend");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void downloadFile(WorkspaceItem folderItem) throws InternalErrorException{
|
||||
|
||||
try{
|
||||
|
||||
ExternalFile externalFile = (ExternalFile) folderItem;
|
||||
|
||||
|
||||
System.out.println("EXTERNAL_FILE DOWNLOAD FOR "+externalFile.getId());
|
||||
//COMMENTED 26/03/2013
|
||||
// String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
|
||||
|
||||
File f2 = new File(externalFile.getName());
|
||||
OutputStream out = new FileOutputStream(f2, true); // ap
|
||||
|
||||
System.out.println("1");
|
||||
|
||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
||||
// IOUtils.copy(externalFile.getData(), resp.getOutputStream());
|
||||
InputStream is = externalFile.getData();
|
||||
|
||||
// //REMOVE THIS -- TODO TEMPORARY SOLUTION
|
||||
if(is==null){
|
||||
logger.error("Error during get input stream: IS is null");
|
||||
throw new Exception("Item is not reachable");
|
||||
}
|
||||
|
||||
System.out.println("2");
|
||||
|
||||
IOUtils.copy(is, out);
|
||||
|
||||
is.close();
|
||||
out.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during external item retrieving "+folderItem.getId(),e);
|
||||
// sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue