fixing the [Incident #12563] Error when trying to publish the content of a workspace folder into the catalogue</Change>
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@171733 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
232be5c370
commit
ea24c207dc
|
@ -3,11 +3,11 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
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.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=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
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset
|
||||||
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-0"
|
||||||
|
date="2018-09-28">
|
||||||
|
<Change>[Incident #12563] Error when trying to publish the content of a workspace folder into the catalogue</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset
|
<Changeset
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-3-3"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-3-3"
|
||||||
date="2018-03-02">
|
date="2018-03-02">
|
||||||
|
@ -39,9 +44,11 @@
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-2-0"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-2-0"
|
||||||
date="2016-12-11">
|
date="2016-12-11">
|
||||||
<Change>A post is automatically created by the Product Catalogue user
|
<Change>A post is automatically created by the Product Catalogue user
|
||||||
every time someone publishes</Change>
|
every time someone publishes
|
||||||
|
</Change>
|
||||||
<Change>The user now can select all files in the hierarchy and publish
|
<Change>The user now can select all files in the hierarchy and publish
|
||||||
them</Change>
|
them
|
||||||
|
</Change>
|
||||||
<Change>The user can now associate the product to the available groups
|
<Change>The user can now associate the product to the available groups
|
||||||
</Change>
|
</Change>
|
||||||
<Change>Removed ASL session dependency</Change>
|
<Change>Removed ASL session dependency</Change>
|
||||||
|
@ -52,7 +59,8 @@
|
||||||
<Change>Creation of a group is now supported</Change>
|
<Change>Creation of a group is now supported</Change>
|
||||||
<Change>Association of a dataset to a group is now supported</Change>
|
<Change>Association of a dataset to a group is now supported</Change>
|
||||||
<Change>Products are copied to .catalogue area when publishing is
|
<Change>Products are copied to .catalogue area when publishing is
|
||||||
performed from workspace</Change>
|
performed from workspace
|
||||||
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset
|
<Changeset
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-0-0"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-0-0"
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>ckan-metadata-publisher-widget</artifactId>
|
<artifactId>ckan-metadata-publisher-widget</artifactId>
|
||||||
<version>1.3.3-SNAPSHOT</version>
|
<version>1.4.0-SNAPSHOT</version>
|
||||||
<name>gCube Ckan metadata publisher widget</name>
|
<name>gCube Ckan metadata publisher widget</name>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -16,8 +16,8 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
|
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.server.utils.CatalogueUtilMethods;
|
import org.gcube.datacatalogue.ckanutillibrary.server.utils.CatalogueUtilMethods;
|
||||||
|
import org.gcube.datacatalogue.ckanutillibrary.server.utils.SessionCatalogueAttributes;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
import org.gcube.datacatalogue.ckanutillibrary.shared.ResourceBean;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
||||||
|
@ -79,7 +79,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
DataCatalogue instance = null;
|
DataCatalogue instance = null;
|
||||||
String scopeInWhichDiscover = null;
|
String scopeInWhichDiscover = null;
|
||||||
try{
|
try{
|
||||||
scopeInWhichDiscover = (scope != null && !scope.isEmpty()) ? scope : GenericUtils.getCurrentContext(getThreadLocalRequest(), false);
|
scopeInWhichDiscover = scope != null && !scope.isEmpty() ? scope : GenericUtils.getCurrentContext(getThreadLocalRequest(), false);
|
||||||
logger.debug("Discovering ckan instance into scope " + scopeInWhichDiscover);
|
logger.debug("Discovering ckan instance into scope " + scopeInWhichDiscover);
|
||||||
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
|
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
@ -92,8 +92,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
* Retrieve the list of organizations in which the user can publish (roles ADMIN/EDITOR)
|
* 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
|
||||||
* @throws UserManagementSystemException
|
* @throws UserManagementSystemException
|
||||||
*/
|
*/
|
||||||
private List<OrganizationBean> getUserOrganizationsListAdmin(String username, String scope) throws UserManagementSystemException, GroupRetrievalFault {
|
private List<OrganizationBean> getUserOrganizationsListAdmin(String username, String scope) throws UserManagementSystemException, GroupRetrievalFault {
|
||||||
|
|
||||||
|
@ -124,11 +124,11 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
try {
|
try {
|
||||||
UserLocalServiceUtil.getService();
|
UserLocalServiceUtil.getService();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
||||||
logger.trace("Development Mode ON");
|
logger.trace("Development Mode ON");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +136,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
* @param chosenLicense
|
* @param chosenLicense
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String findLicenseIdByLicense(String chosenLicense) {
|
private String findLicenseIdByLicense(String chosenLicense) {
|
||||||
|
|
||||||
// get scope from client url
|
// get scope from client url
|
||||||
String scope = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
|
String scope = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
|
||||||
|
@ -259,12 +259,12 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
/**
|
/**
|
||||||
* Discover from the IS the vocabulary of tags for this scope, if present
|
* Discover from the IS the vocabulary of tags for this scope, if present
|
||||||
* @return a list of tags vocabulary
|
* @return a list of tags vocabulary
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private List<String> discoverTagsVocabulary(String context){
|
private List<String> discoverTagsVocabulary(String context){
|
||||||
|
|
||||||
logger.debug("Looking for vocabulary of tags in this context " + context);
|
logger.debug("Looking for vocabulary of tags in this context " + context);
|
||||||
String keyPerVocabulary = CatalogueUtilMethods.concatenateSessionKeyScope(TAGS_VOCABULARY_KEY, context);
|
String keyPerVocabulary = CatalogueUtilMethods.concatenateSessionKeyScope(TAGS_VOCABULARY_KEY, context);
|
||||||
|
|
||||||
List<String> vocabulary = (List<String>) getThreadLocalRequest().getSession().getAttribute(keyPerVocabulary);
|
List<String> vocabulary = (List<String>) getThreadLocalRequest().getSession().getAttribute(keyPerVocabulary);
|
||||||
if(vocabulary == null){
|
if(vocabulary == null){
|
||||||
|
@ -323,7 +323,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
String userApiKey = utils.getApiKeyFromUsername(userName);
|
String userApiKey = utils.getApiKeyFromUsername(userName);
|
||||||
|
|
||||||
String datasetId = utils.createCKanDatasetMultipleCustomFields
|
String datasetId = utils.createCKanDatasetMultipleCustomFields
|
||||||
(userApiKey, title, null, organizationNameOrId, author, authorMail, maintainer,
|
(userApiKey, title, null, organizationNameOrId, author, authorMail, maintainer,
|
||||||
maintainerMail, version, description, licenseId, listOfTags, customFields, resources, setPublic);
|
maintainerMail, version, description, licenseId, listOfTags, customFields, resources, setPublic);
|
||||||
|
|
||||||
if(datasetId != null){
|
if(datasetId != null){
|
||||||
|
@ -343,7 +343,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// start a thread that will associate this dataset with the group
|
// start a thread that will associate this dataset with the group
|
||||||
if(/*toCreate.getChosenType() != null ||*/ toCreate.getGroups() != null){
|
if(/*toCreate.getChosenType() != null ||*/ toCreate.getGroups() != null){
|
||||||
|
|
||||||
AssociationToGroupAndNotifyThread threadAssociationToGroup =
|
AssociationToGroupAndNotifyThread threadAssociationToGroup =
|
||||||
new AssociationToGroupAndNotifyThread(
|
new AssociationToGroupAndNotifyThread(
|
||||||
toCreate.getGroups(),
|
toCreate.getGroups(),
|
||||||
toCreate.getGroupsForceCreation(),
|
toCreate.getGroupsForceCreation(),
|
||||||
|
@ -352,8 +352,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
datasetId,
|
datasetId,
|
||||||
toCreate.getTitle(),
|
toCreate.getTitle(),
|
||||||
GenericUtils.getCurrentUser(getThreadLocalRequest()).getFullname(),
|
GenericUtils.getCurrentUser(getThreadLocalRequest()).getFullname(),
|
||||||
userName,
|
userName,
|
||||||
utils,
|
utils,
|
||||||
organizationNameOrId,
|
organizationNameOrId,
|
||||||
getThreadLocalRequest()
|
getThreadLocalRequest()
|
||||||
);
|
);
|
||||||
|
@ -362,14 +362,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
}
|
}
|
||||||
|
|
||||||
// launch notification thread
|
// launch notification thread
|
||||||
WritePostCatalogueManagerThread threadWritePost =
|
WritePostCatalogueManagerThread threadWritePost =
|
||||||
new WritePostCatalogueManagerThread(
|
new WritePostCatalogueManagerThread(
|
||||||
userName,
|
userName,
|
||||||
scope,
|
scope,
|
||||||
toCreate.getTitle(),
|
toCreate.getTitle(),
|
||||||
datasetUrl,
|
datasetUrl,
|
||||||
false, // send notification to other people
|
false, // send notification to other people
|
||||||
toCreate.getTags(),
|
toCreate.getTags(),
|
||||||
GenericUtils.getCurrentUser(getThreadLocalRequest()).getFullname(),
|
GenericUtils.getCurrentUser(getThreadLocalRequest()).getFullname(),
|
||||||
GenericUtils.getCurrentClientUrl(getThreadLocalRequest())
|
GenericUtils.getCurrentClientUrl(getThreadLocalRequest())
|
||||||
);
|
);
|
||||||
|
@ -405,11 +405,11 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
|
|
||||||
ResourceBean resourceBean = new ResourceBean(
|
ResourceBean resourceBean = new ResourceBean(
|
||||||
resource.getUrl(),
|
resource.getUrl(),
|
||||||
resource.getName(),
|
resource.getName(),
|
||||||
resource.getDescription(),
|
resource.getDescription(),
|
||||||
null,
|
null,
|
||||||
username,
|
username,
|
||||||
datasetId,
|
datasetId,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
|
@ -546,17 +546,26 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
logger.info("Found user's groups in session " + toReturn);
|
logger.info("Found user's groups in session " + toReturn);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
DataCatalogue catalogue = getCatalogue(scope);
|
//Fixing Incident #12563
|
||||||
String apiKey = catalogue.getApiKeyFromUsername(username);
|
try{
|
||||||
Map<String, Map<CkanGroup, RolesCkanGroupOrOrg>> mapRoleGroup = catalogue.getUserRoleByGroup(username, apiKey);
|
DataCatalogue catalogue = getCatalogue(scope);
|
||||||
Set<Entry<String, Map<CkanGroup, RolesCkanGroupOrOrg>>> set = mapRoleGroup.entrySet();
|
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||||
for (Entry<String, Map<CkanGroup, RolesCkanGroupOrOrg>> entry : set) {
|
//Fixing Incident #12563
|
||||||
Set<Entry<CkanGroup, RolesCkanGroupOrOrg>> subSet = entry.getValue().entrySet();
|
if(apiKey!=null && !apiKey.isEmpty()){
|
||||||
for (Entry<CkanGroup, RolesCkanGroupOrOrg> subEntry : subSet) {
|
Map<String, Map<CkanGroup, RolesCkanGroupOrOrg>> mapRoleGroup = catalogue.getUserRoleByGroup(username, apiKey);
|
||||||
toReturn.add(new OrganizationBean(subEntry.getKey().getTitle(), subEntry.getKey().getName(), false));
|
Set<Entry<String, Map<CkanGroup, RolesCkanGroupOrOrg>>> set = mapRoleGroup.entrySet();
|
||||||
}
|
for (Entry<String, Map<CkanGroup, RolesCkanGroupOrOrg>> entry : set) {
|
||||||
|
Set<Entry<CkanGroup, RolesCkanGroupOrOrg>> subSet = entry.getValue().entrySet();
|
||||||
|
for (Entry<CkanGroup, RolesCkanGroupOrOrg> subEntry : subSet) {
|
||||||
|
toReturn.add(new OrganizationBean(subEntry.getKey().getTitle(), subEntry.getKey().getName(), false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
httpSession.setAttribute(keyPerScopeGroups, toReturn);
|
||||||
|
}else
|
||||||
|
logger.warn("The API_KEY for "+username+ " is null or empty in the catalogue: "+catalogue.getCatalogueUrl());
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Error on recovery the user groups for "+username, e);
|
||||||
}
|
}
|
||||||
httpSession.setAttribute(keyPerScopeGroups, toReturn);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
logger.warn("Dev mode detected");
|
logger.warn("Dev mode detected");
|
||||||
|
|
Loading…
Reference in New Issue