task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
11 changed files with 211 additions and 64 deletions
Showing only changes of commit d3954ecd71 - Show all commits

View File

@ -11,3 +11,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [#20650] Provided moderator skills to Catalogue Moderator(s) - [#20650] Provided moderator skills to Catalogue Moderator(s)
- [#23108] Provided Moderation facility accessible to Catalogue Editor/Admin (only) in read only mode - [#23108] Provided Moderation facility accessible to Catalogue Editor/Admin (only) in read only mode
- [#23197] Revised the query passed to gCat with the moderation states - [#23197] Revised the query passed to gCat with the moderation states
- [#23258] Implemented the requirement described in #23156

View File

@ -37,21 +37,27 @@ public class CheckConfigsUxController {
private DISPLAY_FIELD[] displayFields; private DISPLAY_FIELD[] displayFields;
private String initOnItemName;
/** /**
* Instantiates a new check configs ux controller. * Instantiates a new check configs ux controller.
* *
* @param mainPanel the main panel * @param mainPanel the main panel
* @param initItemStatus the init item status * @param initItemStatus the init item status
* @param initOnItemName
* @param displayFields the display fields * @param displayFields the display fields
* @param sortByFields the sort by fields * @param sortByFields the sort by fields
* @param moderatorcheckConfig the moderatorcheck config * @param moderatorcheckConfig the moderatorcheck config
*/ */
protected CheckConfigsUxController(MainPanel mainPanel, ItemStatus initItemStatus, DISPLAY_FIELD[] displayFields, protected CheckConfigsUxController(MainPanel mainPanel, ItemStatus initItemStatus, String initOnItemName,
DISPLAY_FIELD[] sortByFields, CkanContentModeratorCheckConfigs moderatorcheckConfig) { DISPLAY_FIELD[] displayFields, DISPLAY_FIELD[] sortByFields,
CkanContentModeratorCheckConfigs moderatorcheckConfig) {
this.mainPanel = mainPanel; this.mainPanel = mainPanel;
this.basePanelContainer = mainPanel.getMainPanelContainer(); this.basePanelContainer = mainPanel.getMainPanelContainer();
this.moderatorCheckConfig = moderatorcheckConfig; this.moderatorCheckConfig = moderatorcheckConfig;
this.initItemStatus = initItemStatus; this.initItemStatus = initItemStatus;
this.initOnItemName = initOnItemName;
this.displayFields = displayFields; this.displayFields = displayFields;
this.orderByFields = sortByFields; this.orderByFields = sortByFields;
@ -146,8 +152,8 @@ public class CheckConfigsUxController {
} catch (Exception e) { } catch (Exception e) {
} }
cmsController = new CkanContentModeratorWidgetController(initItemStatus, displayFields, orderByFields, cmsController = new CkanContentModeratorWidgetController(initItemStatus, initOnItemName, displayFields,
false, false); orderByFields, false, false);
basePanelContainer.add(cmsController.getMainPanel()); basePanelContainer.add(cmsController.getMainPanel());
mainPanel.setLoggedLabelText("Logged in as Moderator"); mainPanel.setLoggedLabelText("Logged in as Moderator");
@ -178,11 +184,10 @@ public class CheckConfigsUxController {
GWT.log("readOnlyMode is enabled? " + readOnlyMode); GWT.log("readOnlyMode is enabled? " + readOnlyMode);
GWT.log("restrictDataToLoggedInUser is? " + restrictDataToLoggedInUser); GWT.log("restrictDataToLoggedInUser is? " + restrictDataToLoggedInUser);
cmsController = new CkanContentModeratorWidgetController(initItemStatus, displayFields, orderByFields, cmsController = new CkanContentModeratorWidgetController(initItemStatus, initOnItemName, displayFields,
readOnlyMode, restrictDataToLoggedInUser); orderByFields, readOnlyMode, restrictDataToLoggedInUser);
basePanelContainer.add(cmsController.getMainPanel()); basePanelContainer.add(cmsController.getMainPanel());
} }
/** /**

View File

@ -60,7 +60,7 @@ public interface CkanContentModeratorService extends RemoteService {
* @param offset the offset * @param offset the offset
* @param limit the limit * @param limit the limit
* @param restrictedToLoggedInUser the restricted to logged in user * @param restrictedToLoggedInUser the restricted to logged in user
* @param sortForField the sort for field * @param sortForField the sort for field
* @return the list items for status * @return the list items for status
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -75,7 +75,7 @@ public interface CkanContentModeratorService extends RemoteService {
* @param limit the limit * @param limit the limit
* @param serverStartIndex the server start index * @param serverStartIndex the server start index
* @param restrictedToLoggedInUser the restricted to logged in user * @param restrictedToLoggedInUser the restricted to logged in user
* @param sortForField the sort for field * @param sortForField the sort for field
* @return the data for status * @return the data for status
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -124,4 +124,13 @@ public interface CkanContentModeratorService extends RemoteService {
* @throws Exception the exception * @throws Exception the exception
*/ */
public Boolean existsMyItemInModeration() throws Exception; public Boolean existsMyItemInModeration() throws Exception;
/**
* Gets the item for name.
*
* @param itemName the item name
* @return the item for name
* @throws Exception the exception
*/
CatalogueDataset getItemForName(String itemName) throws Exception;
} }

View File

@ -30,9 +30,32 @@ public interface CkanContentModeratorServiceAsync {
void rejectItem(List<String> itemNames, boolean permanentlyDelete, String reasonMsg, void rejectItem(List<String> itemNames, boolean permanentlyDelete, String reasonMsg,
AsyncCallback<OperationReport> callback); AsyncCallback<OperationReport> callback);
/**
* Gets the list items for status.
*
* @param theStatus the the status
* @param offset the offset
* @param limit the limit
* @param restrictedToLoggedInUser the restricted to logged in user
* @param sortForField the sort for field
* @param callback the callback
* @return the list items for status
*/
void getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean restrictedToLoggedInUser, void getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean restrictedToLoggedInUser,
String sortForField, AsyncCallback<List<CatalogueDataset>> callback); String sortForField, AsyncCallback<List<CatalogueDataset>> callback);
/**
* Gets the data for status.
*
* @param status the status
* @param offset the offset
* @param limit the limit
* @param serverStartIndex the server start index
* @param restrictedToLoggedInUser the restricted to logged in user
* @param sortForField the sort for field
* @param asyncCallback the async callback
* @return the data for status
*/
void getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex, void getDataForStatus(ItemStatus status, int offset, int limit, int serverStartIndex,
boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<SearchedData> asyncCallback); boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<SearchedData> asyncCallback);
@ -94,4 +117,13 @@ public interface CkanContentModeratorServiceAsync {
*/ */
void existsMyItemInModeration(AsyncCallback<Boolean> callback); void existsMyItemInModeration(AsyncCallback<Boolean> callback);
/**
* Gets the item for name.
*
* @param itemName the item name
* @param callback the callback
* @return the item for name
*/
void getItemForName(String itemName, AsyncCallback<CatalogueDataset> callback);
} }

View File

@ -33,22 +33,18 @@ public class CkanContentModeratorWidget {
public CkanContentModeratorWidget(ItemStatus initItemStatus, String initOnItemName, DISPLAY_FIELD[] displayFields, public CkanContentModeratorWidget(ItemStatus initItemStatus, String initOnItemName, DISPLAY_FIELD[] displayFields,
DISPLAY_FIELD[] sortByFields) { DISPLAY_FIELD[] sortByFields) {
mainPanel.setWidth("100%"); mainPanel.setWidth("100%");
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, displayFields, sortByFields, null); ccux = new CheckConfigsUxController(mainPanel, initItemStatus, initOnItemName, displayFields, sortByFields, null);
boolean iamModerator = false; boolean isModeratorRoleAssigned = false;
try { try {
iamModerator = ccux.getModeratorCheckConfig().isModeratorRoleAssigned(); isModeratorRoleAssigned = ccux.getModeratorCheckConfig().isModeratorRoleAssigned();
} catch (Exception e) { } catch (Exception e) {
} }
if (iamModerator) { if (isModeratorRoleAssigned) {
mainPanel.setLoggedLabelText("Logged in as Moderator"); mainPanel.setLoggedLabelText("Logged in as Moderator");
} }
if(initOnItemName!=null) {
}
} }
/** /**

View File

@ -34,7 +34,10 @@ import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemFieldDV;
import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchingFilter; import org.gcube.portlets.widgets.ckancontentmoderator.shared.SearchingFilter;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
@ -67,13 +70,15 @@ public class CkanContentModeratorWidgetController {
* Instantiates a new ckan content moderator widget. * Instantiates a new ckan content moderator widget.
* *
* @param status the status * @param status the status
* @param initOnItemName the init on item name
* @param displayFields the display fields * @param displayFields the display fields
* @param sortByField the sort by field * @param sortByFields the sort by fields
* @param readOnlyMode the read only mode * @param readOnlyMode the read only mode
* @param restrictDataToLoggedInUser * @param restrictDataToLoggedInUser the restrict data to logged in user
*/ */
protected CkanContentModeratorWidgetController(ItemStatus status, DISPLAY_FIELD[] displayFields, protected CkanContentModeratorWidgetController(ItemStatus status, final String initOnItemName,
DISPLAY_FIELD[] sortByFields, boolean readOnlyMode, boolean restrictDataToLoggedInUser) { DISPLAY_FIELD[] displayFields, DISPLAY_FIELD[] sortByFields, boolean readOnlyMode,
boolean restrictDataToLoggedInUser) {
DISPLAY_FIELD firstSortField = null; DISPLAY_FIELD firstSortField = null;
if (sortByFields == null || sortByFields.length == 0) { if (sortByFields == null || sortByFields.length == 0) {
@ -101,6 +106,40 @@ public class CkanContentModeratorWidgetController {
howeView.hideUpdateStatusAction(readOnlyMode); howeView.hideUpdateStatusAction(readOnlyMode);
howeView.hideSelectableRow(readOnlyMode); howeView.hideSelectableRow(readOnlyMode);
bindEvents(); bindEvents();
if (initOnItemName != null) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
CkanContentModeratorWidgetController.contentModeratorService.getItemForName(initOnItemName,
new AsyncCallback<CatalogueDataset>() {
@Override
public void onSuccess(CatalogueDataset result) {
GWT.log("CatalogueDataset read is: " + result);
if (result != null) {
eventBus.fireEvent(new ShowItemEvent<CatalogueDataset>(Arrays.asList(result),true));
}
}
@Override
public void onFailure(Throwable caught) {
GWT.log("Error on reading " + initOnItemName + ". Either the item with name: "
+ initOnItemName + " is not valid dataset or not readable");
}
});
}
});
}
} }
/** /**
@ -117,7 +156,7 @@ public class CkanContentModeratorWidgetController {
for (SearchingFilter.ORDER order : SearchingFilter.ORDER.values()) { for (SearchingFilter.ORDER order : SearchingFilter.ORDER.values()) {
ItemFieldDV itemField = new ItemFieldDV(); ItemFieldDV itemField = new ItemFieldDV();
itemField.setDisplayName(display_FIELD.getLabel() + " - " + order); itemField.setDisplayName(display_FIELD.getLabel() + " - " + order);
itemField.setJsonFields(Arrays.asList(display_FIELD.getJsonField() +" "+order.name().toLowerCase())); itemField.setJsonFields(Arrays.asList(display_FIELD.getJsonField() + " " + order.name().toLowerCase()));
listSortByIF.add(itemField); listSortByIF.add(itemField);
} }
} }
@ -156,7 +195,7 @@ public class CkanContentModeratorWidgetController {
@Override @Override
public <T> void onShowItemClicked(ShowItemEvent<T> showItemEvent) { public <T> void onShowItemClicked(ShowItemEvent<T> showItemEvent) {
GWT.log("onShowItemClicked fired");
if (showItemEvent.getSelectItems() != null) { if (showItemEvent.getSelectItems() != null) {
List<T> items = showItemEvent.getSelectItems(); List<T> items = showItemEvent.getSelectItems();
@ -164,7 +203,7 @@ public class CkanContentModeratorWidgetController {
CatalogueDataset clickedDataset = (CatalogueDataset) t; CatalogueDataset clickedDataset = (CatalogueDataset) t;
CkanShowItemFrame csif = new CkanShowItemFrame(eventBus); CkanShowItemFrame csif = new CkanShowItemFrame(eventBus);
csif.instanceFrame(clickedDataset.getUrl()); csif.instanceFrame(clickedDataset.getUrl());
mainTabPanel.addTab(clickedDataset.getTitle(), csif); mainTabPanel.addTab(clickedDataset.getTitle(), csif, showItemEvent.isFocusOnDisplaying());
mapOfItemsTabDisplayed.put(clickedDataset.getUrl(), csif); mapOfItemsTabDisplayed.put(clickedDataset.getUrl(), csif);
} }
} }
@ -228,13 +267,13 @@ public class CkanContentModeratorWidgetController {
infoPanel.clear(); infoPanel.clear();
if (statusSelectedEvent.getItemStatus() != null) { if (statusSelectedEvent.getItemStatus() != null) {
ItemFieldDV sortBy = statusSelectedEvent.getSortBy(); ItemFieldDV sortBy = statusSelectedEvent.getSortBy();
if(sortBy==null) { if (sortBy == null) {
sortBy = toolbar.getActiveSortBy(); sortBy = toolbar.getActiveSortBy();
} }
String sortForField = sortBy.getJsonFields().get(0); String sortForField = sortBy.getJsonFields().get(0);
GWT.log("sortForField is: "+sortForField); GWT.log("sortForField is: " + sortForField);
howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus(), sortForField); howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus(), sortForField);
mainTabPanel.selectTab(0); mainTabPanel.selectTab(0);
} }

View File

@ -36,7 +36,7 @@ public class CkanContentModeratorWidgetTrusted {
GWT.log("CkanContentModeratorWidget called. CkanContentModeratorCheckConfigs: " GWT.log("CkanContentModeratorWidget called. CkanContentModeratorCheckConfigs: "
+ ckanContentModeratorCheckConfig); + ckanContentModeratorCheckConfig);
mainPanel.setWidth("100%"); mainPanel.setWidth("100%");
ccux = new CheckConfigsUxController(mainPanel, initItemStatus, displayFields, sortByFields, ckanContentModeratorCheckConfig); ccux = new CheckConfigsUxController(mainPanel, initItemStatus, null, displayFields, sortByFields, ckanContentModeratorCheckConfig);
} }
/** /**

View File

@ -15,14 +15,17 @@ import com.google.gwt.event.shared.GwtEvent;
public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> { public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
public static Type<ShowItemEventHandler> TYPE = new Type<ShowItemEventHandler>(); public static Type<ShowItemEventHandler> TYPE = new Type<ShowItemEventHandler>();
private List<T> selectItems; private List<T> selectItems;
private boolean focusOnDisplaying = false;
/** /**
* Instantiates a new click item event. * Instantiates a new click item event.
* *
* @param selectItems the select items * @param selectItems the select items
* @param focusOnDisplaying the focus on displaying
*/ */
public ShowItemEvent(List<T> selectItems) { public ShowItemEvent(List<T> selectItems, boolean focusOnDisplaying) {
this.selectItems = selectItems; this.selectItems = selectItems;
this.focusOnDisplaying = focusOnDisplaying;
} }
/** /**
@ -65,4 +68,13 @@ public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
public List<T> getSelectItems() { public List<T> getSelectItems() {
return selectItems; return selectItems;
} }
/**
* Checks if is focus on displaying.
*
* @return true, if is focus on displaying
*/
public boolean isFocusOnDisplaying() {
return focusOnDisplaying;
}
} }

View File

@ -75,7 +75,7 @@ public class MainTabPanel extends Composite {
* @param w the w * @param w the w
* @return the tab * @return the tab
*/ */
public Tab addTab(String heading, Widget w) { public Tab addTab(String heading, Widget w, boolean selectTab) {
final Tab tab = new Tab(); final Tab tab = new Tab();
if (w instanceof CkanShowItemFrame) { if (w instanceof CkanShowItemFrame) {
@ -108,14 +108,15 @@ public class MainTabPanel extends Composite {
mainTabPanel.add(tab); mainTabPanel.add(tab);
// activeTabPanels(false); // activeTabPanels(false);
Scheduler.get().scheduleDeferred(new ScheduledCommand() { if (selectTab) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void execute() { public void execute() {
// mainTabPanel.selectTab(results.size() - 1); mainTabPanel.selectTab(results.size() - 1);
}
} });
}); }
return tab; return tab;
} }
@ -163,25 +164,25 @@ public class MainTabPanel extends Composite {
} }
} }
/** /**
* Sets the no spinner. * Sets the no spinner.
* *
* @param tab the new no spinner * @param tab the new no spinner
*/ */
private void setNoSpinner(Tab tab) { private void setNoSpinner(Tab tab) {
try{ try {
tab.asTabLink().getAnchor().removeStyleName("icon-spin"); tab.asTabLink().getAnchor().removeStyleName("icon-spin");
tab.asTabLink().getAnchor().removeStyleName("icon-rotate-right"); tab.asTabLink().getAnchor().removeStyleName("icon-rotate-right");
Element anchorElem = tab.asTabLink().getAnchor().asWidget().getElement(); Element anchorElem = tab.asTabLink().getAnchor().asWidget().getElement();
anchorElem.getFirstChildElement().removeClassName("icon-spin"); anchorElem.getFirstChildElement().removeClassName("icon-spin");
anchorElem.getFirstChildElement().removeClassName("icon-rotate-right"); anchorElem.getFirstChildElement().removeClassName("icon-rotate-right");
}catch(Exception e){ } catch (Exception e) {
//silent // silent
} }
tab.asTabLink().getAnchor().setIcon(IconType.BOOK); tab.asTabLink().getAnchor().setIcon(IconType.BOOK);
//tab.asTabLink().getAnchor().setVisible(false); // tab.asTabLink().getAnchor().setVisible(false);
//if(tab.asTabLink().getAnchor().setVisible(false);) // if(tab.asTabLink().getAnchor().setVisible(false);)
} }

View File

@ -139,7 +139,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
@Override @Override
public void update(int index, T object, String value) { public void update(int index, T object, String value) {
GWT.log("clicked show"); GWT.log("clicked show");
eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object))); eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object), false));
} }
}); });
sortedCellTable.addColumn(showdItemColumn); sortedCellTable.addColumn(showdItemColumn);

View File

@ -39,6 +39,12 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
private static Logger LOG = LoggerFactory.getLogger(CkanContentModeratorServiceImpl.class); private static Logger LOG = LoggerFactory.getLogger(CkanContentModeratorServiceImpl.class);
/**
* Checks if is moderation enabled.
*
* @param reloadConfig the reload config
* @return the boolean
*/
@Override @Override
public Boolean isModerationEnabled(boolean reloadConfig) { public Boolean isModerationEnabled(boolean reloadConfig) {
LOG.info("called isContentModeratorEnabled"); LOG.info("called isContentModeratorEnabled");
@ -154,10 +160,13 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
*/ */
private String setContexts() { private String setContexts() {
String scope = GcubeContextUtil.getCurrentScope(this.getThreadLocalRequest()); String scope = GcubeContextUtil.getCurrentScope(this.getThreadLocalRequest());
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
String token = GcubeContextUtil.getCurrentToken(scope, user.getUsername());
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(token);
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
if (user != null) {
String token = GcubeContextUtil.getCurrentToken(scope, user.getUsername());
SecurityTokenProvider.instance.set(token);
}
return scope; return scope;
} }
@ -169,7 +178,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
* @param limit the limit * @param limit the limit
* @param restrictedToLoggedInUser if true restricts the list of items to logged * @param restrictedToLoggedInUser if true restricts the list of items to logged
* in user * in user
* @param sortForField the sort for field * @param sortForField the sort for field
* @return the list items for status * @return the list items for status
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -192,15 +201,14 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails); filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails);
} }
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters, sortForField); List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters,
sortForField);
if (datasets != null) { if (datasets != null) {
int size = datasets.size(); int size = datasets.size();
datasetList = new ArrayList<CatalogueDataset>(size); datasetList = new ArrayList<CatalogueDataset>(size);
LOG.info("datasetList for input parameters returned by CMS has size: " + size); LOG.info("datasetList for input parameters returned by CMS has size: " + size);
for (CkanDataset ckanDataset : datasets) { for (CkanDataset ckanDataset : datasets) {
CatalogueDataset ds = CatalogueBeansConverter.toCatalogueDataset.apply(ckanDataset); CatalogueDataset ds = toPatchedCatalogueDataset(ckanDataset, catalogueImpl.getCatalogueUrl());
String datasetURL = String.format("%s/dataset/%s", catalogueImpl.getCatalogueUrl(), ds.getName());
ds.setUrl(datasetURL);
LOG.trace("converted dataset is: " + ds); LOG.trace("converted dataset is: " + ds);
datasetList.add(ds); datasetList.add(ds);
} }
@ -215,6 +223,48 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
return datasetList; return datasetList;
} }
private CatalogueDataset toPatchedCatalogueDataset(CkanDataset ckanDataset, String catalogueURL) {
if (ckanDataset == null)
return null;
CatalogueDataset ds = CatalogueBeansConverter.toCatalogueDataset.apply(ckanDataset);
String datasetURL = String.format("%s/dataset/%s", catalogueURL, ds.getName());
ds.setUrl(datasetURL);
return ds;
}
/**
* Gets the item for name.
*
* @param itemName the item name
* @return the item for name
* @throws Exception the exception
*/
@Override
public CatalogueDataset getItemForName(String itemName) throws Exception {
LOG.info("called getItemForName for: " + itemName);
CatalogueDataset ds = null;
try {
String scope = setContexts();
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
if (user != null) {
CkanDataset ckanDataset = catalogueImpl.getDataset(itemName, user.getUsername());
ds = null;
if (ckanDataset != null) {
ds = toPatchedCatalogueDataset(ckanDataset, catalogueImpl.getCatalogueUrl());
}
}
} catch (Exception e) {
LOG.error("Error occurred on reading item for name: " + itemName, e);
throw e;
}
LOG.info("returning: " + ds);
return ds;
}
/** /**
* Sets the status. * Sets the status.
* *
@ -367,12 +417,12 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
/** /**
* Gets the data for status. * Gets the data for status.
* *
* @param status the status * @param status the status
* @param offset the offset * @param offset the offset
* @param limit the limit * @param limit the limit
* @param serverStartIndex the server start index * @param serverStartIndex the server start index
* @param restrictedToLoggedInUser the restricted to logged in user * @param restrictedToLoggedInUser the restricted to logged in user
* @param sortForField the sort for field * @param sortForField the sort for field
* @return the data for status * @return the data for status
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -400,7 +450,8 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>(); List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>();
try { try {
LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit); LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit);
listDataset = getListItemsForStatus(status, searchStartIndex, limit, restrictedToLoggedInUser, sortForField); listDataset = getListItemsForStatus(status, searchStartIndex, limit, restrictedToLoggedInUser,
sortForField);
} catch (Exception e) { } catch (Exception e) {
String error = "Error occurred on getting items for status: " + status; String error = "Error occurred on getting items for status: " + status;
LOG.error(error, e); LOG.error(error, e);
@ -423,4 +474,5 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
LOG.debug("Returning: " + searchedData); LOG.debug("Returning: " + searchedData);
return searchedData; return searchedData;
} }
} }