Check of permissions is now performed in the widget when needed. Changed some code to reflect changes in the ckan-util-library

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@141792 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-01-25 17:29:47 +00:00
parent 6d95f825c0
commit 2b1cedf78a
17 changed files with 410 additions and 271 deletions

View File

@ -12,11 +12,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -32,5 +27,10 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="${webappDirectory}/WEB-INF/classes"/> <classpathentry kind="output" path="${webappDirectory}/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,7 +1,12 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning

View File

@ -30,7 +30,7 @@
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 --> <!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>
@ -211,7 +211,7 @@
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source>1.7</source> <source>1.7</source>
<target>1.7</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<!-- SA Plugin --> <!-- SA Plugin -->

View File

@ -75,11 +75,10 @@ public interface CKanPublisherService extends RemoteService {
* @return a list of groups' beans * @return a list of groups' beans
*/ */
List<GroupBean> getUserGroups(String orgName); List<GroupBean> getUserGroups(String orgName);
// /** /**
// * Return a tree object representing the whole folder hierarchy * The method checks if the user is a publisher or he/she doesn't have the rights to publish
// * @param folderId * @return true if he/she can publish, false otherwise
// * @return ResourceElementBean */
// */ boolean isPublisherUser(boolean isWorkspaceRequest);
// ResourceElementBean getTreeFolder(String folderId);
} }

View File

@ -83,4 +83,11 @@ public interface CKanPublisherServiceAsync {
* @return a list of groups' beans * @return a list of groups' beans
*/ */
void getUserGroups(String orgName, AsyncCallback<List<GroupBean>> callback); void getUserGroups(String orgName, AsyncCallback<List<GroupBean>> callback);
/**
* The method checks if the user is a publisher or he/she doesn't have the rights to publish
* @return true if he/she can publish, false otherwise
*/
void isPublisherUser(boolean isWorkspaceRequest,
AsyncCallback<Boolean> callback);
} }

View File

@ -150,6 +150,9 @@ public class CreateDatasetForm extends Composite{
@UiField Icon infoIconGroups; @UiField Icon infoIconGroups;
@UiField FocusPanel focusPanelGroups; @UiField FocusPanel focusPanelGroups;
@UiField Popover popoverTitle; @UiField Popover popoverTitle;
@UiField Icon infoIconDescription;
@UiField Popover popoverDescription;
@UiField FocusPanel focusPanelDescription;
@UiField ControlGroup metadataProfilesControlGroup; @UiField ControlGroup metadataProfilesControlGroup;
@UiField ControlGroup productTitleGroup; @UiField ControlGroup productTitleGroup;
@UiField ControlGroup maintainerControlGroup; @UiField ControlGroup maintainerControlGroup;
@ -168,6 +171,7 @@ public class CreateDatasetForm extends Composite{
protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later"; protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later";
protected static final String PRODUCT_CREATED_OK = "Product correctly published!"; protected static final String PRODUCT_CREATED_OK = "Product correctly published!";
private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the product, please wait"; private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the product, please wait";
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to publish on catalogue. Request it to the VRE manager or the portal administrator.";
// tab panel // tab panel
private TabPanel tabPanel; private TabPanel tabPanel;
@ -252,7 +256,7 @@ public class CreateDatasetForm extends Composite{
* @param owner * @param owner
* @param eventBus * @param eventBus
*/ */
private void createDatasetFormBody(final boolean isWorkspaceRequest, String idFolderWorkspace, final HandlerManager eventBus){ private void createDatasetFormBody(final boolean isWorkspaceRequest, final String idFolderWorkspace, final HandlerManager eventBus){
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus; this.eventBus = eventBus;
@ -264,203 +268,227 @@ public class CreateDatasetForm extends Composite{
continueButton.setEnabled(false); continueButton.setEnabled(false);
resetButton.setEnabled(false); resetButton.setEnabled(false);
// set info block // check if the user has publishing rights
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true); setAlertBlock("Checking your permissions, please wait...", AlertType.INFO, true);
// get back the licenses and the metadata information ckanServices.isPublisherUser(isWorkspaceRequest, new AsyncCallback<Boolean>() {
ckanServices.getDatasetBean(idFolderWorkspace, new AsyncCallback<DatasetMetadataBean>() {
@Override @Override
public void onFailure(Throwable caught) { public void onSuccess(Boolean result) {
setAlertBlock("Error while retrieving information, try to refresh the page and retry", AlertType.ERROR, true); if(result){
} // set info block
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
@Override // get back the licenses and the metadata information
public void onSuccess(final DatasetMetadataBean bean) { ckanServices.getDatasetBean(idFolderWorkspace, new AsyncCallback<DatasetMetadataBean>() {
if(bean == null){
setAlertBlock("Error while retrieving information, try to refresh the page and retry", AlertType.ERROR, true);
}
else{
// save it
receivedBean = bean;
// fill the form
titleTextBox.setText(bean.getTitle());
descriptionTextarea.setText(bean.getDescription());
versionTextbox.setText(String.valueOf(bean.getVersion()));
authorTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
authorEmailTextbox.setText(bean.getAuthorEmail());
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
// retrieve custom fields
Map<String, List<String>> customFieldsMap = bean.getCustomFields();
if(customFieldsMap != null){
// get the keys and put them as tags
Iterator<Entry<String, List<String>>> iteratorOverCustomField = customFieldsMap.entrySet().iterator();
while (iteratorOverCustomField.hasNext()) {
Map.Entry<java.lang.String, java.util.List<java.lang.String>> entry = (Map.Entry<java.lang.String, java.util.List<java.lang.String>>) iteratorOverCustomField
.next();
List<String> values = entry.getValue();
for (String value : values) {
// these are fixed key, variable value custom fields
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(), value, false);
customFieldEntriesList.add(toAdd);
customFields.add(toAdd);
// add as tag
tagsPanel.addTagElement(entry.getKey());
}
}
}
if(isWorkspaceRequest){
boolean showAlertMissingResources = bean.getResources() == null || bean.getResources().isEmpty() || bean.getResources().get(0).getChildren() == null ||
bean.getResources().get(0).getChildren().isEmpty();
// if there are not resources, for now just checked it ( and hide so that the step will be skipped)
if(showAlertMissingResources){
alertNoResources.setType(AlertType.WARNING);
alertNoResources.setVisible(true);
}else
resourcesTwinPanel = new TwinColumnSelectionMainPanel(bean.getResources().get(0));
}
// set organizations
List<OrganizationBean> organizations = bean.getOrganizationList();
for (OrganizationBean organization : organizations) {
organizationsListbox.addItem(organization.getTitle());
nameTitleOrganizationMap.put(organization.getTitle(), organization.getName());
}
// force the selection of the first one, and retrieve the list of profiles
organizationsListbox.setSelectedIndex(0);
// add change handler to dinamycally retrieve the list of profiles
organizationsListbox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
event.preventDefault();
organizationsListboxChangeHandlerBody();
}
});
// try to retrieve the profiles
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
// get the name of the organization from the title
final String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText());
// perform remote request of profiles for the selected organization
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
setAlertBlock("Error while retrieving profiles, try later", AlertType.ERROR, true);
setAlertBlock("Error while retrieving information, try to refresh the page and retry", AlertType.ERROR, true);
} }
@Override @Override
public void onSuccess(final List<MetaDataProfileBean> profiles) { public void onSuccess(final DatasetMetadataBean bean) {
if(profiles == null){ if(bean == null){
setAlertBlock("Error while retrieving profiles, try later", AlertType.ERROR, true);
setAlertBlock("Error while retrieving information, try to refresh the page and retry", AlertType.ERROR, true);
} }
else{ else{
receivedBean.setMetadataList(profiles); // save it
prepareMetadataList(receivedBean); receivedBean = bean;
organizationsListbox.setEnabled(true);
metadataProfilesFormatListbox.setEnabled(true);
// try to retrieve the licenses // fill the form
setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, true); titleTextBox.setText(bean.getTitle());
ckanServices.getLicenses(new AsyncCallback<LicensesBean>() { descriptionTextarea.setText(bean.getDescription());
versionTextbox.setText(String.valueOf(bean.getVersion()));
authorTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
authorEmailTextbox.setText(bean.getAuthorEmail());
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
// retrieve custom fields
Map<String, List<String>> customFieldsMap = bean.getCustomFields();
if(customFieldsMap != null){
// get the keys and put them as tags
Iterator<Entry<String, List<String>>> iteratorOverCustomField = customFieldsMap.entrySet().iterator();
while (iteratorOverCustomField.hasNext()) {
Map.Entry<java.lang.String, java.util.List<java.lang.String>> entry = (Map.Entry<java.lang.String, java.util.List<java.lang.String>>) iteratorOverCustomField
.next();
List<String> values = entry.getValue();
for (String value : values) {
// these are fixed key, variable value custom fields
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(), value, false);
customFieldEntriesList.add(toAdd);
customFields.add(toAdd);
// add as tag
tagsPanel.addTagElement(entry.getKey());
}
}
}
if(isWorkspaceRequest){
boolean showAlertMissingResources = bean.getResources() == null || bean.getResources().isEmpty() || bean.getResources().get(0).getChildren() == null ||
bean.getResources().get(0).getChildren().isEmpty();
// if there are not resources, for now just checked it ( and hide so that the step will be skipped)
if(showAlertMissingResources){
alertNoResources.setType(AlertType.WARNING);
alertNoResources.setVisible(true);
}else
resourcesTwinPanel = new TwinColumnSelectionMainPanel(bean.getResources().get(0));
}
// set organizations
List<OrganizationBean> organizations = bean.getOrganizationList();
for (OrganizationBean organization : organizations) {
organizationsListbox.addItem(organization.getTitle());
nameTitleOrganizationMap.put(organization.getTitle(), organization.getName());
}
// force the selection of the first one, and retrieve the list of profiles
organizationsListbox.setSelectedIndex(0);
// add change handler to dinamycally retrieve the list of profiles
organizationsListbox.addChangeHandler(new ChangeHandler() {
@Override @Override
public void onFailure(Throwable caught){ public void onChange(ChangeEvent event) {
setAlertBlock("Error while retrieving licenses, try later", AlertType.ERROR, true); event.preventDefault();
organizationsListboxChangeHandlerBody();
}
});
// try to retrieve the profiles
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
// get the name of the organization from the title
final String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText());
// perform remote request of profiles for the selected organization
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
@Override
public void onFailure(Throwable caught) {
setAlertBlock("Error while retrieving profiles, try later", AlertType.ERROR, true);
} }
@Override @Override
public void onSuccess(LicensesBean lBean) { public void onSuccess(final List<MetaDataProfileBean> profiles) {
if(lBean != null && !lBean.getLicenseTitles().isEmpty()){ if(profiles == null){
setAlertBlock("Error while retrieving profiles, try later", AlertType.ERROR, true);
}
else{
licenseBean = lBean; receivedBean.setMetadataList(profiles);
prepareMetadataList(receivedBean);
// sort the list organizationsListbox.setEnabled(true);
List<String> listOfNames = new ArrayList<String>(); metadataProfilesFormatListbox.setEnabled(true);
Collections.copy(listOfNames, licenseBean.getLicenseTitles());
Collections.sort(listOfNames);
// fill the listbox
for(int i = 0; i < listOfNames.size(); i++){
licenseListbox.addItem(listOfNames.get(i));
}
// set the url of the license, if any
showLicenseUrl();
// try to retrieve the licenses // try to retrieve the licenses
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true); setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, true);
ckanServices.getLicenses(new AsyncCallback<LicensesBean>() {
// request groups
ckanServices.getUserGroups(orgName, new AsyncCallback<List<GroupBean>>() {
@Override @Override
public void onSuccess(List<GroupBean> groups) { public void onFailure(Throwable caught){
if(groups == null){ setAlertBlock("Error while retrieving licenses, try later", AlertType.ERROR, true);
setAlertBlock("Error while retrieving groups", AlertType.ERROR, true); }
}else{
if(groups.isEmpty()){
groupsControlGroup.setVisible(false);
}
else{
// add groups @Override
for (GroupBean group : groups) { public void onSuccess(LicensesBean lBean) {
groupsListbox.addItem(group.getGroupTitle(), group.getGroupName());
} if(lBean != null && !lBean.getLicenseTitles().isEmpty()){
hideGroupsAlreadyInProfile(profiles);
licenseBean = lBean;
// sort the list
List<String> listOfNames = new ArrayList<String>();
Collections.copy(listOfNames, licenseBean.getLicenseTitles());
Collections.sort(listOfNames);
// fill the listbox
for(int i = 0; i < listOfNames.size(); i++){
licenseListbox.addItem(listOfNames.get(i));
} }
// everything went ok
setAlertBlock("", AlertType.ERROR, false); // set the url of the license, if any
continueButton.setEnabled(true); showLicenseUrl();
resetButton.setEnabled(true);
// try to retrieve the licenses
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
// request groups
ckanServices.getUserGroups(orgName, new AsyncCallback<List<GroupBean>>() {
@Override
public void onSuccess(List<GroupBean> groups) {
if(groups == null){
setAlertBlock("Error while retrieving groups", AlertType.ERROR, true);
}else{
if(groups.isEmpty()){
groupsControlGroup.setVisible(false);
}
else{
// add groups
for (GroupBean group : groups) {
groupsListbox.addItem(group.getGroupTitle(), group.getGroupName());
}
hideGroupsAlreadyInProfile(profiles);
}
// everything went ok
setAlertBlock("", AlertType.ERROR, false);
continueButton.setEnabled(true);
resetButton.setEnabled(true);
}
}
@Override
public void onFailure(Throwable caught) {
setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true);
}
});
}else{
setAlertBlock("Error while retrieving licenses, try later", AlertType.ERROR, true);
} }
} }
@Override
public void onFailure(Throwable caught) {
setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true);
}
}); });
}else{
setAlertBlock("Error while retrieving licenses, try later", AlertType.ERROR, true);
} }
} }
}); });
} }
} }
}); });
}else{
setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true);
} }
}
@Override
public void onFailure(Throwable caught) {
setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true);
} }
}); });
} }
@ -1094,6 +1122,17 @@ public class CreateDatasetForm extends Composite{
focusPanelTitle, focusPanelTitle,
popupOpenedIds popupOpenedIds
); );
// description
InfoIconsLabels.preparePopupPanelAndPopover(
InfoIconsLabels.DESCRIPTION_INFO_ID_POPUP,
InfoIconsLabels.DESCRIPTION_INFO_TEXT,
InfoIconsLabels.DESCRIPTION_INFO_CAPTION,
infoIconDescription,
popoverDescription,
focusPanelDescription,
popupOpenedIds
);
// groups // groups
InfoIconsLabels.preparePopupPanelAndPopover( InfoIconsLabels.preparePopupPanelAndPopover(
@ -1194,6 +1233,7 @@ public class CreateDatasetForm extends Composite{
versionControlGroup.setType(ControlGroupType.NONE); versionControlGroup.setType(ControlGroupType.NONE);
metadataProfilesControlGroup.setType(ControlGroupType.NONE); metadataProfilesControlGroup.setType(ControlGroupType.NONE);
organizationsGroup.setType(ControlGroupType.NONE); organizationsGroup.setType(ControlGroupType.NONE);
tagsPanel.setGroupPanelType(ControlGroupType.NONE);
String title = titleTextBox.getText().trim(); String title = titleTextBox.getText().trim();
if(title.isEmpty()){ if(title.isEmpty()){
@ -1239,6 +1279,12 @@ public class CreateDatasetForm extends Composite{
organizationsGroup.setType(ControlGroupType.ERROR); organizationsGroup.setType(ControlGroupType.ERROR);
return "You must select an organization in which you want to publish"; return "You must select an organization in which you want to publish";
} }
// at least one tag..
if(tagsPanel.getTags().isEmpty()){
tagsPanel.setGroupPanelType(ControlGroupType.ERROR);
return "Please add at least one meaningful tag for the product";
}
return null; return null;
} }

View File

@ -89,6 +89,14 @@
<b:TextArea placeholder="eg. Some useful notes about the product" <b:TextArea placeholder="eg. Some useful notes about the product"
width="90%" alternateSize="LARGE" b:id="description" title="Product description" width="90%" alternateSize="LARGE" b:id="description" title="Product description"
ui:field="descriptionTextarea"></b:TextArea> ui:field="descriptionTextarea"></b:TextArea>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverDescription" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelDescription">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconDescription" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
@ -263,11 +271,14 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup ui:field="groupsControlGroup" visible="false"> <b:ControlGroup ui:field="groupsControlGroup"
visible="false">
<b:ControlLabel for="groups" title="The groups for this product">Product Groups:</b:ControlLabel> <b:ControlLabel for="groups" title="The groups for this product">Product Groups:</b:ControlLabel>
<b:Controls> <b:Controls>
<b:ListBox b:id="groups" alternateSize="LARGE" width="91%" multipleSelect="true" <b:ListBox b:id="groups" alternateSize="LARGE" width="91%"
title="The groups for this product (Hold CTRL or Command button for multiple selection)" ui:field="groupsListbox"> multipleSelect="true"
title="The groups for this product (Hold CTRL or Command button for multiple selection)"
ui:field="groupsListbox">
</b:ListBox> </b:ListBox>
<span style="float:right; width:5%; color: #aaaaaa;"> <span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverGroups" html="true" <b:Popover ui:field="popoverGroups" html="true"

View File

@ -6,10 +6,12 @@ import java.util.List;
import org.gcube.portlets.user.gcubewidgets.client.elements.Span; import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Popover; import com.github.gwtbootstrap.client.ui.Popover;
import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.base.ListItem; import com.github.gwtbootstrap.client.ui.base.ListItem;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
@ -36,6 +38,8 @@ public class TagsPanel extends Composite{
@UiField Icon infoIconTags; @UiField Icon infoIconTags;
@UiField FocusPanel focusPanelTags; @UiField FocusPanel focusPanelTags;
@UiField Popover popoverTags; @UiField Popover popoverTags;
@UiField ControlGroup tagsInsertGroup;
// regular expression for tags // regular expression for tags
private static final String REGEX_TAG = "^[a-zA-Z0-9]*$"; private static final String REGEX_TAG = "^[a-zA-Z0-9]*$";
@ -213,4 +217,14 @@ public class TagsPanel extends Composite{
} }
} }
/**
* Set the tag group panel type
* @param none
*/
public void setGroupPanelType(ControlGroupType type) {
tagsInsertGroup.setType(type);
}
} }

View File

@ -7,7 +7,7 @@
} }
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<b:ControlGroup> <b:ControlGroup ui:field="tagsInsertGroup">
<b:ControlLabel for="tags" title="Product tags"> <b:ControlLabel for="tags" title="Product tags">
Tags: Tags:
</b:ControlLabel> </b:ControlLabel>

View File

@ -78,14 +78,21 @@ public class InfoIconsLabels {
// TITLE // TITLE
public static final String TITLE_INFO_ID_POPUP = "title-popup-panel-info"; public static final String TITLE_INFO_ID_POPUP = "title-popup-panel-info";
public static final String TITLE_INFO_TEXT = "Product Title must contain only alphanumer characters, dots, underscore or hyphen minus. No others symbols are allowed."; public static final String TITLE_INFO_TEXT = "Product Title must contain only alphanumer characters, dots, underscore or hyphen minus. No others symbols are allowed. Please note that this field will be always visible, despite the product's visibility.";
public static final String TITLE_INFO_CAPTION = "Product Title"; public static final String TITLE_INFO_CAPTION = "Product Title";
// DESCRIPTION
public static final String DESCRIPTION_INFO_ID_POPUP = "description-popup-panel-info";
public static final String DESCRIPTION_INFO_TEXT = "Description of a few sentences, written in plain language. Should provide a sufficiently comprehensive overview of the resource for anyone, "
+ "to understand its content, origins, and any continuing work on it. The description can be written at the end, since it summarizes key, information from the other metadata fields. Please note that this field will be always visible, despite the product's visibility.";
public static final String DESCRIPTION_INFO_CAPTION = null;
// GROUPS // GROUPS
public static final String GROUPS_INFO_ID_POPUP = "groups-popup-panel-info"; public static final String GROUPS_INFO_ID_POPUP = "groups-popup-panel-info";
public static final String GROUPS_INFO_TEXT = "Associate this product to groups. A group is a view of products belonging to one or more organization."; public static final String GROUPS_INFO_TEXT = "Associate this product to groups. A group is a view of products belonging to one or more organization.";
public static final String GROUPS_INFO_CAPTION = "Product Groups"; public static final String GROUPS_INFO_CAPTION = "Product Groups";
/** /**
* Prepare the popover and the gcube popup panel for information. * Prepare the popover and the gcube popup panel for information.
* @param text * @param text

View File

@ -10,11 +10,12 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogueFactory; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean; import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes; import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods; import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.threads.AssociationToGroupAndNotifyThread; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.threads.AssociationToGroupAndNotifyThread;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.threads.WritePostCatalogueManagerThread; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.threads.WritePostCatalogueManagerThread;
@ -26,9 +27,11 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
@ -76,7 +79,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
/** /**
* Retrieve the list of organizations in which the user can publish (roles ADMIN) * Retrieve the list of organizations in which the user can publish (roles ADMIN/EDITOR)
* @param username * @param username
* @return the list of organizations * @return the list of organizations
* @throws GroupRetrievalFault * @throws GroupRetrievalFault
@ -95,7 +98,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.info("List of organizations was into session " + orgsName); logger.info("List of organizations was into session " + orgsName);
} }
else{ else{
orgsName = Utils.getUserOrganizationsListAdminEditor(scope, username, Utils.getGroupFromScope(scope).getGroupName(), this); Utils.getHighestRole(scope, username, Utils.getGroupFromScope(scope).getGroupName(), this, orgsName);
httpSession.setAttribute(keyPerScope, orgsName); httpSession.setAttribute(keyPerScope, orgsName);
logger.info("Organizations name for user " + username + " has been saved into session " + orgsName); logger.info("Organizations name for user " + username + " has been saved into session " + orgsName);
} }
@ -429,7 +432,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
return true; // it's an error somehow return true; // it's an error somehow
try{ try{
String scope = Utils.getScopeFromClientUrl(getThreadLocalRequest()); String scope = Utils.getScopeFromClientUrl(getThreadLocalRequest());
String idFromTitle = org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods.fromProductTitleToName(title); String idFromTitle = UtilMethods.fromProductTitleToName(title);
return getCatalogue(scope).existProductWithNameOrId(idFromTitle); return getCatalogue(scope).existProductWithNameOrId(idFromTitle);
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to check if such a dataset id already exists", e); logger.error("Unable to check if such a dataset id already exists", e);
@ -464,47 +467,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
return toReturn; return toReturn;
} }
// @Override
// public ResourceElementBean getTreeFolder(String folderId) {
//
// if(folderId == null || folderId.isEmpty()){
// logger.warn("Empty folder id or null, returning");
// return null;
// }
// ASLSession session = getASLSession();
// try{
// if(!isWithinPortal()){
// logger.warn("Running outside the portal");
// Workspace ws = getFakeWS();
// ResourceElementBean toReturn = WorkspaceUtils.getTreeFromFolder(folderId, ws);
// logger.debug("Returning " + toReturn);
// return toReturn;
// }else{
// if(session.getUsername().equals(TEST_USER)){
// return null;
// }else{
// // TODO
// return null;
// }
// }
// }catch(Exception e){
// logger.error("Failed to build the tree", e);
// }
// return null;
// }
//
// /**
// * Retrieve the workspace for the development user
// * @return
// * @throws Exception
// */
// private Workspace getFakeWS() throws Exception{
// return HomeLibrary
// .getHomeManagerFactory()
// .getHomeManager()
// .getHome(getDevelopmentUser()).getWorkspace();
// }
@Override @Override
public List<GroupBean> getUserGroups(String orgName) { public List<GroupBean> getUserGroups(String orgName) {
@ -513,7 +475,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
if(isWithinPortal()){ if(isWithinPortal()){
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername(); String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
logger.debug("Request for user " + username + " groups"); logger.debug("Request for user " + username + " groups. Organization name is " + orgName);
// get http session // get http session
HttpSession httpSession = getThreadLocalRequest().getSession(); HttpSession httpSession = getThreadLocalRequest().getSession();
@ -548,4 +510,74 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
return toReturn; return toReturn;
} }
@Override
public boolean isPublisherUser(boolean isWorkspaceRequest) {
String username = Utils.getCurrentUser(getThreadLocalRequest()).getUsername();
logger.info("Checking if the user " + username + " can publish or not");
try{
HttpSession httpSession = this.getThreadLocalRequest().getSession();
if(!isWithinPortal()){
logger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
return false;
}
// retrieve scope per current portlet url
String scopePerCurrentUrl = Utils.getScopeFromClientUrl(getThreadLocalRequest());
// get key per scope
String keyPerScopeRole = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_HIGHEST_ROLE, scopePerCurrentUrl);
String keyPerScopeOrganizations = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_ORGANIZATIONS_PUBLISH_KEY, scopePerCurrentUrl);
String keyPerScopeGroups = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_GROUPS_MEMBER, scopePerCurrentUrl);
// check if this information was already into session(true means the user has at least in one org
// the role editor), false that he is just a member so he cannot publish
RolesCkanGroupOrOrg role = (RolesCkanGroupOrOrg) httpSession.getAttribute(keyPerScopeRole);
// if the attribute was already set..
if(role != null)
return !role.equals(RolesCkanGroupOrOrg.MEMBER);
else{
try{
GroupManager gm = new LiferayGroupManager();
String groupName = gm.getGroup(gm.getGroupIdFromInfrastructureScope(scopePerCurrentUrl)).getGroupName();
// we build up also a list that keeps track of the scopes (orgs) in which the user has role ADMIN/EDITOR
List<OrganizationBean> orgsInWhichAtLeastEditorRole = new ArrayList<OrganizationBean>();
role = Utils.getHighestRole(scopePerCurrentUrl, username, groupName, this, orgsInWhichAtLeastEditorRole);
// if he is an admin/editor preload:
// 1) organizations in which he can publish (the widget will find these info in session)
if(!role.equals(RolesCkanGroupOrOrg.MEMBER)){
httpSession.setAttribute(keyPerScopeOrganizations, orgsInWhichAtLeastEditorRole);
String orgName = scopePerCurrentUrl.split("/")[scopePerCurrentUrl.split("/").length - 1];
httpSession.setAttribute(keyPerScopeGroups, getUserGroups(orgName));
}
}catch(Exception e){
logger.error("Unable to retrieve the role information for this user. Returning FALSE", e);
return false;
}
}
// set role in session for this scope
httpSession.setAttribute(keyPerScopeRole, role);
logger.info("Does the user have the right to publish on the catalogue? " + role);
return !role.equals(RolesCkanGroupOrOrg.MEMBER);
}catch(Exception e){
logger.error("Failed to check the user's role", e);
}
// return false
return false;
}
} }

View File

@ -8,9 +8,9 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.portal.mailing.EmailNotification; import org.gcube.common.portal.mailing.EmailNotification;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg; import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.GroupBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.GroupBean;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;

View File

@ -66,18 +66,12 @@ public class ServiceEndPointReaderSocial {
} }
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to retrieve such service endpoint information!", e); logger.error("Unable to retrieve such service endpoint information!", e);
}finally{ }finally{
if(oldContext != null && !oldContext.equals(context)) if(oldContext != null && !oldContext.equals(context))
ScopeProvider.instance.set(oldContext); ScopeProvider.instance.set(oldContext);
} }
logger.info("Found base path " + basePath + " for the service"); logger.info("Found base path " + basePath + " for the service");
} }
/** /**

View File

@ -18,11 +18,11 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem; import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.ApplicationProfileScopePerUrlReader; import org.gcube.datacatalogue.ckanutillibrary.server.ApplicationProfileScopePerUrlReader;
import org.gcube.datacatalogue.ckanutillibrary.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
import org.gcube.datacatalogue.ckanutillibrary.models.RolesCkanGroupOrOrg; import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
import org.gcube.datacatalogue.ckanutillibrary.utils.SessionCatalogueAttributes; import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
import org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader; import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader;
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType; import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField; import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;
@ -101,17 +101,20 @@ public class Utils {
} }
return null; return null;
} }
/** /**
* Retrieve the list of organizations in which the user has the admin/editor role * Retrieve the highest ckan role the user has and also retrieve the list of organizations (scopes) in which the user has the ckan-admin or ckan-editor role
* @param currentScope the current scope * @param currentScope the current scope
* @param username the current username * @param username the current username
* @param groupName the current groupName * @param groupName the current groupName
* @param ckanPublisherServicesImpl * @param gcubeCkanDataCatalogServiceImpl
* @param orgsInWhichAdminRole
* @param ckanUtils ckanUtils
*/ */
public static List<OrganizationBean> getUserOrganizationsListAdminEditor(String currentScope, String username, String groupName, CKANPublisherServicesImpl ckanPublisherServicesImpl){ public static RolesCkanGroupOrOrg getHighestRole(String currentScope, String username, String groupName, CKANPublisherServicesImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAtLeastEditorRole){
List<OrganizationBean> toReturn = new ArrayList<OrganizationBean>(); // base role as default value
RolesCkanGroupOrOrg toReturn = RolesCkanGroupOrOrg.MEMBER;
try{ try{
@ -127,36 +130,45 @@ public class Utils {
logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope); logger.debug("Group id is " + currentGroupId + " and scope is " + currentScope);
// retrieve the flat list of organizations // retrieve the flat list of organizations for the current user
List<GCubeGroup> groups = groupManager.listGroupsByUser(userid); List<GCubeGroup> groups = groupManager.listGroupsByUser(userid);
// root (so check into the root, the VOs and the VRES) // root (so check into the root, the VOs and the VRES)
if(groupManager.isRootVO(currentGroupId)){ if(groupManager.isRootVO(currentGroupId)){
logger.debug("The list of organizations of the user " + username + " is " + groups); logger.info("The current scope is the Root Vo, so the list of organizations of the user " + username + " is " + groups);
for (GCubeGroup gCubeGroup : groups) { for (GCubeGroup gCubeGroup : groups) {
// get the name of this vre // get the name of this group
String gCubeGroupName = gCubeGroup.getGroupName(); String gCubeGroupName = gCubeGroup.getGroupName();
// get the role of the users in this vre // get the role of the users in this group
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName)); List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName));
// get highest role according liferay // get highest role
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
// this is a tricky part... because we actually do not know if it is a member or there is no ckan instance there // be sure it is so
if(correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)) checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
continue; correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
if(toReturn.equals(RolesCkanGroupOrOrg.ADMIN))
continue;
else if(toReturn.equals(RolesCkanGroupOrOrg.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN))
toReturn = RolesCkanGroupOrOrg.ADMIN;
else // it was MEMBER
toReturn = correspondentRoleToCheck;
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(), correspondentRoleToCheck, toReturn, groupManager, ckanPublisherServicesImpl);
} }
}else if(groupManager.isVO(currentGroupId)){ }else if(groupManager.isVO(currentGroupId)){
logger.debug("The list of organizations of the user " + username + " to scan is the one under the VO " + groupName);
for (GCubeGroup gCubeGroup : groups) { for (GCubeGroup gCubeGroup : groups) {
// if the gCubeGroup is not under the VO or it is not the VO continue
if(currentGroupId != gCubeGroup.getParentGroupId() || currentGroupId != gCubeGroup.getGroupId()) if(currentGroupId != gCubeGroup.getParentGroupId() || currentGroupId != gCubeGroup.getGroupId())
continue; continue;
@ -164,31 +176,43 @@ public class Utils {
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName)); List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userid, groupManager.getGroupId(gCubeGroupName));
// get highest role according liferay // get highest role
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
// this is a tricky part... because we actually do not know if it is a member or there is no ckan instance there // be sure it is so
if(correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.MEMBER)) checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(),
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
if(toReturn.equals(RolesCkanGroupOrOrg.ADMIN))
continue; continue;
else if(toReturn.equals(RolesCkanGroupOrOrg.EDITOR) && correspondentRoleToCheck.equals(RolesCkanGroupOrOrg.ADMIN))
checkIfRoleIsSetInCkanInstance(username, gCubeGroupName, gCubeGroup.getGroupId(), correspondentRoleToCheck, toReturn, groupManager, ckanPublisherServicesImpl); toReturn = RolesCkanGroupOrOrg.ADMIN;
else
toReturn = correspondentRoleToCheck;
} }
}else if(groupManager.isVRE(currentGroupId)){ // vre }else if(groupManager.isVRE(currentGroupId)){
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username), groupManager.getGroupId(groupName)); List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username), groupManager.getGroupId(groupName));
logger.debug("The list of roles for " + username + " into " + groupName + " is " + roles); logger.debug("The current scope is the vre " + groupName);
// get highest role according liferay // get highest role
RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles); RolesCkanGroupOrOrg correspondentRoleToCheck = getLiferayHighestRoleInOrg(roles);
// be sure it is so
checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId,
correspondentRoleToCheck, groupManager, gcubeCkanDataCatalogServiceImpl, orgsInWhichAtLeastEditorRole);
toReturn = correspondentRoleToCheck;
checkIfRoleIsSetInCkanInstance(username, groupName, currentGroupId, correspondentRoleToCheck, toReturn, groupManager, ckanPublisherServicesImpl);
} }
}catch(Exception e){ }catch(Exception e){
logger.error("Unable to retrieve the role information for this user. Returning member role", e); logger.error("Unable to retrieve the role information for this user. Returning member role", e);
return RolesCkanGroupOrOrg.MEMBER;
} }
logger.info("Retrieved orgs in which the user has admin roles " + toReturn); // return the role
logger.debug("Returning role " + toReturn + " for user " + username);
return toReturn; return toReturn;
} }
@ -207,7 +231,7 @@ public class Utils {
private static void checkIfRoleIsSetInCkanInstance(String username, private static void checkIfRoleIsSetInCkanInstance(String username,
String gCubeGroupName, long groupId, String gCubeGroupName, long groupId,
RolesCkanGroupOrOrg correspondentRoleToCheck, RolesCkanGroupOrOrg correspondentRoleToCheck,
List<OrganizationBean> orgs, GroupManager groupManager, CKANPublisherServicesImpl ckanPublisherServicesImpl) throws UserManagementSystemException, GroupRetrievalFault { GroupManager groupManager, CKANPublisherServicesImpl ckanPublisherServicesImpl, List<OrganizationBean> orgs) throws UserManagementSystemException, GroupRetrievalFault {
// with this invocation, we check if the role is present in ckan and if it is not it will be added // with this invocation, we check if the role is present in ckan and if it is not it will be added
DataCatalogue catalogue = ckanPublisherServicesImpl.getCatalogue(groupManager.getInfrastructureScope(groupId)); DataCatalogue catalogue = ckanPublisherServicesImpl.getCatalogue(groupManager.getInfrastructureScope(groupId));
@ -599,4 +623,5 @@ public class Utils {
return gm.getGroup(groupId); return gm.getGroup(groupId);
} }
} }

View File

@ -15,7 +15,8 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.catalogue.WorkspaceCatalogue; import org.gcube.common.homelibrary.home.workspace.catalogue.WorkspaceCatalogue;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean; import org.gcube.datacatalogue.ckanutillibrary.server.models.ResourceBean;
import org.gcube.datacatalogue.ckanutillibrary.server.utils.UtilMethods;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
@ -62,7 +63,7 @@ public class WorkspaceUtils {
// change name of the copied folder to match the title (append the timestamp to avoid ties) // change name of the copied folder to match the title (append the timestamp to avoid ties)
long referenceTime = System.currentTimeMillis(); long referenceTime = System.currentTimeMillis();
((WorkspaceFolder)copiedFolder).rename(org.gcube.datacatalogue.ckanutillibrary.utils.UtilMethods.fromProductTitleToName(bean.getTitle()) + "_" + referenceTime); ((WorkspaceFolder)copiedFolder).rename(UtilMethods.fromProductTitleToName(bean.getTitle()) + "_" + referenceTime);
// copy only the selected ones // copy only the selected ones
for(ResourceElementBean resource : resourcesToAdd){ for(ResourceElementBean resource : resourcesToAdd){

View File

@ -10,7 +10,7 @@
<set-property name="bootstrap.responsiveDesign" value="true" /> <set-property name="bootstrap.responsiveDesign" value="true" />
<inherits name='com.github.gwtbootstrap.datetimepicker.Datetimepicker' /> <inherits name='com.github.gwtbootstrap.datetimepicker.Datetimepicker' />
<inherits name='com.github.gwtbootstrap.datepicker.Datepicker' /> <inherits name='com.github.gwtbootstrap.datepicker.Datepicker' />
<inherits name='org.gcube.datacatalogue.ckanutillibrary.CkanUtilLibrary' />
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->

View File

@ -1,2 +0,0 @@
sendButton = Envoyer
nameField = Entrez votre nom