Commit 055784a1 authored by Sara Bertocco's avatar Sara Bertocco
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+3 −0
Original line number Original line Diff line number Diff line
target/**
nbactions.xml

README.md

0 → 100644
+56 −0
Original line number Original line Diff line number Diff line
# VOSpace XML

## Generating beans from XML schema

    cd xsd
    xjc vospace.xsd

### Changes to the online XSD files

It seems that xjc does something wrong when retriving the imported XSD from the web, so the dependent files have been downloaded and relative path has been specified in `schemaLocation` attribute.

In vospace.xsd:

    <xsd:import namespace="http://www.ivoa.net/xml/UWS/v1.0" schemaLocation="./uws.xsd"/>

In uws.xsd:

    <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="./xlink.xsd"/>

### Changes to the generated classes

In package-info.java the following element has been added to serialize the XML keeping the namespace.

    xmlns = {
        @javax.xml.bind.annotation.XmlNs(
                namespaceURI = "http://www.ivoa.net/xml/VOSpace/v2.0",
                prefix = "vos"
        )
    }

Some issues emerged in handling inheritance and namespaces in a way compatible both to JSON and XML formats.

In Node.java type has been added:

    @XmlAttribute(name = "type", namespace = "http://www.w3.org/2001/XMLSchema-instance")
    protected String type;

    public String getType() {
        return type;
    }

For JSON compatibility the following has been added to Node.java (annotation on class):

    @JsonTypeInfo(use = JsonTypeInfo.Id.CUSTOM, property = "type", include = JsonTypeInfo.As.EXISTING_PROPERTY)
    @JsonTypeIdResolver(NodeTypeJsonResolver.class)

The `@JsonTypeInfo` tells to Jackson that the field type is used to handle inheritance. A custom type id resolver has been created to handle the `vos:` prefix.

2 annotations have been added to each node subtype:

    @XmlRootElement(name = "node")
    @JsonDeserialize(converter = NodeTypeSetter.UnstructuredDataNode.class)

`@XmlRootElement` is necessary to parse single nodes. The value `"node"` has been specified because by default the bean would be serialized as `<unstructuredDataNode>`.

The `NodeTypeSetter` class fills the `type` field during JSON serialization and deserialization.

database/Dockerfile

0 → 100644
+9 −0
Original line number Original line Diff line number Diff line
FROM library/postgres:11
#ENV POSTGRES_USER vospaceusr
#ENV POSTGRES_PASSWORD Peper0ne
ENV POSTGRES_DB vospacedb
ENV POSTGRES_HOST_AUTH_METHOD=trust
COPY src/main/resources/db_init.sql /docker-entrypoint-initdb.d/
COPY database/user.sql /docker-entrypoint-initdb.d/

database/docker-env

0 → 100644
+5 −0
Original line number Original line Diff line number Diff line
POSTGRES_USER=vospaceusr
POSTGRES_PASSWORD=Peper0ne
POSTGRES_DB=vospacedb

database/user.sql

0 → 100644
+5 −0
Original line number Original line Diff line number Diff line
CREATE ROLE vospaceusr WITH LOGIN PASSWORD 'Peper0ne';
GRANT USAGE ON SCHEMA public TO vospaceusr;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO vospaceusr;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO vospaceusr;