merged 4.1
git-svn-id: http://svn.research-infrastructures.eu/d4science/gcube/trunk/spatial-data/geonetwork@133591 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ae4b04a1d1
commit
56bed0b8ab
|
@ -14,5 +14,7 @@
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="geonetwork.3-1-0" date="2016-09-09">
|
<Changeset component="geonetwork.3-1-0" date="2016-09-09">
|
||||||
<Change>Added Security token management</Change>
|
<Change>Added Security token management</Change>
|
||||||
|
<Change>Multiple GN version handling by integrating geonetwork-manager 1.4-SNAPSHOT</Change>
|
||||||
|
<Change>Introduced 'Publish and promote' API</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
</ReleaseNotes>
|
</ReleaseNotes>
|
|
@ -1,5 +0,0 @@
|
||||||
24968
|
|
||||||
24969
|
|
||||||
24970
|
|
||||||
24971
|
|
||||||
24975
|
|
19
pom.xml
19
pom.xml
|
@ -62,12 +62,18 @@
|
||||||
<artifactId>common-gcore-resources</artifactId>
|
<artifactId>common-gcore-resources</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
|
<artifactId>uri-resolver-manager</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- EXTERNAL -->
|
<!-- EXTERNAL -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.geosolutions</groupId>
|
<groupId>it.geosolutions</groupId>
|
||||||
<artifactId>geonetwork-manager</artifactId>
|
<artifactId>geonetwork-manager</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.4-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -95,7 +101,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>0.11.6</version>
|
<version>1.14.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TEST -->
|
<!-- TEST -->
|
||||||
|
@ -107,12 +113,7 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
|
||||||
<artifactId>uri-resolver-manager</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
@ -125,7 +126,7 @@
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>GeoSolutions</id>
|
<id>GeoSolutions</id>
|
||||||
<url>http://maven.research-infrastructures.eu:8081/nexus/content/repositories/geo-solutions/</url>
|
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/geo-solutions-snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>GeoToolkit</id>
|
<id>GeoToolkit</id>
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
package org.gcube.spatial.data.geonetwork;
|
package org.gcube.spatial.data.geonetwork;
|
||||||
|
|
||||||
import it.geosolutions.geonetwork.GNClient;
|
|
||||||
import it.geosolutions.geonetwork.exception.GNLibException;
|
|
||||||
import it.geosolutions.geonetwork.exception.GNServerException;
|
|
||||||
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
|
|
||||||
import it.geosolutions.geonetwork.util.GNPriv;
|
|
||||||
import it.geosolutions.geonetwork.util.GNPrivConfiguration;
|
|
||||||
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
|
||||||
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -23,12 +14,12 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
||||||
import org.gcube.spatial.data.geonetwork.configuration.ConfigurationManager;
|
import org.gcube.spatial.data.geonetwork.configuration.ConfigurationManager;
|
||||||
|
import org.gcube.spatial.data.geonetwork.configuration.ScopeConfigurationUtils;
|
||||||
import org.gcube.spatial.data.geonetwork.configuration.XMLAdapter;
|
import org.gcube.spatial.data.geonetwork.configuration.XMLAdapter;
|
||||||
import org.gcube.spatial.data.geonetwork.extension.GNClientExtension;
|
import org.gcube.spatial.data.geonetwork.extension.GNClientExtension;
|
||||||
|
import org.gcube.spatial.data.geonetwork.extension.ServerAccess;
|
||||||
import org.gcube.spatial.data.geonetwork.model.Account;
|
import org.gcube.spatial.data.geonetwork.model.Account;
|
||||||
import org.gcube.spatial.data.geonetwork.model.Group;
|
import org.gcube.spatial.data.geonetwork.model.Group;
|
||||||
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
||||||
|
@ -48,6 +39,16 @@ import org.jdom.output.Format;
|
||||||
import org.jdom.output.XMLOutputter;
|
import org.jdom.output.XMLOutputter;
|
||||||
import org.opengis.metadata.Metadata;
|
import org.opengis.metadata.Metadata;
|
||||||
|
|
||||||
|
import it.geosolutions.geonetwork.GNClient;
|
||||||
|
import it.geosolutions.geonetwork.exception.GNLibException;
|
||||||
|
import it.geosolutions.geonetwork.exception.GNServerException;
|
||||||
|
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
|
||||||
|
import it.geosolutions.geonetwork.util.GNPriv;
|
||||||
|
import it.geosolutions.geonetwork.util.GNPrivConfiguration;
|
||||||
|
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||||
|
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class GeoNetwork implements GeoNetworkAdministration {
|
public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
|
|
||||||
|
@ -83,7 +84,6 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void login(LoginLevel lvl) throws AuthorizationException, MissingServiceEndpointException, MissingConfigurationException {
|
public void login(LoginLevel lvl) throws AuthorizationException, MissingServiceEndpointException, MissingConfigurationException {
|
||||||
GNClient client=getClient();
|
|
||||||
String user=null;
|
String user=null;
|
||||||
String password=null;
|
String password=null;
|
||||||
switch(lvl){
|
switch(lvl){
|
||||||
|
@ -106,16 +106,41 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.login(user, password);
|
setAccess(new ServerAccess(config.getGeoNetworkEndpoint(),config.getGeoNetworkVersion(),true,password,user,lvl));
|
||||||
currentLoggedLevel=lvl;
|
getClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ServerAccess getAccess(ScopeConfiguration scopeConfig,LoginLevel lvl) throws MissingServiceEndpointException{
|
||||||
|
String user=null;
|
||||||
|
String password=null;
|
||||||
|
switch(lvl){
|
||||||
|
case ADMIN :{ user=config.getAdminAccount().getUser();
|
||||||
|
password=config.getAdminAccount().getPassword();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CKAN : {
|
||||||
|
ScopeConfiguration scopeConfiguration=scopeConfig;
|
||||||
|
Account account=scopeConfiguration.getAccounts().get(Account.Type.CKAN);
|
||||||
|
user=account.getUser();
|
||||||
|
password=account.getPassword();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
ScopeConfiguration scopeConfiguration=scopeConfig;
|
||||||
|
Account account=scopeConfiguration.getAccounts().get(Account.Type.SCOPE);
|
||||||
|
user=account.getUser();
|
||||||
|
password=account.getPassword();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ServerAccess(config.getGeoNetworkEndpoint(),config.getGeoNetworkVersion(),true,password,user,lvl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logout() {
|
public void logout() throws MissingServiceEndpointException {
|
||||||
theClient=null;
|
setAccess(new ServerAccess(config.getGeoNetworkEndpoint(),config.getGeoNetworkVersion()));
|
||||||
currentLoggedLevel=null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,24 +195,24 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setCurrentLoginPrivileges(long metadataId) throws MissingConfigurationException, MissingServiceEndpointException, GNLibException, GNServerException{
|
private void setPrivileges(long metadataId,ScopeConfiguration toUseConfig,LoginLevel toUseLevel) throws MissingConfigurationException, MissingServiceEndpointException, GNLibException, GNServerException{
|
||||||
GNPrivConfiguration cfg=null;
|
GNPrivConfiguration cfg=null;
|
||||||
|
|
||||||
switch(currentLoggedLevel){
|
switch(toUseLevel){
|
||||||
case ADMIN : break;
|
case ADMIN : break;
|
||||||
case CKAN : break;
|
case CKAN : break;
|
||||||
case DEFAULT : {
|
case DEFAULT : {
|
||||||
cfg=new GNPrivConfiguration();
|
cfg=new GNPrivConfiguration();
|
||||||
cfg.addPrivileges(config.getScopeConfiguration().getDefaultGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
cfg.addPrivileges(toUseConfig.getDefaultGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PRIVATE :{
|
case PRIVATE :{
|
||||||
cfg=new GNPrivConfiguration();
|
cfg=new GNPrivConfiguration();
|
||||||
cfg.addPrivileges(config.getScopeConfiguration().getPrivateGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
cfg.addPrivileges(toUseConfig.getPrivateGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
||||||
break;
|
break;
|
||||||
}case SCOPE : {
|
}case SCOPE : {
|
||||||
cfg=new GNPrivConfiguration();
|
cfg=new GNPrivConfiguration();
|
||||||
cfg.addPrivileges(config.getScopeConfiguration().getPublicGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
cfg.addPrivileges(toUseConfig.getPublicGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,15 +222,17 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.spatial.data.geonetwork.GeoNetworkReader#insertMetadata(it.geosolutions.geonetwork.util.GNInsertConfiguration, java.io.File)
|
* @see org.gcube.spatial.data.geonetwork.GeoNetworkReader#insertMetadata(it.geosolutions.geonetwork.util.GNInsertConfiguration, java.io.File)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long insertMetadata(GNInsertConfiguration configuration,File metadataFile) throws GNLibException, GNServerException, MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException{
|
public long insertMetadata(GNInsertConfiguration configuration,File metadataFile) throws GNLibException, GNServerException, MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException{
|
||||||
checkPublishingConfiguration(configuration);
|
checkPublishingConfiguration(configuration,config.getScopeConfiguration());
|
||||||
GNClient client=getClient();
|
GNClient client=getClient();
|
||||||
long toReturn=client.insertMetadata(configuration, metadataFile);
|
long toReturn=client.insertMetadata(configuration, metadataFile);
|
||||||
setCurrentLoginPrivileges(toReturn);
|
setPrivileges(toReturn,config.getScopeConfiguration(),getCurrentLoginLevel());
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -223,7 +250,7 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
public long insertMetadata(File requestFile) throws GNLibException, GNServerException, MissingServiceEndpointException, MissingConfigurationException{
|
public long insertMetadata(File requestFile) throws GNLibException, GNServerException, MissingServiceEndpointException, MissingConfigurationException{
|
||||||
GNClient client=getClient();
|
GNClient client=getClient();
|
||||||
long toReturn= client.insertRequest(requestFile);
|
long toReturn= client.insertRequest(requestFile);
|
||||||
setCurrentLoginPrivileges(toReturn);
|
setPrivileges(toReturn,config.getScopeConfiguration(),getCurrentLoginLevel());
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -235,6 +262,96 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//**************** INSERT AND PROMOTE
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insertAndPromoteMetadata(File requestFile)
|
||||||
|
throws GNLibException, GNServerException, MissingServiceEndpointException, MissingConfigurationException {
|
||||||
|
LoginLevel currentLevel=getCurrentLoginLevel();
|
||||||
|
|
||||||
|
// get parent configuration set access to GN
|
||||||
|
ScopeConfiguration parentConfig=getParentConfiguration();
|
||||||
|
ServerAccess parentAccess=getAccess(parentConfig, LoginLevel.DEFAULT);
|
||||||
|
setAccess(parentAccess);
|
||||||
|
GNClient client=getClient();
|
||||||
|
|
||||||
|
// actually publish as promoted access
|
||||||
|
long toReturn= client.insertRequest(requestFile);
|
||||||
|
setPrivileges(toReturn,parentConfig,LoginLevel.DEFAULT);
|
||||||
|
|
||||||
|
// restore logged level
|
||||||
|
try{
|
||||||
|
login(currentLevel);
|
||||||
|
}catch(AuthorizationException e){
|
||||||
|
throw new GNLibException("Unabel to restore level. This should not happen.",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insertAndPromoteMetadata(GNInsertConfiguration configuration, File metadataFile)
|
||||||
|
throws GNLibException, GNServerException, MissingServiceEndpointException, MissingConfigurationException,
|
||||||
|
InvalidInsertConfigurationException, AuthorizationException {
|
||||||
|
|
||||||
|
LoginLevel currentLevel=getCurrentLoginLevel();
|
||||||
|
|
||||||
|
// get parent configuration set access to GN
|
||||||
|
ScopeConfiguration parentConfig=getParentConfiguration();
|
||||||
|
ServerAccess parentAccess=getAccess(parentConfig, LoginLevel.DEFAULT);
|
||||||
|
setAccess(parentAccess);
|
||||||
|
|
||||||
|
GNInsertConfiguration toUseConfig=null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
toUseConfig=getUserConfiguration(configuration.getCategory(), configuration.getStyleSheet(),parentConfig,LoginLevel.DEFAULT);
|
||||||
|
}catch(GeoNetworkException e){
|
||||||
|
throw new GNLibException("Unabel to get publish configuration ",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
checkPublishingConfiguration(toUseConfig,parentConfig);
|
||||||
|
GNClient client=getClient();
|
||||||
|
|
||||||
|
|
||||||
|
// actually publish
|
||||||
|
long toReturn=client.insertMetadata(toUseConfig, metadataFile);
|
||||||
|
setPrivileges(toReturn,parentConfig,LoginLevel.DEFAULT);
|
||||||
|
|
||||||
|
// restore logged level
|
||||||
|
try{
|
||||||
|
login(currentLevel);
|
||||||
|
}catch(AuthorizationException e){
|
||||||
|
throw new GNLibException("Unabel to restore level. This should not happen.",e);
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insertAndPromoteMetadata(GNInsertConfiguration configuration, Metadata meta)
|
||||||
|
throws GNLibException, GNServerException, IOException, JAXBException, MissingServiceEndpointException,
|
||||||
|
MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException {
|
||||||
|
return insertAndPromoteMetadata(configuration, meta2File(meta,registeredXMLAdapters));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insertAndPromoteMetadata(Metadata meta) throws GNLibException, GNServerException, IOException,
|
||||||
|
JAXBException, MissingServiceEndpointException, MissingConfigurationException {
|
||||||
|
return insertAndPromoteMetadata(meta2File(meta, registeredXMLAdapters));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ScopeConfiguration getParentConfiguration() throws MissingConfigurationException, MissingServiceEndpointException{
|
||||||
|
ArrayList<String> parent=ScopeUtils.getParentScopes();
|
||||||
|
return ScopeConfigurationUtils.getByScope(config.getExistingConfigurations(),parent.get(parent.size()-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.spatial.data.geonetwork.GeoNetworkReader#updateMetadata(long, java.io.File)
|
* @see org.gcube.spatial.data.geonetwork.GeoNetworkReader#updateMetadata(long, java.io.File)
|
||||||
*/
|
*/
|
||||||
|
@ -243,6 +360,8 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
GNClient client=getClient();
|
GNClient client=getClient();
|
||||||
client.updateMetadata(id, metadataFile);
|
client.updateMetadata(id, metadataFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.spatial.data.geonetwork.GeoNetworkReader#updateMetadata(long, org.opengis.metadata.Metadata)
|
* @see org.gcube.spatial.data.geonetwork.GeoNetworkReader#updateMetadata(long, org.opengis.metadata.Metadata)
|
||||||
*/
|
*/
|
||||||
|
@ -265,24 +384,27 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GNInsertConfiguration getCurrentUserConfiguration(String category,String styleSheet) throws AuthorizationException, GeoNetworkException {
|
public GNInsertConfiguration getCurrentUserConfiguration(String category,String styleSheet) throws AuthorizationException, GeoNetworkException {
|
||||||
if(currentLoggedLevel==null) throw new AuthorizationException("Client is not authenticated, please use Login before publishing");
|
if(getCurrentLoginLevel()==null) throw new AuthorizationException("Client is not authenticated, please use Login before publishing");
|
||||||
ScopeConfiguration scopeConfig=config.getScopeConfiguration();
|
return getUserConfiguration(category, styleSheet, config.getScopeConfiguration(), getCurrentLoginLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GNInsertConfiguration getUserConfiguration(String category,String styleSheet, ScopeConfiguration configuration,LoginLevel lvl) throws AuthorizationException, GeoNetworkException {
|
||||||
Integer configuredGroup=null;
|
Integer configuredGroup=null;
|
||||||
switch(currentLoggedLevel){
|
switch(getCurrentLoginLevel()){
|
||||||
case CKAN : throw new AuthorizationException("Current logged level "+currentLoggedLevel+"is read-only");
|
case CKAN : throw new AuthorizationException("Current logged level "+getCurrentLoginLevel()+"is read-only");
|
||||||
case ADMIN : throw new GeoNetworkException("Current logged level is Admin, unable to determine publihing configuration");
|
case ADMIN : throw new GeoNetworkException("Current logged level is Admin, unable to determine publihing configuration");
|
||||||
case DEFAULT : configuredGroup=scopeConfig.getDefaultGroup();
|
case DEFAULT : configuredGroup=configuration.getDefaultGroup();
|
||||||
break;
|
break;
|
||||||
case PRIVATE : configuredGroup=scopeConfig.getPrivateGroup();
|
case PRIVATE : configuredGroup=configuration.getPrivateGroup();
|
||||||
break;
|
break;
|
||||||
case SCOPE : configuredGroup=scopeConfig.getPublicGroup();
|
case SCOPE : configuredGroup=configuration.getPublicGroup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GNInsertConfiguration(configuredGroup+"", category, styleSheet, true);
|
return new GNInsertConfiguration(configuredGroup+"", category, styleSheet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//******************************* ADMIN ********************************* //
|
//******************************* ADMIN ********************************* //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -299,13 +421,13 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAvailableOwnershipTransfer(Integer userId)
|
public String getAvailableOwnershipTransfer(Integer userId)
|
||||||
throws GNServerException, MissingServiceEndpointException {
|
throws GNServerException, MissingServiceEndpointException, GNLibException {
|
||||||
return getClient().getPossibleOwnershipTransfer(userId);
|
return getClient().getPossibleOwnershipTransfer(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMetadataOwners() throws GNServerException,
|
public String getMetadataOwners() throws GNServerException,
|
||||||
MissingServiceEndpointException {
|
MissingServiceEndpointException, GNLibException {
|
||||||
return getClient().getMetadataOwners();
|
return getClient().getMetadataOwners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,17 +454,18 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignOwnership(List<Long> toTransferIds,Integer targetUserId, Integer targetGroupId) throws AuthorizationException, GNServerException, MissingServiceEndpointException {
|
public void assignOwnership(List<Long> toTransferIds,Integer targetUserId, Integer targetGroupId) throws AuthorizationException, GNServerException, MissingServiceEndpointException, GNLibException {
|
||||||
if(this.currentLoggedLevel==null||(!this.currentLoggedLevel.equals(LoginLevel.ADMIN))) throw new AuthorizationException("You need to login as Admin to massively transfer ownership");
|
if(getCurrentLoginLevel()==null||(!getCurrentLoginLevel().equals(LoginLevel.ADMIN))) throw new AuthorizationException("You need to login as Admin to massively transfer ownership");
|
||||||
getClient().assignOwnership(toTransferIds, targetUserId, targetGroupId);
|
getClient().assignOwnership(toTransferIds, targetUserId, targetGroupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transferOwnership(Integer sourceUserId, Integer sourceGroupId,
|
public void transferOwnership(Integer sourceUserId, Integer sourceGroupId,
|
||||||
Integer targetUserId, Integer targetGroupId)
|
Integer targetUserId, Integer targetGroupId)
|
||||||
throws GNServerException, MissingServiceEndpointException {
|
throws GNServerException, MissingServiceEndpointException, GNLibException {
|
||||||
getClient().transferOwnership(sourceUserId, sourceGroupId, targetUserId, targetGroupId);
|
getClient().transferOwnership(sourceUserId, sourceGroupId, targetUserId, targetGroupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScopeConfiguration createCurrentScopeConfiguration() throws GNLibException, GNServerException, MissingServiceEndpointException {
|
private ScopeConfiguration createCurrentScopeConfiguration() throws GNLibException, GNServerException, MissingServiceEndpointException {
|
||||||
try{
|
try{
|
||||||
String currentScopeName=ScopeUtils.getCurrentScopeName();
|
String currentScopeName=ScopeUtils.getCurrentScopeName();
|
||||||
|
@ -461,36 +584,50 @@ public class GeoNetwork implements GeoNetworkAdministration {
|
||||||
|
|
||||||
private GNClientExtension theClient=null;
|
private GNClientExtension theClient=null;
|
||||||
|
|
||||||
|
private ServerAccess currentAccess=null;
|
||||||
|
|
||||||
|
private void setAccess(ServerAccess access){
|
||||||
|
this.currentAccess=access;
|
||||||
|
theClient=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServerAccess getCurrentAccess() throws MissingServiceEndpointException{
|
||||||
|
if(currentAccess==null) currentAccess=new ServerAccess(config.getGeoNetworkEndpoint(),config.getGeoNetworkVersion());
|
||||||
|
return currentAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoginLevel getCurrentLoginLevel() throws MissingServiceEndpointException{
|
||||||
|
return getCurrentAccess().getLoggedLevel();
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized GNClientExtension getClient() throws MissingServiceEndpointException{
|
private synchronized GNClientExtension getClient() throws MissingServiceEndpointException{
|
||||||
if(theClient==null)
|
if(theClient==null)
|
||||||
theClient = new GNClientExtension(config.getGeoNetworkEndpoint());
|
theClient = new GNClientExtension(getCurrentAccess());
|
||||||
return theClient;
|
return theClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LoginLevel currentLoggedLevel=null;
|
|
||||||
|
|
||||||
private void checkPublishingConfiguration(GNInsertConfiguration configuration) throws AuthorizationException, InvalidInsertConfigurationException, MissingConfigurationException, MissingServiceEndpointException{
|
private void checkPublishingConfiguration(GNInsertConfiguration configuration,ScopeConfiguration toUseConfig) throws AuthorizationException, InvalidInsertConfigurationException, MissingConfigurationException, MissingServiceEndpointException{
|
||||||
if(currentLoggedLevel==null) throw new AuthorizationException("Client is not authenticated, please use Login before publishing");
|
if(getCurrentLoginLevel()==null) throw new AuthorizationException("Client is not authenticated, please use Login before publishing");
|
||||||
if(!configuration.getValidate()) throw new InvalidInsertConfigurationException("Validate option is mandatory");
|
if(!configuration.getValidate()) throw new InvalidInsertConfigurationException("Validate option is mandatory");
|
||||||
|
|
||||||
// CHECK GROUP
|
// CHECK GROUP
|
||||||
Integer targetGroup=Integer.parseInt(configuration.getGroup());
|
Integer targetGroup=Integer.parseInt(configuration.getGroup());
|
||||||
Integer configuredGroup=null;
|
Integer configuredGroup=null;
|
||||||
ScopeConfiguration scopeConfig=config.getScopeConfiguration();
|
|
||||||
|
|
||||||
|
|
||||||
switch(currentLoggedLevel){
|
switch(getCurrentLoginLevel()){
|
||||||
case CKAN : throw new AuthorizationException("Current logged level "+currentLoggedLevel+"is read-only");
|
case CKAN : throw new AuthorizationException("Current logged level "+getCurrentLoginLevel()+"is read-only");
|
||||||
case ADMIN : break;
|
case ADMIN : break;
|
||||||
case DEFAULT : configuredGroup=scopeConfig.getDefaultGroup();
|
case DEFAULT : configuredGroup=toUseConfig.getDefaultGroup();
|
||||||
break;
|
break;
|
||||||
case PRIVATE : configuredGroup=scopeConfig.getPrivateGroup();
|
case PRIVATE : configuredGroup=toUseConfig.getPrivateGroup();
|
||||||
break;
|
break;
|
||||||
case SCOPE : configuredGroup=scopeConfig.getPublicGroup();
|
case SCOPE : configuredGroup=toUseConfig.getPublicGroup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (configuredGroup!=null&&(!targetGroup.equals(configuredGroup)))
|
if (configuredGroup!=null&&(!targetGroup.equals(configuredGroup)))
|
||||||
throw new InvalidInsertConfigurationException(String.format("Invalid logged level %s and specified group %d, expected %d", currentLoggedLevel,targetGroup,configuredGroup));
|
throw new InvalidInsertConfigurationException(String.format("Invalid logged level %s and specified group %d, expected %d", getCurrentLoginLevel(),targetGroup,configuredGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ public interface GeoNetworkAdministration extends GeoNetworkPublisher {
|
||||||
public void createUsers(String username, String password, Profile profile,
|
public void createUsers(String username, String password, Profile profile,
|
||||||
Collection<Integer> groups) throws GNLibException,
|
Collection<Integer> groups) throws GNLibException,
|
||||||
GNServerException, MissingServiceEndpointException;
|
GNServerException, MissingServiceEndpointException;
|
||||||
public void assignOwnership(List<Long> toTransferIds,Integer targetUserId, Integer targetGroupId) throws AuthorizationException, GNServerException, MissingServiceEndpointException;
|
public void assignOwnership(List<Long> toTransferIds,Integer targetUserId, Integer targetGroupId) throws AuthorizationException, GNServerException, MissingServiceEndpointException, GNLibException;
|
||||||
|
|
||||||
public String getAvailableOwnershipTransfer(Integer userId)throws GNServerException, MissingServiceEndpointException;
|
public String getAvailableOwnershipTransfer(Integer userId)throws GNServerException, MissingServiceEndpointException, GNLibException;
|
||||||
public String getMetadataOwners()throws GNServerException, MissingServiceEndpointException;
|
public String getMetadataOwners()throws GNServerException, MissingServiceEndpointException, GNLibException;
|
||||||
public void transferOwnership(Integer sourceUserId,Integer sourceGroupId,Integer targetUserId,Integer targetGroupId) throws GNServerException, MissingServiceEndpointException;
|
public void transferOwnership(Integer sourceUserId,Integer sourceGroupId,Integer targetUserId,Integer targetGroupId) throws GNServerException, MissingServiceEndpointException, GNLibException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,21 @@ public interface GeoNetworkPublisher extends GeoNetworkReader {
|
||||||
public void setPrivileges(long metadataId, GNPrivConfiguration cfg)
|
public void setPrivileges(long metadataId, GNPrivConfiguration cfg)
|
||||||
throws GNLibException, GNServerException,MissingServiceEndpointException;
|
throws GNLibException, GNServerException,MissingServiceEndpointException;
|
||||||
|
|
||||||
public long insertMetadata(GNInsertConfiguration configuration,
|
public long insertMetadata(GNInsertConfiguration configuration,File metadataFile) throws GNLibException, GNServerException,MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException;
|
||||||
File metadataFile) throws GNLibException, GNServerException,MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException;
|
|
||||||
|
|
||||||
public long insertMetadata(GNInsertConfiguration configuration,
|
public long insertMetadata(GNInsertConfiguration configuration,Metadata meta) throws GNLibException, GNServerException,IOException, JAXBException,MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException;
|
||||||
Metadata meta) throws GNLibException, GNServerException,
|
|
||||||
IOException, JAXBException,MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException;
|
|
||||||
|
|
||||||
public long insertMetadata(File requestFile) throws GNLibException,
|
public long insertMetadata(File requestFile) throws GNLibException, GNServerException,MissingServiceEndpointException, MissingConfigurationException;
|
||||||
GNServerException,MissingServiceEndpointException, MissingConfigurationException;
|
|
||||||
|
|
||||||
public long insertMetadata(Metadata meta) throws GNLibException,
|
public long insertMetadata(Metadata meta) throws GNLibException,GNServerException, IOException, JAXBException,MissingServiceEndpointException, MissingConfigurationException;
|
||||||
GNServerException, IOException,
|
|
||||||
JAXBException,MissingServiceEndpointException, MissingConfigurationException;
|
public long insertAndPromoteMetadata(GNInsertConfiguration configuration,File metadataFile) throws GNLibException, GNServerException,MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException;
|
||||||
|
|
||||||
|
public long insertAndPromoteMetadata(GNInsertConfiguration configuration,Metadata meta) throws GNLibException, GNServerException,IOException, JAXBException,MissingServiceEndpointException, MissingConfigurationException, InvalidInsertConfigurationException, AuthorizationException;
|
||||||
|
|
||||||
|
public long insertAndPromoteMetadata(File requestFile) throws GNLibException, GNServerException,MissingServiceEndpointException, MissingConfigurationException;
|
||||||
|
|
||||||
|
public long insertAndPromoteMetadata(Metadata meta) throws GNLibException,GNServerException, IOException, JAXBException,MissingServiceEndpointException, MissingConfigurationException;
|
||||||
|
|
||||||
|
|
||||||
public void updateMetadata(long id, File metadataFile)
|
public void updateMetadata(long id, File metadataFile)
|
||||||
|
|
|
@ -36,5 +36,5 @@ public interface GeoNetworkReader {
|
||||||
|
|
||||||
public void login(LoginLevel level)throws AuthorizationException,MissingServiceEndpointException, MissingConfigurationException;
|
public void login(LoginLevel level)throws AuthorizationException,MissingServiceEndpointException, MissingConfigurationException;
|
||||||
|
|
||||||
public void logout();
|
public void logout() throws MissingServiceEndpointException;
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ package org.gcube.spatial.data.geonetwork.configuration;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.gcube.spatial.data.geonetwork.extension.ServerAccess.Version;
|
||||||
import org.gcube.spatial.data.geonetwork.model.Account;
|
import org.gcube.spatial.data.geonetwork.model.Account;
|
||||||
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
||||||
import org.gcube.spatial.data.geonetwork.model.faults.EncryptionException;
|
import org.gcube.spatial.data.geonetwork.model.faults.EncryptionException;
|
||||||
|
@ -12,6 +13,8 @@ public interface Configuration {
|
||||||
|
|
||||||
public String getGeoNetworkEndpoint()throws MissingServiceEndpointException;
|
public String getGeoNetworkEndpoint()throws MissingServiceEndpointException;
|
||||||
|
|
||||||
|
public Version getGeoNetworkVersion()throws MissingServiceEndpointException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return current scope configuration
|
* @return current scope configuration
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
|
import org.gcube.spatial.data.geonetwork.extension.ServerAccess.Version;
|
||||||
import org.gcube.spatial.data.geonetwork.model.Account;
|
import org.gcube.spatial.data.geonetwork.model.Account;
|
||||||
import org.gcube.spatial.data.geonetwork.model.Account.Type;
|
import org.gcube.spatial.data.geonetwork.model.Account.Type;
|
||||||
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
||||||
|
@ -98,6 +99,14 @@ public class DefaultConfiguration implements Configuration {
|
||||||
|
|
||||||
//**************************** INTERFACE IMPLEMENTATION
|
//**************************** INTERFACE IMPLEMENTATION
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Version getGeoNetworkVersion() throws MissingServiceEndpointException {
|
||||||
|
short version=getISServiceEndpoint().profile().platform().version();
|
||||||
|
if(version<3) return Version.DUE;
|
||||||
|
else return Version.TRE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Account getAdminAccount() throws MissingServiceEndpointException {
|
public Account getAdminAccount() throws MissingServiceEndpointException {
|
||||||
loadFromIs();
|
loadFromIs();
|
||||||
|
@ -141,7 +150,7 @@ public class DefaultConfiguration implements Configuration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ScopeConfiguration> getParentScopesConfiguration() throws MissingServiceEndpointException{
|
public Set<ScopeConfiguration> getParentScopesConfiguration() throws MissingServiceEndpointException{
|
||||||
Set<String> parentScopes=ScopeUtils.getParentScopes();
|
List<String> parentScopes=ScopeUtils.getParentScopes();
|
||||||
HashSet<ScopeConfiguration> toReturn=new HashSet<>();
|
HashSet<ScopeConfiguration> toReturn=new HashSet<>();
|
||||||
|
|
||||||
if(!parentScopes.isEmpty()) {// in order to avoid loading from IS
|
if(!parentScopes.isEmpty()) {// in order to avoid loading from IS
|
||||||
|
@ -161,6 +170,7 @@ public class DefaultConfiguration implements Configuration {
|
||||||
|
|
||||||
private boolean loaded=false;
|
private boolean loaded=false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loads configuration from Is
|
* loads configuration from Is
|
||||||
* @throws MissingServiceEndpointException
|
* @throws MissingServiceEndpointException
|
||||||
|
@ -188,16 +198,6 @@ public class DefaultConfiguration implements Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse endpoint to load all configurations
|
|
||||||
*
|
|
||||||
* @param toUseEndpoint
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// protected Set<ScopeConfiguration> loadExisting(ServiceEndpoint toUseEndpoint) throws MissingServiceEndpointException{
|
|
||||||
// AccessPoint point=getTheRightAccessPoint(toUseEndpoint);
|
|
||||||
// return ScopeConfigurationUtils.fromMap(point.propertyMap(), props);
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected AccessPoint getIsAccessPoint() throws MissingServiceEndpointException{
|
protected AccessPoint getIsAccessPoint() throws MissingServiceEndpointException{
|
||||||
log.debug("Querying IS for Geonetwork information..");
|
log.debug("Querying IS for Geonetwork information..");
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ScopeConfigurationUtils {
|
||||||
return new ScopeConfiguration(assignedScope, publicGroup, privateGroup, accounts, defaultGroup);
|
return new ScopeConfiguration(assignedScope, publicGroup, privateGroup, accounts, defaultGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ScopeConfiguration getByScope(Set<ScopeConfiguration> existing, String scope) throws MissingConfigurationException{
|
public static ScopeConfiguration getByScope(Set<ScopeConfiguration> existing, String scope) throws MissingConfigurationException{
|
||||||
for(ScopeConfiguration configuration : existing)
|
for(ScopeConfiguration configuration : existing)
|
||||||
if(configuration.getAssignedScope().equals(scope)) return configuration;
|
if(configuration.getAssignedScope().equals(scope)) return configuration;
|
||||||
throw new MissingConfigurationException("Scope "+scope+" has no configuration");
|
throw new MissingConfigurationException("Scope "+scope+" has no configuration");
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package org.gcube.spatial.data.geonetwork.extension;
|
package org.gcube.spatial.data.geonetwork.extension;
|
||||||
|
|
||||||
import it.geosolutions.geonetwork.GNClient;
|
import java.io.File;
|
||||||
import it.geosolutions.geonetwork.exception.GNLibException;
|
|
||||||
import it.geosolutions.geonetwork.exception.GNServerException;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -13,64 +10,162 @@ import org.gcube.spatial.data.geonetwork.model.User;
|
||||||
import org.gcube.spatial.data.geonetwork.model.User.Profile;
|
import org.gcube.spatial.data.geonetwork.model.User.Profile;
|
||||||
import org.gcube.spatial.data.geonetwork.utils.GroupUtils;
|
import org.gcube.spatial.data.geonetwork.utils.GroupUtils;
|
||||||
import org.gcube.spatial.data.geonetwork.utils.UserUtils;
|
import org.gcube.spatial.data.geonetwork.utils.UserUtils;
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
public class GNClientExtension extends GNClient {
|
import it.geosolutions.geonetwork.GN26Client;
|
||||||
|
import it.geosolutions.geonetwork.GN3Client;
|
||||||
|
import it.geosolutions.geonetwork.GNClient;
|
||||||
|
import it.geosolutions.geonetwork.exception.GNLibException;
|
||||||
|
import it.geosolutions.geonetwork.exception.GNServerException;
|
||||||
|
import it.geosolutions.geonetwork.op.gn3.GN3MetadataGetInfo.MetadataInfo;
|
||||||
|
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
|
||||||
|
import it.geosolutions.geonetwork.util.GNPrivConfiguration;
|
||||||
|
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||||
|
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||||
|
import it.geosolutions.geonetwork.util.HTTPUtils;
|
||||||
|
|
||||||
private String gnServiceURL;
|
public class GNClientExtension implements GNClient {
|
||||||
|
|
||||||
public GNClientExtension(String serviceURL) {
|
private GNClient client;
|
||||||
super(serviceURL);
|
|
||||||
this.gnServiceURL=serviceURL;
|
private ServerAccess access;
|
||||||
|
|
||||||
|
public GNClientExtension(ServerAccess access) {
|
||||||
|
this.access=access;
|
||||||
|
switch(access.getVersion()){
|
||||||
|
case DUE : {
|
||||||
|
client=access.isLogin()?new GN26Client(access.getGnServiceURL(), access.getUser(), access.getPassword()):new GN26Client(access.getGnServiceURL());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default : {
|
||||||
|
client=access.isLogin()?new GN3Client(access.getGnServiceURL(), access.getUser(), access.getPassword()):new GN3Client(access.getGnServiceURL());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createGroup(String name, String description, String mail)throws GNLibException, GNServerException {
|
public void createGroup(String name, String description, String mail)throws GNLibException, GNServerException {
|
||||||
GNMetadataAdminExtension.createGroup(getConnection(), gnServiceURL, name, description, mail);
|
GNMetadataAdminExtension.createGroup(getConnection(), access.getGnServiceURL(), name, description, mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Set<Group> getGroups() throws GNLibException, GNServerException{
|
public Set<Group> getGroups() throws GNLibException, GNServerException{
|
||||||
return GroupUtils.parseGroupXMLResponse(GNMetadataAdminExtension.getGroups(getConnection(), gnServiceURL));
|
return GroupUtils.parseGroupXMLResponse(GNMetadataAdminExtension.getGroups(getConnection(), access.getGnServiceURL()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Set<User> getUsers() throws GNLibException, GNServerException{
|
public Set<User> getUsers() throws GNLibException, GNServerException{
|
||||||
return UserUtils.parseUserXMLResponse(GNMetadataAdminExtension.getUsers(getConnection(), gnServiceURL));
|
return UserUtils.parseUserXMLResponse(GNMetadataAdminExtension.getUsers(getConnection(), access.getGnServiceURL()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createUser(String name, String password, Profile profile, Collection<Integer> groups) throws GNServerException, GNLibException{
|
public void createUser(String name, String password, Profile profile, Collection<Integer> groups) throws GNServerException, GNLibException{
|
||||||
GNMetadataAdminExtension.createUser(getConnection(), gnServiceURL, name, password, profile, groups);
|
GNMetadataAdminExtension.createUser(getConnection(), access.getGnServiceURL(), name, password, profile, groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editUser(User toAdd, Collection<Integer> groups) throws GNServerException,GNLibException{
|
public void editUser(User toAdd, Collection<Integer> groups) throws GNServerException,GNLibException{
|
||||||
Set<Integer> alreadyAddedGroups=getGroupsByUser(toAdd.getId());
|
Set<Integer> alreadyAddedGroups=getGroupsByUser(toAdd.getId());
|
||||||
alreadyAddedGroups.addAll(groups);
|
alreadyAddedGroups.addAll(groups);
|
||||||
GNMetadataAdminExtension.editUser(getConnection(), gnServiceURL, toAdd, alreadyAddedGroups);
|
GNMetadataAdminExtension.editUser(getConnection(), access.getGnServiceURL(), toAdd, alreadyAddedGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getGroupsByUser(Integer userId) throws GNLibException, GNServerException{
|
public Set<Integer> getGroupsByUser(Integer userId) throws GNLibException, GNServerException{
|
||||||
return UserUtils.parseGroupsByUserResponse(GNMetadataAdminExtension.getUserGroupd(getConnection(), gnServiceURL, userId));
|
return UserUtils.parseGroupsByUserResponse(GNMetadataAdminExtension.getUserGroupd(getConnection(), access.getGnServiceURL(), userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assignOwnership(List<Long> toTransferIds,Integer targetUserId,Integer targetGroupId) throws GNServerException{
|
public void assignOwnership(List<Long> toTransferIds,Integer targetUserId,Integer targetGroupId) throws GNServerException, GNLibException{
|
||||||
try{
|
try{
|
||||||
GNMetadataAdminExtension.selectMeta(getConnection(), gnServiceURL, toTransferIds);
|
GNMetadataAdminExtension.selectMeta(getConnection(), access.getGnServiceURL(), toTransferIds);
|
||||||
GNMetadataAdminExtension.assignMassiveOwnership(getConnection(), gnServiceURL, targetUserId, targetGroupId);
|
GNMetadataAdminExtension.assignMassiveOwnership(getConnection(), access.getGnServiceURL(), targetUserId, targetGroupId);
|
||||||
}finally{
|
}finally{
|
||||||
GNMetadataAdminExtension.clearMetaSelection(getConnection(), gnServiceURL);
|
GNMetadataAdminExtension.clearMetaSelection(getConnection(), access.getGnServiceURL());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPossibleOwnershipTransfer(Integer userId) throws GNServerException{
|
public String getPossibleOwnershipTransfer(Integer userId) throws GNServerException, GNLibException{
|
||||||
return GNMetadataAdminExtension.allowedOwnershipTransfer(getConnection(), gnServiceURL, userId);
|
return GNMetadataAdminExtension.allowedOwnershipTransfer(getConnection(), access.getGnServiceURL(), userId);
|
||||||
}
|
}
|
||||||
public String getMetadataOwners() throws GNServerException{
|
public String getMetadataOwners() throws GNServerException, GNLibException{
|
||||||
return GNMetadataAdminExtension.metadataOwners(getConnection(), gnServiceURL);
|
return GNMetadataAdminExtension.metadataOwners(getConnection(), access.getGnServiceURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferOwnership(Integer sourceUserId,Integer sourceGroupId,Integer targetUserId,Integer targetGroupId) throws GNServerException{
|
public void transferOwnership(Integer sourceUserId,Integer sourceGroupId,Integer targetUserId,Integer targetGroupId) throws GNServerException, GNLibException{
|
||||||
GNMetadataAdminExtension.transferOwnership(getConnection(), gnServiceURL, sourceUserId, sourceGroupId, targetUserId, targetGroupId);
|
GNMetadataAdminExtension.transferOwnership(getConnection(), access.getGnServiceURL(), sourceUserId, sourceGroupId, targetUserId, targetGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//***************************** OVERRIDES
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ping() {
|
||||||
|
return client.ping();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insertMetadata(GNInsertConfiguration cfg, File metadataFile) throws GNLibException, GNServerException {
|
||||||
|
return client.insertMetadata(cfg, metadataFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long insertRequest(File requestFile) throws GNLibException, GNServerException {
|
||||||
|
return client.insertRequest(requestFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPrivileges(long metadataId, GNPrivConfiguration cfg) throws GNLibException, GNServerException {
|
||||||
|
client.setPrivileges(metadataId, cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GNSearchResponse search(GNSearchRequest searchRequest) throws GNLibException, GNServerException {
|
||||||
|
return client.search(searchRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GNSearchResponse search(File fileRequest) throws GNLibException, GNServerException {
|
||||||
|
return client.search(fileRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Element get(Long id) throws GNLibException, GNServerException {
|
||||||
|
return client.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Element get(String uuid) throws GNLibException, GNServerException {
|
||||||
|
return client.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteMetadata(long id) throws GNLibException, GNServerException {
|
||||||
|
client.deleteMetadata(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMetadata(long id, File metadataFile) throws GNLibException, GNServerException {
|
||||||
|
client.updateMetadata(id, metadataFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMetadata(long id, File metadataFile, String encoding) throws GNLibException, GNServerException {
|
||||||
|
client.updateMetadata(id, metadataFile,encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetadataInfo getInfo(Long id) throws GNLibException, GNServerException {
|
||||||
|
return client.getInfo(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetadataInfo getInfo(String uuid) throws GNLibException, GNServerException {
|
||||||
|
return client.getInfo(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HTTPUtils getConnection() throws GNLibException {
|
||||||
|
return client.getConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package org.gcube.spatial.data.geonetwork.extension;
|
||||||
|
|
||||||
|
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ServerAccess{
|
||||||
|
|
||||||
|
public static enum Version{
|
||||||
|
TRE,DUE
|
||||||
|
}
|
||||||
|
|
||||||
|
private String gnServiceURL;
|
||||||
|
private Version version;
|
||||||
|
private boolean login=false;
|
||||||
|
private String password;
|
||||||
|
private String user;
|
||||||
|
private LoginLevel loggedLevel=null;
|
||||||
|
public ServerAccess(String gnServiceURL, Version version) {
|
||||||
|
super();
|
||||||
|
this.gnServiceURL = gnServiceURL;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package org.gcube.spatial.data.geonetwork.iso;
|
||||||
|
|
||||||
|
public class BoundingBox {
|
||||||
|
|
||||||
|
public static final BoundingBox WORLD_EXTENT=new BoundingBox(90, -90, 180, -180);
|
||||||
|
|
||||||
|
private double N=90;
|
||||||
|
private double S=-90;
|
||||||
|
private double W=180;
|
||||||
|
private double E=-180;
|
||||||
|
|
||||||
|
public BoundingBox(double n, double s, double w, double e) {
|
||||||
|
super();
|
||||||
|
N = n;
|
||||||
|
S = s;
|
||||||
|
W = w;
|
||||||
|
E = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assumed order is E, S, W, N
|
||||||
|
*
|
||||||
|
* @param bbox
|
||||||
|
*/
|
||||||
|
public BoundingBox(double[] bbox) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double getN() {
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setN(double n) {
|
||||||
|
N = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getS() {
|
||||||
|
return S;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setS(double s) {
|
||||||
|
S = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getW() {
|
||||||
|
return W;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setW(double w) {
|
||||||
|
W = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getE() {
|
||||||
|
return E;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setE(double e) {
|
||||||
|
E = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return E, S, W, N
|
||||||
|
*/
|
||||||
|
public double[] toArray(){
|
||||||
|
return new double[]{
|
||||||
|
E,S,W,N
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return E, S, W, N
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return E+","+S+","+W+","+N;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -5,11 +5,17 @@ import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException;
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
|
||||||
|
import org.gcube.spatial.data.geonetwork.utils.ScopeUtils;
|
||||||
import org.geotoolkit.metadata.iso.DefaultMetadata;
|
import org.geotoolkit.metadata.iso.DefaultMetadata;
|
||||||
import org.geotoolkit.metadata.iso.citation.DefaultAddress;
|
import org.geotoolkit.metadata.iso.citation.DefaultAddress;
|
||||||
import org.geotoolkit.metadata.iso.citation.DefaultCitation;
|
import org.geotoolkit.metadata.iso.citation.DefaultCitation;
|
||||||
|
@ -59,6 +65,7 @@ public class ISOMetadataFactory {
|
||||||
distributorAddress.getElectronicMailAddresses().add(params.getConfig().getDistributorEMail());
|
distributorAddress.getElectronicMailAddresses().add(params.getConfig().getDistributorEMail());
|
||||||
distributorContact.setAddress(distributorAddress);
|
distributorContact.setAddress(distributorAddress);
|
||||||
DefaultOnlineResource distributorOnline=new DefaultOnlineResource (new URI(params.getConfig().getDistributorSite()));
|
DefaultOnlineResource distributorOnline=new DefaultOnlineResource (new URI(params.getConfig().getDistributorSite()));
|
||||||
|
distributorOnline.setName(params.getConfig().getProjectName()+" site.");
|
||||||
distributorOnline.setProtocol(params.getConfig().getHttpProtocolDeclaration());
|
distributorOnline.setProtocol(params.getConfig().getHttpProtocolDeclaration());
|
||||||
distributorContact.setOnlineResource(distributorOnline);
|
distributorContact.setOnlineResource(distributorOnline);
|
||||||
distributor.setContactInfo(distributorContact);
|
distributor.setContactInfo(distributorContact);
|
||||||
|
@ -72,6 +79,7 @@ public class ISOMetadataFactory {
|
||||||
providerAddress.getElectronicMailAddresses().add(params.getConfig().getProviderEMail());
|
providerAddress.getElectronicMailAddresses().add(params.getConfig().getProviderEMail());
|
||||||
providerContact.setAddress(providerAddress);
|
providerContact.setAddress(providerAddress);
|
||||||
DefaultOnlineResource providerOnline=new DefaultOnlineResource (new URI(params.getConfig().getProviderSite()));
|
DefaultOnlineResource providerOnline=new DefaultOnlineResource (new URI(params.getConfig().getProviderSite()));
|
||||||
|
providerOnline.setName(params.getConfig().getProjectName()+" site.");
|
||||||
providerOnline.setProtocol(params.getConfig().getHttpProtocolDeclaration());
|
providerOnline.setProtocol(params.getConfig().getHttpProtocolDeclaration());
|
||||||
providerContact.setOnlineResource(providerOnline);
|
providerContact.setOnlineResource(providerOnline);
|
||||||
provider.setContactInfo(providerContact);
|
provider.setContactInfo(providerContact);
|
||||||
|
@ -115,7 +123,7 @@ public class ISOMetadataFactory {
|
||||||
thesaurusParty.setOrganisationName(new DefaultInternationalString(entry.getKey().getCitationOrganization()));
|
thesaurusParty.setOrganisationName(new DefaultInternationalString(entry.getKey().getCitationOrganization()));
|
||||||
thesaurusParty.setRole(Role.POINT_OF_CONTACT);
|
thesaurusParty.setRole(Role.POINT_OF_CONTACT);
|
||||||
DefaultContact thesaurusContact=new DefaultContact();
|
DefaultContact thesaurusContact=new DefaultContact();
|
||||||
thesaurusContact.setOnlineResource(new DefaultOnlineResource(new URI(entry.getKey().getCitationUri())));
|
thesaurusContact.setOnlineResource(getOnline(entry.getKey().getTitle(),entry.getKey().getCitationUri()));
|
||||||
thesaurusParty.setContactInfo(thesaurusContact);
|
thesaurusParty.setContactInfo(thesaurusContact);
|
||||||
thesaurus.getCitedResponsibleParties().add(thesaurusParty);
|
thesaurus.getCitedResponsibleParties().add(thesaurusParty);
|
||||||
}
|
}
|
||||||
|
@ -165,55 +173,6 @@ public class ISOMetadataFactory {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//***************** Not general Approach
|
|
||||||
// DefaultDataQuality processQuality=new DefaultDataQuality();
|
|
||||||
// DefaultLineage processLineage=new DefaultLineage();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// DefaultSource source=new DefaultSource();
|
|
||||||
// DefaultNominalResolution sourceResolution=new DefaultNominalResolution();
|
|
||||||
// sourceResolution.setGroundResolution(0.5d);
|
|
||||||
// sourceResolution.setScanningResolution(0.5d);
|
|
||||||
// source.getSourceExtents().add(DefaultExtent.WORLD);
|
|
||||||
// //FIXME Breaks Validation
|
|
||||||
//// source.setResolution(sourceResolution);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// DefaultCitation sourceCitation=new DefaultCitation();
|
|
||||||
// sourceCitation.setTitle(new DefaultInternationalString(params.getSourceTitle()));
|
|
||||||
// sourceCitation.getDates().add(new DefaultCitationDate(params.getSourceGenerationDate(), DateType.CREATION));
|
|
||||||
// sourceCitation.getIdentifiers().add(new DefaultIdentifier(params.getSourceTableName()));
|
|
||||||
// source.setSourceCitation(sourceCitation);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// DefaultProcessStep processStep=new DefaultProcessStep();
|
|
||||||
// processStep.setDescription(new DefaultInternationalString("AquaMaps Ecological Niche Modelling"));
|
|
||||||
//// DefaultProcessing processing=new DefaultProcessing();
|
|
||||||
//// DefaultAlgorithm algorithm=new DefaultAlgorithm();
|
|
||||||
//// algorithm.setDescription(new DefaultInternationalString(AquaMapsObjectMetadataParameter.algorithmDescription));
|
|
||||||
//// StringBuilder customList=new StringBuilder();
|
|
||||||
//// for(SpeciesCustomization custom:params.getCustomizations())
|
|
||||||
//// customList.append(custom.toXML());
|
|
||||||
//// processing.setRunTimeParameters(new DefaultInternationalString(customList.toString()));
|
|
||||||
//// processing.getAlgorithms().add(algorithm);
|
|
||||||
//
|
|
||||||
// // FIXME Brakes Validation
|
|
||||||
//// processStep.setProcessingInformation(processing);
|
|
||||||
//
|
|
||||||
// processLineage.setStatement(new DefaultInternationalString(AquaMapsObjectMetadataParameter.algorithmDescription));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// processLineage.getProcessSteps().add(processStep);
|
|
||||||
// processLineage.getSources().add(source);
|
|
||||||
// processQuality.setLineage(processLineage);
|
|
||||||
// processQuality.setScope(new DefaultScope(ScopeCode.DATASET));
|
|
||||||
|
|
||||||
|
|
||||||
//*************** The Meta Object
|
//*************** The Meta Object
|
||||||
DefaultMetadata meta=new DefaultMetadata(author, new Date(System.currentTimeMillis()), ident);
|
DefaultMetadata meta=new DefaultMetadata(author, new Date(System.currentTimeMillis()), ident);
|
||||||
|
@ -237,18 +196,21 @@ public class ISOMetadataFactory {
|
||||||
distribution.getTransferOptions().add(getTransferOptionsByLayer(layerName, geoserverUrl, style, bbox, config));
|
distribution.getTransferOptions().add(getTransferOptionsByLayer(layerName, geoserverUrl, style, bbox, config));
|
||||||
|
|
||||||
DefaultFormat format1 = new DefaultFormat();
|
DefaultFormat format1 = new DefaultFormat();
|
||||||
format1.setName(new DefaultInternationalString("WMS"));
|
format1.setName(new DefaultInternationalString(Protocol.WMS.getName()));
|
||||||
format1.setVersion(new DefaultInternationalString("1.1.0"));
|
format1.setVersion(new DefaultInternationalString(Protocol.WMS.getVersion()));
|
||||||
DefaultFormat format2 = new DefaultFormat();
|
DefaultFormat format2 = new DefaultFormat();
|
||||||
format2.setName(new DefaultInternationalString("WFS"));
|
format2.setName(new DefaultInternationalString(Protocol.WFS.getName()));
|
||||||
format2.setVersion(new DefaultInternationalString("1.1.0"));
|
format2.setVersion(new DefaultInternationalString(Protocol.WFS.getVersion()));
|
||||||
DefaultFormat format3 = new DefaultFormat();
|
DefaultFormat format3 = new DefaultFormat();
|
||||||
format3.setName(new DefaultInternationalString("WCS"));
|
format3.setName(new DefaultInternationalString(Protocol.WCS.getName()));
|
||||||
format3.setVersion(new DefaultInternationalString("1.0.0"));
|
format3.setVersion(new DefaultInternationalString(Protocol.WCS.getVersion()));
|
||||||
|
|
||||||
|
DefaultFormat format4 = new DefaultFormat();
|
||||||
|
format4.setName(new DefaultInternationalString(Protocol.HTTP.getName()));
|
||||||
|
format4.setVersion(new DefaultInternationalString(Protocol.HTTP.getVersion()));
|
||||||
|
|
||||||
|
|
||||||
|
distribution.setDistributionFormats(new ArrayList<DefaultFormat>(Arrays.asList(format1, format2,format3, format4)));
|
||||||
distribution.setDistributionFormats(new ArrayList<DefaultFormat>(Arrays.asList(format1, format2, format3)));
|
|
||||||
return distribution;
|
return distribution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,50 +218,61 @@ public class ISOMetadataFactory {
|
||||||
public static DefaultDigitalTransferOptions getTransferOptionsByLayer(String layerName, String geoserverUrl, String style, String bbox, EnvironmentConfiguration config ) throws URISyntaxException{
|
public static DefaultDigitalTransferOptions getTransferOptionsByLayer(String layerName, String geoserverUrl, String style, String bbox, EnvironmentConfiguration config ) throws URISyntaxException{
|
||||||
DefaultDigitalTransferOptions transferOptions=new DefaultDigitalTransferOptions();
|
DefaultDigitalTransferOptions transferOptions=new DefaultDigitalTransferOptions();
|
||||||
|
|
||||||
transferOptions.getOnLines().add(getOnline(layerName,config.getWmsProtocolDeclaration(),getWmsUrl(geoserverUrl, layerName, style, bbox, config.getDefaultCRS())));
|
transferOptions.getOnLines().add(getOnline(Protocol.WMS.getName()+" link to layer.",config.getWmsProtocolDeclaration(),getWmsUrl(geoserverUrl, layerName, style, bbox, config.getDefaultCRS())));
|
||||||
transferOptions.getOnLines().add(getOnline(layerName,config.getWfsProtocolDeclaration(),getWfsUrl(geoserverUrl,layerName)));
|
transferOptions.getOnLines().add(getOnline(Protocol.WFS.getName()+" link to layer.",config.getWfsProtocolDeclaration(),getWfsUrl(geoserverUrl,layerName)));
|
||||||
transferOptions.getOnLines().add(getOnline(layerName,config.getWcsProtocolDeclaration(),getWcsUrl(geoserverUrl,layerName,bbox)));
|
transferOptions.getOnLines().add(getOnline(Protocol.WCS.getName()+" link to layer.",config.getWcsProtocolDeclaration(),getWcsUrl(geoserverUrl,layerName,bbox)));
|
||||||
return transferOptions;
|
return transferOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DefaultOnlineResource getOnline(String name, String protocol, String uriString) throws URISyntaxException{
|
public static DefaultOnlineResource getOnline(String name,String uriString) throws URISyntaxException{
|
||||||
|
return getOnline(name,Protocol.getByURI(uriString).getDeclaration(),Protocol.getByURI(uriString).getName()+" link to resource.",uriString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefaultOnlineResource getOnline(String name,String protocolDeclaration,String uriString) throws URISyntaxException{
|
||||||
|
return getOnline(name,protocolDeclaration,Protocol.getByURI(uriString).getName()+" link to resource.",uriString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefaultOnlineResource getOnline(String name,String protocol, String description, String uriString) throws URISyntaxException{
|
||||||
URI uri=new URI(uriString);
|
URI uri=new URI(uriString);
|
||||||
DefaultOnlineResource resource=new DefaultOnlineResource(uri);
|
DefaultOnlineResource resource=new DefaultOnlineResource(uri);
|
||||||
resource.setName(name);
|
resource.setName(name);
|
||||||
resource.setProtocol(protocol);
|
resource.setProtocol(protocol);
|
||||||
|
resource.setDescription(new DefaultInternationalString(description));
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getWmsUrl(String geoServerUrl, String layerName,String style, String bbox,String CRS) {
|
|
||||||
|
|
||||||
|
public static String getWmsUrl(String geoServerUrl, String layerName,String style, String bbox,String CRS) {
|
||||||
|
if(bbox==null) bbox=BoundingBox.WORLD_EXTENT.toString();
|
||||||
return geoServerUrl +
|
return geoServerUrl +
|
||||||
"/wms?service=wms&version=1.1.0"
|
"/wms?service=wms&version=1.1.0"
|
||||||
+ "&request=GetMap&layers=" + layerName
|
+ "&request=GetMap&layers=" + layerName
|
||||||
+ "&styles=" + (style == null ? "" : style)
|
+ "&styles=" + (style == null ? "" : style)
|
||||||
+ "&bbox=" + bbox + "&width=676&height=330" +
|
+ "&bbox=" + bbox + "&width=676&height=330" +
|
||||||
"&srs=EPSG:4326&crs="+CRS+"&format=application/openlayers";
|
"&srs=EPSG:4326&crs="+CRS+"&format=application/openlayers";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private static String getWfsUrl(String geoServerUrl, String layerName) {
|
public static String getWfsUrl(String geoServerUrl, String layerName) {
|
||||||
return geoServerUrl +
|
return geoServerUrl +
|
||||||
"/ows?service=wfs&version=1.0.0"
|
"/ows?service=wfs&version=1.0.0"
|
||||||
+ "&request=GetFeature&typeName=" + layerName
|
+ "&request=GetFeature&typeName=" + layerName
|
||||||
+"&format=json";
|
+"&format=json";
|
||||||
}
|
}
|
||||||
private static String getWcsUrl(String geoServerUrl, String layerName,String bbox) {
|
public static String getWcsUrl(String geoServerUrl, String layerName,String bbox) {
|
||||||
|
if(bbox==null) bbox=BoundingBox.WORLD_EXTENT.toString();
|
||||||
return geoServerUrl + "/wcs?service=wcs&version=1.0.0" + "&request=GetCoverage&coverage=" +
|
return geoServerUrl + "/wcs?service=wcs&version=1.0.0" + "&request=GetCoverage&coverage=" +
|
||||||
layerName + "&CRS=EPSG:4326" + "&bbox=" + bbox + "&width=676&height=330&format=geotiff";
|
layerName + "&CRS=EPSG:4326" + "&bbox=" + bbox + "&width=676&height=330&format=geotiff";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private static final String WMS_PROTOCOL="OGC:WMS-1.3.0-http-get-map";
|
public static String getGisLinkByUUID(String uuid) throws UriResolverMapException, IllegalArgumentException{
|
||||||
// private static final String WFS_PROTOCOL="OGC:WFS-1.0.0-http-get-feature";
|
Map<String,String> params=new HashMap<String,String>();
|
||||||
// private static final String HTTP_PROTOCOL="WWW:LINK-1.0-http--link";
|
params.put("scope", ScopeUtils.getCurrentScope());
|
||||||
//
|
params.put("gis-UUID", uuid);
|
||||||
// public static final String getProtocol(String uri){
|
UriResolverManager resolver = new UriResolverManager("GIS");
|
||||||
// uri=uri.toLowerCase();
|
return resolver.getLink(params, true);
|
||||||
// if(uri.contains(("service=wms"))) return WMS_PROTOCOL;
|
}
|
||||||
// else if(uri.contains("service=wfs")) return WFS_PROTOCOL;
|
|
||||||
// else return HTTP_PROTOCOL;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.gcube.spatial.data.geonetwork.iso;
|
||||||
|
|
||||||
|
public enum Protocol {
|
||||||
|
|
||||||
|
HTTP("HTTP","WWW:LINK-1.0-http--link","1.0.0"),
|
||||||
|
WFS("WFS","OGC:WFS-1.0.0-http-get-feature","1.0.0"),
|
||||||
|
WCS("WCS","OGC:WCS-1.0.0-http-get-coverage","1.0.0"),
|
||||||
|
WMS("WMS","OGC:WMS-1.3.0-http-get-map","1.3.0");
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String declaration;
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
private Protocol(String name,String declaration,String version){
|
||||||
|
this.name=name;
|
||||||
|
this.declaration=declaration;
|
||||||
|
this.version=version;
|
||||||
|
}
|
||||||
|
public String getDeclaration() {
|
||||||
|
return declaration;
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final Protocol getByURI(String uri){
|
||||||
|
uri=uri.toLowerCase();
|
||||||
|
if(uri.contains(("service=wms"))) return Protocol.WMS;
|
||||||
|
else if(uri.contains("service=wfs")) return Protocol.WFS;
|
||||||
|
else if(uri.contains("service=wcs")) return Protocol.WCS;
|
||||||
|
else return Protocol.HTTP;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,8 @@ package org.gcube.spatial.data.geonetwork.utils;
|
||||||
|
|
||||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
@ -51,10 +51,10 @@ public class ScopeUtils {
|
||||||
return current.substring(current.lastIndexOf('/')+1);
|
return current.substring(current.lastIndexOf('/')+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getParentScopes(){
|
public static ArrayList<String> getParentScopes(){
|
||||||
String currentScope=getCurrentScope();
|
String currentScope=getCurrentScope();
|
||||||
String[] splitted=currentScope.substring(1).split("/");
|
String[] splitted=currentScope.substring(1).split("/");
|
||||||
HashSet<String> toReturn=new HashSet<String>();
|
ArrayList<String> toReturn=new ArrayList<String>();
|
||||||
for(int i=0;i<splitted.length-1;i++){
|
for(int i=0;i<splitted.length-1;i++){
|
||||||
toReturn.add(splitted[i]);
|
toReturn.add(splitted[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||||
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
||||||
|
import org.gcube.spatial.data.geonetwork.extension.ServerAccess.Version;
|
||||||
import org.gcube.spatial.data.geonetwork.model.Account;
|
import org.gcube.spatial.data.geonetwork.model.Account;
|
||||||
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
||||||
import org.gcube.spatial.data.geonetwork.model.faults.MissingConfigurationException;
|
import org.gcube.spatial.data.geonetwork.model.faults.MissingConfigurationException;
|
||||||
|
@ -62,6 +63,10 @@ public class MyConfiguration implements Configuration {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public Version getGeoNetworkVersion() throws MissingServiceEndpointException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package org.gcube.spatial.data.geonetwork.test;
|
package org.gcube.spatial.data.geonetwork.test;
|
||||||
|
|
||||||
import it.geosolutions.geonetwork.GNClient;
|
|
||||||
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -64,6 +61,10 @@ import org.opengis.metadata.spatial.SpatialRepresentationType;
|
||||||
import org.opengis.metadata.spatial.TopologyLevel;
|
import org.opengis.metadata.spatial.TopologyLevel;
|
||||||
import org.opengis.util.InternationalString;
|
import org.opengis.util.InternationalString;
|
||||||
|
|
||||||
|
import it.geosolutions.geonetwork.GN26Client;
|
||||||
|
import it.geosolutions.geonetwork.GNClient;
|
||||||
|
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
|
||||||
|
|
||||||
public class NetCDFMetadata {
|
public class NetCDFMetadata {
|
||||||
|
|
||||||
private String geonetworkUrl = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geonetwork/";
|
private String geonetworkUrl = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geonetwork/";
|
||||||
|
@ -420,8 +421,7 @@ public class NetCDFMetadata {
|
||||||
meta.getDataQualityInfo().add(processQuality);
|
meta.getDataQualityInfo().add(processQuality);
|
||||||
meta.setLanguage(Locale.ENGLISH);
|
meta.setLanguage(Locale.ENGLISH);
|
||||||
|
|
||||||
GNClient client = new GNClient(geonetworkUrl);
|
GNClient client = new GN26Client(geonetworkUrl,geonetworkUser,geonetworkPwd);
|
||||||
client.login(geonetworkUser, geonetworkPwd);
|
|
||||||
File tmetafile = meta2File(meta);
|
File tmetafile = meta2File(meta);
|
||||||
client.insertMetadata(new GNInsertConfiguration("3", "datasets", "_none_", true), tmetafile);
|
client.insertMetadata(new GNInsertConfiguration("3", "datasets", "_none_", true), tmetafile);
|
||||||
tmetafile.delete();
|
tmetafile.delete();
|
||||||
|
|
|
@ -19,10 +19,11 @@ public class ScopeTests {
|
||||||
String[] scopes=new String[]{
|
String[] scopes=new String[]{
|
||||||
// "/gcube",
|
// "/gcube",
|
||||||
// "/gcube/devsec",
|
// "/gcube/devsec",
|
||||||
"/gcube/devsec/devVRE"
|
// "/gcube/devsec/devVRE",
|
||||||
|
// "/gcube/devNext/NextNext"
|
||||||
|
|
||||||
// "/d4science.research-infrastructures.eu"
|
"/d4science.research-infrastructures.eu/gCubeApps/EcologicalModelling",
|
||||||
// "/d4science.research-infrastructures.eu"
|
"/d4science.research-infrastructures.eu/gCubeApps"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@ import java.util.Properties;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class TokenSetter {
|
public class TokenSetter {
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,10 +24,15 @@ public class TokenSetter {
|
||||||
|
|
||||||
|
|
||||||
public static void set(String scope){
|
public static void set(String scope){
|
||||||
|
try{
|
||||||
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||||
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||||
|
}catch(Throwable e){
|
||||||
|
log.warn("Unable to set token for scope "+scope,e);
|
||||||
|
}
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TrueMarbleMeta {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
TokenSetter.set("/gcube/devsec/devVRE");
|
TokenSetter.set("/gcube/devNext/NextNext");
|
||||||
// TokenSetter.set("/d4science.research-infrastructures.eu");
|
// TokenSetter.set("/d4science.research-infrastructures.eu");
|
||||||
GcubeISOMetadata gMeta=new GcubeISOMetadata();
|
GcubeISOMetadata gMeta=new GcubeISOMetadata();
|
||||||
gMeta.setAbstractField("This layer is used as a base layer for GIS VIewer widget");
|
gMeta.setAbstractField("This layer is used as a base layer for GIS VIewer widget");
|
||||||
|
@ -50,15 +50,9 @@ public class TrueMarbleMeta {
|
||||||
publisher.login(LoginLevel.PRIVATE);
|
publisher.login(LoginLevel.PRIVATE);
|
||||||
GNInsertConfiguration config=publisher.getCurrentUserConfiguration("dataset", "_none_");
|
GNInsertConfiguration config=publisher.getCurrentUserConfiguration("dataset", "_none_");
|
||||||
|
|
||||||
Long id=publisher.insertMetadata(config,meta);
|
Long id=publisher.insertAndPromoteMetadata(config,meta);
|
||||||
System.out.println("Inserted meta with id : "+id);
|
System.out.println("Inserted meta with id : "+id);
|
||||||
|
|
||||||
// setting privileges
|
|
||||||
// GNPrivConfiguration privs=new GNPrivConfiguration();
|
|
||||||
// ScopeConfiguration scopeConfig=publisher.getConfiguration().getScopeConfiguration();
|
|
||||||
// privs.addPrivileges(scopeConfig.getDefaultGroup(), EnumSet.of(GNPriv.VIEW,GNPriv.FEATURED));
|
|
||||||
// publisher.setPrivileges(id, privs);
|
|
||||||
// System.out.println("Privileges set");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13892
transferred_err.txt
13892
transferred_err.txt
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue