|
|
|
@ -176,6 +176,8 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
* @param theStatus the the status
|
|
|
|
|
* @param offset the offset
|
|
|
|
|
* @param limit the limit
|
|
|
|
|
* @param allFields the all fields. If true returns the all
|
|
|
|
|
* fields of an item
|
|
|
|
|
* @param restrictedToLoggedInUser if true restricts the list of items to logged
|
|
|
|
|
* in user
|
|
|
|
|
* @param sortForField the sort for field
|
|
|
|
@ -184,7 +186,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int offset, int limit,
|
|
|
|
|
boolean restrictedToLoggedInUser, String sortForField) throws Exception {
|
|
|
|
|
boolean allFields, boolean restrictedToLoggedInUser, String sortForField) throws Exception {
|
|
|
|
|
LOG.info("called getListItemsForStatus with [status: " + theStatus + ", offset: " + offset + ", limit: " + limit
|
|
|
|
|
+ ", restrictedToLoggedInUser: " + restrictedToLoggedInUser + "]");
|
|
|
|
|
List<CatalogueDataset> datasetList = null;
|
|
|
|
@ -201,7 +203,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, filters,
|
|
|
|
|
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset, allFields, filters,
|
|
|
|
|
sortForField);
|
|
|
|
|
if (datasets != null) {
|
|
|
|
|
int size = datasets.size();
|
|
|
|
@ -248,32 +250,34 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
String scope = setContexts();
|
|
|
|
|
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
|
|
|
|
|
GCubeUser user = GcubeContextUtil.getCurrentUser(this.getThreadLocalRequest());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean moderationCheckPassed = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user != null) {
|
|
|
|
|
CkanDataset ckanDataset = catalogueImpl.getDataset(itemName, user.getUsername());
|
|
|
|
|
ds = null;
|
|
|
|
|
if (ckanDataset != null) {
|
|
|
|
|
ds = toPatchedCatalogueDataset(ckanDataset, catalogueImpl.getCatalogueUrl());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boolean userModerator = isModeratorRoleAssigned();
|
|
|
|
|
moderationCheckPassed = userModerator?true:false;
|
|
|
|
|
LOG.info("Moderation check: is the user a Moderator? "+moderationCheckPassed);
|
|
|
|
|
//The user is not a Moderator, yes otherwise
|
|
|
|
|
if(!moderationCheckPassed) {
|
|
|
|
|
moderationCheckPassed = userModerator ? true : false;
|
|
|
|
|
LOG.info("Moderation check: is the user a Moderator? " + moderationCheckPassed);
|
|
|
|
|
// The user is not a Moderator, yes otherwise
|
|
|
|
|
if (!moderationCheckPassed) {
|
|
|
|
|
String datasetAuthorMail = ds.getAuthorEmail();
|
|
|
|
|
String userMail = user.getEmail();
|
|
|
|
|
if(datasetAuthorMail!=null && userMail!=null && datasetAuthorMail.compareTo(userMail)==0) {
|
|
|
|
|
//The user is the owner of the dataset, so he/she can view the dataset (moderation check passed)
|
|
|
|
|
moderationCheckPassed = true;
|
|
|
|
|
if (datasetAuthorMail != null && userMail != null
|
|
|
|
|
&& datasetAuthorMail.compareTo(userMail) == 0) {
|
|
|
|
|
// The user is the owner of the dataset, so he/she can view the dataset
|
|
|
|
|
// (moderation check passed)
|
|
|
|
|
moderationCheckPassed = true;
|
|
|
|
|
}
|
|
|
|
|
LOG.info("Moderation check: is the user the owner of the dataset? "+moderationCheckPassed);
|
|
|
|
|
LOG.info("Moderation check: is the user the owner of the dataset? " + moderationCheckPassed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!moderationCheckPassed) {
|
|
|
|
|
|
|
|
|
|
if (!moderationCheckPassed) {
|
|
|
|
|
LOG.info("Moderation ckeck not passed, returning null");
|
|
|
|
|
ds = null;
|
|
|
|
|
}
|
|
|
|
@ -283,7 +287,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG.info("getItemForName "+itemName+", returning: " + ds);
|
|
|
|
|
LOG.info("getItemForName " + itemName + ", returning: " + ds);
|
|
|
|
|
return ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -472,7 +476,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
List<CatalogueDataset> listDataset = new ArrayList<CatalogueDataset>();
|
|
|
|
|
try {
|
|
|
|
|
LOG.debug("getListItemsForStatus with searchStartIndex: " + searchStartIndex + ", limit: " + limit);
|
|
|
|
|
listDataset = getListItemsForStatus(status, searchStartIndex, limit, restrictedToLoggedInUser,
|
|
|
|
|
listDataset = getListItemsForStatus(status, searchStartIndex, limit, true, restrictedToLoggedInUser,
|
|
|
|
|
sortForField);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
String error = "Error occurred on getting items for status: " + status;
|
|
|
|
|