moved to jakarta

This commit is contained in:
lucio 2024-03-12 17:28:51 +01:00
parent dd5d5073ed
commit ba36a1da87
12 changed files with 171 additions and 166 deletions

View File

@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
@ -13,14 +23,17 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

51
pom.xml
View File

@ -7,9 +7,12 @@
<version>1.0.1-SNAPSHOT</version>
<name>Legacy is publisher</name>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/legacy-is-publisher-connector</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/legacy-is-publisher-connector</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/legacy-is-publisher-connector</url>
<connection>
scm:git:https://code-repo.d4science.org/gCubeSystem/legacy-is-publisher-connector</connection>
<developerConnection>
scm:git:https://code-repo.d4science.org/gCubeSystem/legacy-is-publisher-connector</developerConnection>
<url>
https://code-repo.d4science.org/gCubeSystem/legacy-is-publisher-connector</url>
</scm>
<properties>
<maven.compiler.source>11</maven.compiler.source>
@ -25,13 +28,35 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>3.0.0</version>
<version>3.0.1-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@ -56,22 +81,6 @@
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</project>

View File

@ -27,14 +27,12 @@ import org.slf4j.LoggerFactory;
@SmartgearsProfilePublisher
public class LegacyISPublisher implements Publisher {
private static Logger logger = LoggerFactory.getLogger(LegacyISPublisher.class);
private Registry registry = new Registry();
private static Map<String, Resource> resourcesCache = new HashMap<String, Resource>();
@Override
public boolean create(ContainerContext container, Set<String> contexts) {
ContainerProfileBuilder cpb = new ContainerProfileBuilder(container);
@ -56,23 +54,17 @@ public class LegacyISPublisher implements Publisher{
resourcesCache.put(id, hostingNode);
}
for (String context : filterICContexts(hostingNode.scopes().asCollection()))
try {
for (String context : filterICContexts(hostingNode.scopes().asCollection())) {
logger.info("publishing container in context {}", context);
AuthorizedTasks.executeSafely(() -> {
try {
registry.getStubs().create(toXml(hostingNode), hostingNode.type().toString());
}catch (Exception e) {
logger.error("error publishing container", e);
throw new RuntimeException(e);
}
}, new ICSecret(context));
} catch (Throwable e) {
logger.error("error publishing container in context {}", context, e);
}
}, new ICSecret(context));
}
return true;
}
@ -95,22 +87,17 @@ public class LegacyISPublisher implements Publisher{
resourcesCache.put(id, endpoint);
}
for (String context : filterICContexts(endpoint.scopes().asCollection()))
try {
for (String context : filterICContexts(endpoint.scopes().asCollection())) {
logger.info("publishing application in context {}", context);
AuthorizedTasks.executeSafely(() -> {
try {
String resource = toXml(endpoint);
registry.getStubs().create(resource, endpoint.type().toString());
}catch (Exception e) {
logger.error("error publishing application", e);
throw new RuntimeException(e);
} catch (Throwable e) {
logger.error("error publishing application in {}", context, e);
}
}, new ICSecret(context));
}catch (Throwable e) {
logger.error("error publishing application profile in context {}", context, e);
}
return true;
}
@ -142,7 +129,7 @@ public class LegacyISPublisher implements Publisher{
try {
logger.info("removing container from context {}", context);
registry.getStubs().remove(hostingNode.id(), hostingNode.type().toString());
}catch (Exception e) {
} catch (Throwable e) {
throw new RuntimeException(e);
}
@ -157,7 +144,7 @@ public class LegacyISPublisher implements Publisher{
AuthorizedTasks.executeSafely(() -> {
try {
registry.getStubs().update(hostingNode.id(), hostingNode.type().toString(), toXml(hostingNode));
}catch (Exception e) {
} catch (Throwable e) {
throw new RuntimeException(e);
}
@ -197,7 +184,7 @@ public class LegacyISPublisher implements Publisher{
try {
logger.info("removing container in context {}", context);
registry.getStubs().remove(endpoint.id(), endpoint.type().toString());
}catch (Exception e) {
} catch (Throwable e) {
throw new RuntimeException(e);
}
@ -213,7 +200,7 @@ public class LegacyISPublisher implements Publisher{
logger.info("updating application in context {}", context);
String resource = toXml(endpoint);
registry.getStubs().update(endpoint.id(), endpoint.type().toString(), resource);
}catch (Exception e) {
} catch (Throwable e) {
throw new RuntimeException(e);
}
}, new ICSecret(context));
@ -233,20 +220,17 @@ public class LegacyISPublisher implements Publisher{
endpoint = (GCoreEndpoint) resourcesCache.get(id);
}
for (String context : filterICContexts(endpoint.scopes().asCollection()))
try {
for (String context : filterICContexts(endpoint.scopes().asCollection())) {
logger.info("updating application in context {}", context);
AuthorizedTasks.executeSafely(() -> {
try {
String resource = toXml(endpoint);
registry.getStubs().update(endpoint.id(), endpoint.type().toString(), resource);
}catch (Exception e) {
throw new RuntimeException(e);
}
}, new ICSecret(context));
} catch (Throwable e) {
logger.error("error updating application profile in context {}", context, e);
}
}, new ICSecret(context));
}
return true;
}
@ -265,20 +249,17 @@ public class LegacyISPublisher implements Publisher{
resourcesCache.put(id, hostingNode);
}
for (String context : filterICContexts(hostingNode.scopes().asCollection()))
try {
for (String context : filterICContexts(hostingNode.scopes().asCollection())) {
logger.info("updating container in context {}", context);
AuthorizedTasks.executeSafely(() -> {
try {
logger.info("updating container in context {}", context);
registry.getStubs().update(hostingNode.id(), hostingNode.type().toString(), toXml(hostingNode));
}catch (Exception e) {
throw new RuntimeException(e);
} catch (Throwable e) {
logger.error("error updating container in context {}", context, e);
}
}, new ICSecret(context));
}catch (Throwable e) {
logger.error("error updating container in context {}", context, e);
}
return true;
}
@ -310,11 +291,11 @@ public class LegacyISPublisher implements Publisher{
private <T extends Resource> boolean anotherBrotherVREOrVOOnResource(T resource, String scope) {
if (!new ContextBean(scope).is(Type.VRE))
throw new IllegalArgumentException("anotherBrotherVREOrVOOnResource method: the input scope must be a VRE scope");
throw new IllegalArgumentException(
"anotherBrotherVREOrVOOnResource method: the input scope must be a VRE scope");
String enclosedScope = new ContextBean(scope).enclosingScope().toString();
for (String s : resource.scopes()) {
if (isChildScope(enclosedScope, s) ||
((enclosedScope != null) && (enclosedScope.toString().equals(s))))
if (isChildScope(enclosedScope, s) || ((enclosedScope != null) && (enclosedScope.toString().equals(s))))
return true;
}
return false;
@ -330,6 +311,7 @@ public class LegacyISPublisher implements Publisher{
}
return false;
}
private boolean isChildScope(String fatherScope, String sonScope) {
ContextBean currentEnclosedScope = new ContextBean(sonScope).enclosingScope();
return (currentEnclosedScope != null) && (currentEnclosedScope.toString().equals(fatherScope));
@ -338,7 +320,8 @@ public class LegacyISPublisher implements Publisher{
private <T extends Resource> boolean anotherInfraScopeOnResource(T resource, String scope) {
if (!new ContextBean(scope).is(Type.INFRASTRUCTURE))
throw new IllegalArgumentException("anotherInfraScopeOnResource method: the input scope must be a INFRASTRUCTURE scope");
throw new IllegalArgumentException(
"anotherInfraScopeOnResource method: the input scope must be a INFRASTRUCTURE scope");
String infraScopeFound = null;
for (String s : resource.scopes()) {
while (new ContextBean(s).enclosingScope() != null)

View File

@ -24,8 +24,6 @@ public class Registry {
private List<URI> endpoints;
private static final Logger log = LoggerFactory.getLogger(Registry.class);
public List<URI> getEndPoints(){
String scope=SecretManagerProvider.get().getContext();
@ -46,24 +44,25 @@ public class Registry {
.setResult("$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint[string(@EntryName) eq '"+RegistryConstants.service_entrypoint+"']/string()");
endpoints = client.submit(query);
if (endpoints.size()==0){
throw new IllegalArgumentException("No registry endpoint founded");
throw new IllegalArgumentException("No endpoint for registry found");
}
// able/disable cache
cache.put(scope, endpoints);
}
return endpoints;
}
public RegistryStub getStubs() throws RegistryNotFoundException{
String context=SecretManagerProvider.get().getContext();
URI endpoint=null;
//use another method to cache epr
endpoint = getEndPoints().get(0);
log.debug("get stubs from endpoint: "+ endpoint);
log.debug("get stubs in context {} from endpoint {} ", context, endpoint);
return stubFor(RegistryConstants.registry).at(endpoint);
}
public RegistryStub getStubs(URI endpoint) throws RegistryNotFoundException{
log.debug("get stubs from endpoint: "+ endpoint);
String context=SecretManagerProvider.get().getContext();
log.debug("get stubs in context {} from fixed endpoint {} ", context, endpoint);
return stubFor(RegistryConstants.registry).at(endpoint);
}

View File

@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import javax.servlet.ServletRegistration;
import jakarta.servlet.ServletRegistration;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.smartgears.configuration.ProxyAddress;

View File

@ -1,11 +1,7 @@
package org.gcube.common.core.publisher.is.legacy.stubs;
import static org.gcube.common.core.publisher.is.legacy.stubs.RegistryConstants.*;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import static org.gcube.common.core.publisher.is.legacy.stubs.RegistryConstants.portType;
import static org.gcube.common.core.publisher.is.legacy.stubs.RegistryConstants.target_namespace;
import org.gcube.common.core.publisher.is.legacy.stubs.fault.CreateException;
import org.gcube.common.core.publisher.is.legacy.stubs.fault.InvalidResourceException;
@ -14,6 +10,11 @@ import org.gcube.common.core.publisher.is.legacy.stubs.fault.ResourceDoesNotExis
import org.gcube.common.core.publisher.is.legacy.stubs.fault.ResourceNotAcceptedException;
import org.gcube.common.core.publisher.is.legacy.stubs.fault.UpdateException;
import jakarta.jws.WebMethod;
import jakarta.jws.WebParam;
import jakarta.jws.WebResult;
import jakarta.jws.WebService;
/**
* A local interface to the resource discovery service.
*

View File

@ -1,10 +1,10 @@
package org.gcube.common.core.publisher.is.legacy.stubs.fault;
import javax.xml.ws.WebFault;
import org.gcube.common.core.publisher.is.legacy.stubs.RegistryStub;
import jakarta.xml.ws.WebFault;
/**
* Thrown by {@link RegistryStub#create(String, String)} when something is failed on creation
*/

View File

@ -1,9 +1,9 @@
package org.gcube.common.core.publisher.is.legacy.stubs.fault;
import javax.xml.ws.WebFault;
import org.gcube.common.core.publisher.is.legacy.stubs.RegistryStub;
import jakarta.xml.ws.WebFault;
/**
* Thrown by {@link RegistryStub#create(String, String)} when the resource type is invalid
* service.

View File

@ -1,9 +1,9 @@
package org.gcube.common.core.publisher.is.legacy.stubs.fault;
import javax.xml.ws.WebFault;
import org.gcube.common.core.publisher.is.legacy.stubs.RegistryStub;
import jakarta.xml.ws.WebFault;
/**
* Thrown by {@link RegistryStub#remove(String, String)} when something is failed on remove
*/

View File

@ -1,9 +1,9 @@
package org.gcube.common.core.publisher.is.legacy.stubs.fault;
import javax.xml.ws.WebFault;
import org.gcube.common.core.publisher.is.legacy.stubs.RegistryStub;
import jakarta.xml.ws.WebFault;
/**
* Thrown by {@link RegistryStub#remove(String, String)} when the resource does not exist in the collector
*/

View File

@ -2,10 +2,10 @@ package org.gcube.common.core.publisher.is.legacy.stubs.fault;
import javax.xml.ws.WebFault;
import org.gcube.common.core.publisher.is.legacy.stubs.RegistryStub;
import jakarta.xml.ws.WebFault;
/**
* Thrown by {@link RegistryStub#create(String, String)} when the resource is not accepted cause it doesn't satisfy a requirement
*/

View File

@ -1,10 +1,10 @@
package org.gcube.common.core.publisher.is.legacy.stubs.fault;
import javax.xml.ws.WebFault;
import org.gcube.common.core.publisher.is.legacy.stubs.RegistryStub;
import jakarta.xml.ws.WebFault;
/**
* Thrown by {@link RegistryStub#update(String, String)} when something is failed on update
*/