219: Workspace: modify the WorkspaceItem properties

Task-Url: https://support.d4science.org/issues/219

Added dialog EditProperties and relative RPC

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@115344 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-06-12 10:24:01 +00:00
parent 433125a415
commit a422814bb2
11 changed files with 852 additions and 157 deletions

View File

@ -375,5 +375,8 @@ public interface Icons extends ClientBundle {
*/
@Source("icons/edit-permissions.png")
ImageResource permissions();
@Source("icons/pencil16.png")
ImageResource pencil();
}

View File

@ -294,6 +294,11 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.documents());
}
public static AbstractImagePrototype getIconPencil(){
return AbstractImagePrototype.create(ICONS.pencil());
}
public static AbstractImagePrototype getIconHistory(){
return AbstractImagePrototype.create(ICONS.history());

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.rpc;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
@ -292,4 +293,20 @@ public interface GWTWorkspaceService extends RemoteService{
ReportAssignmentACL validateACLToUser(String folderId,
List<String> listLogins, String aclType) throws Exception;
Map<String, String> loadGcubeItemProperties(String itemId) throws Exception;
/**
* @param itemId
* @return
* @throws Exception
*/
String getHTMLGcubeItemProperties(String itemId) throws Exception;
/**
* @param itemId
* @param properties
* @throws Exception
*/
void setGcubeItemProperties(String itemId, Map<String, String> properties) throws Exception;
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.rpc;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
@ -230,4 +231,17 @@ public interface GWTWorkspaceServiceAsync {
void validateACLToUser(String folderId, List<String> listLogins,
String aclType, AsyncCallback<ReportAssignmentACL> callback);
/**
* @param itemId
* @param asyncCallback
*/
void loadGcubeItemProperties(String itemId,
AsyncCallback<Map<String, String>> asyncCallback);
void getHTMLGcubeItemProperties(String itemId,
AsyncCallback<String> callback);
void setGcubeItemProperties(String itemId, Map<String, String> properties,
AsyncCallback<Void> callback);
}

View File

@ -0,0 +1,151 @@
/**
*
*/
package org.gcube.portlets.user.workspace.client.view.windows;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The Class DialogEditProperties.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 11, 2015
*/
public class DialogEditProperties extends Dialog{
private FileModel item;
private int widthDialog = 450;
private int heigthDialog = 300;
private Command commad;
private List<TextField<String>> fields;
private FormLayout layout;
/**
* Instantiates a new dialog edit properties.
*
* @param itemId
* the item id
*/
public DialogEditProperties(FileModel item, Command command) {
this.item = item;
this.commad = command;
layout = new FormLayout();
layout.setLabelWidth(90);
layout.setDefaultWidth(300);
setLayout(layout);
setHeading(item.getName() + " set properties");
setButtonAlign(HorizontalAlignment.RIGHT);
setModal(true);
// setBodyBorder(true);
setBodyStyle("padding: 9px; background: none");
setWidth(widthDialog);
setHeight(350);
setScrollMode(Scroll.AUTOY);
setResizable(false);
setButtons(Dialog.OK);
getButtonById(Dialog.OK).setText("Save");
getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
saveProperties();
}
});
}
/* (non-Javadoc)
* @see com.extjs.gxt.ui.client.widget.Window#show()
*/
@Override
public void show() {
resetForm();
loadGcubeItemProperties();
super.show();
}
/**
*
*/
private void resetForm() {
if(fields!=null)
fields.clear();
fields = null;
removeAll();
}
private void saveProperties(){
Map<String,String> prp = new HashMap<String, String>(fields.size());
for (TextField<String> field : fields) {
prp.put(field.getFieldLabel(), field.getValue());
}
AppControllerExplorer.rpcWorkspaceService.setGcubeItemProperties(item.getIdentifier(), prp, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", caught.getMessage(), null);
}
@Override
public void onSuccess(Void result) {
commad.execute();
}
});
}
private void loadGcubeItemProperties(){
// mask("Loading properties...");
AppControllerExplorer.rpcWorkspaceService.loadGcubeItemProperties(item.getIdentifier(), new AsyncCallback<Map<String,String>>() {
@Override
public void onSuccess(Map<String, String> result) {
// unmask();
setProperties(result);
}
@Override
public void onFailure(Throwable caught) {
// unmask();
GWT.log("an error occured in loadGcubeItemProperties "+item + " "+caught.getMessage());
}
});
}
private void setProperties(Map<String, String> result) {
fields = new ArrayList<TextField<String>>(result.size());
for (String key: result.keySet()) {
TextField<String> field = new TextField<String>();
field.setFieldLabel(key);
field.setValue(result.get(key));
add(field);
fields.add(field);
}
layout(true);
}
}

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
@ -21,8 +22,12 @@ 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.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Image;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -49,10 +54,13 @@ public class DialogGetInfo extends Dialog {
private TextField<String> txtShared = new TextField<String>();
// private TextArea textAreaSharedWith = new TextArea();
private Html htmlUsersWidget = new Html();
private Html htmlPropertiesWidget = new Html();
private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
// private TextField<String> txtGcubeItemProperties;
private HorizontalPanel hpGcubeProperties;
private DialogEditProperties editProperties = null;
public DialogGetInfo(FileModel fileModel) {
public DialogGetInfo(final FileModel fileModel) {
FormLayout layout = new FormLayout();
layout.setLabelWidth(90);
@ -86,13 +94,51 @@ public class DialogGetInfo extends Dialog {
loadLocation(fileModel.getIdentifier());
add(txtLocation);
txtAreaDescription.setFieldLabel("Description");
txtAreaDescription.setHeight(30);
txtAreaDescription.setReadOnly(true);
add(txtAreaDescription);
//GCUBE PROPERTIES
hpGcubeProperties = new HorizontalPanel();
hpGcubeProperties.setStyleAttribute("padding-top", "6px");
hpGcubeProperties.setStyleAttribute("margin-bottom", "6px");
Label labelProperties = new Label("Properties");
labelProperties.setTitle("Gcube Properties");
labelProperties.setStyleAttribute("padding-right", "47px");
hpGcubeProperties.add(labelProperties);
loadGcubeItemProperties(fileModel.getIdentifier());
htmlPropertiesWidget.setHeight(heightTextArea);
htmlPropertiesWidget.setWidth("270px");
Image imgProperties = Resources.getIconPencil().createImage(); //EDIT PROPERTIES
hpGcubeProperties.add(imgProperties);
final Command cmdReloadProperties = new Command() {
@Override
public void execute() {
loadGcubeItemProperties(fileModel.getIdentifier());
}
};
imgProperties.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(editProperties==null)
editProperties = new DialogEditProperties(fileModel, cmdReloadProperties);
editProperties.show();
}
});
htmlPropertiesWidget.setStyleAttribute("margin-left", "5px");
hpGcubeProperties.add(htmlPropertiesWidget);
hpGcubeProperties.setScrollMode(Scroll.AUTOY);
add(hpGcubeProperties);
setVisibleGcubeProperties(false);
if(fileModel.isDirectory()){
txtAreaDescription.setValue(fileModel.getDescription());
@ -121,16 +167,11 @@ public class DialogGetInfo extends Dialog {
txtCreated = new TextField<String>();
txtCreated.setFieldLabel("Created");
txtCreated.setReadOnly(true);
// if(fileModel instanceof FileGridModel)
// textFieldSetValue(txtCreated, ((FileGridModel) fileModel).getCreationDate().toString());
// else
// loadCreationDate(fileModel.getIdentifier());
loadCreationDate(fileModel.getIdentifier());
add(txtCreated);
txtLastMofication = new TextField<String>();
txtLastMofication.setFieldLabel("Last Mofication");
txtLastMofication.setReadOnly(true);
@ -139,7 +180,6 @@ public class DialogGetInfo extends Dialog {
else
loadLastModificationDate(fileModel.getIdentifier());
// loadLastModificationDate(fileModel.getIdentifier());
add(txtLastMofication);
txtSize = new TextField<String>();
@ -152,15 +192,15 @@ public class DialogGetInfo extends Dialog {
loadSize(fileModel.getIdentifier());
add(txtSize);
//SHARED
txtShared = new TextField<String>();
txtShared.setFieldLabel("Shared");
txtShared.setReadOnly(true);
textFieldSetValue(txtShared,fileModel.isShared()+"");
add(txtShared);
//USERS SHARED
if(fileModel.isShared()){
HorizontalPanel hp = new HorizontalPanel();
@ -168,14 +208,6 @@ public class DialogGetInfo extends Dialog {
Label label = new Label("Shared with");
label.setStyleAttribute("padding-right", "39px");
hp.add(label);
/*
textAreaSharedWith.setFieldLabel("Shared with");
textAreaSharedWith.setHeight(heightTextArea);
textAreaSharedWith.setReadOnly(true);
loadListSharedContacts(fileModel.getIdentifier());
add(textAreaSharedWith);
*/
// htmlUsersWidget.setStyleAttribute("border", "1px solid #B5B8C8");
loadACLsDescriptionForSharedFolder(fileModel.getIdentifier());
htmlUsersWidget.setHeight(heightTextArea);
htmlUsersWidget.setWidth("297px");
@ -192,12 +224,13 @@ public class DialogGetInfo extends Dialog {
hide();
}
});
// System.out.println("fileModel in getinfo "+fileModel);
this.show();
}
private void setVisibleGcubeProperties(boolean bool){
hpGcubeProperties.setVisible(bool);
}
/**
* @param identifier
*/
@ -263,9 +296,7 @@ public class DialogGetInfo extends Dialog {
private void loadOwner(final String itemId){
txtOwner.mask();
// System.out.println("owner by id "+itemId);
AppControllerExplorer.rpcWorkspaceService.getOwnerByItemId(itemId, new AsyncCallback<InfoContactModel>() {
@Override
@ -282,6 +313,39 @@ public class DialogGetInfo extends Dialog {
});
}
private void loadGcubeItemProperties(final String itemId){
GWT.log("Load GcubeItemProperties");
htmlPropertiesWidget.mask();
AppControllerExplorer.rpcWorkspaceService.getHTMLGcubeItemProperties(itemId, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
htmlPropertiesWidget.unmask();
GWT.log("an error occured in load properties by Id "+itemId + " "+caught.getMessage());
setVisibleGcubeProperties(true);
htmlPropertiesWidget.setHtml("Error on recovering properties");
}
@Override
public void onSuccess(String result) {
// setVisibleGcubeProperties(true);
htmlPropertiesWidget.unmask();
if(result!=null){
setVisibleGcubeProperties(true);
htmlPropertiesWidget.setHtml(result);
}
// else{
// htmlPropertiesWidget.setHeight(20);
// htmlPropertiesWidget.setHtml("None");
// }
}
});
}
private void loadSize(final String itemId){
GWT.log("Load size");
txtSize.mask();
@ -325,37 +389,6 @@ public class DialogGetInfo extends Dialog {
});
}
// private void loadListSharedContacts(String sharedId){
//
// textAreaSharedWith.mask();
//
// AppControllerExplorer.rpcWorkspaceService.getListUserSharedBySharedItem(sharedId, new AsyncCallback<List<InfoContactModel>>() {
//
// @Override
// public void onFailure(Throwable caught) {
// textAreaSharedWith.unmask();
//
// }
//
// @Override
// public void onSuccess(List<InfoContactModel> result) {
//
// String users = "";
//
// for (int i = 0; i < result.size()-1; i++) {
// users+= result.get(i).getName() + ", ";
// }
//
// if(result.size()>1)
// users += result.get(result.size()-1).getName();
//
// textAreaSharedWith.setValue(users);
//
// textAreaSharedWith.unmask();
// }
// });
// }
private void loadACLsDescriptionForSharedFolder(String sharedId){
htmlUsersWidget.mask();
@ -423,7 +456,4 @@ public class DialogGetInfo extends Dialog {
});
}
}

View File

@ -3,18 +3,28 @@
*/
package org.gcube.portlets.user.workspace.client.workspace.exceptions;
/**
* @author Federico De Faveri defaveri@isti.cnr.it
* The Class WrongItemTypeException.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 11, 2015
*/
public class WrongItemTypeException extends Exception{
private static final long serialVersionUID = 3660227882791095368L;
/**
*
*/
private static final long serialVersionUID = -6229136748121940285L;
/**
* Instantiates a new wrong item type exception.
*
* @param message the message
*/
public WrongItemTypeException(String message) {
super(message);
}
}

View File

@ -88,8 +88,9 @@ import com.thoughtworks.xstream.XStream;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* The Class GWTWorkspaceBuilder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/
public class GWTWorkspaceBuilder {
@ -103,15 +104,16 @@ public class GWTWorkspaceBuilder {
/**
* @param logger
*/
* Instantiates a new GWT workspace builder.
*/
public GWTWorkspaceBuilder() {
}
/**
* Used in test mode
* @return
* Used in test mode.
*
* @return the hash test users
*/
public static HashMap<String, InfoContactModel> getHashTestUsers(){
@ -137,6 +139,12 @@ public class GWTWorkspaceBuilder {
return hashTestUser;
}
/**
* To date.
*
* @param calendar the calendar
* @return the date
*/
protected Date toDate(Calendar calendar)
{
if (calendar == null) return new Date(0);
@ -144,6 +152,12 @@ public class GWTWorkspaceBuilder {
}
/**
* To date format to string.
*
* @param calendar the calendar
* @return the string
*/
protected String toDateFormatToString(Calendar calendar){
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z");
@ -154,6 +168,12 @@ public class GWTWorkspaceBuilder {
}
/**
* To date format.
*
* @param calendar the calendar
* @return the date
*/
protected Date toDateFormat(Calendar calendar){
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM, yyyy HH:mm:ss z");
@ -173,6 +193,12 @@ public class GWTWorkspaceBuilder {
}
/**
* Gets the date.
*
* @param calendar the calendar
* @return the date
*/
private Date getDate(Calendar calendar) {
Date resultdate = null;
@ -186,6 +212,13 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gwt properties.
*
* @param metadata the metadata
* @return the GWT properties
* @throws InternalErrorException the internal error exception
*/
protected GWTProperties buildGWTProperties(Properties metadata) throws InternalErrorException
{
//FIXME temp solution
@ -194,16 +227,35 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the image url.
*
* @param id the id
* @return the string
*/
protected String buildImageUrl(String id)
{
return buildImageServiceUrl(id, ImageRequestType.IMAGE);
}
/**
* Builds the thumbnail url.
*
* @param id the id
* @return the string
*/
protected String buildThumbnailUrl(String id)
{
return buildImageServiceUrl(id, ImageRequestType.THUMBNAIL);
}
/**
* Builds the image service url.
*
* @param id the id
* @param requestType the request type
* @return the string
*/
protected String buildImageServiceUrl(String id, ImageRequestType requestType){
StringBuilder sb = new StringBuilder();
sb.append(IMAGE_SERVICE_URL);
@ -586,7 +638,16 @@ public class GWTWorkspaceBuilder {
///////////////////////*********************USED
//ADD FRANCESCO
@SuppressWarnings("unchecked")
/**
* Builds the gwt workspace image.
*
* @param item the item
* @param isInteralImage the is interal image
* @param fullDetails the full details
* @return the GWT workspace item
* @throws InternalErrorException the internal error exception
*/
@SuppressWarnings("unchecked")
protected GWTWorkspaceItem buildGWTWorkspaceImage(WorkspaceItem item, boolean isInteralImage, boolean fullDetails) throws InternalErrorException
{
@ -598,9 +659,9 @@ public class GWTWorkspaceBuilder {
GCubeItem image = (GCubeItem) item; //Cast OLD Image Document
List<DocumentAlternativeLink> links = (List<DocumentAlternativeLink>) new XStream().fromXML(image.getItemProperties().get(NodeProperty.ALTERNATIVES.toString()));
List<DocumentPartLink> parts = (List<DocumentPartLink>) new XStream().fromXML(image.getItemProperties().get(NodeProperty.PARTS.toString()));
Map<String, DocumentMetadata> metadatas = (Map<String, DocumentMetadata>) new XStream().fromXML(image.getItemProperties().get(NodeProperty.METADATA.toString()));
List<DocumentAlternativeLink> links = (List<DocumentAlternativeLink>) new XStream().fromXML(image.getProperties().getPropertyValue(NodeProperty.ALTERNATIVES.toString()));
List<DocumentPartLink> parts = (List<DocumentPartLink>) new XStream().fromXML(image.getProperties().getPropertyValue(NodeProperty.PARTS.toString()));
Map<String, DocumentMetadata> metadatas = (Map<String, DocumentMetadata>) new XStream().fromXML(image.getProperties().getPropertyValue(NodeProperty.METADATA.toString()));
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(metadatas, image.getId());
gwtImage = (GWTImageDocument) new GWTImageDocument(
@ -615,17 +676,17 @@ public class GWTWorkspaceBuilder {
null,
buildImageUrl(image.getId()),
buildThumbnailUrl(image.getId()),
Integer.parseInt(image.getItemProperties().get(NodeProperty.IMAGE_WIDTH.toString())),
Integer.parseInt(image.getItemProperties().get(NodeProperty.IMAGE_HEIGHT.toString())),
Integer.parseInt(image.getItemProperties().get(NodeProperty.THUMBNAIL_WIDTH.toString())),
Integer.parseInt(image.getItemProperties().get(NodeProperty.THUMBNAIL_HEIGHT.toString())),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.IMAGE_WIDTH.toString())),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.IMAGE_HEIGHT.toString())),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.THUMBNAIL_WIDTH.toString())),
Integer.parseInt(image.getProperties().getPropertyValue(NodeProperty.THUMBNAIL_HEIGHT.toString())),
-1,
image.getLength(),
image.getMimeType(),
image.getItemProperties().get(NodeProperty.OID.toString()),
image.getProperties().getPropertyValue(NodeProperty.OID.toString()),
gwtmetadatas,
new LinkedHashMap<String, String>(),
image.getItemProperties().get(NodeProperty.COLLECTION_NAME.toString()),
image.getProperties().getPropertyValue(NodeProperty.COLLECTION_NAME.toString()),
links.size(),
parts.size());
}
@ -674,6 +735,14 @@ public class GWTWorkspaceBuilder {
/**
* Builds the gwt external url.
*
* @param url the url
* @param parent the parent
* @return the GWT external url
* @throws InternalErrorException the internal error exception
*/
protected GWTExternalUrl buildGWTExternalUrl(ExternalUrl url, GWTWorkspaceFolder parent) throws InternalErrorException
{
GWTProperties gwtProperties = buildGWTProperties(url.getProperties());
@ -694,23 +763,29 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gwt worspace url.
*
* @param item the item
* @param isInternalUrl the is internal url
* @param fullDetails the full details
* @return the GWT workspace item
* @throws InternalErrorException the internal error exception
*/
@SuppressWarnings("unchecked")
protected GWTWorkspaceItem buildGWTWorspaceUrl(WorkspaceItem item, boolean isInternalUrl, boolean fullDetails) throws InternalErrorException
{
GWTWorkspaceItem gwtUrl = null;
GWTProperties gwtProperties = buildGWTProperties(item.getProperties());
// GWTUrlDocument gwtUrlDocument = null;
if(isInternalUrl){
GCubeItem document = (GCubeItem) item; //Cast OLD UrlDocument
// UrlDocument document = (UrlDocument) item; //Cast
List<DocumentAlternativeLink> links = (List<DocumentAlternativeLink>) new XStream().fromXML(document.getItemProperties().get(NodeProperty.ALTERNATIVES.toString()));
List<DocumentPartLink> parts = (List<DocumentPartLink>) new XStream().fromXML(document.getItemProperties().get(NodeProperty.PARTS.toString()));
Map<String, DocumentMetadata> metadatas = (Map<String, DocumentMetadata>) new XStream().fromXML(document.getItemProperties().get(NodeProperty.METADATA.toString()));
List<DocumentAlternativeLink> links = (List<DocumentAlternativeLink>) new XStream().fromXML(document.getProperties().getPropertyValue(NodeProperty.ALTERNATIVES.toString()));
List<DocumentPartLink> parts = (List<DocumentPartLink>) new XStream().fromXML(document.getProperties().getPropertyValue(NodeProperty.PARTS.toString()));
Map<String, DocumentMetadata> metadatas = (Map<String, DocumentMetadata>) new XStream().fromXML(document.getProperties().getPropertyValue(NodeProperty.METADATA.toString()));
Map<String, GWTDocumentMetadata> gwtmetadatas = getMetadatas(metadatas, document.getId());
gwtUrl = new GWTUrlDocument(
@ -724,49 +799,47 @@ public class GWTWorkspaceBuilder {
GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()),
null,
document.getLength(),
document.getItemProperties().get(NodeProperty.OID.toString()),
document.getProperties().getPropertyValue(NodeProperty.OID.toString()),
document.getMimeType(),
gwtmetadatas,
new LinkedHashMap<String, String>(),
document.getItemProperties().get(NodeProperty.COLLECTION_NAME.toString()),
document.getProperties().getPropertyValue(NodeProperty.COLLECTION_NAME.toString()),
links.size(),
parts.size(),
document.getItemProperties().get(NodeProperty.URL.toString()));
document.getProperties().getPropertyValue(NodeProperty.URL.toString()));
}
else{
ExternalUrl document = (ExternalUrl) item; //Cast
if(fullDetails){
gwtUrl = new GWTExternalUrl(
toDate(document.getCreationTime()),
document.getId(),
gwtProperties,
document.getName(),
document.getOwner().getPortalLogin(),
document.getDescription(),
toDate(document.getLastModificationTime()),
GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()),
null,
document.getLength(),
document.getUrl());
toDate(document.getCreationTime()),
document.getId(),
gwtProperties,
document.getName(),
document.getOwner().getPortalLogin(),
document.getDescription(),
toDate(document.getLastModificationTime()),
GWTWorkspaceItemAction.valueOf(document.getLastAction().toString()),
null,
document.getLength(),
document.getUrl());
}
else{
else
gwtUrl = new GWTExternalUrl(document.getUrl());
}
}
return gwtUrl;
}
/**
* Gets the metadatas.
*
* @param metadatas the metadatas
* @param documentId the document id
* @return the metadatas
*/
protected Map<String, GWTDocumentMetadata> getMetadatas(Map<String, DocumentMetadata> metadatas, String documentId)
{
Map<String, GWTDocumentMetadata> gwtmetadatas = new LinkedHashMap<String, GWTDocumentMetadata>();
@ -776,6 +849,13 @@ public class GWTWorkspaceBuilder {
return gwtmetadatas;
}
/**
* Gets the metadata.
*
* @param metadata the metadata
* @param documentId the document id
* @return the metadata
*/
protected GWTDocumentMetadata getMetadata(DocumentMetadata metadata, String documentId)
{
return new GWTDocumentMetadata(metadata.getSchemaName(),
@ -788,6 +868,13 @@ public class GWTWorkspaceBuilder {
//*****************************************************NEW
/**
* Builds the workspace file model root.
*
* @param workspaceRoot the workspace root
* @return the folder model
* @throws InternalErrorException the internal error exception
*/
public FolderModel buildWorkspaceFileModelRoot(WorkspaceFolder workspaceRoot) throws InternalErrorException {
logger.trace("workspace id: "+ workspaceRoot.getId());
@ -801,6 +888,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list file model item.
*
* @param workspaceFolder the workspace folder
* @param parentFolderModel the parent folder model
* @return the list
* @throws InternalErrorException the internal error exception
*/
protected List<FileModel> buildGXTListFileModelItem(WorkspaceItem workspaceFolder, FileModel parentFolderModel) throws InternalErrorException
{
@ -833,6 +928,13 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list file model item for attachs.
*
* @param listWorspaceItems the list worspace items
* @return the list
* @throws InternalErrorException the internal error exception
*/
protected List<FileModel> buildGXTListFileModelItemForAttachs(List<WorkspaceItem> listWorspaceItems) throws InternalErrorException
{
@ -876,9 +978,10 @@ public class GWTWorkspaceBuilder {
/**
*
* @param listPortalLogin
* @return
* Builds the gxt info contacts from portal logins.
*
* @param listPortalLogin the list portal login
* @return the list
*/
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin){
@ -893,9 +996,10 @@ public class GWTWorkspaceBuilder {
}
/**
*
* @param portalLogin
* @return
* Builds the gxt info contact from portal login.
*
* @param portalLogin the portal login
* @return the info contact model
*/
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
@ -910,9 +1014,10 @@ public class GWTWorkspaceBuilder {
/**
* Used in test mode
* @param listPortalLogin
* @return
* Used in test mode.
*
* @param listPortalLogin the list portal login
* @return the list
*/
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
@ -925,6 +1030,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt file model item.
*
* @param item the item
* @param parentFolderModel the parent folder model
* @return the file model
* @throws InternalErrorException the internal error exception
*/
protected FileModel buildGXTFileModelItem(WorkspaceItem item, FileModel parentFolderModel) throws InternalErrorException
{
@ -988,6 +1101,13 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list file grid model item for search.
*
* @param listSearchItems the list search items
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<FileGridModel> buildGXTListFileGridModelItemForSearch(List<SearchItem> listSearchItems) throws InternalErrorException
{
@ -1002,6 +1122,14 @@ public class GWTWorkspaceBuilder {
return listFileGridModel;
}
/**
* Builds the gxt file grid model item for search.
*
* @param item the item
* @param parentFileModel the parent file model
* @return the file grid model
* @throws InternalErrorException the internal error exception
*/
private FileGridModel buildGXTFileGridModelItemForSearch(SearchItem item, FileModel parentFileModel) throws InternalErrorException{
FileGridModel fileGridModel = null;
@ -1062,6 +1190,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list file grid model item.
*
* @param listWorkspaceItems the list workspace items
* @param parentFileModel the parent file model
* @return the list
* @throws InternalErrorException the internal error exception
*/
protected List<FileGridModel> buildGXTListFileGridModelItem(List<WorkspaceItem> listWorkspaceItems, FileModel parentFileModel) throws InternalErrorException
{
@ -1080,6 +1216,14 @@ public class GWTWorkspaceBuilder {
return listFileGridModel;
}
/**
* Builds the gxt file grid model item.
*
* @param item the item
* @param parentFileModel the parent file model
* @return the file grid model
* @throws InternalErrorException the internal error exception
*/
public FileGridModel buildGXTFileGridModelItem(WorkspaceItem item, FileModel parentFileModel) throws InternalErrorException{
@ -1149,6 +1293,13 @@ public class GWTWorkspaceBuilder {
}
/**
* Sets the folder item type for search.
*
* @param fileModel the file model
* @param searchFolderItem the search folder item
* @return the file model
*/
protected FileModel setFolderItemTypeForSearch(FileModel fileModel, SearchFolderItem searchFolderItem){
if(searchFolderItem.getFolderItemType()==null){
@ -1233,6 +1384,13 @@ public class GWTWorkspaceBuilder {
/**
* Sets the folder item type.
*
* @param fileModel the file model
* @param worspaceFolderItem the worspace folder item
* @return the file model
*/
protected FileModel setFolderItemType(FileModel fileModel, FolderItem worspaceFolderItem){
switch(worspaceFolderItem.getFolderItemType())
@ -1336,6 +1494,13 @@ public class GWTWorkspaceBuilder {
return fileModel;
}
/**
* Gets the publi link for folder item.
*
* @param worspaceFolderItem the worspace folder item
* @return the publi link for folder item
* @throws InternalErrorException the internal error exception
*/
public String getPubliLinkForFolderItem(FolderItem worspaceFolderItem) throws InternalErrorException{
if(worspaceFolderItem==null)
@ -1385,11 +1550,12 @@ public class GWTWorkspaceBuilder {
}
/**
*
* @param wsFolder
* @param parent
* @return
* @throws InternalErrorException
* Builds the gxt folder model item.
*
* @param wsFolder the ws folder
* @param parent the parent
* @return the folder model
* @throws InternalErrorException the internal error exception
*/
public FolderModel buildGXTFolderModelItem(WorkspaceFolder wsFolder, FileModel parent) throws InternalErrorException {
@ -1426,11 +1592,13 @@ public class GWTWorkspaceBuilder {
/**
* TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS WORKSPACESPECIALFOLDER****
* REMOVE THIS METHOD AND ADDING INSTANCE OF AT buildGXTFolderModelItem
* @param wsFolder
* @param parent
* @return
* @throws InternalErrorException
* REMOVE THIS METHOD AND ADDING INSTANCE OF AT buildGXTFolderModelItem.
*
* @param wsFolder the ws folder
* @param parent the parent
* @param specialFolderName the special folder name
* @return the folder model
* @throws InternalErrorException the internal error exception
*/
public FolderModel buildGXTFolderModelItemHandleSpecialFolder(WorkspaceFolder wsFolder, FileModel parent, String specialFolderName) throws InternalErrorException {
@ -1467,6 +1635,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gwt workspace file details.
*
* @param wsItem the ws item
* @param item the item
* @return the file details model
* @throws InternalErrorException the internal error exception
*/
public FileDetailsModel buildGWTWorkspaceFileDetails(WorkspaceItem wsItem, FileModel item) throws InternalErrorException {
FileDetailsModel fileDetailsModel = new FileDetailsModel(
@ -1485,6 +1661,13 @@ public class GWTWorkspaceBuilder {
return fileDetailsModel;
}
/**
* Gets the folder item type category.
*
* @param item the item
* @return the folder item type category
* @throws InternalErrorException the internal error exception
*/
protected String getFolderItemTypeCategory(SearchItem item) throws InternalErrorException{
switch (item.getType()) {
@ -1535,6 +1718,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Filter list file grid model item by category.
*
* @param listSearchItem the list search item
* @param category the category
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<FileGridModel> filterListFileGridModelItemByCategory(List<SearchItem> listSearchItem, String category) throws InternalErrorException {
List<FileGridModel> filteredList = new ArrayList<FileGridModel>();
@ -1560,6 +1751,13 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list smart folder model.
*
* @param listWorkspaceSmartFolder the list workspace smart folder
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<SmartFolderModel> buildGXTListSmartFolderModel(List<WorkspaceSmartFolder> listWorkspaceSmartFolder) throws InternalErrorException {
List<SmartFolderModel> listSmartFolder = new ArrayList<SmartFolderModel>();
@ -1570,6 +1768,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt smart folder model.
*
* @param wsFolder the ws folder
* @param query the query
* @return the smart folder model
* @throws InternalErrorException the internal error exception
*/
public SmartFolderModel buildGXTSmartFolderModel(WorkspaceSmartFolder wsFolder, String query) throws InternalErrorException {
SmartFolderModel smartFolderModel = new SmartFolderModel(
@ -1581,6 +1787,13 @@ public class GWTWorkspaceBuilder {
return smartFolderModel;
}
/**
* Builds the gxt list scope model.
*
* @param listFilteredScopes the list filtered scopes
* @param mapPortalScopes the map portal scopes
* @return the list
*/
public List<ScopeModel> buildGXTListScopeModel(List<String> listFilteredScopes, Map<String, String> mapPortalScopes) {
List<ScopeModel> listScopeModel = new ArrayList<ScopeModel>();
@ -1598,6 +1811,13 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt list contacts model from user model.
*
* @param listUsers the list users
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<InfoContactModel> buildGXTListContactsModelFromUserModel(List<UserModel> listUsers) throws InternalErrorException {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
@ -1622,10 +1842,11 @@ public class GWTWorkspaceBuilder {
}
/**
*
* @param list
* @return
* @throws InternalErrorException
* Builds the gxt list contacts model from gcube group.
*
* @param list the list
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<InfoContactModel> buildGXTListContactsModelFromGcubeGroup(List<GCubeGroup> list) throws InternalErrorException {
@ -1670,10 +1891,11 @@ public class GWTWorkspaceBuilder {
/**
*
* @param listContactsModel
* Builds the list login from contanct model.
*
* @param listContactsModel the list contacts model
* @return list of portal logins
* @throws InternalErrorException
* @throws InternalErrorException the internal error exception
*/
public List<String> buildListLoginFromContanctModel(List<InfoContactModel> listContactsModel) throws InternalErrorException {
@ -1689,6 +1911,14 @@ public class GWTWorkspaceBuilder {
/**
* Builds the gxt list message model for grid.
*
* @param listMessages the list messages
* @param typeMessages the type messages
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<MessageModel> buildGXTListMessageModelForGrid(List<WorkspaceMessage> listMessages, String typeMessages) throws InternalErrorException {
List<MessageModel> listMessageModel = new ArrayList<MessageModel>();
@ -1718,6 +1948,15 @@ public class GWTWorkspaceBuilder {
return listMessageModel;
}
/**
* Builds the gxt message model.
*
* @param mess the mess
* @param listWorkspaceItems the list workspace items
* @param messageType the message type
* @return the message model
* @throws InternalErrorException the internal error exception
*/
public MessageModel buildGXTMessageModel(WorkspaceMessage mess, List<WorkspaceItem> listWorkspaceItems, String messageType) throws InternalErrorException {
@ -1734,10 +1973,11 @@ public class GWTWorkspaceBuilder {
/**
*
* @param user
* Builds the gxt info contact model.
*
* @param user the user
* @return InfoContactModel
* @throws InternalErrorException
* @throws InternalErrorException the internal error exception
*/
public InfoContactModel buildGXTInfoContactModel(User user) throws InternalErrorException{
@ -1747,6 +1987,13 @@ public class GWTWorkspaceBuilder {
return new InfoContactModel();
}
/**
* Builds the gxt list bulk creator model.
*
* @param listFBC the list fbc
* @return the list
* @throws InternalErrorException the internal error exception
*/
public List<BulkCreatorModel> buildGXTListBulkCreatorModel(List<FolderBulkCreator> listFBC) throws InternalErrorException {
List<BulkCreatorModel> listBulkCreatorModel = new ArrayList<BulkCreatorModel>();
@ -1780,7 +2027,11 @@ public class GWTWorkspaceBuilder {
/**
* @param accouting
* Builds the gxt accounting item.
*
* @param accoutings the accoutings
* @param gxtEntryType the gxt entry type
* @return the list
*/
public List<GxtAccountingField> buildGXTAccountingItem(List<AccountingEntry> accoutings, GxtAccountingEntryType gxtEntryType) {
@ -2020,8 +2271,10 @@ public class GWTWorkspaceBuilder {
/**
* @param readers
* @return
* Builds the gxt accounting item from readers.
*
* @param readers the readers
* @return the list
*/
public List<GxtAccountingField> buildGXTAccountingItemFromReaders(List<AccountingEntryRead> readers) {
@ -2061,13 +2314,22 @@ public class GWTWorkspaceBuilder {
/**
* @param infoContactModel
* Sets the user logged.
*
* @param infoContactModel the new user logged
*/
public void setUserLogged(InfoContactModel infoContactModel) {
this.userLogged = infoContactModel;
}
/**
* Gets the workspace acl from ac ls.
*
* @param types the types
* @return the workspace acl from ac ls
* @throws Exception the exception
*/
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACLType> types) throws Exception{
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
@ -2103,6 +2365,13 @@ public class GWTWorkspaceBuilder {
return acls;
}
/**
* Builds the gxt list trash content.
*
* @param trash the trash
* @return the list
* @throws Exception the exception
*/
public List<FileTrashedModel> buildGXTListTrashContent(WorkspaceTrashFolder trash) throws Exception
{
List<WorkspaceTrashItem> trashContent = trash.listTrashItems();
@ -2133,10 +2402,11 @@ public class GWTWorkspaceBuilder {
}
/**
*
* @param trashedItem
* @return
* @throws InternalErrorException
* Builds the gxt trash model item.
*
* @param trashedItem the trashed item
* @return the file trashed model
* @throws InternalErrorException the internal error exception
*/
public FileTrashedModel buildGXTTrashModelItem(WorkspaceTrashItem trashedItem) throws InternalErrorException{
@ -2172,6 +2442,14 @@ public class GWTWorkspaceBuilder {
}
/**
* Builds the gxt trash model item by id.
*
* @param itemId the item id
* @param trash the trash
* @return the file trashed model
* @throws InternalErrorException the internal error exception
*/
public FileTrashedModel buildGXTTrashModelItemById(String itemId, WorkspaceTrashFolder trash) throws InternalErrorException{
return null;
@ -2179,10 +2457,12 @@ public class GWTWorkspaceBuilder {
/**
* @param aclOwner
* @return
* Gets the formatted html acl from ac ls.
*
* @param aclOwner the acl owner
* @return the formatted html acl from ac ls
*/
public String getFormattedHtmlACLFromACLs(Map<ACLType, List<String>> aclOwner) {
public String getFormatHtmlACLFromACLs(Map<ACLType, List<String>> aclOwner) {
String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">";
@ -2210,9 +2490,10 @@ public class GWTWorkspaceBuilder {
}
/**
* returns dynamically the formated size
* @param size
* @return
* returns dynamically the formated size.
*
* @param size the size
* @return the string
*/
public static String formatFileSize(long size) {
String formattedSize = null;
@ -2240,6 +2521,13 @@ public class GWTWorkspaceBuilder {
return formattedSize;
}
/**
* Gets the item description for type by id.
*
* @param item the item
* @return the item description for type by id
* @throws Exception the exception
*/
public String getItemDescriptionForTypeById(WorkspaceItem item) throws Exception {
if(item==null)
@ -2290,4 +2578,65 @@ public class GWTWorkspaceBuilder {
throw new Exception(error);
}
}
/**
* Gets the format html gcube item properties.
*
* @param item the item
* @return Format HTML. A DIV HTML containing gcube item properties. If item is a GcubeItem and contains properties return HTML, null otherwise
*/
public String getFormatHtmlGcubeItemProperties(WorkspaceItem item) {
Map<String, String> properties = getGcubeItemProperties(item);
if(properties!=null){
if(properties.size()==0){
try {
logger.warn("Gcube Item Properties not found for item: "+item.getId());
} catch (InternalErrorException e) {
//SILENT
}
return null;
}
String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">";
for (String key : properties.keySet()) {
String value = properties.get(key);
html+="<span style=\"font-weight:bold; padding-top: 5px;\">"+key+": </span>";
html+="<span style=\"font-weight:normal;\">";
html+=value;
html+="</span><br/>";
}
html+="</div>";
return html;
}
return null;
}
/**
* Gets the gcube item properties.
*
* @param item the item
* @return the gcube item properties
*/
public Map<String, String> getGcubeItemProperties(WorkspaceItem item) {
if(item instanceof GCubeItem){
GCubeItem gItem = (GCubeItem) item;
try {
return gItem.getProperties().getProperties();
} catch (InternalErrorException e) {
logger.error("Error in server getItemProperties: ", e);
return null;
}
}
return null;
}
}

View File

@ -35,6 +35,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNot
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.homelibrary.home.workspace.search.SearchItem;
import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage;
import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder;
@ -3222,7 +3223,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* Gets the AC ls description for shared folder id.
*
* @param folderId the folder id
* @return Formatted HTML DIV containing ACLs description for folderId
* @return Format HTML - A DIV HTML containing ACLs description for folderId
* @throws Exception the exception
*/
@Override
@ -3231,7 +3232,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
WorkspaceFolder wsFolder = getSharedWorkspaceFolderForId(folderId);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
return builder.getFormattedHtmlACLFromACLs(wsFolder.getACLOwner());
return builder.getFormatHtmlACLFromACLs(wsFolder.getACLOwner());
} catch (Exception e) {
workspaceLogger.error("Error in server get getACLForFolderId", e);
String error = ConstantsExplorer.SERVER_ERROR +" get ACL rules for selected folder. "+e.getMessage();
@ -3746,5 +3747,100 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#loadGcubeItemProperties(java.lang.String)
*/
@Override
public Map<String, String> loadGcubeItemProperties(String itemId) throws Exception {
workspaceLogger.info("Getting GcubeItemProperties for itemId: "+itemId);
if(itemId==null || itemId.isEmpty()){
workspaceLogger.warn("Getting GcubeItemProperties identifier is null or empty, returning null");
return null;
}
try {
Workspace workspace = getWorkspace();
WorkspaceItem item = workspace.getItem(itemId);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
Map<String, String> mapProperties = builder.getGcubeItemProperties(item);
if(mapProperties!=null)
workspaceLogger.info("Returning "+mapProperties.size()+" properties");
else
workspaceLogger.info("Returning null properties");
return mapProperties;
} catch (Exception e) {
workspaceLogger.error("Error in server GcubeItemProperties: ", e);
String error = ConstantsExplorer.SERVER_ERROR +" getting gcube item properties for item id: "+itemId;
throw new Exception(error);
}
}
/**
* Gets the HTML gcube item properties.
*
* @param itemId the item id
* @return The Gcube Item Properties in HTML format if itemId is a GcubeItem and contains properties, null otherwise
* @throws Exception the exception
*/
@Override
public String getHTMLGcubeItemProperties(String itemId) throws Exception {
workspaceLogger.info("Getting FormattedGcubeItemProperties for itemId: "+itemId);
if(itemId==null || itemId.isEmpty()){
workspaceLogger.warn("Getting FormattedGcubeItemProperties identifier is null or empty, returning null");
return null;
}
try {
Workspace workspace = getWorkspace();
WorkspaceItem item = workspace.getItem(itemId);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
return builder.getFormatHtmlGcubeItemProperties(item);
} catch (Exception e) {
workspaceLogger.error("Error in server FormattedGcubeItemProperties: ", e);
String error = ConstantsExplorer.SERVER_ERROR +" getting gcube item properties for item id: "+itemId;
throw new Exception(error);
}
}
/**
* Sets the gcube item properties.
*
* @param itemId the item id
* @param properties the properties
* @throws Exception the exception
*/
@Override
public void setGcubeItemProperties(String itemId, Map<String, String> properties) throws Exception {
workspaceLogger.info("Set GcubeItemProperties for itemId: "+itemId);
if(itemId==null || itemId.isEmpty()){
workspaceLogger.warn("Set GcubeItemProperties, identifier is null or empty, returning null");
throw new Exception("The item id is null or empty");
}
try {
Workspace workspace = getWorkspace();
WorkspaceItem item = workspace.getItem(itemId);
if(item instanceof GCubeItem){
GCubeItem gItem = (GCubeItem) item;
for (String key : properties.keySet()) //ADD PROPERTIES
gItem.getProperties().addProperty(key, properties.get(key));
}else
throw new NoGcubeItemTypeException("The item is not a Gcube Item");
} catch (NoGcubeItemTypeException e){
workspaceLogger.error("Error in server FormattedGcubeItemProperties: ", e);
throw new Exception(e.getMessage());
} catch (Exception e) {
workspaceLogger.error("Error in server FormattedGcubeItemProperties: ", e);
String error = ConstantsExplorer.SERVER_ERROR +" setting gcube item properties for item id: "+itemId;
throw new Exception(error);
}
}
}

View File

@ -0,0 +1,20 @@
/**
*
*/
package org.gcube.portlets.user.workspace.server;
/**
* @author Federico De Faveri defaveri@isti.cnr.it
*
*/
public class NoGcubeItemTypeException extends Exception{
private static final long serialVersionUID = 3660227882791095368L;
public NoGcubeItemTypeException(String message) {
super(message);
}
}