Fix for username (ckan uses name_surname format whereas liferay name.surname)
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@129067 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6cd048cba6
commit
549267ab1c
|
@ -5,6 +5,9 @@
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
<dependent-module archiveName="ckan-util-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
|
||||||
|
<dependency-type>uses</dependency-type>
|
||||||
|
</dependent-module>
|
||||||
<property name="context-root" value="ckan-metadata-publisher-widget"/>
|
<property name="context-root" value="ckan-metadata-publisher-widget"/>
|
||||||
<property name="java-output-path" value="/ckan-metadata-publisher-widget/target/ckan-metadata-publisher-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/ckan-metadata-publisher-widget/target/ckan-metadata-publisher-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class CKanMetadataPublisher implements EntryPoint {
|
||||||
private void startExample() {
|
private void startExample() {
|
||||||
|
|
||||||
String idFolderWorkspace = "d3a37eb9-1589-4c95-a9d0-c473a02d4f0f";
|
String idFolderWorkspace = "d3a37eb9-1589-4c95-a9d0-c473a02d4f0f";
|
||||||
String owner = "costantino_perciante";
|
String owner = "costantino.perciante";
|
||||||
RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(owner));
|
RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(owner));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -739,6 +739,10 @@ public class CreateDatasetForm extends Composite{
|
||||||
errorMessage = "You must select a metadata profile different frome none";
|
errorMessage = "You must select a metadata profile different frome none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(organizationsListbox.getSelectedItemText() == null){
|
||||||
|
errorMessage = "You must select an organization in which you want to publish";
|
||||||
|
}
|
||||||
|
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
* Retrieve the list of metadata beans
|
* Retrieve the list of metadata beans
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<MetaDataProfileBean> getMetadataProfilesList() {
|
private List<MetaDataProfileBean> getMetadataProfilesList() {
|
||||||
|
|
||||||
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
|
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
|
||||||
|
|
||||||
|
@ -277,12 +277,11 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
bean.setAuthorEmail(userOwner.getEmail());
|
bean.setAuthorEmail(userOwner.getEmail());
|
||||||
bean.setMaintainer(userOwner.getFullname());
|
bean.setMaintainer(userOwner.getFullname());
|
||||||
bean.setMaintainerEmail(userOwner.getEmail());
|
bean.setMaintainerEmail(userOwner.getEmail());
|
||||||
bean.setOrganizationList(getUserOrganizationsList(owner));
|
bean.setOrganizationList(getUserOrganizationsList(fromOwnerToCKanOwner(owner)));
|
||||||
|
|
||||||
// if the request comes from the workspace
|
// if the request comes from the workspace
|
||||||
if(folderId != null && !folderId.isEmpty()){
|
if(folderId != null && !folderId.isEmpty()){
|
||||||
|
|
||||||
|
|
||||||
Workspace ws = HomeLibrary
|
Workspace ws = HomeLibrary
|
||||||
.getHomeManagerFactory()
|
.getHomeManagerFactory()
|
||||||
.getHomeManager()
|
.getHomeManager()
|
||||||
|
@ -330,7 +329,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
bean.setAuthorEmail("costantino.perciante@isti.cnr.it");
|
bean.setAuthorEmail("costantino.perciante@isti.cnr.it");
|
||||||
bean.setMaintainer("Costantino Perciante");
|
bean.setMaintainer("Costantino Perciante");
|
||||||
bean.setMaintainerEmail("costantino.perciante@isti.cnr.it");
|
bean.setMaintainerEmail("costantino.perciante@isti.cnr.it");
|
||||||
bean.setOrganizationList(getUserOrganizationsList(owner));
|
bean.setOrganizationList(getUserOrganizationsList(fromOwnerToCKanOwner(owner)));
|
||||||
bean.setOwnerIdentifier(owner);
|
bean.setOwnerIdentifier(owner);
|
||||||
|
|
||||||
if(folderId != null && !folderId.isEmpty()){
|
if(folderId != null && !folderId.isEmpty()){
|
||||||
|
@ -402,11 +401,11 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// retrieve ckan's catalog url
|
// retrieve ckan's catalog url
|
||||||
String ckanPortalUrl = getCatalogueUrl();
|
String ckanPortalUrl = getCatalogueUrl();
|
||||||
|
|
||||||
// retrieve the owner identifier
|
// retrieve the owner identifier (i.e. costantino.perciante)
|
||||||
String owner = toCreate.getOwnerIdentifier();
|
String owner = toCreate.getOwnerIdentifier();
|
||||||
|
|
||||||
// retrieve the api key for this user
|
// retrieve the api key for this user
|
||||||
String apiKey = getCKANApikeyFromUser(owner);
|
String apiKey = getCKANApikeyFromUser(fromOwnerToCKanOwner(owner));
|
||||||
|
|
||||||
logger.info("Trying to create the dataset described by this bean " + toCreate + " into CKAN catalog at url " + ckanPortalUrl);
|
logger.info("Trying to create the dataset described by this bean " + toCreate + " into CKAN catalog at url " + ckanPortalUrl);
|
||||||
|
|
||||||
|
@ -499,7 +498,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
newResource.setUrl(item.getPublicLink(false));
|
newResource.setUrl(item.getPublicLink(false));
|
||||||
newResource.setName(item.getName());
|
newResource.setName(item.getName());
|
||||||
newResource.setMimetype(item.getMimeType());
|
newResource.setMimetype(item.getMimeType());
|
||||||
|
newResource.setOwner(fromOwnerToCKanOwner(owner));
|
||||||
resources.add(newResource);
|
resources.add(newResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,6 +542,15 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
return toCreate;
|
return toCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ckan username has _ instead of . (that is, costantino_perciante)
|
||||||
|
* @param owner
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String fromOwnerToCKanOwner(String owner){
|
||||||
|
return owner.replaceAll("\\.", "_");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the dataset visibility.
|
* Set the dataset visibility.
|
||||||
* @param created
|
* @param created
|
||||||
|
@ -555,8 +563,10 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// set its visibility (true means public, false means private)
|
// set its visibility (true means public, false means private)
|
||||||
boolean mustbePrivate = !created.getVisibility();
|
boolean mustbePrivate = !created.getVisibility();
|
||||||
String currentScope = getCurrentScope();
|
String currentScope = getCurrentScope();
|
||||||
|
|
||||||
CKanUtilsFactory.getInstance().
|
CKanUtilsFactory.getInstance().
|
||||||
getCkanUtilsForScope(currentScope).setDatasetPrivate(mustbePrivate, orgOwnerId, created.getId(), created.getOwnerIdentifier());
|
getCkanUtilsForScope(currentScope).
|
||||||
|
setDatasetPrivate(mustbePrivate, orgOwnerId, created.getId(), fromOwnerToCKanOwner(created.getOwnerIdentifier()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +618,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
String ckanPortalUrl = getCatalogueUrl();
|
String ckanPortalUrl = getCatalogueUrl();
|
||||||
|
|
||||||
// retrieve the api key for this user
|
// retrieve the api key for this user
|
||||||
String apiKey = getCKANApikeyFromUser(owner);
|
String apiKey = getCKANApikeyFromUser(fromOwnerToCKanOwner(owner));
|
||||||
|
|
||||||
CkanResource resource = new CkanResource(ckanPortalUrl, datasetId);
|
CkanResource resource = new CkanResource(ckanPortalUrl, datasetId);
|
||||||
resource.setName(resourceBean.getName());
|
resource.setName(resourceBean.getName());
|
||||||
|
@ -620,7 +630,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
resource.setDescription(htmlRend.toString());
|
resource.setDescription(htmlRend.toString());
|
||||||
resource.setUrl(resourceBean.getUrl());
|
resource.setUrl(resourceBean.getUrl());
|
||||||
resource.setOwner(owner);
|
resource.setOwner(fromOwnerToCKanOwner(owner));
|
||||||
|
|
||||||
// Checked client
|
// Checked client
|
||||||
CheckedCkanClient client = new CheckedCkanClient(ckanPortalUrl, apiKey);
|
CheckedCkanClient client = new CheckedCkanClient(ckanPortalUrl, apiKey);
|
||||||
|
@ -657,7 +667,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
String ckanPortalUrl = getCatalogueUrl();
|
String ckanPortalUrl = getCatalogueUrl();
|
||||||
|
|
||||||
// retrieve the api key for this user
|
// retrieve the api key for this user
|
||||||
String apiKey = getCKANApikeyFromUser(owner);
|
String apiKey = getCKANApikeyFromUser(fromOwnerToCKanOwner(owner));
|
||||||
|
|
||||||
// Checked client
|
// Checked client
|
||||||
CheckedCkanClient client = new CheckedCkanClient(ckanPortalUrl, apiKey);
|
CheckedCkanClient client = new CheckedCkanClient(ckanPortalUrl, apiKey);
|
||||||
|
|
Loading…
Reference in New Issue