refactored
This commit is contained in:
parent
ae1cc32387
commit
5d0b45649a
|
@ -12,12 +12,13 @@ import java.util.Map;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportalcommon.shared.GNADataConfigProfile;
|
||||||
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
||||||
import org.gcube.application.geoportalcommon.shared.config.GNAUserRightsConfigException;
|
|
||||||
import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
|
import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
|
||||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
|
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
|
||||||
import org.gcube.application.geoportalcommon.shared.exception.ApplicationProfileNotFoundException;
|
import org.gcube.application.geoportalcommon.shared.exception.ApplicationProfileNotFoundException;
|
||||||
|
import org.gcube.application.geoportalcommon.shared.exception.GNAUserRightsConfigException;
|
||||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
|
@ -29,13 +30,13 @@ import org.w3c.dom.Document;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class GNADataEntryConfigsProfileReader.
|
* The Class GNADataConfigProfileReader.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Dec 2, 2021
|
* Dec 2, 2021
|
||||||
*/
|
*/
|
||||||
public class GNADataEntryConfigsProfileReader {
|
public class GNADataConfigProfileReader {
|
||||||
|
|
||||||
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
||||||
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
||||||
|
@ -44,12 +45,12 @@ public class GNADataEntryConfigsProfileReader {
|
||||||
|
|
||||||
private String scope;
|
private String scope;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(GNADataEntryConfigsProfileReader.class);
|
private static final Logger LOG = LoggerFactory.getLogger(GNADataConfigProfileReader.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new application profile reader.
|
* Instantiates a new application profile reader.
|
||||||
*/
|
*/
|
||||||
public GNADataEntryConfigsProfileReader() {
|
public GNADataConfigProfileReader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +59,7 @@ public class GNADataEntryConfigsProfileReader {
|
||||||
* @return the map
|
* @return the map
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public GNADataEntryConfigs readProfileFromInfrastrucure() throws Exception {
|
public GNADataConfigProfile readProfileFromInfrastrucure() throws Exception {
|
||||||
LOG.info("called readProfileFromInfrastrucure");
|
LOG.info("called readProfileFromInfrastrucure");
|
||||||
String queryString = getGcubeGenericQueryString(SECONDARY_TYPE, GENERIC_RESOURCE_NAME);
|
String queryString = getGcubeGenericQueryString(SECONDARY_TYPE, GENERIC_RESOURCE_NAME);
|
||||||
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
||||||
|
@ -67,7 +68,7 @@ public class GNADataEntryConfigsProfileReader {
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
throw new Exception("Scope is null, set scope into ScopeProvider");
|
throw new Exception("Scope is null, set scope into ScopeProvider");
|
||||||
|
|
||||||
GNADataEntryConfigs gnDEC = new GNADataEntryConfigs();
|
GNADataConfigProfile gnDEC = new GNADataConfigProfile();
|
||||||
String permissions_for_role = "";
|
String permissions_for_role = "";
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package org.gcube.application.geoportalcommon.config;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
|
||||||
|
|
||||||
|
|
||||||
public class GNADataEntryConfigs {
|
|
||||||
|
|
||||||
List<RoleRights> permissionsForRole = null;
|
|
||||||
|
|
||||||
public GNADataEntryConfigs() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public GNADataEntryConfigs(List<RoleRights> permissionsForRole) {
|
|
||||||
super();
|
|
||||||
this.permissionsForRole = permissionsForRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RoleRights> getPermissionsForRole() {
|
|
||||||
return permissionsForRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPermissionsForRole(List<RoleRights> permissionsForRole) {
|
|
||||||
this.permissionsForRole = permissionsForRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("GNADataEntryConfigs [permissionsForRole=");
|
|
||||||
builder.append(permissionsForRole);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,6 +3,8 @@ package org.gcube.application.geoportalcommon.shared;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||||
|
|
||||||
public class GNADataConfigProfile implements Serializable {
|
public class GNADataConfigProfile implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,14 +12,16 @@ public class GNADataConfigProfile implements Serializable {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 5152380669677928785L;
|
private static final long serialVersionUID = 5152380669677928785L;
|
||||||
private List<ItemField> listItemFields;
|
private List<ItemField> listItemFields;
|
||||||
|
private List<RoleRights> permissionsForRole;
|
||||||
|
|
||||||
public GNADataConfigProfile() {
|
public GNADataConfigProfile() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GNADataConfigProfile(List<ItemField> listItemFields) {
|
public GNADataConfigProfile(List<ItemField> listItemFields, List<RoleRights> permissionsForRole) {
|
||||||
super();
|
super();
|
||||||
this.listItemFields = listItemFields;
|
this.listItemFields = listItemFields;
|
||||||
|
this.permissionsForRole = permissionsForRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemField> getListItemFields() {
|
public List<ItemField> getListItemFields() {
|
||||||
|
@ -28,6 +32,14 @@ public class GNADataConfigProfile implements Serializable {
|
||||||
this.listItemFields = listItemFields;
|
this.listItemFields = listItemFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RoleRights> getPermissionsForRole() {
|
||||||
|
return permissionsForRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermissionsForRole(List<RoleRights> permissionsForRole) {
|
||||||
|
this.permissionsForRole = permissionsForRole;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.gcube.application.geoportalcommon.shared.config;
|
package org.gcube.application.geoportalcommon.shared.exception;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class GNAUserRightsConfigException extends Exception {
|
public class GNAUserRightsConfigException extends Exception {
|
|
@ -2,6 +2,7 @@ package org.gcube.application;
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||||
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
||||||
|
import org.gcube.application.geoportalcommon.config.GNADataConfigProfileReader;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||||
|
@ -46,7 +47,7 @@ public class TestGNACommon {
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void queryConcessioniTest() throws Exception {
|
public void queryConcessioniTest() throws Exception {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -67,5 +68,18 @@ public class TestGNACommon {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readUserRights() throws Exception {
|
||||||
|
|
||||||
|
GNADataConfigProfileReader r = new GNADataConfigProfileReader();
|
||||||
|
try {
|
||||||
|
ScopeProvider.instance.set(CONTEXT);
|
||||||
|
r.readProfileFromInfrastrucure();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue