Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 9b33209b authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

add Jaxb implementation

parent 87c4d775
No related branches found
No related tags found
No related merge requests found
......@@ -67,9 +67,9 @@
<javaee-api.version>7.0</javaee-api.version>
<javax.annotation.version>1.3.2</javax.annotation.version>
<javax.mail.version>1.6.2</javax.mail.version>
<jaxb.version>2.3.0.1</jaxb.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<jaxb2-basics.version>1.11.1</jaxb2-basics.version>
<org.glassfish.jaxb.jaxb-runtime.version>2.3.8</org.glassfish.jaxb.jaxb-runtime.version>
<jakarta.xml.bind-api.version>2.3.3</jakarta.xml.bind-api.version>
<jstl.version>1.2</jstl.version>
<junit.version>4.13.2</junit.version>
<junit-jupiter.version>5.9.2</junit-jupiter.version>
......@@ -213,7 +213,16 @@
<artifactId>cxf-rt-features-logging</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta.xml.bind-api.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${org.glassfish.jaxb.jaxb-runtime.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
......
......@@ -74,16 +74,16 @@ export class ResourceDetailsPanelComponent implements BeforeLeaveGuard {
this.resourceForm.markAsPristine();
}
onShowButtonDocumentClicked(){
onShowButtonDocumentClicked() {
// set selected resource
this.editResourceService.selectedResource = this.resource;
let node:NavigationNode = this.createNew();
let node: NavigationNode = this.createNew();
this.navigationService.selected.children = [node]
this.navigationService.select(node);
}
public createNew():NavigationNode{
public createNew(): NavigationNode {
return {
code: "resource-document",
icon: "note",
......@@ -104,17 +104,11 @@ export class ResourceDetailsPanelComponent implements BeforeLeaveGuard {
return "The private resource is accessible only to the resource members!"
}
if (this.group.visibility == VisibilityEnum.Private) {
return "The resource belongs to the private group. The resource is accessible only to the members of the group (direct and indirect group members)!"
return "The resource belongs to the private group. Only the group members and group resource members can access the resource!"
}
if (this.domain.visibility == VisibilityEnum.Private) {
return "The resource belongs to the private domain. The resource is accessible only to the members of the domain (direct and indirect domain members)!"
return "The resource belongs to the private domain. Only the domain members, domain group members and its resource members can access the resource!"
}
return "The resource is public on the public group and the public domain. The resource data is accessible to all users."
}
}
......@@ -22,8 +22,8 @@
</parent>
<properties>
<maven.deploy.skip>false</maven.deploy.skip>
<jaxb-api.version>2.3.1</jaxb-api.version>
<org.glassfish.jaxb.jaxb-runtime.version>2.3.8</org.glassfish.jaxb.jaxb-runtime.version>
<jakarta.xml.bind-api.version>2.3.3</jakarta.xml.bind-api.version>
</properties>
<artifactId>oasis-cppa3-spi</artifactId>
<name>oasis-cppa3-spi</name>
......@@ -102,7 +102,7 @@
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<version>${jakarta.xml.bind-api.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
......
......@@ -5,7 +5,6 @@ import eu.europa.ec.smp.spi.api.model.ResourceIdentifier;
import eu.europa.ec.smp.spi.exceptions.CPPARuntimeException;
import eu.europa.ec.smp.spi.exceptions.ResourceException;
import eu.europa.ec.smp.spi.resource.ResourceHandlerSpi;
import gen.eu.europa.ec.ddc.api.cppa.CPP;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
......@@ -67,7 +66,7 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
JAXBContext jaxbContext = JAXBContext.newInstance(CPP.class);
return jaxbContext.createUnmarshaller();
} catch (JAXBException ex) {
LOG.error("Error occurred while initializing JAXBContext for ServiceGroup. Cause message:" + ex, ex);
LOG.error("Error occurred while initializing JAXBContext for ServiceGroup. Cause message:" + ex, ex);
}
return null;
});
......@@ -78,7 +77,7 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
JAXBContext jaxbContext = JAXBContext.newInstance(CPP.class);
return jaxbContext.createMarshaller();
} catch (JAXBException ex) {
LOG.error("Error occurred while initializing JAXBContext for ServiceGroup. Cause message:" + ex, ex);
LOG.error("Error occurred while initializing JAXBContext for ServiceGroup. Cause message:" + ex, ex);
}
return null;
});
......@@ -99,6 +98,7 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
public Marshaller getMarshaller() {
return jaxbMarshaller.get();
}
/**
* Removes the current thread's ServiceGroup Unmarshaller for this thread-local variable. If this thread-local variable
* is subsequently read by the current thread, its value will be reinitialized by invoking its initialValue method.
......@@ -147,14 +147,14 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
public CPP parseNative(Document document) {
try {
return (CPP)jaxbUnmarshaller.get().unmarshal(document);
return (CPP) jaxbUnmarshaller.get().unmarshal(document);
} catch (JAXBException ex) {
throw new CPPARuntimeException(CPPARuntimeException.ErrorCode.PARSE_ERROR, "Can not parse XML Document ! Error: [" + ExceptionUtils.getRootCauseMessage(ex) + "]", ex);
}
}
public CPP parseNative(InputStream inputStream) {
public CPP parseNative(InputStream inputStream) {
try {
DocumentBuilder db = createDocumentBuilder();
// just to validate DISALLOW_DOCTYPE_FEATURE parse to Document
......@@ -171,11 +171,12 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
return;
}
Marshaller jaxbMarshaller = getMarshaller();
// Pretty Print XML
try {
if (prettyPrint) {
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, prettyPrint);
}
jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, prettyPrint ? Boolean.TRUE : Boolean.FALSE);
// to remove xmlDeclaration
jaxbMarshaller.marshal(jaxbObject, outputStream);
} catch (JAXBException ex) {
......@@ -188,8 +189,6 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
}
public QName getRootElementQName(Document document) {
Element element = document.getDocumentElement();
String namespace = element.getNamespaceURI();
......@@ -197,7 +196,6 @@ public abstract class AbstractHandler implements ResourceHandlerSpi {
}
public ResourceIdentifier getResourceIdentifier(RequestData resourceData) throws ResourceException {
if (resourceData == null || resourceData.getResourceIdentifier() == null || StringUtils.isEmpty(resourceData.getResourceIdentifier().getValue())) {
throw new ResourceException(ResourceException.ErrorCode.INVALID_PARAMETERS, "Missing resource identifier for the resource CPP ");
......
......@@ -39,7 +39,14 @@
<artifactId>oasis-cppa3-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>eu.europa.ec.dynamic-discovery</groupId>
<artifactId>dynamic-discovery-client</artifactId>
......
com.sun.xml.bind.v2.ContextFactory
\ No newline at end of file
......@@ -34,6 +34,7 @@
</prefer-application-packages>
<prefer-application-resources>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
<resource-name>META-INF/services/javax.xml.bind.JAXBContext</resource-name>
</prefer-application-resources>
</container-descriptor>
</weblogic-web-app>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment