Reviewed-on: #1
This commit is contained in:
commit
5cfffd201a
|
@ -2,5 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.spatial.data.gcube-sdi-suite
|
||||
|
||||
## [v1.0.1] - 2021-12-07
|
||||
- Introduced cms-plugin-framework
|
||||
- Introduced concessioni use case
|
||||
- Fixed internal group ids
|
||||
|
||||
## [v1.0.0] - 2021-2-11
|
||||
First release
|
||||
- First release
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Changelog for org.gcube.application.cms-plugin-framework
|
||||
|
||||
## [v1.0.0] 2021-09-20
|
||||
- First release
|
|
@ -0,0 +1,26 @@
|
|||
# Acknowledgments
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
|
||||
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
|
||||
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
|
||||
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
|
||||
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
|
||||
- the H2020 research and innovation programme
|
||||
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
|
||||
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
|
||||
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
|
||||
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
|
||||
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
|
||||
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
|
||||
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
|
||||
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
|
||||
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
|
||||
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
|
||||
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
|
||||
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
|
||||
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);
|
|
@ -0,0 +1,312 @@
|
|||
# European Union Public Licence V. 1.1
|
||||
|
||||
|
||||
EUPL © the European Community 2007
|
||||
|
||||
|
||||
This European Union Public Licence (the “EUPL”) applies to the Work or Software
|
||||
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||
the Work, other than as authorised under this Licence is prohibited (to the
|
||||
extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
The Original Work is provided under the terms of this Licence when the Licensor
|
||||
(as defined below) has placed the following notice immediately following the
|
||||
copyright notice for the Original Work:
|
||||
|
||||
Licensed under the EUPL V.1.1
|
||||
|
||||
or has expressed by any other mean his willingness to license under the EUPL.
|
||||
|
||||
|
||||
|
||||
## 1. Definitions
|
||||
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
- The Licence: this Licence.
|
||||
|
||||
- The Original Work or the Software: the software distributed and/or
|
||||
communicated by the Licensor under this Licence, available as Source Code and
|
||||
also as Executable Code as the case may be.
|
||||
|
||||
- Derivative Works: the works or software that could be created by the Licensee,
|
||||
based upon the Original Work or modifications thereof. This Licence does not
|
||||
define the extent of modification or dependence on the Original Work required
|
||||
in order to classify a work as a Derivative Work; this extent is determined by
|
||||
copyright law applicable in the country mentioned in Article 15.
|
||||
|
||||
- The Work: the Original Work and/or its Derivative Works.
|
||||
|
||||
- The Source Code: the human-readable form of the Work which is the most
|
||||
convenient for people to study and modify.
|
||||
|
||||
- The Executable Code: any code which has generally been compiled and which is
|
||||
meant to be interpreted by a computer as a program.
|
||||
|
||||
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||
the Work under the Licence.
|
||||
|
||||
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||
Software under the terms of the Licence.
|
||||
|
||||
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||
renting, distributing, communicating, transmitting, or otherwise making
|
||||
available, on-line or off-line, copies of the Work or providing access to its
|
||||
essential functionalities at the disposal of any other natural or legal
|
||||
person.
|
||||
|
||||
|
||||
|
||||
## 2. Scope of the rights granted by the Licence
|
||||
|
||||
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||
sub-licensable licence to do the following, for the duration of copyright vested
|
||||
in the Original Work:
|
||||
|
||||
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||
- to the public, including the right to make available or display the Work or
|
||||
- copies thereof to the public and perform publicly, as the case may be, the
|
||||
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||
- thereof, sub-license rights in the Work or copies thereof.
|
||||
|
||||
Those rights can be exercised on any media, supports and formats, whether now
|
||||
known or later invented, as far as the applicable law permits so.
|
||||
|
||||
In the countries where moral rights apply, the Licensor waives his right to
|
||||
exercise his moral right to the extent allowed by law in order to make effective
|
||||
the licence of the economic rights here above listed.
|
||||
|
||||
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||
any patents held by the Licensor, to the extent necessary to make use of the
|
||||
rights granted on the Work under this Licence.
|
||||
|
||||
|
||||
|
||||
## 3. Communication of the Source Code
|
||||
|
||||
The Licensor may provide the Work either in its Source Code form, or as
|
||||
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||
provides in addition a machine-readable copy of the Source Code of the Work
|
||||
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||
a notice following the copyright notice attached to the Work, a repository where
|
||||
the Source Code is easily and freely accessible for as long as the Licensor
|
||||
continues to distribute and/or communicate the Work.
|
||||
|
||||
|
||||
|
||||
## 4. Limitations on copyright
|
||||
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||
any exception or limitation to the exclusive rights of the rights owners in the
|
||||
Original Work or Software, of the exhaustion of those rights or of other
|
||||
applicable limitations thereto.
|
||||
|
||||
|
||||
|
||||
## 5. Obligations of the Licensee
|
||||
|
||||
The grant of the rights mentioned above is subject to some restrictions and
|
||||
obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||
trademarks notices and all notices that refer to the Licence and to the
|
||||
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||
notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||
Original Works or Derivative Works based upon the Original Work, this
|
||||
Distribution and/or Communication will be done under the terms of this Licence
|
||||
or of a later version of this Licence unless the Original Work is expressly
|
||||
distributed only under this version of the Licence. The Licensee (becoming
|
||||
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||
or Derivative Work that alter or restrict the terms of the Licence.
|
||||
|
||||
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||
Works or copies thereof based upon both the Original Work and another work
|
||||
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||
conflict with his/her obligations under this Licence, the obligations of the
|
||||
Compatible Licence shall prevail.
|
||||
|
||||
Provision of Source Code: When distributing and/or communicating copies of the
|
||||
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||
indicate a repository where this Source will be easily and freely available for
|
||||
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||
|
||||
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||
trademarks, service marks, or names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the copyright notice.
|
||||
|
||||
|
||||
|
||||
## 6. Chain of Authorship
|
||||
|
||||
The original Licensor warrants that the copyright in the Original Work granted
|
||||
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each time You accept the Licence, the original Licensor and subsequent
|
||||
Contributors grant You a licence to their contributions to the Work, under the
|
||||
terms of this Licence.
|
||||
|
||||
|
||||
|
||||
## 7. Disclaimer of Warranty
|
||||
|
||||
The Work is a work in progress, which is continuously improved by numerous
|
||||
contributors. It is not a finished work and may therefore contain defects or
|
||||
“bugs” inherent to this type of software development.
|
||||
|
||||
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||
and without warranties of any kind concerning the Work, including without
|
||||
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||
copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||
for the grant of any rights to the Work.
|
||||
|
||||
|
||||
|
||||
## 8. Disclaimer of Liability
|
||||
|
||||
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||
of the Work, including without limitation, damages for loss of goodwill, work
|
||||
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||
damage, even if the Licensor has been advised of the possibility of such
|
||||
damage. However, the Licensor will be liable under statutory product liability
|
||||
laws as far such laws apply to the Work.
|
||||
|
||||
|
||||
|
||||
## 9. Additional agreements
|
||||
|
||||
While distributing the Original Work or Derivative Works, You may choose to
|
||||
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||
support, warranty, indemnity, or other liability obligations and/or services
|
||||
consistent with this Licence. However, in accepting such obligations, You may
|
||||
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||
the original Licensor or any other Contributor, and only if You agree to
|
||||
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
||||
by, or claims asserted against such Contributor by the fact You have accepted
|
||||
any such warranty or additional liability.
|
||||
|
||||
|
||||
|
||||
## 10. Acceptance of the Licence
|
||||
|
||||
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||
placed under the bottom of a window displaying the text of this Licence or by
|
||||
affirming consent in any other similar way, in accordance with the rules of
|
||||
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||
acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||
Distribution and/or Communication by You of the Work or copies thereof.
|
||||
|
||||
|
||||
|
||||
## 11. Information to the public
|
||||
|
||||
In case of any Distribution and/or Communication of the Work by means of
|
||||
electronic communication by You (for example, by offering to download the Work
|
||||
from a remote location) the distribution channel or media (for example, a
|
||||
website) must at least provide to the public the information requested by the
|
||||
applicable law regarding the Licensor, the Licence and the way it may be
|
||||
accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
|
||||
|
||||
## 12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically upon
|
||||
any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has
|
||||
received the Work from the Licensee under the Licence, provided such persons
|
||||
remain in full compliance with the Licence.
|
||||
|
||||
|
||||
|
||||
## 13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete
|
||||
agreement between the Parties as to the Work licensed hereunder.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable
|
||||
law, this will not affect the validity or enforceability of the Licence as a
|
||||
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||
it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions and/or new
|
||||
versions of this Licence, so far this is required and reasonable, without
|
||||
reducing the scope of the rights granted by the Licence. New versions of the
|
||||
Licence will be published with a unique version number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission,
|
||||
have identical value. Parties can take advantage of the linguistic version of
|
||||
their choice.
|
||||
|
||||
|
||||
|
||||
## 14. Jurisdiction
|
||||
|
||||
Any litigation resulting from the interpretation of this License, arising
|
||||
between the European Commission, as a Licensor, and any Licensee, will be
|
||||
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||
as laid down in article 238 of the Treaty establishing the European Community.
|
||||
|
||||
Any litigation arising between Parties, other than the European Commission, and
|
||||
resulting from the interpretation of this License, will be subject to the
|
||||
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||
conducts its primary business.
|
||||
|
||||
|
||||
|
||||
## 15. Applicable Law
|
||||
|
||||
This Licence shall be governed by the law of the European Union country where
|
||||
the Licensor resides or has his registered office.
|
||||
|
||||
This licence shall be governed by the Belgian law if:
|
||||
|
||||
- a litigation arises between the European Commission, as a Licensor, and any
|
||||
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||
- or registered office inside a European Union country.
|
||||
|
||||
|
||||
|
||||
## Appendix
|
||||
|
||||
|
||||
|
||||
“Compatible Licences” according to article 5 EUPL are:
|
||||
|
||||
|
||||
- GNU General Public License (GNU GPL) v. 2
|
||||
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
|
||||
- Common Public License v. 1.0
|
||||
|
||||
- Eclipse Public License v. 1.0
|
||||
|
||||
- Cecill v. 2.0
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
CMS - Plugin Framework
|
||||
--------------------------------------------------
|
||||
|
||||
CMS Plugin Framework is a library containing the definition of Java interfaces that plugins should implement
|
||||
|
||||
## Built with
|
||||
* [gCube SDI] (https://gcube.wiki.gcube-system.org/gcube/) - The gCube SDI
|
||||
* [gCube SmartGears] (https://gcube.wiki.gcube-system.org/gcube/SmartGears) - The gCube SmartGears framework
|
||||
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||
* [JAX-RS](https://github.com/eclipse-ee4j/jaxrs-api) - Java™ API for RESTful Web Services
|
||||
* [Jersey](https://jersey.github.io/) - JAX-RS runtime
|
||||
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation can be found [here](https://gcube.wiki.gcube-system.org/gcube/GeoPortal).
|
||||
|
||||
## Change log
|
||||
|
||||
See [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
|
||||
## About the gCube Framework
|
||||
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- DILIGENT (grant no. 004260).
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- D4Science (grant no. 212488);
|
||||
- D4Science-II (grant no.239019);
|
||||
- ENVRI (grant no. 283465);
|
||||
- iMarine(grant no. 283644);
|
||||
- EUBrazilOpenBio (grant no. 288754).
|
||||
- the H2020 research and innovation programme
|
||||
- SoBigData (grant no. 654024);
|
||||
- PARTHENOS (grant no. 654119);
|
||||
- EGIEngage (grant no. 654142);
|
||||
- ENVRIplus (grant no. 654182);
|
||||
- BlueBRIDGE (grant no. 675680);
|
||||
- PerformFish (grant no. 727610);
|
||||
- AGINFRAplus (grant no. 731001);
|
||||
- DESIRA (grant no. 818194);
|
||||
- ARIADNEplus (grant no. 823914);
|
||||
- RISIS2 (grant no. 824091);
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cms-plugin-framework</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<properties>
|
||||
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
|
||||
<sis.version>1.0</sis.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection>
|
||||
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection>
|
||||
<url>${gitBaseUrl}/gcube-cms-suite</url>
|
||||
</scm>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.application.cms.plugins;
|
||||
|
||||
import org.gcube.application.cms.plugins.faults.InitializationException;
|
||||
import org.gcube.application.cms.plugins.faults.ShutDownException;
|
||||
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
||||
|
||||
public interface InitializablePlugin extends Plugin{
|
||||
/**
|
||||
* To be called once per context
|
||||
* @return
|
||||
* @throws InitializationException
|
||||
*/
|
||||
|
||||
public InitializationReport initInContext()throws InitializationException;
|
||||
|
||||
/**
|
||||
* To be called for static initialization
|
||||
* @return
|
||||
* @throws InitializationException
|
||||
*/
|
||||
public InitializationReport init()throws InitializationException;
|
||||
|
||||
/**
|
||||
* To be called at application shutdown
|
||||
* @throws ShutDownException
|
||||
*/
|
||||
public void shutdown() throws ShutDownException;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package org.gcube.application.cms.plugins;
|
||||
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.cms.plugins.reports.ExecutionReport;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
|
||||
public interface LifecycleManager extends InitializablePlugin{
|
||||
|
||||
// Lifecycle operations
|
||||
|
||||
public ExecutionReport performStep(StepExecutionRequest request)throws StepException;
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.application.cms.plugins;
|
||||
|
||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||
|
||||
public interface Plugin {
|
||||
|
||||
public PluginDescriptor getDescriptor();
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.application.cms.plugins.faults;
|
||||
|
||||
public class InitializationException extends Exception{
|
||||
|
||||
public InitializationException() {
|
||||
}
|
||||
|
||||
public InitializationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InitializationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InitializationException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public InitializationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.application.cms.plugins.faults;
|
||||
|
||||
public class ShutDownException extends Exception {
|
||||
|
||||
public ShutDownException() {
|
||||
}
|
||||
|
||||
public ShutDownException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ShutDownException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ShutDownException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ShutDownException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.application.cms.plugins.faults;
|
||||
|
||||
public class StepException extends Exception {
|
||||
|
||||
public StepException() {
|
||||
}
|
||||
|
||||
public StepException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public StepException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public StepException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public StepException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.application.cms.plugins.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PluginDescriptor {
|
||||
|
||||
public static class BaseTypes{
|
||||
public static final String LIFECYCLE_MANAGER="LifecycleManagement";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String id;
|
||||
@NonNull
|
||||
private String type;
|
||||
private String label;
|
||||
private String description;
|
||||
private ComparableVersion version;
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.application.cms.plugins.reports;
|
||||
|
||||
import lombok.Data;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
|
||||
@Data
|
||||
public class ExecutionReport extends Report{
|
||||
|
||||
StepExecutionRequest request;
|
||||
|
||||
ProfiledDocument result;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package org.gcube.application.cms.plugins.reports;
|
||||
|
||||
public class InitializationReport {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.gcube.application.cms.plugins.reports;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Report {
|
||||
|
||||
public static enum Status {
|
||||
ERROR,WARNING,OK
|
||||
}
|
||||
|
||||
private Status status;
|
||||
private List<String> messages;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.application.cms.plugins.requests;
|
||||
|
||||
import lombok.Data;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
|
||||
@Data
|
||||
public class StepExecutionRequest {
|
||||
|
||||
public static class Steps{
|
||||
public static final String ON_INIT_DOCUMENT="@@@INIT_DOCUMENT@@";
|
||||
public static final String ON_UPDATE_DOCUMENT="@@@UPDATE_DOCUMENT@@";
|
||||
public static final String ON_DELETE_DOCUMENT="@@@DELETE_DOCUMENT@@";
|
||||
|
||||
public static final String ON_MATERIALIZE_DOCUMENT="@@@MATERIALIZE_DOCUMENT@@";
|
||||
public static final String ON_DEMATERIALIZE_DOCUMENT="@@@DEMATERIALIZE_DOCUMENT@@";
|
||||
|
||||
public static final String ON_INDEX_DOCUMENT="@@@INDEX_DOCUMENT@@";
|
||||
public static final String ON_DEINDEX_DOCUMENT="@@@DEINDEX_DOCUMENT@@";
|
||||
}
|
||||
|
||||
|
||||
Profile profile;
|
||||
ProfiledDocument document;
|
||||
String step;
|
||||
Document callParameters;
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Changelog for org.gcube.application.cms.cms-test-commons
|
||||
## [v1.0.1] - 2021-09-11
|
||||
- Introduced profiled documents
|
||||
|
||||
## [v1.0.0] - 2021-09-11
|
||||
First release
|
||||
- First release
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cms-test-commons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<name>CMS Test Commons</name>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
|
||||
|
@ -49,10 +49,21 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-plugin-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.gcube.application.cms.tests;
|
||||
|
||||
import ch.qos.logback.core.net.SyslogOutputStream;
|
||||
import org.gcube.application.cms.plugins.InitializablePlugin;
|
||||
import org.gcube.application.cms.plugins.Plugin;
|
||||
import org.gcube.application.cms.plugins.faults.InitializationException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
|
||||
import java.rmi.ServerError;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class BasicPluginTest {
|
||||
|
||||
static List<Plugin> plugins;
|
||||
|
||||
@BeforeClass
|
||||
public static void checkPluginRegistration() {
|
||||
|
||||
|
||||
Reflections reflections = new Reflections(
|
||||
new ConfigurationBuilder()
|
||||
.forPackage("org.gcube.application.cms")
|
||||
.filterInputsBy(new FilterBuilder().includePackage("org.gcube.application.cms")));
|
||||
|
||||
reflections.getSubTypesOf(Plugin.class).iterator().forEachRemaining(pluginClass->{
|
||||
if(!pluginClass.isInterface()){
|
||||
try {
|
||||
Plugin plugin = pluginClass.newInstance();
|
||||
plugins.add(plugin);
|
||||
}catch (Throwable t){
|
||||
t.printStackTrace(System.err);
|
||||
Assert.fail("Unable to Load "+pluginClass);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Assert.assertFalse(plugins.isEmpty());
|
||||
System.out.println("Plugin Loading OK");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void basicChecks(){
|
||||
plugins.forEach(p->{
|
||||
System.out.println("INIT Plugin "+p.getClass());
|
||||
Assert.assertNotNull(p.getDescriptor());
|
||||
Assert.assertNotNull(p.getDescriptor().getId());
|
||||
Assert.assertNotNull(p.getDescriptor().getType());
|
||||
Assert.assertNotNull(p.getDescriptor().getVersion());
|
||||
if(p instanceof InitializablePlugin){
|
||||
InitializablePlugin ip=(InitializablePlugin)p;
|
||||
try {
|
||||
ip.init();
|
||||
} catch (InitializationException e) {
|
||||
e.printStackTrace(System.err);
|
||||
Assert.fail("Unable to Init "+p.getDescriptor().getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,33 +1,20 @@
|
|||
package org.gcube.application.cms.tests.model;
|
||||
package org.gcube.application.cms.tests.model.concessioni;
|
||||
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import sun.misc.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TestFilters {
|
||||
public class TestConcessioniFilters {
|
||||
|
||||
public static final HashMap<String,String> filters=new HashMap<>();
|
||||
|
||||
static{
|
||||
|
||||
for(File f:new File(TestModel.getBaseFolder(),"filters").listFiles()){
|
||||
for(File f:new File(TestConcessioniModel.getBaseFolder(),"filters").listFiles()){
|
||||
try {
|
||||
filters.put(f.getName(), Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset()));
|
||||
} catch (IOException e) {
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.cms.tests.model;
|
||||
package org.gcube.application.cms.tests.model.concessioni;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -8,7 +8,7 @@ import java.util.Arrays;
|
|||
import org.bson.types.ObjectId;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
|
||||
public class TestModel {
|
||||
public class TestConcessioniModel {
|
||||
|
||||
public static File getBaseFolder(){
|
||||
File toReturn =new File("../test-data/concessioni");
|
|
@ -1,21 +1,19 @@
|
|||
package org.gcube.application.cms.tests.model;
|
||||
package org.gcube.application.cms.tests.model.concessioni;
|
||||
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import sun.misc.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TestQueries {
|
||||
public class TestConcessioniQueries {
|
||||
|
||||
public static final HashMap<String,String> queries =new HashMap<>();
|
||||
|
||||
static{
|
||||
|
||||
for(File f:new File(TestModel.getBaseFolder(),"queries").listFiles()){
|
||||
for(File f:new File(TestConcessioniModel.getBaseFolder(),"queries").listFiles()){
|
||||
try {
|
||||
queries.put(f.getName(), Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset()));
|
||||
} catch (IOException e) {
|
|
@ -0,0 +1,6 @@
|
|||
package org.gcube.application.cms.commons.model;
|
||||
|
||||
public class Serialization {
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.application.cms.commons.model.concessioni;
|
||||
|
||||
import org.gcube.application.cms.tests.model.TestFilters;
|
||||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniFilters;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -11,14 +11,14 @@ public class Models {
|
|||
|
||||
@Test
|
||||
public void checkFilters(){
|
||||
assertTrue(TestFilters.filters.size()>0);
|
||||
TestFilters.filters.keySet().forEach(f -> {
|
||||
assertTrue(TestConcessioniFilters.filters.size()>0);
|
||||
TestConcessioniFilters.filters.keySet().forEach(f -> {
|
||||
System.out.println(f);});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkConcessione(){
|
||||
Concessione c= TestModel.prepareConcessione(3,5);
|
||||
Concessione c= TestConcessioniModel.prepareConcessione(3,5);
|
||||
assertTrue(c.getPianteFineScavo().size()==3);
|
||||
assertTrue(c.getImmaginiRappresentative().size()==5);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.application.cms.commons.model.concessioni;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||
|
@ -17,8 +17,8 @@ public class PathsTest {
|
|||
|
||||
@Test
|
||||
public void embeddedPaths() {
|
||||
Concessione c= TestModel.prepareConcessione();
|
||||
c=TestModel.setIds(c);
|
||||
Concessione c= TestConcessioniModel.prepareConcessione();
|
||||
c= TestConcessioniModel.setIds(c);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ package org.gcube.application.cms.commons.model.concessioni;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SerializationTest {
|
||||
|
||||
|
||||
|
@ -35,24 +37,30 @@ public class SerializationTest {
|
|||
@Test
|
||||
public void readProfile() throws JsonProcessingException, IOException {
|
||||
|
||||
Profile concessione=mapper.readerFor(Profile.class).readValue(new File(TestModel.getBaseFolder(),"ProfileConcessioni.json"));
|
||||
Profile concessione=mapper.readerFor(Profile.class).readValue(new File(TestConcessioniModel.getBaseFolder(),"ProfileConcessioni.json"));
|
||||
|
||||
System.out.println("Profile is "+mapper.writeValueAsString(concessione));
|
||||
|
||||
Assert.assertTrue(concessione.getFields().size()>0);
|
||||
//Assert.assertTrue(concessione .getFields().size()>0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readConcessione() throws JsonProcessingException, IOException {
|
||||
Concessione concessione=mapper.readerFor(Concessione.class).readValue(new File(TestModel.getBaseFolder(),"Concessione.json"));
|
||||
System.out.println("Concessione is "+concessione.toString());
|
||||
|
||||
Concessione concessione=mapper.readerFor(Concessione.class).readValue(new File(TestConcessioniModel.getBaseFolder(),"Concessione.json"));
|
||||
System.out.println("Concessione is "+concessione.toString());
|
||||
|
||||
concessione.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
assertEquals(AccessPolicy.EMBARGOED,concessione.getRelazioneScavo().getPolicy());
|
||||
|
||||
concessione=mapper.readerFor(Concessione.class).readValue(mapper.writeValueAsString(concessione));
|
||||
assertEquals(AccessPolicy.EMBARGOED,concessione.getRelazioneScavo().getPolicy());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generic() throws JsonProcessingException, IOException {
|
||||
Concessione conc= TestModel.prepareConcessione();
|
||||
Concessione conc= TestConcessioniModel.prepareConcessione();
|
||||
conc.validate();
|
||||
full(conc);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Changelog for org.gcube.application.cms.concessioni-lifecycle
|
||||
|
||||
This library contains custom extensions for the support of GNA "concessioni" use case
|
||||
|
||||
## [v1.0.0] - 2021-12-15
|
||||
- First release
|
|
@ -0,0 +1,26 @@
|
|||
# Acknowledgments
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
|
||||
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
|
||||
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
|
||||
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
|
||||
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
|
||||
- the H2020 research and innovation programme
|
||||
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
|
||||
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
|
||||
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
|
||||
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
|
||||
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
|
||||
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
|
||||
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
|
||||
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
|
||||
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
|
||||
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
|
||||
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
|
||||
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
|
||||
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);
|
|
@ -0,0 +1,312 @@
|
|||
# European Union Public Licence V. 1.1
|
||||
|
||||
|
||||
EUPL © the European Community 2007
|
||||
|
||||
|
||||
This European Union Public Licence (the “EUPL”) applies to the Work or Software
|
||||
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||
the Work, other than as authorised under this Licence is prohibited (to the
|
||||
extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
The Original Work is provided under the terms of this Licence when the Licensor
|
||||
(as defined below) has placed the following notice immediately following the
|
||||
copyright notice for the Original Work:
|
||||
|
||||
Licensed under the EUPL V.1.1
|
||||
|
||||
or has expressed by any other mean his willingness to license under the EUPL.
|
||||
|
||||
|
||||
|
||||
## 1. Definitions
|
||||
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
- The Licence: this Licence.
|
||||
|
||||
- The Original Work or the Software: the software distributed and/or
|
||||
communicated by the Licensor under this Licence, available as Source Code and
|
||||
also as Executable Code as the case may be.
|
||||
|
||||
- Derivative Works: the works or software that could be created by the Licensee,
|
||||
based upon the Original Work or modifications thereof. This Licence does not
|
||||
define the extent of modification or dependence on the Original Work required
|
||||
in order to classify a work as a Derivative Work; this extent is determined by
|
||||
copyright law applicable in the country mentioned in Article 15.
|
||||
|
||||
- The Work: the Original Work and/or its Derivative Works.
|
||||
|
||||
- The Source Code: the human-readable form of the Work which is the most
|
||||
convenient for people to study and modify.
|
||||
|
||||
- The Executable Code: any code which has generally been compiled and which is
|
||||
meant to be interpreted by a computer as a program.
|
||||
|
||||
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||
the Work under the Licence.
|
||||
|
||||
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||
Software under the terms of the Licence.
|
||||
|
||||
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||
renting, distributing, communicating, transmitting, or otherwise making
|
||||
available, on-line or off-line, copies of the Work or providing access to its
|
||||
essential functionalities at the disposal of any other natural or legal
|
||||
person.
|
||||
|
||||
|
||||
|
||||
## 2. Scope of the rights granted by the Licence
|
||||
|
||||
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||
sub-licensable licence to do the following, for the duration of copyright vested
|
||||
in the Original Work:
|
||||
|
||||
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||
- to the public, including the right to make available or display the Work or
|
||||
- copies thereof to the public and perform publicly, as the case may be, the
|
||||
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||
- thereof, sub-license rights in the Work or copies thereof.
|
||||
|
||||
Those rights can be exercised on any media, supports and formats, whether now
|
||||
known or later invented, as far as the applicable law permits so.
|
||||
|
||||
In the countries where moral rights apply, the Licensor waives his right to
|
||||
exercise his moral right to the extent allowed by law in order to make effective
|
||||
the licence of the economic rights here above listed.
|
||||
|
||||
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||
any patents held by the Licensor, to the extent necessary to make use of the
|
||||
rights granted on the Work under this Licence.
|
||||
|
||||
|
||||
|
||||
## 3. Communication of the Source Code
|
||||
|
||||
The Licensor may provide the Work either in its Source Code form, or as
|
||||
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||
provides in addition a machine-readable copy of the Source Code of the Work
|
||||
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||
a notice following the copyright notice attached to the Work, a repository where
|
||||
the Source Code is easily and freely accessible for as long as the Licensor
|
||||
continues to distribute and/or communicate the Work.
|
||||
|
||||
|
||||
|
||||
## 4. Limitations on copyright
|
||||
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||
any exception or limitation to the exclusive rights of the rights owners in the
|
||||
Original Work or Software, of the exhaustion of those rights or of other
|
||||
applicable limitations thereto.
|
||||
|
||||
|
||||
|
||||
## 5. Obligations of the Licensee
|
||||
|
||||
The grant of the rights mentioned above is subject to some restrictions and
|
||||
obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||
trademarks notices and all notices that refer to the Licence and to the
|
||||
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||
notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||
Original Works or Derivative Works based upon the Original Work, this
|
||||
Distribution and/or Communication will be done under the terms of this Licence
|
||||
or of a later version of this Licence unless the Original Work is expressly
|
||||
distributed only under this version of the Licence. The Licensee (becoming
|
||||
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||
or Derivative Work that alter or restrict the terms of the Licence.
|
||||
|
||||
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||
Works or copies thereof based upon both the Original Work and another work
|
||||
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||
conflict with his/her obligations under this Licence, the obligations of the
|
||||
Compatible Licence shall prevail.
|
||||
|
||||
Provision of Source Code: When distributing and/or communicating copies of the
|
||||
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||
indicate a repository where this Source will be easily and freely available for
|
||||
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||
|
||||
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||
trademarks, service marks, or names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the copyright notice.
|
||||
|
||||
|
||||
|
||||
## 6. Chain of Authorship
|
||||
|
||||
The original Licensor warrants that the copyright in the Original Work granted
|
||||
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each time You accept the Licence, the original Licensor and subsequent
|
||||
Contributors grant You a licence to their contributions to the Work, under the
|
||||
terms of this Licence.
|
||||
|
||||
|
||||
|
||||
## 7. Disclaimer of Warranty
|
||||
|
||||
The Work is a work in progress, which is continuously improved by numerous
|
||||
contributors. It is not a finished work and may therefore contain defects or
|
||||
“bugs” inherent to this type of software development.
|
||||
|
||||
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||
and without warranties of any kind concerning the Work, including without
|
||||
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||
copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||
for the grant of any rights to the Work.
|
||||
|
||||
|
||||
|
||||
## 8. Disclaimer of Liability
|
||||
|
||||
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||
of the Work, including without limitation, damages for loss of goodwill, work
|
||||
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||
damage, even if the Licensor has been advised of the possibility of such
|
||||
damage. However, the Licensor will be liable under statutory product liability
|
||||
laws as far such laws apply to the Work.
|
||||
|
||||
|
||||
|
||||
## 9. Additional agreements
|
||||
|
||||
While distributing the Original Work or Derivative Works, You may choose to
|
||||
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||
support, warranty, indemnity, or other liability obligations and/or services
|
||||
consistent with this Licence. However, in accepting such obligations, You may
|
||||
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||
the original Licensor or any other Contributor, and only if You agree to
|
||||
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
||||
by, or claims asserted against such Contributor by the fact You have accepted
|
||||
any such warranty or additional liability.
|
||||
|
||||
|
||||
|
||||
## 10. Acceptance of the Licence
|
||||
|
||||
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||
placed under the bottom of a window displaying the text of this Licence or by
|
||||
affirming consent in any other similar way, in accordance with the rules of
|
||||
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||
acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||
Distribution and/or Communication by You of the Work or copies thereof.
|
||||
|
||||
|
||||
|
||||
## 11. Information to the public
|
||||
|
||||
In case of any Distribution and/or Communication of the Work by means of
|
||||
electronic communication by You (for example, by offering to download the Work
|
||||
from a remote location) the distribution channel or media (for example, a
|
||||
website) must at least provide to the public the information requested by the
|
||||
applicable law regarding the Licensor, the Licence and the way it may be
|
||||
accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
|
||||
|
||||
## 12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically upon
|
||||
any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has
|
||||
received the Work from the Licensee under the Licence, provided such persons
|
||||
remain in full compliance with the Licence.
|
||||
|
||||
|
||||
|
||||
## 13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete
|
||||
agreement between the Parties as to the Work licensed hereunder.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable
|
||||
law, this will not affect the validity or enforceability of the Licence as a
|
||||
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||
it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions and/or new
|
||||
versions of this Licence, so far this is required and reasonable, without
|
||||
reducing the scope of the rights granted by the Licence. New versions of the
|
||||
Licence will be published with a unique version number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission,
|
||||
have identical value. Parties can take advantage of the linguistic version of
|
||||
their choice.
|
||||
|
||||
|
||||
|
||||
## 14. Jurisdiction
|
||||
|
||||
Any litigation resulting from the interpretation of this License, arising
|
||||
between the European Commission, as a Licensor, and any Licensee, will be
|
||||
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||
as laid down in article 238 of the Treaty establishing the European Community.
|
||||
|
||||
Any litigation arising between Parties, other than the European Commission, and
|
||||
resulting from the interpretation of this License, will be subject to the
|
||||
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||
conducts its primary business.
|
||||
|
||||
|
||||
|
||||
## 15. Applicable Law
|
||||
|
||||
This Licence shall be governed by the law of the European Union country where
|
||||
the Licensor resides or has his registered office.
|
||||
|
||||
This licence shall be governed by the Belgian law if:
|
||||
|
||||
- a litigation arises between the European Commission, as a Licensor, and any
|
||||
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||
- or registered office inside a European Union country.
|
||||
|
||||
|
||||
|
||||
## Appendix
|
||||
|
||||
|
||||
|
||||
“Compatible Licences” according to article 5 EUPL are:
|
||||
|
||||
|
||||
- GNU General Public License (GNU GPL) v. 2
|
||||
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
|
||||
- Common Public License v. 1.0
|
||||
|
||||
- Eclipse Public License v. 1.0
|
||||
|
||||
- Cecill v. 2.0
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
gCube CMS Suite
|
||||
--------------------------------------------------
|
||||
|
||||
gCube CMS Suite is a set of components designed to manage complex space-temporal Documents defined by metadata Profiles.
|
||||
|
||||
## Built with
|
||||
* [gCube SmartGears] (https://gcube.wiki.gcube-system.org/gcube/SmartGears) - The gCube SmartGears framework
|
||||
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||
* [JAX-RS](https://github.com/eclipse-ee4j/jaxrs-api) - Java™ API for RESTful Web Services
|
||||
* [Jersey](https://jersey.github.io/) - JAX-RS runtime
|
||||
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation can be found [here](https://gcube.wiki.gcube-system.org/gcube/GeoPortal_Service).
|
||||
|
||||
## Change log
|
||||
|
||||
See [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
|
||||
## About the gCube Framework
|
||||
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- DILIGENT (grant no. 004260).
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- D4Science (grant no. 212488);
|
||||
- D4Science-II (grant no.239019);
|
||||
- ENVRI (grant no. 283465);
|
||||
- iMarine(grant no. 283644);
|
||||
- EUBrazilOpenBio (grant no. 288754).
|
||||
- the H2020 research and innovation programme
|
||||
- SoBigData (grant no. 654024);
|
||||
- PARTHENOS (grant no. 654119);
|
||||
- EGIEngage (grant no. 654142);
|
||||
- ENVRIplus (grant no. 654182);
|
||||
- BlueBRIDGE (grant no. 675680);
|
||||
- PerformFish (grant no. 727610);
|
||||
- AGINFRAplus (grant no. 731001);
|
||||
- DESIRA (grant no. 818194);
|
||||
- ARIADNEplus (grant no. 823914);
|
||||
- RISIS2 (grant no. 824091);
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>concessioni-lifecycle</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>GNA Concessioni Lifecycle</name>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection>
|
||||
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection>
|
||||
<url>${gitBaseUrl}/gcube-cms-suite</url>
|
||||
</scm>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-plugin-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-test-commons</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>concessioni-model</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,102 @@
|
|||
package org.gcube.application.cms.concessioni.plugins;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
|
||||
import org.gcube.application.cms.plugins.LifecycleManager;
|
||||
import org.gcube.application.cms.plugins.faults.InitializationException;
|
||||
import org.gcube.application.cms.plugins.faults.ShutDownException;
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||
import org.gcube.application.cms.plugins.reports.ExecutionReport;
|
||||
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
||||
import org.gcube.application.cms.plugins.reports.Report;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.utils.JSONPathWrapper;
|
||||
|
||||
@Slf4j
|
||||
public class ConcessioniLifeCycleManager implements LifecycleManager {
|
||||
|
||||
private static final PluginDescriptor DESCRIPTOR=new PluginDescriptor("GNA-CONCESSIONI-LC", PluginDescriptor.BaseTypes.LIFECYCLE_MANAGER);
|
||||
static {
|
||||
DESCRIPTOR.setDescription("GNA Concessioni. This plugin supports custom lifecycle management for the GNA Concessioni UseCase.");
|
||||
DESCRIPTOR.setVersion(new ComparableVersion("1.0.0"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InitializationReport initInContext() throws InitializationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InitializationReport init() throws InitializationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() throws ShutDownException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionReport performStep(StepExecutionRequest request) throws StepException {
|
||||
log.info("Serving Request {}",request);
|
||||
ExecutionReport report=new ExecutionReport();
|
||||
report.setRequest(request);
|
||||
report.setStatus(Report.Status.OK);
|
||||
try {
|
||||
switch (request.getStep()) {
|
||||
case StepExecutionRequest.Steps.ON_INIT_DOCUMENT:
|
||||
// Set Defaults as for on update
|
||||
case StepExecutionRequest.Steps.ON_UPDATE_DOCUMENT: {
|
||||
ProfiledDocument doc = request.getDocument();
|
||||
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_MATERIALIZE_DOCUMENT: {
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DEMATERIALIZE_DOCUMENT: {
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DEINDEX_DOCUMENT: {
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_INDEX_DOCUMENT: {
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DELETE_DOCUMENT: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new StepException("Invalid Step " + request.getStep());
|
||||
}
|
||||
}catch (StepException e){
|
||||
throw e;
|
||||
}catch (Throwable t){
|
||||
log.error("Unable to perform step "+request.getStep(),t);
|
||||
report.setStatus(Report.Status.ERROR);
|
||||
report.getMessages().add("Unable to execute Step "+request.getStep()+". Error was "+t.getMessage());
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
|
||||
// STATIC ROUTINES
|
||||
|
||||
private static final ProfiledDocument setDefaults(ProfiledDocument document){
|
||||
ProfiledConcessione c =(ProfiledConcessione) document;
|
||||
c.setDefaults();
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.application.cms.concessioni.plugins;
|
||||
|
||||
import org.gcube.application.cms.tests.BasicPluginTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Tests extends BasicPluginTest {
|
||||
|
||||
@Test
|
||||
public void testLoad(){
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Changelog for org.gcube.application.cms.concessioni-model
|
||||
|
||||
This library contains custom BEANS for the support of GNA "concessioni" use case
|
||||
|
||||
## [v1.0.0-SNAPSHOT] - 2021-12-15
|
||||
- First release
|
|
@ -0,0 +1,26 @@
|
|||
# Acknowledgments
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
|
||||
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
|
||||
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
|
||||
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
|
||||
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
|
||||
- the H2020 research and innovation programme
|
||||
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
|
||||
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
|
||||
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
|
||||
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
|
||||
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
|
||||
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
|
||||
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
|
||||
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
|
||||
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
|
||||
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
|
||||
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
|
||||
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
|
||||
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);
|
|
@ -0,0 +1,312 @@
|
|||
# European Union Public Licence V. 1.1
|
||||
|
||||
|
||||
EUPL © the European Community 2007
|
||||
|
||||
|
||||
This European Union Public Licence (the “EUPL”) applies to the Work or Software
|
||||
(as defined below) which is provided under the terms of this Licence. Any use of
|
||||
the Work, other than as authorised under this Licence is prohibited (to the
|
||||
extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
The Original Work is provided under the terms of this Licence when the Licensor
|
||||
(as defined below) has placed the following notice immediately following the
|
||||
copyright notice for the Original Work:
|
||||
|
||||
Licensed under the EUPL V.1.1
|
||||
|
||||
or has expressed by any other mean his willingness to license under the EUPL.
|
||||
|
||||
|
||||
|
||||
## 1. Definitions
|
||||
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
- The Licence: this Licence.
|
||||
|
||||
- The Original Work or the Software: the software distributed and/or
|
||||
communicated by the Licensor under this Licence, available as Source Code and
|
||||
also as Executable Code as the case may be.
|
||||
|
||||
- Derivative Works: the works or software that could be created by the Licensee,
|
||||
based upon the Original Work or modifications thereof. This Licence does not
|
||||
define the extent of modification or dependence on the Original Work required
|
||||
in order to classify a work as a Derivative Work; this extent is determined by
|
||||
copyright law applicable in the country mentioned in Article 15.
|
||||
|
||||
- The Work: the Original Work and/or its Derivative Works.
|
||||
|
||||
- The Source Code: the human-readable form of the Work which is the most
|
||||
convenient for people to study and modify.
|
||||
|
||||
- The Executable Code: any code which has generally been compiled and which is
|
||||
meant to be interpreted by a computer as a program.
|
||||
|
||||
- The Licensor: the natural or legal person that distributes and/or communicates
|
||||
the Work under the Licence.
|
||||
|
||||
- Contributor(s): any natural or legal person who modifies the Work under the
|
||||
Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
- The Licensee or “You”: any natural or legal person who makes any usage of the
|
||||
Software under the terms of the Licence.
|
||||
|
||||
- Distribution and/or Communication: any act of selling, giving, lending,
|
||||
renting, distributing, communicating, transmitting, or otherwise making
|
||||
available, on-line or off-line, copies of the Work or providing access to its
|
||||
essential functionalities at the disposal of any other natural or legal
|
||||
person.
|
||||
|
||||
|
||||
|
||||
## 2. Scope of the rights granted by the Licence
|
||||
|
||||
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
|
||||
sub-licensable licence to do the following, for the duration of copyright vested
|
||||
in the Original Work:
|
||||
|
||||
- use the Work in any circumstance and for all usage, reproduce the Work, modify
|
||||
- the Original Work, and make Derivative Works based upon the Work, communicate
|
||||
- to the public, including the right to make available or display the Work or
|
||||
- copies thereof to the public and perform publicly, as the case may be, the
|
||||
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
|
||||
- thereof, sub-license rights in the Work or copies thereof.
|
||||
|
||||
Those rights can be exercised on any media, supports and formats, whether now
|
||||
known or later invented, as far as the applicable law permits so.
|
||||
|
||||
In the countries where moral rights apply, the Licensor waives his right to
|
||||
exercise his moral right to the extent allowed by law in order to make effective
|
||||
the licence of the economic rights here above listed.
|
||||
|
||||
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
|
||||
any patents held by the Licensor, to the extent necessary to make use of the
|
||||
rights granted on the Work under this Licence.
|
||||
|
||||
|
||||
|
||||
## 3. Communication of the Source Code
|
||||
|
||||
The Licensor may provide the Work either in its Source Code form, or as
|
||||
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||
provides in addition a machine-readable copy of the Source Code of the Work
|
||||
along with each copy of the Work that the Licensor distributes or indicates, in
|
||||
a notice following the copyright notice attached to the Work, a repository where
|
||||
the Source Code is easily and freely accessible for as long as the Licensor
|
||||
continues to distribute and/or communicate the Work.
|
||||
|
||||
|
||||
|
||||
## 4. Limitations on copyright
|
||||
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
||||
any exception or limitation to the exclusive rights of the rights owners in the
|
||||
Original Work or Software, of the exhaustion of those rights or of other
|
||||
applicable limitations thereto.
|
||||
|
||||
|
||||
|
||||
## 5. Obligations of the Licensee
|
||||
|
||||
The grant of the rights mentioned above is subject to some restrictions and
|
||||
obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
Attribution right: the Licensee shall keep intact all copyright, patent or
|
||||
trademarks notices and all notices that refer to the Licence and to the
|
||||
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
||||
copy of the Licence with every copy of the Work he/she distributes and/or
|
||||
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||
notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
Copyleft clause: If the Licensee distributes and/or communicates copies of the
|
||||
Original Works or Derivative Works based upon the Original Work, this
|
||||
Distribution and/or Communication will be done under the terms of this Licence
|
||||
or of a later version of this Licence unless the Original Work is expressly
|
||||
distributed only under this version of the Licence. The Licensee (becoming
|
||||
Licensor) cannot offer or impose any additional terms or conditions on the Work
|
||||
or Derivative Work that alter or restrict the terms of the Licence.
|
||||
|
||||
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
|
||||
Works or copies thereof based upon both the Original Work and another work
|
||||
licensed under a Compatible Licence, this Distribution and/or Communication can
|
||||
be done under the terms of this Compatible Licence. For the sake of this clause,
|
||||
“Compatible Licence” refers to the licences listed in the appendix attached to
|
||||
this Licence. Should the Licensee’s obligations under the Compatible Licence
|
||||
conflict with his/her obligations under this Licence, the obligations of the
|
||||
Compatible Licence shall prevail.
|
||||
|
||||
Provision of Source Code: When distributing and/or communicating copies of the
|
||||
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||
indicate a repository where this Source will be easily and freely available for
|
||||
as long as the Licensee continues to distribute and/or communicate the Work.
|
||||
|
||||
Legal Protection: This Licence does not grant permission to use the trade names,
|
||||
trademarks, service marks, or names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the copyright notice.
|
||||
|
||||
|
||||
|
||||
## 6. Chain of Authorship
|
||||
|
||||
The original Licensor warrants that the copyright in the Original Work granted
|
||||
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each Contributor warrants that the copyright in the modifications he/she brings
|
||||
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
||||
power and authority to grant the Licence.
|
||||
|
||||
Each time You accept the Licence, the original Licensor and subsequent
|
||||
Contributors grant You a licence to their contributions to the Work, under the
|
||||
terms of this Licence.
|
||||
|
||||
|
||||
|
||||
## 7. Disclaimer of Warranty
|
||||
|
||||
The Work is a work in progress, which is continuously improved by numerous
|
||||
contributors. It is not a finished work and may therefore contain defects or
|
||||
“bugs” inherent to this type of software development.
|
||||
|
||||
For the above reason, the Work is provided under the Licence on an “as is” basis
|
||||
and without warranties of any kind concerning the Work, including without
|
||||
limitation merchantability, fitness for a particular purpose, absence of defects
|
||||
or errors, accuracy, non-infringement of intellectual property rights other than
|
||||
copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This disclaimer of warranty is an essential part of the Licence and a condition
|
||||
for the grant of any rights to the Work.
|
||||
|
||||
|
||||
|
||||
## 8. Disclaimer of Liability
|
||||
|
||||
Except in the cases of wilful misconduct or damages directly caused to natural
|
||||
persons, the Licensor will in no event be liable for any direct or indirect,
|
||||
material or moral, damages of any kind, arising out of the Licence or of the use
|
||||
of the Work, including without limitation, damages for loss of goodwill, work
|
||||
stoppage, computer failure or malfunction, loss of data or any commercial
|
||||
damage, even if the Licensor has been advised of the possibility of such
|
||||
damage. However, the Licensor will be liable under statutory product liability
|
||||
laws as far such laws apply to the Work.
|
||||
|
||||
|
||||
|
||||
## 9. Additional agreements
|
||||
|
||||
While distributing the Original Work or Derivative Works, You may choose to
|
||||
conclude an additional agreement to offer, and charge a fee for, acceptance of
|
||||
support, warranty, indemnity, or other liability obligations and/or services
|
||||
consistent with this Licence. However, in accepting such obligations, You may
|
||||
act only on your own behalf and on your sole responsibility, not on behalf of
|
||||
the original Licensor or any other Contributor, and only if You agree to
|
||||
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
||||
by, or claims asserted against such Contributor by the fact You have accepted
|
||||
any such warranty or additional liability.
|
||||
|
||||
|
||||
|
||||
## 10. Acceptance of the Licence
|
||||
|
||||
The provisions of this Licence can be accepted by clicking on an icon “I agree”
|
||||
placed under the bottom of a window displaying the text of this Licence or by
|
||||
affirming consent in any other similar way, in accordance with the rules of
|
||||
applicable law. Clicking on that icon indicates your clear and irrevocable
|
||||
acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
||||
such as the use of the Work, the creation by You of a Derivative Work or the
|
||||
Distribution and/or Communication by You of the Work or copies thereof.
|
||||
|
||||
|
||||
|
||||
## 11. Information to the public
|
||||
|
||||
In case of any Distribution and/or Communication of the Work by means of
|
||||
electronic communication by You (for example, by offering to download the Work
|
||||
from a remote location) the distribution channel or media (for example, a
|
||||
website) must at least provide to the public the information requested by the
|
||||
applicable law regarding the Licensor, the Licence and the way it may be
|
||||
accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
|
||||
|
||||
## 12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically upon
|
||||
any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has
|
||||
received the Work from the Licensee under the Licence, provided such persons
|
||||
remain in full compliance with the Licence.
|
||||
|
||||
|
||||
|
||||
## 13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete
|
||||
agreement between the Parties as to the Work licensed hereunder.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable
|
||||
law, this will not affect the validity or enforceability of the Licence as a
|
||||
whole. Such provision will be construed and/or reformed so as necessary to make
|
||||
it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions and/or new
|
||||
versions of this Licence, so far this is required and reasonable, without
|
||||
reducing the scope of the rights granted by the Licence. New versions of the
|
||||
Licence will be published with a unique version number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission,
|
||||
have identical value. Parties can take advantage of the linguistic version of
|
||||
their choice.
|
||||
|
||||
|
||||
|
||||
## 14. Jurisdiction
|
||||
|
||||
Any litigation resulting from the interpretation of this License, arising
|
||||
between the European Commission, as a Licensor, and any Licensee, will be
|
||||
subject to the jurisdiction of the Court of Justice of the European Communities,
|
||||
as laid down in article 238 of the Treaty establishing the European Community.
|
||||
|
||||
Any litigation arising between Parties, other than the European Commission, and
|
||||
resulting from the interpretation of this License, will be subject to the
|
||||
exclusive jurisdiction of the competent court where the Licensor resides or
|
||||
conducts its primary business.
|
||||
|
||||
|
||||
|
||||
## 15. Applicable Law
|
||||
|
||||
This Licence shall be governed by the law of the European Union country where
|
||||
the Licensor resides or has his registered office.
|
||||
|
||||
This licence shall be governed by the Belgian law if:
|
||||
|
||||
- a litigation arises between the European Commission, as a Licensor, and any
|
||||
- Licensee; the Licensor, other than the European Commission, has no residence
|
||||
- or registered office inside a European Union country.
|
||||
|
||||
|
||||
|
||||
## Appendix
|
||||
|
||||
|
||||
|
||||
“Compatible Licences” according to article 5 EUPL are:
|
||||
|
||||
|
||||
- GNU General Public License (GNU GPL) v. 2
|
||||
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
|
||||
- Common Public License v. 1.0
|
||||
|
||||
- Eclipse Public License v. 1.0
|
||||
|
||||
- Cecill v. 2.0
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
gCube CMS Suite
|
||||
--------------------------------------------------
|
||||
|
||||
gCube CMS Suite is a set of components designed to manage complex space-temporal Documents defined by metadata Profiles.
|
||||
|
||||
## Built with
|
||||
* [gCube SmartGears] (https://gcube.wiki.gcube-system.org/gcube/SmartGears) - The gCube SmartGears framework
|
||||
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||
* [JAX-RS](https://github.com/eclipse-ee4j/jaxrs-api) - Java™ API for RESTful Web Services
|
||||
* [Jersey](https://jersey.github.io/) - JAX-RS runtime
|
||||
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation can be found [here](https://gcube.wiki.gcube-system.org/gcube/GeoPortal_Service).
|
||||
|
||||
## Change log
|
||||
|
||||
See [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
|
||||
## About the gCube Framework
|
||||
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- DILIGENT (grant no. 004260).
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- D4Science (grant no. 212488);
|
||||
- D4Science-II (grant no.239019);
|
||||
- ENVRI (grant no. 283465);
|
||||
- iMarine(grant no. 283644);
|
||||
- EUBrazilOpenBio (grant no. 288754).
|
||||
- the H2020 research and innovation programme
|
||||
- SoBigData (grant no. 654024);
|
||||
- PARTHENOS (grant no. 654119);
|
||||
- EGIEngage (grant no. 654142);
|
||||
- ENVRIplus (grant no. 654182);
|
||||
- BlueBRIDGE (grant no. 675680);
|
||||
- PerformFish (grant no. 727610);
|
||||
- AGINFRAplus (grant no. 731001);
|
||||
- DESIRA (grant no. 818194);
|
||||
- ARIADNEplus (grant no. 823914);
|
||||
- RISIS2 (grant no. 824091);
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>concessioni-model</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>GNA Concessioni Model</name>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection>
|
||||
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection>
|
||||
<url>${gitBaseUrl}/gcube-cms-suite</url>
|
||||
</scm>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-test-commons</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.application.cms.custom.gna.concessioni.model;
|
||||
|
||||
public interface DefaultLogicHolder {
|
||||
|
||||
public void setDefaults();
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.gcube.application.cms.custom.gna.concessioni.model;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
public class DocumentedRelazioneScavo extends Document implements DefaultLogicHolder{
|
||||
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package org.gcube.application.cms.custom.gna.concessioni.model;
|
||||
|
||||
import org.bson.BsonDocument;
|
||||
import org.bson.BsonString;
|
||||
import org.bson.BsonValue;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.Access;
|
||||
import org.gcube.application.geoportal.common.model.document.AccessPolicy;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.RegisteredFileSet;
|
||||
import org.gcube.application.geoportal.common.model.legacy.AbstractRelazione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.Check;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ProfiledConcessione extends ProfiledDocument {
|
||||
|
||||
public static final String NOME="nome";
|
||||
//Introduzione (descrizione del progetto)
|
||||
public final static String INTRODUZIONE = "introduzione";
|
||||
//Descrizione del contenuto
|
||||
public final static String DSCRIZIONE_CONTENUTO ="descrizioneContenuto";
|
||||
//Autori
|
||||
public final static String AUTHORS= "authors";
|
||||
//Soggetto che materialmente invia i dati.
|
||||
public final static String CONTRIBUTORE ="contributore";
|
||||
|
||||
//Indicare il nome del titolare/i dei dati contenuti nel dataset e/o per sue specifiche parti.
|
||||
public final static String TITOLARI="titolari";
|
||||
|
||||
public final static String RESPONSABILE="responsabile";
|
||||
public final static String EDITORS ="editore";
|
||||
|
||||
public final static String FONTI_FINANZIAMENTO="fontiFinanziamento";
|
||||
//Research Excavation; Archaeology (valori di default)
|
||||
public final static String SOGGETTO="soggetto";
|
||||
|
||||
//Referenze bibliografiche, DOI (se esistenti) di risorse correlate all’indagine in oggetto
|
||||
public final static String RISORSE_CORRELATE="risorseCorrelate";
|
||||
|
||||
public final static String DATA_INZIO_PROGETTO="dataInizioProgetto";
|
||||
public final static String DATA_FINE_PROGETTO="dataFineProgetto";
|
||||
|
||||
public final static String TITOLARE_LICENZA="titolareLicenza";
|
||||
public final static String TITOLARE_COPYRIGHT="titolareCopyright";
|
||||
|
||||
public final static String PAROLE_CHIAVE_LIBERE="paroleChiaveLibere";
|
||||
public final static String PAREOLE_CHIAVE_ICCD="paroleChiaveICCD";
|
||||
|
||||
public final static String RELAZIONE_SCAVO="relazioneScavo";
|
||||
public final static String ABSTRACT_RELAZIONE ="abstractRelazione";
|
||||
public final static String IMMAGINI_RAPPRESENTATIVE="immaginiRappresentative";
|
||||
public final static String POSIZIONAMENTO_SCAVO = "posizionamentoScavo";
|
||||
public final static String PIANTE_FINE_SCAVO = "pianteFineScavo";
|
||||
public final static String GENERIC_CONTENT= "genericContent";
|
||||
|
||||
public static class Sections{
|
||||
public static final String TITOLO="titolo";
|
||||
}
|
||||
public static class Relazione{
|
||||
|
||||
public static final String RESPONSABILI= "responsabili";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
Document doc=this.getTheDocument();
|
||||
doc.putIfAbsent(SOGGETTO,new String[]{"Research Excavation","Archaeology"});
|
||||
|
||||
doc.putIfAbsent(DSCRIZIONE_CONTENUTO,"Relazione di fine scavo e relativo abstract; selezione di immagini rappresentative;"
|
||||
+ " posizionamento topografico dell'area indagata, pianta di fine scavo.");
|
||||
|
||||
// Super Section
|
||||
this.getInfo().getAccess().setLicense(
|
||||
ConstraintCheck.defaultFor(getInfo().getAccess().getLicense(), "CC0-1.0").evaluate());
|
||||
|
||||
|
||||
//RELAZIONE
|
||||
doc.putIfAbsent(RELAZIONE_SCAVO,new RegisteredFileSet());
|
||||
Document rel=doc.get(RELAZIONE_SCAVO,Document.class);
|
||||
rel.putIfAbsent(Sections.TITOLO,doc.getString(NOME)+" relazione di scavo");
|
||||
rel.putIfAbsent(SOGGETTO,doc.get(SOGGETTO));
|
||||
rel.putIfAbsent(RegisteredFileSet.CREATION_INFO,this.getInfo().getCreationInfo());
|
||||
rel.putIfAbsent(RegisteredFileSet.ACCESS,this.getInfo().getAccess());
|
||||
Access relAccess=rel.get(RegisteredFileSet.ACCESS,Access.class);
|
||||
relAccess.setLicense(ConstraintCheck.defaultFor(relAccess.getLicense(),"CC-BY-4.0").evaluate());
|
||||
relAccess.setPolicy(ConstraintCheck.defaultFor(relAccess.getPolicy(), AccessPolicy.OPEN).evaluate());
|
||||
|
||||
//ABSTRACT Relazione
|
||||
doc.putIfAbsent(ABSTRACT_RELAZIONE,new RegisteredFileSet());
|
||||
Document abs=doc.get(ABSTRACT_RELAZIONE,Document.class);
|
||||
abs.putIfAbsent(Sections.TITOLO,doc.getString(NOME)+" abstract relazione di scavo");
|
||||
abs.putIfAbsent(RegisteredFileSet.CREATION_INFO,this.getInfo().getCreationInfo());
|
||||
abs.putIfAbsent(RegisteredFileSet.ACCESS,this.getInfo().getAccess());
|
||||
Access absAccess=rel.get(RegisteredFileSet.ACCESS,Access.class);
|
||||
absAccess.setLicense(ConstraintCheck.defaultFor(absAccess.getLicense(),"CC-BY-4.0").evaluate());
|
||||
absAccess.setPolicy(ConstraintCheck.defaultFor(absAccess.getPolicy(), AccessPolicy.OPEN).evaluate());
|
||||
|
||||
//IMMAGINI RAPPRESENTATIVE
|
||||
|
||||
|
||||
// if(doc.containsKey(IMMAGINI_RAPPRESENTATIVE)) {
|
||||
// for (BsonValue bsonValue : doc.toBsonDocument(null, null).
|
||||
// getArray(IMMAGINI_RAPPRESENTATIVE)) {
|
||||
// BsonDocument imgDocument = bsonValue.asDocument();
|
||||
// imgDocument.putIfAbsent(SOGGETTO,new BsonString(doc.getString(SOGGETTO));
|
||||
// imgDocument.putIfAbsent(RegisteredFileSet.CREATION_INFO,new BsonDocument(this.getInfo().getCreationInfo());
|
||||
// imgDocument.putIfAbsent(RegisteredFileSet.ACCESS,this.getInfo().getAccess());
|
||||
// Access absAccess=rel.get(RegisteredFileSet.ACCESS,Access.class);
|
||||
// absAccess.setLicense(ConstraintCheck.defaultFor(absAccess.getLicense(),"CC-BY-4.0").evaluate());
|
||||
// absAccess.setPolicy(ConstraintCheck.defaultFor(absAccess.getPolicy(), AccessPolicy.OPEN).evaluate());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -2,26 +2,28 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.application.geoportal-client
|
||||
|
||||
## [v1.0.6] - 2021-09-20
|
||||
- Changed artifact dependencies
|
||||
- Default Profiled Documents client
|
||||
|
||||
## [v1.0.5] - 2021-09-20
|
||||
Refactored repositories
|
||||
- Refactored repositories
|
||||
|
||||
## [v1.0.4-SNAPSHOT] - 2020-11-11
|
||||
Serialization utils
|
||||
Queries & Filters support
|
||||
Test Reports
|
||||
UseCases
|
||||
Fixes #21897
|
||||
- Serialization utils
|
||||
- Queries & Filters support
|
||||
- Test Reports
|
||||
- UseCases
|
||||
- Fixes #21897
|
||||
|
||||
## [v1.0.3] - 2020-11-11
|
||||
Stateful Concessioni Manager client over mongo
|
||||
- Stateful Concessioni Manager client over mongo
|
||||
|
||||
## [v1.0.2] - 2020-11-11
|
||||
Fixed dulicate dependency declaration
|
||||
- Fixed dulicate dependency declaration
|
||||
|
||||
## [v1.0.1] - 2020-11-11
|
||||
Excluded common-calls 1.2.0
|
||||
|
||||
-Excluded common-calls 1.2.0
|
||||
|
||||
## [v1.0.0] - 2020-11-11
|
||||
|
||||
First release
|
||||
- First release
|
|
@ -4,14 +4,14 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-client</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.6</version>
|
||||
<name>Geoportal Client</name>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package org.gcube.application.geoportal.client;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class DefaultProfiledConcessioni implements MongoConcessioni {
|
||||
|
||||
|
||||
@Override
|
||||
public Concessione createNew(Concessione c) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id, Boolean force) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione getById(String id) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Concessione> getList() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione publish(String id) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione registerFileSet(String id, AddSectionToConcessioneRequest request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione cleanFileSet(String id, String path) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione update(String id, String jsonUpdate) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione replace(Concessione replacement) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unPublish(String id) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getCurrentConfiguration() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Concessione> search(String filter) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Concessione> query(QueryRequest request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryForJSON(QueryRequest request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Iterator<T> queryForType(QueryRequest request, Class<T> clazz) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package org.gcube.application.geoportal.client;
|
||||
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Iterator;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class DefaultProfiledDocuments implements ProfiledDocumentsI<ProfiledDocument> {
|
||||
|
||||
@NonNull
|
||||
private final ProxyDelegate<WebTarget> delegate;
|
||||
|
||||
@Override
|
||||
public ProfiledDocument createNew(Document toCreate) throws RemoteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id) throws RemoteException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id, Boolean force) throws RemoteException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument getById(String id) throws RemoteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() throws RemoteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ProfiledDocument> query(QueryRequest request) throws RemoteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String querForJSON(QueryRequest request) throws RemoteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument performStep(String id, String step, Document request) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package org.gcube.application.geoportal.client;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.project.Project;
|
||||
import org.gcube.application.geoportal.common.rest.ProjectsI;
|
||||
import org.gcube.common.clients.Call;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class DefaultProjects implements ProjectsI{
|
||||
|
||||
@NonNull
|
||||
private final ProxyDelegate<WebTarget> delegate;
|
||||
|
||||
@Override
|
||||
public void deleteById(String profileId, String projectId) throws RemoteException {
|
||||
deleteById(profileId,projectId,false);
|
||||
}
|
||||
@Override
|
||||
public void deleteById(String profileId, String projectId,Boolean force) throws RemoteException {
|
||||
// Call<WebTarget,String> call= new Call<WebTarget, String>() {
|
||||
//
|
||||
// @Override
|
||||
// public String call(WebTarget endpoint) throws Exception {
|
||||
// endpoint.path(profileId).path(projectId).request(MediaType.APPLICATION_JSON).delete();
|
||||
// }
|
||||
// };
|
||||
// try{
|
||||
// delegate.make(call);
|
||||
// }catch(Exception e) {
|
||||
//// throw new RemoteException(e);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Project> getAll() throws RemoteException {
|
||||
Call<WebTarget,Iterator<Project>> call=new Call<WebTarget,Iterator<Project>>(){
|
||||
@Override
|
||||
public Iterator<Project> call(WebTarget endpoint) throws Exception {
|
||||
throw new Exception("Client method not ready");
|
||||
}
|
||||
};
|
||||
try{
|
||||
return delegate.make(call);
|
||||
}catch(Exception e) {
|
||||
throw new RemoteException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Project> getByFilter(String filter) throws RemoteException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Project> getByFilter(String filter, String profileId) throws RemoteException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getById(String profileId, String id) throws RemoteException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Project> getByProfile(String profileId) throws RemoteException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project registrNew(String profileId, String jsonDocument) throws RemoteException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project update(String profileId, String projectId, String jsonDocument) throws RemoteException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -6,14 +6,14 @@ import javax.xml.transform.dom.DOMResult;
|
|||
import javax.xml.ws.EndpointReference;
|
||||
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.rest.ProjectsI;
|
||||
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
||||
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||
import org.gcube.common.clients.config.ProxyConfig;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public class ProjectsPlugin extends GeoportalAbstractPlugin<WebTarget, ProjectsI>{
|
||||
public class ProjectsPlugin extends GeoportalAbstractPlugin<WebTarget, ProfiledDocumentsI>{
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -22,8 +22,8 @@ public class ProjectsPlugin extends GeoportalAbstractPlugin<WebTarget, ProjectsI
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProjectsI newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||
return new DefaultProjects(delegate);
|
||||
public ProfiledDocumentsI newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||
return new DefaultProfiledDocuments(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.gcube.application.geoportal.common.rest.TempFile;
|
|||
public interface ConcessioniManagerI extends MongoConcessioni{
|
||||
|
||||
|
||||
public Concessione getCurrent();
|
||||
public Concessione addImmagineRappresentativa(UploadedImage toAdd,TempFile f) throws Exception;
|
||||
public Concessione addPiantaFineScavo(LayerConcessione toAdd,TempFile...files)throws Exception;
|
||||
public Concessione setPosizionamento(LayerConcessione toSet,TempFile...files)throws Exception;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.gcube.application.geoportal.client.DefaultMongoConcessioni;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
|
@ -21,97 +22,98 @@ public class StatefulMongoConcessioni extends DefaultMongoConcessioni implements
|
|||
super(delegate);
|
||||
}
|
||||
|
||||
private Concessione currentC=null;
|
||||
@Getter
|
||||
private Concessione current =null;
|
||||
private StorageUtils storage=new StorageUtils();
|
||||
|
||||
|
||||
// Override methods to handle state
|
||||
@Override
|
||||
public Concessione createNew(Concessione c) throws Exception {
|
||||
currentC=super.createNew(c);
|
||||
return currentC;
|
||||
current =super.createNew(c);
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione getById(String id) throws Exception {
|
||||
currentC= super.getById(id);
|
||||
return currentC;
|
||||
current = super.getById(id);
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione publish() throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC=super.publish(currentC.getMongo_id());
|
||||
return currentC;
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current =super.publish(current.getMongo_id());
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete() throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
super.deleteById(currentC.getMongo_id());
|
||||
currentC=null;
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
super.deleteById(current.getMongo_id());
|
||||
current =null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione addImmagineRappresentativa(UploadedImage toAdd, TempFile f) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(currentC.getImmaginiRappresentative()==null) currentC.setImmaginiRappresentative(new ArrayList<UploadedImage>());
|
||||
currentC.getImmaginiRappresentative().add(toAdd);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(current.getImmaginiRappresentative()==null) current.setImmaginiRappresentative(new ArrayList<UploadedImage>());
|
||||
current.getImmaginiRappresentative().add(toAdd);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
FileSets.build(Paths.imgByIndex(currentC.getImmaginiRappresentative().size()-1),f).getTheRequest());
|
||||
return currentC;
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.imgByIndex(current.getImmaginiRappresentative().size()-1),f).getTheRequest());
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione addPiantaFineScavo(LayerConcessione toAdd, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(currentC.getPianteFineScavo()==null) currentC.setPianteFineScavo(new ArrayList<>());
|
||||
currentC.getPianteFineScavo().add(toAdd);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
if(current.getPianteFineScavo()==null) current.setPianteFineScavo(new ArrayList<>());
|
||||
current.getPianteFineScavo().add(toAdd);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
FileSets.build(Paths.piantaByIndex(currentC.getPianteFineScavo().size()-1),files).getTheRequest());
|
||||
return currentC;
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.piantaByIndex(current.getPianteFineScavo().size()-1),files).getTheRequest());
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione setPosizionamento(LayerConcessione toSet, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC.setPosizionamentoScavo(toSet);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current.setPosizionamentoScavo(toSet);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.POSIZIONAMENTO,files).getTheRequest());
|
||||
return currentC;
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione setRelazioneScavo(RelazioneScavo toSet, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC.setRelazioneScavo(toSet);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current.setRelazioneScavo(toSet);
|
||||
current =replace(current);
|
||||
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.RELAZIONE,files).getTheRequest());
|
||||
return currentC;
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Concessione setAbstractRelazioneScavo(AbstractRelazione toSet, TempFile... files) throws Exception {
|
||||
if(currentC==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
currentC.setAbstractRelazione(toSet);
|
||||
currentC=replace(currentC);
|
||||
if(current ==null) throw new Exception("Invalid operation : current Concessione is null.");
|
||||
current.setAbstractRelazione(toSet);
|
||||
current =replace(current);
|
||||
|
||||
currentC=super.registerFileSet(currentC.getMongo_id(),
|
||||
current =super.registerFileSet(current.getMongo_id(),
|
||||
FileSets.build(Paths.ABSTRACT_RELAZIONE,files).getTheRequest());
|
||||
return currentC;
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.application.geoportal;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.application.cms.tests.TokenSetter;
|
||||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
|
||||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
|
|
|
@ -7,8 +7,9 @@ public class BasicVreTests {
|
|||
|
||||
@BeforeClass
|
||||
public static void setScope(){
|
||||
// TokenSetter.set("/gcube/devNext/NextNext");
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
// TokenSetter.set("/pred4s/preprod/preVRE");
|
||||
// TokenSetter.set("/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype");
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,13 +7,11 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.InputStreamDescriptor;
|
||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
|
||||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
|
@ -31,55 +29,66 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
StorageUtils storage=new StorageUtils();
|
||||
|
||||
|
||||
Concessione toRegister= TestModel.prepareEmptyConcessione();
|
||||
Concessione toRegister= TestConcessioniModel.prepareEmptyConcessione();
|
||||
toRegister.setNome("Mock module");
|
||||
manager.createNew(toRegister);
|
||||
|
||||
Concessione source=TestModel.prepareConcessione();
|
||||
|
||||
|
||||
|
||||
Concessione source=TestConcessioniModel.prepareConcessione();
|
||||
|
||||
|
||||
UploadedImage toRegisterImg= source.getImmaginiRappresentative().get(0);
|
||||
|
||||
// TEMP Files are hosted in INFRASTRUCTURE's VOLATILE AREA
|
||||
TempFile toUpload=storage.putOntoStorage(
|
||||
new File(TestModel.getBaseFolder(),"immagine.png"), "immagine.png");
|
||||
new File(TestConcessioniModel.getBaseFolder(),"immagine1.png"), "immagine.png");
|
||||
|
||||
manager.addImmagineRappresentativa(toRegisterImg, toUpload);
|
||||
|
||||
|
||||
//Alternative Method
|
||||
InputStreamDescriptor isDesc=
|
||||
new InputStreamDescriptor(new FileInputStream(new File(TestModel.getBaseFolder(),
|
||||
"immagine.png")), "San Mauro_drone totale.JPG");
|
||||
new InputStreamDescriptor(new FileInputStream(new File(TestConcessioniModel.getBaseFolder(),
|
||||
"immagine1.png")), "San Mauro_drone totale.JPG");
|
||||
manager.addImmagineRappresentativa(toRegisterImg, isDesc);
|
||||
|
||||
source.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
assertEquals(AccessPolicy.EMBARGOED,source.getRelazioneScavo().getPolicy());
|
||||
|
||||
//Relazione
|
||||
manager.setRelazioneScavo(source.getRelazioneScavo(),
|
||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"),
|
||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf"));
|
||||
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"),
|
||||
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf"));
|
||||
assertEquals(AccessPolicy.EMBARGOED,manager.getCurrent().getRelazioneScavo().getPolicy());
|
||||
|
||||
//Abstract
|
||||
manager.setAbstractRelazioneScavo(
|
||||
source.getAbstractRelazione(),
|
||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_it.pdf"),
|
||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf"));
|
||||
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_it.pdf"),
|
||||
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf"));
|
||||
|
||||
|
||||
|
||||
// Posizionamento scavo
|
||||
|
||||
manager.setPosizionamento(source.getPosizionamentoScavo(),
|
||||
storage.putOntoStorage(
|
||||
new File(TestModel.getBaseFolder(),"pos.shp"),"pos.shp"));
|
||||
new File(TestConcessioniModel.getBaseFolder(),"pos.shp"),"pos.shp"));
|
||||
|
||||
// Piante
|
||||
manager.addPiantaFineScavo(source.getPianteFineScavo().get(0),
|
||||
storage.putOntoStorage(
|
||||
new File(TestModel.getBaseFolder(),"pianta.shp"),"pianta.shp"));
|
||||
new File(TestConcessioniModel.getBaseFolder(),"pianta.shp"),"pianta.shp"));
|
||||
// new File("/Users/fabioisti/Documents/invio_08_05/Montalto di Castro (VT)_Vulci_Indagini non invasive_Doc. paragr._Va/CONSEGNA_WGS84")
|
||||
// .listFiles((file,name)->{return name.startsWith("Mag_anomalies_WGS84");})));
|
||||
|
||||
return manager.publish();
|
||||
|
||||
|
||||
|
||||
Concessione toReturn=manager.publish();
|
||||
assertEquals(AccessPolicy.EMBARGOED,toReturn.getRelazioneScavo().getPolicy());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +119,7 @@ public class StatefulClientTests extends BasicVreTests{
|
|||
ConcessioniManagerI manager=statefulMongoConcessioni().build();
|
||||
StorageUtils storage=new StorageUtils();
|
||||
|
||||
manager.createNew(TestModel.prepareEmptyConcessione());
|
||||
manager.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
|
||||
manager.delete();
|
||||
}
|
||||
|
|
|
@ -11,14 +11,17 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.gcube.application.cms.tests.model.TestFilters;
|
||||
import org.gcube.application.cms.tests.model.TestModel;
|
||||
import org.gcube.application.cms.tests.model.TestQueries;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniFilters;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniQueries;
|
||||
import org.gcube.application.geoportal.client.utils.Queries;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
|
||||
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
|
@ -37,22 +40,28 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void searches() throws Exception {
|
||||
TestFilters.filters.forEach((k,v)->{
|
||||
TestConcessioniFilters.filters.forEach((k, v)->{
|
||||
try {
|
||||
System.out.println("Count for " + k + "\t" + count(client.search(v)));
|
||||
}catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void query() throws Exception {
|
||||
|
||||
System.out.println("FRA "+ count(client.query(
|
||||
Queries.parse(TestConcessioniQueries.queries.get("emptyresult.json")))));
|
||||
|
||||
// No Transformation
|
||||
System.out.print("First Registered \t");
|
||||
Iterator<Concessione> queriedDocuments=client.query(
|
||||
Queries.parse(TestQueries.queries.get("firstRegistered.json")));
|
||||
Queries.parse(TestConcessioniQueries.queries.get("firstRegistered.json")));
|
||||
// Expected one result
|
||||
assertTrue(count(queriedDocuments)==1);
|
||||
|
||||
|
@ -61,7 +70,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
System.out.print("Last Registered \t");
|
||||
// Expected one result
|
||||
queriedDocuments=client.query(
|
||||
Queries.parse(TestQueries.queries.get("lastRegistered.json")));
|
||||
Queries.parse(TestConcessioniQueries.queries.get("lastRegistered.json")));
|
||||
assertTrue(count(queriedDocuments)==1);
|
||||
|
||||
queriedDocuments.forEachRemaining((Concessione c)->{System.out.println(c.getNome());});
|
||||
|
@ -70,11 +79,11 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
// Transformations
|
||||
System.out.println(
|
||||
client.queryForJSON(
|
||||
Queries.parse(TestQueries.queries.get("lastNameRegisteredByFabio.json"))));
|
||||
Queries.parse(TestConcessioniQueries.queries.get("lastNameRegisteredByFabio.json"))));
|
||||
|
||||
System.out.println(
|
||||
client.queryForJSON(
|
||||
Queries.parse(TestQueries.queries.get("publicationWarningMessages.json"))));
|
||||
Queries.parse(TestConcessioniQueries.queries.get("publicationWarningMessages.json"))));
|
||||
|
||||
// String query=Files.readFileAsString(filterFile.getAbsolutePath(), Charset.defaultCharset());
|
||||
// System.out.println("Count for "+filterFile.getName()+"\t"+ count(client.search(query)));
|
||||
|
@ -91,14 +100,14 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testCreateNew() throws Exception {
|
||||
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
||||
Concessione c= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
assertNotNull(c);
|
||||
assertNotNull(c.getMongo_id());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplace() throws Exception {
|
||||
Concessione testObject= client.createNew(TestModel.prepareEmptyConcessione());
|
||||
Concessione testObject= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
String title="My new shiny Title";
|
||||
testObject.setNome(title);
|
||||
Concessione c1=client.replace(testObject);
|
||||
|
@ -107,11 +116,11 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testUploadFileSet() throws Exception {
|
||||
Concessione testObject= client.createNew(TestModel.prepareConcessione());
|
||||
Concessione testObject= client.createNew(TestConcessioniModel.prepareConcessione());
|
||||
AddSectionToConcessioneRequest request=
|
||||
// FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf"));
|
||||
// FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"));
|
||||
FileSets.build(Paths.ABSTRACT_RELAZIONE).add(
|
||||
new StorageUtils().putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
||||
new StorageUtils().putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
||||
.getTheRequest();
|
||||
|
||||
testObject= client.registerFileSet(testObject.getMongo_id(), request);
|
||||
|
@ -124,13 +133,13 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testDeleteById() throws Exception {
|
||||
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
||||
Concessione c= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
client.deleteById(c.getMongo_id());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPublsh() throws Exception {
|
||||
public void testPublish() throws Exception {
|
||||
Concessione c=prepare();
|
||||
|
||||
assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED));
|
||||
|
@ -171,34 +180,46 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
private Concessione prepare() throws Exception {
|
||||
int numImgs=1;
|
||||
Concessione c= client.createNew(TestModel.prepareConcessione(1,numImgs));
|
||||
Concessione c= client.createNew(TestConcessioniModel.prepareConcessione(1,numImgs));
|
||||
StorageUtils storage = new StorageUtils();
|
||||
|
||||
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
String mongoId=c.getMongo_id();
|
||||
c=client.update(mongoId, Serialization.write(c));
|
||||
|
||||
client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.ABSTRACT_RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
for(int i=0;i<numImgs;i++)
|
||||
client.registerFileSet(mongoId,
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.build(Paths.imgByIndex(i)).
|
||||
add(storage.putOntoStorage(new File(TestModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
||||
add(storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
||||
i+"San Mauro_drone totale.JPG")).getTheRequest());
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestModel.getBaseFolder(),"pos.shp")));
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestConcessioniModel.getBaseFolder(),"pos.shp")));
|
||||
|
||||
client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestModel.getBaseFolder(),"pianta.shp")));
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestConcessioniModel.getBaseFolder(),"pianta.shp")));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.publish(mongoId);
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,40 +2,44 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.application.geoportal-common
|
||||
|
||||
# [v1.0.8] - 2021-11-10
|
||||
- Fixes [#22369](https://support.d4science.org/issues/22369)
|
||||
- Fixes [#22338](https://support.d4science.org/issues/22338)
|
||||
- Profiled Documents
|
||||
- Changed group id
|
||||
|
||||
|
||||
# [v1.0.7] - 2021-09-20
|
||||
Refactored repositories
|
||||
- Refactored repositories
|
||||
|
||||
# [v1.0.6-SNAPSHOT] - 2021-08-3
|
||||
Forced Deletion
|
||||
Search & query
|
||||
Clean Fileset
|
||||
Interfaces return iterator instead of iterable
|
||||
Name in WorkspaceContent (https://support.d4science.org/issues/22032)
|
||||
Section AbstractRelazione (https://support.d4science.org/issues/22031)
|
||||
- Forced Deletion
|
||||
- Search & query
|
||||
- Clean Fileset
|
||||
- Interfaces return iterator instead of iterable
|
||||
- Name in WorkspaceContent (https://support.d4science.org/issues/22032)
|
||||
- Section AbstractRelazione (https://support.d4science.org/issues/22031)
|
||||
|
||||
# [v1.0.5] - 2020-12-9
|
||||
Mongo Id in record
|
||||
Mongo Concessioni interface
|
||||
Added Files.fixFileNAme
|
||||
ValidationReport as field
|
||||
Updated Model (#20357)
|
||||
- Mongo Id in record
|
||||
- Mongo Concessioni interface
|
||||
- Added Files.fixFileNAme
|
||||
- ValidationReport as field
|
||||
- Updated Model (#20357)
|
||||
|
||||
|
||||
# [v1.0.4-SNAPSHOT] - 2020-12-9
|
||||
Projects Rest Interface
|
||||
TempFile support
|
||||
- Projects Rest Interface
|
||||
- TempFile support
|
||||
|
||||
# [v1.0.3] - 2020-12-4
|
||||
Project model update
|
||||
|
||||
- Project model update
|
||||
|
||||
# [v1.0.2-SNAPSHOT] - 2020-12-4
|
||||
Model update
|
||||
- Model update
|
||||
|
||||
## [v1.0.1] - 2020-11-11
|
||||
|
||||
Model update
|
||||
- Model update
|
||||
|
||||
## [v1.0.0] - 2020-11-11
|
||||
|
||||
First release
|
||||
- First release
|
|
@ -2,16 +2,15 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<version>1.0.8</version>
|
||||
<name>Geoportal Common</name>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -42,6 +41,11 @@
|
|||
<artifactId>authorization-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class Access {
|
||||
|
||||
public static final String POLICY="policy";
|
||||
public static final String LICENSE="license";
|
||||
|
||||
private AccessPolicy policy;
|
||||
private String license;
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
public enum AccessPolicy {
|
||||
|
||||
OPEN,RESTRICTED,EMBARGOED;
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class AccountingInfo {
|
||||
|
||||
public static final String USER="user";
|
||||
public static final String CONTEXT="context";
|
||||
public static final String INSTANT="instant";
|
||||
|
||||
private User user;
|
||||
private Context context;
|
||||
private LocalDateTime instant;
|
||||
}
|
|
@ -0,0 +1,840 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Generic implementation of version comparison.
|
||||
* </p>
|
||||
*
|
||||
* Features:
|
||||
* <ul>
|
||||
* <li>mixing of '<code>-</code>' (hyphen) and '<code>.</code>' (dot) separators,</li>
|
||||
* <li>transition between characters and digits also constitutes a separator:
|
||||
* <code>1.0alpha1 => [1, 0, alpha, 1]</code></li>
|
||||
* <li>unlimited number of version components,</li>
|
||||
* <li>version components in the text can be digits or strings,</li>
|
||||
* <li>strings are checked for well-known qualifiers and the qualifier ordering is used for version ordering.
|
||||
* Well-known qualifiers (case insensitive) are:<ul>
|
||||
* <li><code>alpha</code> or <code>a</code></li>
|
||||
* <li><code>beta</code> or <code>b</code></li>
|
||||
* <li><code>milestone</code> or <code>m</code></li>
|
||||
* <li><code>rc</code> or <code>cr</code></li>
|
||||
* <li><code>snapshot</code></li>
|
||||
* <li><code>(the empty string)</code> or <code>ga</code> or <code>final</code></li>
|
||||
* <li><code>sp</code></li>
|
||||
* </ul>
|
||||
* Unknown qualifiers are considered after known qualifiers, with lexical order (always case insensitive),
|
||||
* </li>
|
||||
* <li>a hyphen usually precedes a qualifier, and is always less important than something preceded with a dot.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see <a href="https://cwiki.apache.org/confluence/display/MAVENOLD/Versioning">"Versioning" on Maven Wiki</a>
|
||||
* @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
|
||||
* @author <a href="mailto:hboutemy@apache.org">Hervé Boutemy</a>
|
||||
*/
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ComparableVersion
|
||||
implements Comparable<ComparableVersion>
|
||||
{
|
||||
private static final int MAX_INTITEM_LENGTH = 9;
|
||||
|
||||
private static final int MAX_LONGITEM_LENGTH = 18;
|
||||
|
||||
private String value;
|
||||
|
||||
private String canonical;
|
||||
|
||||
private ListItem items;
|
||||
|
||||
private interface Item
|
||||
{
|
||||
int INT_ITEM = 3;
|
||||
int LONG_ITEM = 4;
|
||||
int BIGINTEGER_ITEM = 0;
|
||||
int STRING_ITEM = 1;
|
||||
int LIST_ITEM = 2;
|
||||
|
||||
int compareTo( Item item );
|
||||
|
||||
int getType();
|
||||
|
||||
boolean isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a numeric item in the version item list that can be represented with an int.
|
||||
*/
|
||||
private static class IntItem
|
||||
implements Item
|
||||
{
|
||||
private final int value;
|
||||
|
||||
public static final IntItem ZERO = new IntItem();
|
||||
|
||||
private IntItem()
|
||||
{
|
||||
this.value = 0;
|
||||
}
|
||||
|
||||
IntItem( String str )
|
||||
{
|
||||
this.value = Integer.parseInt( str );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
return INT_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull()
|
||||
{
|
||||
return value == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
return ( value == 0 ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
|
||||
}
|
||||
|
||||
switch ( item.getType() )
|
||||
{
|
||||
case INT_ITEM:
|
||||
int itemValue = ( (IntItem) item ).value;
|
||||
return Integer.compare( value, itemValue );
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1;
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException( "invalid item: " + item.getClass() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IntItem intItem = (IntItem) o;
|
||||
|
||||
return value == intItem.value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return Integer.toString( value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a numeric item in the version item list that can be represented with a long.
|
||||
*/
|
||||
private static class LongItem
|
||||
implements Item
|
||||
{
|
||||
private final long value;
|
||||
|
||||
LongItem( String str )
|
||||
{
|
||||
this.value = Long.parseLong( str );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
return LONG_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull()
|
||||
{
|
||||
return value == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
return ( value == 0 ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
|
||||
}
|
||||
|
||||
switch ( item.getType() )
|
||||
{
|
||||
case INT_ITEM:
|
||||
return 1;
|
||||
case LONG_ITEM:
|
||||
long itemValue = ( (LongItem) item ).value;
|
||||
return Long.compare( value, itemValue );
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1;
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException( "invalid item: " + item.getClass() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LongItem longItem = (LongItem) o;
|
||||
|
||||
return value == longItem.value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (int) ( value ^ ( value >>> 32 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return Long.toString( value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a numeric item in the version item list.
|
||||
*/
|
||||
private static class BigIntegerItem
|
||||
implements Item
|
||||
{
|
||||
private final BigInteger value;
|
||||
|
||||
BigIntegerItem( String str )
|
||||
{
|
||||
this.value = new BigInteger( str );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
return BIGINTEGER_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull()
|
||||
{
|
||||
return BigInteger.ZERO.equals( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
return BigInteger.ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1
|
||||
}
|
||||
|
||||
switch ( item.getType() )
|
||||
{
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
return 1;
|
||||
|
||||
case BIGINTEGER_ITEM:
|
||||
return value.compareTo( ( (BigIntegerItem) item ).value );
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException( "invalid item: " + item.getClass() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BigIntegerItem that = (BigIntegerItem) o;
|
||||
|
||||
return value.equals( that.value );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a string in the version item list, usually a qualifier.
|
||||
*/
|
||||
private static class StringItem
|
||||
implements Item
|
||||
{
|
||||
private static final List<String> QUALIFIERS =
|
||||
Arrays.asList( "alpha", "beta", "milestone", "rc", "snapshot", "", "sp" );
|
||||
|
||||
private static final Properties ALIASES = new Properties();
|
||||
static
|
||||
{
|
||||
ALIASES.put( "ga", "" );
|
||||
ALIASES.put( "final", "" );
|
||||
ALIASES.put( "release", "" );
|
||||
ALIASES.put( "cr", "rc" );
|
||||
}
|
||||
|
||||
/**
|
||||
* A comparable value for the empty-string qualifier. This one is used to determine if a given qualifier makes
|
||||
* the version older than one without a qualifier, or more recent.
|
||||
*/
|
||||
private static final String RELEASE_VERSION_INDEX = String.valueOf( QUALIFIERS.indexOf( "" ) );
|
||||
|
||||
private final String value;
|
||||
|
||||
StringItem( String value, boolean followedByDigit )
|
||||
{
|
||||
if ( followedByDigit && value.length() == 1 )
|
||||
{
|
||||
// a1 = alpha-1, b1 = beta-1, m1 = milestone-1
|
||||
switch ( value.charAt( 0 ) )
|
||||
{
|
||||
case 'a':
|
||||
value = "alpha";
|
||||
break;
|
||||
case 'b':
|
||||
value = "beta";
|
||||
break;
|
||||
case 'm':
|
||||
value = "milestone";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
this.value = ALIASES.getProperty( value , value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
return STRING_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull()
|
||||
{
|
||||
return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a comparable value for a qualifier.
|
||||
*
|
||||
* This method takes into account the ordering of known qualifiers then unknown qualifiers with lexical
|
||||
* ordering.
|
||||
*
|
||||
* just returning an Integer with the index here is faster, but requires a lot of if/then/else to check for -1
|
||||
* or QUALIFIERS.size and then resort to lexical ordering. Most comparisons are decided by the first character,
|
||||
* so this is still fast. If more characters are needed then it requires a lexical sort anyway.
|
||||
*
|
||||
* @param qualifier
|
||||
* @return an equivalent value that can be used with lexical comparison
|
||||
*/
|
||||
public static String comparableQualifier( String qualifier )
|
||||
{
|
||||
int i = QUALIFIERS.indexOf( qualifier );
|
||||
|
||||
return i == -1 ? ( QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
// 1-rc < 1, 1-ga > 1
|
||||
return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX );
|
||||
}
|
||||
switch ( item.getType() )
|
||||
{
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1; // 1.any < 1.1 ?
|
||||
|
||||
case STRING_ITEM:
|
||||
return comparableQualifier( value ).compareTo( comparableQualifier( ( (StringItem) item ).value ) );
|
||||
|
||||
case LIST_ITEM:
|
||||
return -1; // 1.any < 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException( "invalid item: " + item.getClass() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
StringItem that = (StringItem) o;
|
||||
|
||||
return value.equals( that.value );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a version list item. This class is used both for the global item list and for sub-lists (which start
|
||||
* with '-(number)' in the version specification).
|
||||
*/
|
||||
private static class ListItem
|
||||
extends ArrayList<Item>
|
||||
implements Item
|
||||
{
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
return LIST_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull()
|
||||
{
|
||||
return ( size() == 0 );
|
||||
}
|
||||
|
||||
void normalize()
|
||||
{
|
||||
for ( int i = size() - 1; i >= 0; i-- )
|
||||
{
|
||||
Item lastItem = get( i );
|
||||
|
||||
if ( lastItem.isNull() )
|
||||
{
|
||||
// remove null trailing items: 0, "", empty list
|
||||
remove( i );
|
||||
}
|
||||
else if ( !( lastItem instanceof ListItem ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( Item item )
|
||||
{
|
||||
if ( item == null )
|
||||
{
|
||||
if ( size() == 0 )
|
||||
{
|
||||
return 0; // 1-0 = 1- (normalize) = 1
|
||||
}
|
||||
// Compare the entire list of items with null - not just the first one, MNG-6964
|
||||
for ( Item i : this )
|
||||
{
|
||||
int result = i.compareTo( null );
|
||||
if ( result != 0 )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
switch ( item.getType() )
|
||||
{
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1; // 1-1 < 1.0.x
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1-1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
Iterator<Item> left = iterator();
|
||||
Iterator<Item> right = ( (ListItem) item ).iterator();
|
||||
|
||||
while ( left.hasNext() || right.hasNext() )
|
||||
{
|
||||
Item l = left.hasNext() ? left.next() : null;
|
||||
Item r = right.hasNext() ? right.next() : null;
|
||||
|
||||
// if this is shorter, then invert the compare and mul with -1
|
||||
int result = l == null ? ( r == null ? 0 : -1 * r.compareTo( l ) ) : l.compareTo( r );
|
||||
|
||||
if ( result != 0 )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException( "invalid item: " + item.getClass() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for ( Item item : this )
|
||||
{
|
||||
if ( buffer.length() > 0 )
|
||||
{
|
||||
buffer.append( ( item instanceof ListItem ) ? '-' : '.' );
|
||||
}
|
||||
buffer.append( item );
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the contents in the same format that is used when you call toString() on a List.
|
||||
*/
|
||||
private String toListString()
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append( "[" );
|
||||
for ( Item item : this )
|
||||
{
|
||||
if ( buffer.length() > 1 )
|
||||
{
|
||||
buffer.append( ", " );
|
||||
}
|
||||
if ( item instanceof ListItem )
|
||||
{
|
||||
buffer.append( ( (ListItem ) item ).toListString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.append( item );
|
||||
}
|
||||
}
|
||||
buffer.append( "]" );
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public ComparableVersion( String version )
|
||||
{
|
||||
parseVersion( version );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "checkstyle:innerassignment" )
|
||||
public final void parseVersion( String version )
|
||||
{
|
||||
this.value = version;
|
||||
|
||||
items = new ListItem();
|
||||
|
||||
version = version.toLowerCase( Locale.ENGLISH );
|
||||
|
||||
ListItem list = items;
|
||||
|
||||
Deque<Item> stack = new ArrayDeque<>();
|
||||
stack.push( list );
|
||||
|
||||
boolean isDigit = false;
|
||||
|
||||
int startIndex = 0;
|
||||
|
||||
for ( int i = 0; i < version.length(); i++ )
|
||||
{
|
||||
char c = version.charAt( i );
|
||||
|
||||
if ( c == '.' )
|
||||
{
|
||||
if ( i == startIndex )
|
||||
{
|
||||
list.add( IntItem.ZERO );
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add( parseItem( isDigit, version.substring( startIndex, i ) ) );
|
||||
}
|
||||
startIndex = i + 1;
|
||||
}
|
||||
else if ( c == '-' )
|
||||
{
|
||||
if ( i == startIndex )
|
||||
{
|
||||
list.add( IntItem.ZERO );
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add( parseItem( isDigit, version.substring( startIndex, i ) ) );
|
||||
}
|
||||
startIndex = i + 1;
|
||||
|
||||
list.add( list = new ListItem() );
|
||||
stack.push( list );
|
||||
}
|
||||
else if ( Character.isDigit( c ) )
|
||||
{
|
||||
if ( !isDigit && i > startIndex )
|
||||
{
|
||||
list.add( new StringItem( version.substring( startIndex, i ), true ) );
|
||||
startIndex = i;
|
||||
|
||||
list.add( list = new ListItem() );
|
||||
stack.push( list );
|
||||
}
|
||||
|
||||
isDigit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isDigit && i > startIndex )
|
||||
{
|
||||
list.add( parseItem( true, version.substring( startIndex, i ) ) );
|
||||
startIndex = i;
|
||||
|
||||
list.add( list = new ListItem() );
|
||||
stack.push( list );
|
||||
}
|
||||
|
||||
isDigit = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( version.length() > startIndex )
|
||||
{
|
||||
list.add( parseItem( isDigit, version.substring( startIndex ) ) );
|
||||
}
|
||||
|
||||
while ( !stack.isEmpty() )
|
||||
{
|
||||
list = (ListItem) stack.pop();
|
||||
list.normalize();
|
||||
}
|
||||
}
|
||||
|
||||
private static Item parseItem( boolean isDigit, String buf )
|
||||
{
|
||||
if ( isDigit )
|
||||
{
|
||||
buf = stripLeadingZeroes( buf );
|
||||
if ( buf.length() <= MAX_INTITEM_LENGTH )
|
||||
{
|
||||
// lower than 2^31
|
||||
return new IntItem( buf );
|
||||
}
|
||||
else if ( buf.length() <= MAX_LONGITEM_LENGTH )
|
||||
{
|
||||
// lower than 2^63
|
||||
return new LongItem( buf );
|
||||
}
|
||||
return new BigIntegerItem( buf );
|
||||
}
|
||||
return new StringItem( buf, false );
|
||||
}
|
||||
|
||||
private static String stripLeadingZeroes( String buf )
|
||||
{
|
||||
if ( buf == null || buf.isEmpty() )
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
for ( int i = 0; i < buf.length(); ++i )
|
||||
{
|
||||
char c = buf.charAt( i );
|
||||
if ( c != '0' )
|
||||
{
|
||||
return buf.substring( i );
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( ComparableVersion o )
|
||||
{
|
||||
return items.compareTo( o.items );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getCanonical()
|
||||
{
|
||||
if ( canonical == null )
|
||||
{
|
||||
canonical = items.toString();
|
||||
}
|
||||
return canonical;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
return ( o instanceof ComparableVersion ) && items.equals( ( (ComparableVersion) o ).items );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return items.hashCode();
|
||||
}
|
||||
|
||||
// CHECKSTYLE_OFF: LineLength
|
||||
/**
|
||||
* Main to test version parsing and comparison.
|
||||
* <p>
|
||||
* To check how "1.2.7" compares to "1.2-SNAPSHOT", for example, you can issue
|
||||
* <pre>java -jar ${maven.repo.local}/org/apache/maven/maven-artifact/${maven.version}/maven-artifact-${maven.version}.jar "1.2.7" "1.2-SNAPSHOT"</pre>
|
||||
* command to command line. Result of given command will be something like this:
|
||||
* <pre>
|
||||
* Display parameters as parsed by Maven (in canonical form) and comparison result:
|
||||
* 1. 1.2.7 == 1.2.7
|
||||
* 1.2.7 > 1.2-SNAPSHOT
|
||||
* 2. 1.2-SNAPSHOT == 1.2-snapshot
|
||||
* </pre>
|
||||
*
|
||||
* @param args the version strings to parse and compare. You can pass arbitrary number of version strings and always
|
||||
* two adjacent will be compared
|
||||
*/
|
||||
// CHECKSTYLE_ON: LineLength
|
||||
public static void main( String... args )
|
||||
{
|
||||
System.out.println( "Display parameters as parsed by Maven (in canonical form and as a list of tokens) and"
|
||||
+ " comparison result:" );
|
||||
if ( args.length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ComparableVersion prev = null;
|
||||
int i = 1;
|
||||
for ( String version : args )
|
||||
{
|
||||
ComparableVersion c = new ComparableVersion( version );
|
||||
|
||||
if ( prev != null )
|
||||
{
|
||||
int compare = prev.compareTo( c );
|
||||
System.out.println( " " + prev.toString() + ' '
|
||||
+ ( ( compare == 0 ) ? "==" : ( ( compare < 0 ) ? "<" : ">" ) ) + ' ' + version );
|
||||
}
|
||||
|
||||
System.out.println( ( i++ ) + ". " + version + " -> " + c.getCanonical()
|
||||
+ "; tokens: " + c.items.toListString() );
|
||||
|
||||
prev = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class Context {
|
||||
public static final String ID="id";
|
||||
public static final String NAME = "name";
|
||||
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class LifecycleInformation {
|
||||
|
||||
public static final String PHASE="phase";
|
||||
public static final String LAST_OPERATION_STATUS="lastOperationStatus";
|
||||
public static final String ERROR_MESSAGES="errorMessages";
|
||||
public static final String WARNING_MESSAGES="warningMEssages";
|
||||
public static final String CHILDREN="children";
|
||||
|
||||
public static enum Status{
|
||||
PASSED,ERROR,WARNING
|
||||
}
|
||||
|
||||
|
||||
private String phase;
|
||||
private Status lastOperationStatus;
|
||||
private List<String> errorMessages;
|
||||
private List<String> warningMessages;
|
||||
private List<LifecycleInformation> children;
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import com.mongodb.client.model.geojson.GeoJsonObjectType;
|
||||
import lombok.*;
|
||||
import org.bson.Document;
|
||||
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ProfiledDocument {
|
||||
|
||||
public static final String _ID="_id";
|
||||
public static final String VERSION="version";
|
||||
public static final String INFO="info";
|
||||
public static final String PROFILE_ID="profileID";
|
||||
public static final String PROFILE_VERSION="profileVersion";
|
||||
public static final String LIFECYCLE_INFORMATION="lifecycleInformation";
|
||||
public static final String RELATIONSHIPS="relationships";
|
||||
public static final String SPATIAL_REFERENCE="spatialReference";
|
||||
public static final String TEMPORAL_REFERENCE="temporalReference";
|
||||
public static final String THE_DOCUMENT="theDocument";
|
||||
|
||||
// CORE METADATA
|
||||
|
||||
private String _id;
|
||||
private ComparableVersion version;
|
||||
|
||||
// Publication Info
|
||||
private PublicationInfo info;
|
||||
|
||||
// Profile reference
|
||||
private String profileID;
|
||||
private ComparableVersion profileVersion;
|
||||
|
||||
private LifecycleInformation lifecycleInformation;
|
||||
|
||||
private Relationship[] relationships;
|
||||
|
||||
private GeoJsonObjectType spatialReference;
|
||||
|
||||
private TemporalReference temporalReference;
|
||||
|
||||
private Document theDocument;
|
||||
|
||||
public void setDefaults(){
|
||||
// TODO APPLY DEFAULTS ??
|
||||
|
||||
};
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class PublicationInfo {
|
||||
|
||||
public static final String CREATION_INFO="creationInfo";
|
||||
public static final String LAST_EDIT_INFO="lastEditInfo";
|
||||
public static final String ACCESS = "access";
|
||||
|
||||
|
||||
private AccountingInfo creationInfo;
|
||||
private AccountingInfo lastEditInfo;
|
||||
private Access access;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class RegisteredFile {
|
||||
|
||||
public static String MIMETYPE="mimetype";
|
||||
public static String STORAGE_ID="storageID";
|
||||
public static String LINK="link";
|
||||
public static String NAME="NAME";
|
||||
|
||||
private String mimetype;
|
||||
private String storageID;
|
||||
private String link;
|
||||
private String name;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class RegisteredFileSet {
|
||||
|
||||
public static final String CREATION_INFO="creationInfo";
|
||||
public static final String ACCESS="access";
|
||||
public static final String FOLDER_ID="folderID";
|
||||
public static final String PAYLOADS="payloads";
|
||||
|
||||
private AccountingInfo creationInfo;
|
||||
private Access access;
|
||||
private String folderID;
|
||||
|
||||
private List<RegisteredFile> payloads;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class Relationship {
|
||||
|
||||
public static final String RELATIONSHIP_NAME="relationshipName";
|
||||
public static final String TARGET_ID="targetID";
|
||||
|
||||
private String relationshipName;
|
||||
private String targetID;
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class TemporalReference {
|
||||
|
||||
private String field;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.application.geoportal.common.model.document;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class User {
|
||||
|
||||
public static final String USERNAME="username";
|
||||
|
||||
|
||||
private String username;
|
||||
|
||||
}
|
|
@ -218,7 +218,7 @@ public class Concessione extends Record{
|
|||
|
||||
validator.setObjectName("Concessione");
|
||||
|
||||
setPolicy(AccessPolicy.OPEN);
|
||||
// setPolicy(AccessPolicy.OPEN);
|
||||
|
||||
|
||||
|
||||
|
@ -258,18 +258,6 @@ public class Concessione extends Record{
|
|||
validator.addChild(abstractRelazione.validateForInsertion());
|
||||
}
|
||||
|
||||
// if(immaginiRappresentative!=null)
|
||||
//
|
||||
// for(UploadedImage img : immaginiRappresentative) {
|
||||
// validator.setDefault(img.getSoggetto(),getSoggetto());
|
||||
// validator.setDefault(img.getCreationTime(),getCreationTime());
|
||||
// validator.setDefault(img.getPolicy(), getPolicy());
|
||||
// validator.setDefault(img.getLicenzaID(), getLicenzaID());
|
||||
//
|
||||
// validator.addChild(img.validateForInsertion());
|
||||
// }
|
||||
//
|
||||
|
||||
if(validator.checkMandatory(posizionamentoScavo, "Posizionamento scavo")) {
|
||||
|
||||
ValidationReport posReport=posizionamentoScavo.validateForInsertion();
|
||||
|
@ -282,15 +270,11 @@ public class Concessione extends Record{
|
|||
for(OtherContent content:genericContent)
|
||||
validator.addChild(content.validateForInsertion());
|
||||
|
||||
if(validator.checkMandatory(pianteFineScavo,"Piante fine scavo"))
|
||||
if(pianteFineScavo!=null)
|
||||
for(LayerConcessione l:pianteFineScavo) {
|
||||
validator.addChild(l.validateForInsertion());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return validator;
|
||||
}
|
||||
|
||||
|
@ -317,15 +301,15 @@ public class Concessione extends Record{
|
|||
relazioneScavo.setTitolo(ConstraintCheck.defaultFor(relazioneScavo.getTitolo(),getNome()+" relazione di scavo").evaluate());
|
||||
relazioneScavo.setSoggetto(ConstraintCheck.defaultFor(relazioneScavo.getSoggetto(),getSoggetto()).evaluate());
|
||||
relazioneScavo.setCreationTime(ConstraintCheck.defaultFor(relazioneScavo.getCreationTime(),getCreationTime()).evaluate());
|
||||
relazioneScavo.setLicenseID(ConstraintCheck.defaultFor(getLicenzaID(), "CC-BY-4.0").evaluate());
|
||||
relazioneScavo.setPolicy(getPolicy());
|
||||
relazioneScavo.setLicenseID(ConstraintCheck.defaultFor(relazioneScavo.getLicenseID(), "CC-BY-4.0").evaluate());
|
||||
relazioneScavo.setPolicy(ConstraintCheck.defaultFor(relazioneScavo.getPolicy(),AccessPolicy.OPEN).evaluate());
|
||||
|
||||
|
||||
if(abstractRelazione == null) abstractRelazione = new AbstractRelazione();
|
||||
abstractRelazione.setTitolo(ConstraintCheck.defaultFor(abstractRelazione.getTitolo(),getNome()+" abstract relazione di scavo").evaluate());
|
||||
abstractRelazione.setCreationTime(ConstraintCheck.defaultFor(abstractRelazione.getCreationTime(),getCreationTime()).evaluate());
|
||||
abstractRelazione.setLicenseID(ConstraintCheck.defaultFor(getLicenzaID(), "CC-BY-4.0").evaluate());
|
||||
abstractRelazione.setPolicy(getPolicy());
|
||||
abstractRelazione.setLicenseID(ConstraintCheck.defaultFor(abstractRelazione.getLicenseID(), "CC-BY-4.0").evaluate());
|
||||
abstractRelazione.setPolicy(ConstraintCheck.defaultFor(abstractRelazione.getPolicy(),AccessPolicy.OPEN).evaluate());
|
||||
|
||||
|
||||
if(immaginiRappresentative!=null)
|
||||
|
|
|
@ -7,9 +7,11 @@ import java.util.List;
|
|||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Slf4j
|
||||
public class ConstraintCheck<T> {
|
||||
|
||||
public static <T> ConstraintCheck<T> defaultFor(T toCheck,T defaultValue){
|
||||
|
@ -55,6 +57,8 @@ public class ConstraintCheck<T> {
|
|||
T result=theObject;
|
||||
if(isError()) {
|
||||
result=theDefault;
|
||||
log.debug("Applying default {} for current value {}",theDefault,theObject);
|
||||
|
||||
if(theDefault!=null && theDefault instanceof Collection) {
|
||||
Collection defaultCollection=(Collection) theDefault;
|
||||
ArrayList target=new ArrayList(defaultCollection);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
public class DefaultCompiler {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class Field {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
public class FieldMapping {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
import lombok.Data;
|
||||
import org.bson.Document;
|
||||
|
||||
@Data
|
||||
public class HandlerDeclaration {
|
||||
|
||||
private String id;
|
||||
private String type;
|
||||
private Document configuration;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
public class IndexDefinition {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
public class IsoMapper {
|
||||
|
||||
private String className;
|
||||
|
||||
}
|
|
@ -1,24 +1,46 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.AccountingInfo;
|
||||
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
|
||||
|
||||
@Getter
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@XmlRootElement
|
||||
public class Profile{
|
||||
|
||||
private String name;
|
||||
private String id;
|
||||
private List<Field> fields;
|
||||
|
||||
private List<DefaultCompiler> defaultCompilers;
|
||||
private List<Validator> validators;
|
||||
private IsoMapper isoMapper;
|
||||
private List<FieldMapping> centroidsMapping;
|
||||
private List<IndexDefinition> indexes;
|
||||
private ComparableVersion version;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private AccountingInfo creationInfo;
|
||||
|
||||
private Document schema;
|
||||
|
||||
private List<HandlerDeclaration> handlers;
|
||||
|
||||
/**
|
||||
* Returns map Type -> Handler Declaration
|
||||
* @return
|
||||
*/
|
||||
public Map<String,List<HandlerDeclaration>> getHandlersMap(){
|
||||
HashMap<String,List<HandlerDeclaration>> toReturn=new HashMap<>();
|
||||
handlers.forEach(h->{
|
||||
if(!toReturn.containsKey(h.getType()))
|
||||
toReturn.put(h.getType(),new ArrayList<>());
|
||||
toReturn.get(h.getType()).add(h);
|
||||
});
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
|
||||
public class Validator {
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
public class Centroid {
|
||||
|
||||
private Double x;
|
||||
private Double y;
|
||||
private Double z;
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.BasicJSONObject;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
public class Project {
|
||||
|
||||
|
||||
/**
|
||||
* Project{
|
||||
_id:
|
||||
profile_id:
|
||||
publication :{
|
||||
creation_time:
|
||||
creation_user:
|
||||
last_update_time:
|
||||
last_update_user:
|
||||
version :
|
||||
license :
|
||||
policy :
|
||||
status : VALID,
|
||||
PUBLISHED,INVALID
|
||||
document : {.....}
|
||||
centroid : {
|
||||
x:
|
||||
y:
|
||||
z:}
|
||||
}
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
private String _id;
|
||||
private String profile_id;
|
||||
private Status status;
|
||||
private Object document;
|
||||
private Centroid centroid;
|
||||
private PublicationDetails publication;
|
||||
|
||||
private String json;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PublicationDetails {
|
||||
|
||||
public static enum Policy{
|
||||
OPEN,RESTRICTED,EMBARGOED;
|
||||
}
|
||||
|
||||
private LocalDateTime creation_time;
|
||||
private String creation_user;
|
||||
private LocalDateTime last_update_time;
|
||||
private String last_update_user;
|
||||
private String version;
|
||||
private String license;
|
||||
private String policy;
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Status {
|
||||
|
||||
|
||||
private StatusPhase phase;
|
||||
private List<String> messages;
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
public enum StatusPhase {
|
||||
|
||||
DRAFT,
|
||||
UNDER_VALIDATION,
|
||||
INVALID,
|
||||
VALID,
|
||||
UNDER_PUBLICATION,
|
||||
PUBLICATION_ERROR,
|
||||
PUBLISHED
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ public class InterfaceConstants {
|
|||
public static final String PROFILES="profiles";
|
||||
public static final String SECTIONS="sections";
|
||||
public static final String PROJECTS="projects";
|
||||
|
||||
|
||||
public static final String CONCESSIONI="concessioni";
|
||||
public static final String MONGO_CONCESSIONI="mongo-concessioni";
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ProfiledDocumentsI<P extends ProfiledDocument> {
|
||||
|
||||
// CRUD
|
||||
public P createNew(Document toCreate)throws RemoteException;
|
||||
public void deleteById(String id) throws RemoteException;
|
||||
public void deleteById(String id,Boolean force) throws RemoteException;
|
||||
public P getById(String id) throws RemoteException;
|
||||
|
||||
// CONFIG
|
||||
public Configuration getConfiguration() throws RemoteException;
|
||||
|
||||
// QUERY
|
||||
public Iterator<P> query (QueryRequest request) throws RemoteException;
|
||||
public String querForJSON(QueryRequest request)throws RemoteException;
|
||||
|
||||
//Execution
|
||||
public P performStep(String id, String step, Document request);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.project.Project;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ProjectsI {
|
||||
|
||||
|
||||
public Iterator<Project> getAll() throws Exception;
|
||||
public Iterator<Project> getByProfile(String profileId) throws Exception;
|
||||
public Project getById(String profileId,String id) throws Exception;
|
||||
public Iterator<Project> getByFilter(String filter)throws Exception;
|
||||
public Iterator<Project> getByFilter(String filter, String profileId)throws Exception;
|
||||
public Project registrNew(String profileId, String jsonDocument)throws Exception;
|
||||
public Project update(String profileId, String projectId,String jsonDocument) throws Exception;
|
||||
public void deleteById(String profileId, String projectId)throws Exception;
|
||||
public void deleteById(String profileId, String projectId, Boolean force)throws Exception;
|
||||
}
|
|
@ -85,6 +85,8 @@ public class Files {
|
|||
}
|
||||
|
||||
public static String fixFilename(String toFix) {
|
||||
if(toFix.startsWith("\\."))
|
||||
toFix=toFix.replaceFirst("\\.","_");
|
||||
String extension="";
|
||||
if(toFix.contains(".")) {
|
||||
//preserve extension
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.application.geoportal.common.utils;
|
||||
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.Option;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JSONPathWrapper {
|
||||
|
||||
public static Configuration JSON_PATH_ALWAYS_LIST_CONFIG=null;
|
||||
public static Configuration JSON_PATH_PATHS_CONFIGURATION=null;
|
||||
|
||||
static {
|
||||
JSON_PATH_ALWAYS_LIST_CONFIG= Configuration.builder().options(Option.ALWAYS_RETURN_LIST,Option.SUPPRESS_EXCEPTIONS,Option.DEFAULT_PATH_LEAF_TO_NULL).build();
|
||||
JSON_PATH_PATHS_CONFIGURATION = Configuration.builder().options(Option.AS_PATH_LIST,Option.SUPPRESS_EXCEPTIONS,Option.DEFAULT_PATH_LEAF_TO_NULL).build();
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
DocumentContext ctx=null;
|
||||
|
||||
public JSONPathWrapper(String json) {
|
||||
ctx=JsonPath.using(JSON_PATH_ALWAYS_LIST_CONFIG).parse(json);
|
||||
}
|
||||
|
||||
public List<Object> getByPath(String path){
|
||||
throw new RuntimeException("TO IMPLEMENT");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package org.gcube.application.geoportal.common.legacy;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DefaultsTests {
|
||||
|
||||
@Test
|
||||
public void checkConstraints(){
|
||||
assertEquals(AccessPolicy.OPEN,ConstraintCheck.defaultFor(null,AccessPolicy.OPEN).evaluate());
|
||||
assertEquals(AccessPolicy.EMBARGOED,ConstraintCheck.defaultFor(AccessPolicy.EMBARGOED,AccessPolicy.OPEN).evaluate());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkDefaults(){
|
||||
|
||||
Concessione c= new Concessione();
|
||||
|
||||
c.setDefaults();
|
||||
c.validate();
|
||||
System.out.println(c.getReport());
|
||||
// Mandatory fields without defaults
|
||||
assertEquals(ValidationReport.ValidationStatus.ERROR,c.getReport().getStatus());
|
||||
|
||||
c=new Concessione();
|
||||
c.setRelazioneScavo(new RelazioneScavo());
|
||||
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||
c.setPolicy(AccessPolicy.OPEN);
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
c.setDefaults();
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -2,36 +2,40 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.application.geoportal-service
|
||||
|
||||
## [v1.0.8] 2021-09-20
|
||||
- Logging
|
||||
- Fixes [#22193](https://support.d4science.org/issues/22193)
|
||||
- Fixes [#22280](https://support.d4science.org/issues/22280)
|
||||
- Fixes [#20755](https://support.d4science.org/issues/20755)
|
||||
- Profiled Documents
|
||||
|
||||
|
||||
## [v1.0.6] 2021-09-20
|
||||
Refactored repositories
|
||||
Fixes #22193
|
||||
Fixes #22217
|
||||
- Refactored repositories
|
||||
- Fixes #22193
|
||||
- Fixes #22217
|
||||
|
||||
## [v1.0.5-SNAPSHOT] 2021-07-23
|
||||
Upgrade to gcube-smartgears-bom 2.1.0
|
||||
Fix register postgis table layer
|
||||
Added PostgisIndexRecordManager
|
||||
- Upgrade to gcube-smartgears-bom 2.1.0
|
||||
- Fix register postgis table layer
|
||||
- Added PostgisIndexRecordManager
|
||||
|
||||
## [v1.0.4] 2020-11-11
|
||||
Mongo integration with Concessione
|
||||
Project interface
|
||||
TempFile management
|
||||
WorkspaceContent and publication for Concessioni-over-mongo
|
||||
- Mongo integration with Concessione
|
||||
- Project interface
|
||||
- TempFile management
|
||||
- WorkspaceContent and publication for Concessioni-over-mongo
|
||||
|
||||
## [v1.0.3] 2020-11-11
|
||||
Fixed HTTP method
|
||||
- Fixed HTTP method
|
||||
|
||||
## [v1.0.2] 2020-11-11
|
||||
Delete method
|
||||
Excluded upper bound release gCube 5
|
||||
- Delete method
|
||||
- Excluded upper bound release gCube 5
|
||||
|
||||
|
||||
## [v1.0.1] 2020-11-11
|
||||
|
||||
Project interface
|
||||
- Project interface
|
||||
|
||||
## [v1.0.0] 2020-11-11
|
||||
|
||||
First release
|
||||
|
||||
|
||||
- First release
|
|
@ -4,14 +4,14 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-service</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.0.8</version>
|
||||
<name>Geoportal Service</name>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>gcube-cms-suite</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -83,10 +83,15 @@
|
|||
|
||||
<!-- INTERNAL LOGIC -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>cms-plugin-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- SDI -->
|
||||
<dependency>
|
||||
|
@ -185,6 +190,11 @@
|
|||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- STORAGE -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
|
@ -203,6 +213,12 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application.cms</groupId>
|
||||
<artifactId>concessioni-lifecycle</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -3,8 +3,9 @@ package org.gcube.application.geoportal.service;
|
|||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.service.rest.ConcessioniOverMongo;
|
||||
import org.gcube.application.geoportal.service.rest.Profiles;
|
||||
import org.gcube.application.geoportal.service.rest.Projects;
|
||||
|
||||
|
||||
import org.gcube.application.geoportal.service.rest.ProfiledDocuments;
|
||||
import org.gcube.application.geoportal.service.rest.Sections;
|
||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
@ -21,9 +22,9 @@ public class GeoPortalService extends ResourceConfig{
|
|||
//Register interrfaces
|
||||
// registerClasses(Concessioni.class);
|
||||
registerClasses(ConcessioniOverMongo.class);
|
||||
registerClasses(Projects.class);
|
||||
registerClasses(ProfiledDocuments.class);
|
||||
registerClasses(Sections.class);
|
||||
registerClasses(Profiles.class);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.application.geoportal.service.engine;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Synchronized;
|
||||
import org.gcube.application.cms.plugins.Plugin;
|
||||
import org.gcube.application.geoportal.service.engine.providers.*;
|
||||
|
||||
public class ImplementationProvider {
|
||||
|
@ -38,25 +39,29 @@ public class ImplementationProvider {
|
|||
@Setter
|
||||
private ISProvider isProvider=new ISProvider();
|
||||
|
||||
// @Getter
|
||||
// @Setter
|
||||
// private EMFProvider emfProvider=new ScopedEMFProvider();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private ProfileMapCache profiles=new ProfileMapCache();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private PluginManager pluginManager=new PluginManager();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private StorageHubProvider sHubProvider=new StorageHubProvider();
|
||||
|
||||
public void shutdown() {
|
||||
// Stop JPA
|
||||
// AbstractRecordManager.shutdown();
|
||||
|
||||
mongoClientProvider.shutdown();
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
// AbstractRecordManager.setDefaultProvider(emfProvider);
|
||||
|
||||
mongoClientProvider.init();
|
||||
}
|
||||
// public void shutdown() {
|
||||
// // Stop JPA
|
||||
//// AbstractRecordManager.shutdown();
|
||||
//
|
||||
// mongoClientProvider.shutdown();
|
||||
// pluginManager.shutdown();
|
||||
// }
|
||||
//
|
||||
// public void startup() {
|
||||
//// AbstractRecordManager.setDefaultProvider(emfProvider);
|
||||
// pluginManager.init();
|
||||
// mongoClientProvider.init();
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package org.gcube.application.geoportal.service.engine.handlers;
|
||||
|
||||
import com.google.protobuf.DescriptorProtos;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.plugins.LifecycleManager;
|
||||
import org.gcube.application.cms.plugins.faults.InitializationException;
|
||||
import org.gcube.application.cms.plugins.faults.ShutDownException;
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||
import org.gcube.application.cms.plugins.reports.ExecutionReport;
|
||||
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
|
||||
|
||||
@Slf4j
|
||||
public class SimpleLifeCycleManager implements LifecycleManager {
|
||||
|
||||
|
||||
private static final PluginDescriptor DESCRIPTOR=new PluginDescriptor("SIMPLE-LIFECYCLE", "Simple Lifecycle manager");
|
||||
static {
|
||||
DESCRIPTOR.setDescription("Simple Lifecycle Management. This plugin supports a simple publication lifecycle.");
|
||||
DESCRIPTOR.setVersion(new ComparableVersion("1.0.0"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InitializationReport initInContext() throws InitializationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InitializationReport init() throws InitializationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() throws ShutDownException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionReport performStep(StepExecutionRequest request) throws StepException {
|
||||
log.info("Received Request ");
|
||||
|
||||
switch(request.getStep()){
|
||||
case StepExecutionRequest.Steps.ON_INIT_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_MATERIALIZE_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DEMATERIALIZE_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DEINDEX_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_INDEX_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DELETE_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
default : throw new StepException("Invalid Step "+request.getStep());
|
||||
}
|
||||
|
||||
|
||||
throw new StepException("Still to implement");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PluginDescriptor getDescriptor() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -67,7 +67,7 @@ public class SDIManager {
|
|||
geoserverHostName=new URL(currentGeoserver.getUrl()).getHost();
|
||||
|
||||
log.debug("Contacting Data Transfer from geoserver {} ",geoserverHostName);
|
||||
dtGeoServer=DataTransferClient.getInstanceByEndpoint("http://"+geoserverHostName);
|
||||
dtGeoServer=DataTransferClient.getInstanceByEndpoint("https://"+geoserverHostName);
|
||||
if(!currentGeoserver.getReader().existGeoserver())
|
||||
throw new Exception("Geoserver not reachable");
|
||||
}catch(Exception e) {
|
||||
|
@ -222,7 +222,7 @@ public class SDIManager {
|
|||
|
||||
RESTLayer l=gsReader.getLayer(workspace, toSetLayerName);
|
||||
RESTFeatureType f= gsReader.getFeatureType(l);
|
||||
/*http://geoserver1.dev.d4science.org/geoserver/gna_conc_18/wms?
|
||||
/*https://geoserver1.dev.d4science.org/geoserver/gna_conc_18/wms?
|
||||
service=WMS&version=1.1.0&request=GetMap&layers=gna_conc_18:pos&
|
||||
styles=&bbox=8.62091913167495,40.62975046683799,8.621178639172953,40.630257904721645&
|
||||
width=392&height=768&srs=EPSG:4326&format=application/openlayers */
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.gcube.application.geoportal.service.engine.WorkspaceManager.FolderOpt
|
|||
import org.gcube.application.geoportal.service.engine.postgis.PostgisIndex;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.*;
|
||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||
import org.gcube.application.geoportal.service.utils.UserUtils;
|
||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.data.transfer.library.faults.RemoteServiceException;
|
||||
|
@ -33,6 +34,7 @@ import java.io.InputStream;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -48,7 +50,7 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
super();
|
||||
}
|
||||
private static final String collectionName="legacyConcessioni";
|
||||
private static final String DB_NAME="gna_dev";
|
||||
//private static final String DB_NAME="gna_dev";
|
||||
|
||||
|
||||
private MongoDatabase db=null;
|
||||
|
@ -78,34 +80,46 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
}
|
||||
|
||||
|
||||
// *** PUBLIC METHODS
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************** PUBLIC METHODS ***********************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Concessione registerNew(Concessione toRegister) throws IOException {
|
||||
log.trace("Registering {} ",toRegister);
|
||||
toRegister.setDefaults();
|
||||
log.trace("Going to register {} ",toRegister);
|
||||
toRegister=onUpdate(toRegister);
|
||||
log.trace("Concessione with defaults is {}",toRegister);
|
||||
ObjectId id=insert(asDocument(toRegister), collectionName);
|
||||
|
||||
log.trace("Obtained id {}",id);
|
||||
Concessione toReturn=asConcessione(getById(id,collectionName));
|
||||
toReturn.setMongo_id(asString(id));
|
||||
|
||||
return asConcessione(replace(asDocument(toReturn),collectionName));
|
||||
|
||||
toReturn = asConcessione(replace(asDocument(toReturn),collectionName));
|
||||
log.debug("Registered {} ",toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public Concessione replace(Concessione toRegister) throws IOException {
|
||||
log.trace("Replacing {} ",toRegister);
|
||||
toRegister.setDefaults();
|
||||
toRegister=onUpdate(toRegister);
|
||||
return asConcessione(replace(asDocument(toRegister),collectionName));
|
||||
}
|
||||
|
||||
public Concessione update(String id,String json) throws IOException {
|
||||
/* public Concessione update(String id,String json) throws IOException {
|
||||
log.trace("Updating id {} with {} ",id,json);
|
||||
Concessione toReturn=asConcessione(update(asId(id),asDoc(json),collectionName));
|
||||
log.debug("Refreshing defaults..");
|
||||
toReturn.setDefaults();
|
||||
return asConcessione(replace(asDocument(toReturn),collectionName));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
public Iterable<Concessione> list(){
|
||||
|
@ -171,6 +185,7 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
delete(asId(id), collectionName);
|
||||
}catch(DeletionException e) {
|
||||
//storing updated - partially deleted
|
||||
concessione=onUpdate(concessione);
|
||||
replace(asDocument(concessione), collectionName);
|
||||
throw e;
|
||||
}
|
||||
|
@ -188,15 +203,17 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
log.debug("Removed from centroids "+toReturn.getMongo_id());
|
||||
toReturn = unpublish(toReturn);
|
||||
log.debug("Concessione after unpublishing is "+toReturn);
|
||||
toReturn = onUpdate(toReturn);
|
||||
|
||||
return asConcessione(replace(asDocument(toReturn),collectionName));
|
||||
}catch(Throwable t){
|
||||
throw new DeletionException("Unable to unpublish "+id,t);
|
||||
}
|
||||
}
|
||||
|
||||
public Concessione publish(String id) throws JsonProcessingException, IOException, InvalidStateException{
|
||||
public Concessione publish(String id) throws IOException{
|
||||
Concessione toReturn=asConcessione(getById(asId(id),collectionName));
|
||||
toReturn.setDefaults();
|
||||
toReturn=onUpdate(toReturn);
|
||||
toReturn.validate();
|
||||
|
||||
// MATERIALIZE LAYERS
|
||||
|
@ -211,35 +228,6 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static Concessione removeContent(Concessione concessione) throws DeletionException {
|
||||
if(concessione.getFolderId()==null) {
|
||||
log.debug("No content for " + concessione.getMongo_id());
|
||||
return concessione;
|
||||
}
|
||||
try {
|
||||
log.debug("Removing content for " + concessione.getMongo_id());
|
||||
WorkspaceManager manager = new WorkspaceManager();
|
||||
manager.removeFolderById(concessione.getFolderId());
|
||||
|
||||
//Removing references from Object
|
||||
concessione.setFolderId(null);
|
||||
ArrayList<AssociatedContent> list = new ArrayList<>();
|
||||
list.add(concessione.getPosizionamentoScavo());
|
||||
list.addAll(concessione.getPianteFineScavo());
|
||||
list.addAll(concessione.getImmaginiRappresentative());
|
||||
list.addAll(concessione.getGenericContent());
|
||||
for (AssociatedContent c : list) {
|
||||
c.getActualContent().clear();
|
||||
}
|
||||
return concessione;
|
||||
}catch(Throwable t){
|
||||
throw new DeletionException("Unable to delete from WS ",t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Concessione unregisterFileset(String id, String toClearPath) throws Exception {
|
||||
log.info("Clearing Fileset at {} for {} ",toClearPath,id);
|
||||
try {
|
||||
|
@ -258,8 +246,7 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
}
|
||||
toClearContent.getActualContent().clear();
|
||||
|
||||
log.debug("Updating dafults for {} ",c);
|
||||
c.setDefaults();
|
||||
c=onUpdate(c);
|
||||
return asConcessione(replace(asDocument(c),collectionName));
|
||||
|
||||
}catch(Exception e) {
|
||||
|
@ -288,14 +275,39 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
AssociatedContent section=c.getContentByPath(destinationPath);
|
||||
log.debug("Found section {} for path {}",section,destinationPath);
|
||||
store(section,files,ws,storage,baseFolder);
|
||||
log.debug("Updating dafults for {} ",c);
|
||||
c.setDefaults();
|
||||
|
||||
c=onUpdate(c);
|
||||
return asConcessione(replace(asDocument(c),collectionName));
|
||||
}catch(Exception e) {
|
||||
throw new Exception("Unable to save file.",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************** STATIC ROUTINES *******************************/
|
||||
|
||||
|
||||
/**
|
||||
Sets Accounting data and Defaults
|
||||
*/
|
||||
private static Concessione onUpdate(Concessione c){
|
||||
log.debug("Updating Account data for {} ",c);
|
||||
|
||||
// SET ACCOUNTING
|
||||
c.setLastUpdateTime(LocalDateTime.now());
|
||||
try{
|
||||
c.setLastUpdateUser(UserUtils.getCurrent().getUser().getId());
|
||||
}catch(Throwable t){
|
||||
log.warn("Unable to get User details ",t);
|
||||
}
|
||||
|
||||
log.debug("Updating defaults for {}",c);
|
||||
// Set Defaults
|
||||
c.setDefaults();
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
private static Concessione index(Concessione record) {
|
||||
log.info("Indexing {} ",record.getId());
|
||||
ValidationReport report= new ValidationReport("Index Report ");
|
||||
|
@ -400,6 +412,8 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
((LayerConcessione) c).setBbox(null);
|
||||
((LayerConcessione) c).setWmsLink(null);
|
||||
((LayerConcessione) c).setWorkspace(null);
|
||||
((LayerConcessione) c).setLayerName(null);
|
||||
|
||||
|
||||
//Remove reference to removed content
|
||||
c.getActualContent().removeAll(toRemove);
|
||||
|
@ -467,4 +481,31 @@ public class ConcessioniMongoManager extends MongoManager{
|
|||
content.setMongo_id(asString(new ObjectId()));
|
||||
}
|
||||
|
||||
|
||||
private static Concessione removeContent(Concessione concessione) throws DeletionException {
|
||||
if(concessione.getFolderId()==null) {
|
||||
log.debug("No content for " + concessione.getMongo_id());
|
||||
return concessione;
|
||||
}
|
||||
try {
|
||||
log.debug("Removing content for " + concessione.getMongo_id());
|
||||
WorkspaceManager manager = new WorkspaceManager();
|
||||
manager.removeFolderById(concessione.getFolderId());
|
||||
|
||||
//Removing references from Object
|
||||
concessione.setFolderId(null);
|
||||
ArrayList<AssociatedContent> list = new ArrayList<>();
|
||||
list.add(concessione.getPosizionamentoScavo());
|
||||
list.addAll(concessione.getPianteFineScavo());
|
||||
list.addAll(concessione.getImmaginiRappresentative());
|
||||
list.addAll(concessione.getGenericContent());
|
||||
for (AssociatedContent c : list) {
|
||||
c.getActualContent().clear();
|
||||
}
|
||||
return concessione;
|
||||
}catch(Throwable t){
|
||||
throw new DeletionException("Unable to delete from WS ",t);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.DeletionException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface MongoManagerI<T> {
|
||||
|
||||
|
||||
// create
|
||||
|
||||
public T registerNew(Document toRegister) throws IOException, StepException;
|
||||
|
||||
// update
|
||||
public T update(String id,T toSet) throws IOException, StepException;
|
||||
|
||||
// delete
|
||||
|
||||
public void delete(String id,boolean force) throws DeletionException;
|
||||
|
||||
// get By ID
|
||||
|
||||
public T getByID(String id) throws IOException;
|
||||
|
||||
// query
|
||||
|
||||
public Iterable<Document> query(QueryRequest request);
|
||||
public Iterable<T> filter(QueryRequest request);
|
||||
|
||||
// materialize
|
||||
|
||||
public T materialize(String id);
|
||||
|
||||
// dematerialize
|
||||
|
||||
public T dematerialize(String id);
|
||||
// index
|
||||
|
||||
public T index(String id);
|
||||
|
||||
// deIndex
|
||||
public T deIndex(String id);
|
||||
|
||||
public T performStep(String id, String step, Document options);
|
||||
}
|
|
@ -1,5 +1,256 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
public class ProfiledMongoManager {
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import lombok.Synchronized;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.gcube.application.cms.plugins.LifecycleManager;
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||
import org.gcube.application.cms.plugins.reports.ExecutionReport;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.*;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
|
||||
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
|
||||
import org.gcube.application.geoportal.service.engine.providers.PluginManager;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.DeletionException;
|
||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||
import org.gcube.application.geoportal.service.utils.UserUtils;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.gcube.application.geoportal.service.engine.mongo.ConcessioniMongoManager.asConcessione;
|
||||
|
||||
@Slf4j
|
||||
public class ProfiledMongoManager extends MongoManager implements MongoManagerI<ProfiledDocument>{
|
||||
|
||||
|
||||
Profile profile;
|
||||
MongoDatabase db=null;
|
||||
|
||||
LifecycleManager lfManager;
|
||||
|
||||
|
||||
public ProfiledMongoManager(String profileId) throws ConfigurationException {
|
||||
// Check Profile ID
|
||||
log.info("Loading profile ID {} ",profileId);
|
||||
if(profileId==null) throw new InvalidParameterException("Profile ID cannot be null");
|
||||
Map<String,Profile> profiles=ImplementationProvider.get().getProfiles().getObject();
|
||||
if(!profiles.containsKey(profileId)) {
|
||||
log.debug("Asked profile {} not found. Available ones are {} ",profileId,profiles.keySet());
|
||||
throw new WebApplicationException("Profile " + profileId + " not registered", Response.Status.NOT_FOUND);
|
||||
}
|
||||
profile=profiles.get(profileId);
|
||||
log.debug("Loaded Profile {} ",profile);
|
||||
|
||||
|
||||
|
||||
|
||||
//Getting Lifecycle Manager declaration from Profile
|
||||
List<HandlerDeclaration> handlerDeclarations= profile.getHandlersMap().get(PluginDescriptor.BaseTypes.LIFECYCLE_MANAGER);
|
||||
if(handlerDeclarations==null || handlerDeclarations.isEmpty()) throw new ConfigurationException("No Lifecycle Handler defined for profile ID "+profileId);
|
||||
if(handlerDeclarations.size()>1) throw new ConfigurationException("Too many Lifecycle Handlers defined ("+handlerDeclarations+") in profile ID "+profileId);
|
||||
|
||||
HandlerDeclaration lcHandlerDeclaration=handlerDeclarations.get(0);
|
||||
|
||||
// Loading Lifecycle Manager
|
||||
log.debug("Looking for handler {} ",lcHandlerDeclaration);
|
||||
try{
|
||||
lfManager=(LifecycleManager) ImplementationProvider.get().getPluginManager().getObject().get(lcHandlerDeclaration.getId());
|
||||
if(lfManager==null) throw new ConfigurationException("Unable to find Lifecycle Manager Plugin. ID "+lcHandlerDeclaration.getId());
|
||||
}catch(ClassCastException e){
|
||||
throw new ConfigurationException("Unable to use "+lcHandlerDeclaration.getId()+" as Lifecycle Manager");
|
||||
}
|
||||
|
||||
|
||||
// Connect to DB
|
||||
String toUseDB=super.client.getConnection().getDatabase();
|
||||
log.info("Connecting to DB {} ",toUseDB);
|
||||
|
||||
// TODO MAP OF DATABASES?
|
||||
db=client.getTheClient().getDatabase(toUseDB);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private ProfiledDocument onUpdate(ProfiledDocument updatedDocument) throws StepException {
|
||||
|
||||
UserUtils.AuthenticatedUser u = UserUtils.getCurrent();
|
||||
updatedDocument.getInfo().setLastEditInfo(u.asInfo());
|
||||
|
||||
return step(updatedDocument,StepExecutionRequest.Steps.ON_UPDATE_DOCUMENT).getResult();
|
||||
}
|
||||
|
||||
private Document asDocument(ProfiledDocument d) throws JsonProcessingException {
|
||||
return Document.parse(Serialization.write(d));
|
||||
}
|
||||
|
||||
private ProfiledDocument asProfiledDocument(Document d) throws IOException {
|
||||
return Serialization.read(d.toJson(),ProfiledDocument.class);
|
||||
}
|
||||
|
||||
private String getCollectionName(){
|
||||
// TODO Profile can directly specify, use ID only as default
|
||||
|
||||
return profile.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MongoDatabase getDatabase(){
|
||||
return db;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument registerNew(Document toRegisterDoc) throws IOException, StepException {
|
||||
log.info("Registering new document in {} ",profile.getId());
|
||||
log.debug("Going to register {}",toRegisterDoc.toJson());
|
||||
|
||||
ProfiledDocument toRegister = new ProfiledDocument();
|
||||
toRegister.setTheDocument(toRegisterDoc);
|
||||
|
||||
|
||||
PublicationInfo pubInfo=new PublicationInfo();
|
||||
pubInfo.setCreationInfo(UserUtils.getCurrent().asInfo());
|
||||
|
||||
// TODO Set Access From Profile
|
||||
Access access=new Access();
|
||||
access.setLicense("");
|
||||
access.setPolicy(AccessPolicy.OPEN);
|
||||
pubInfo.setAccess(access);
|
||||
|
||||
toRegister.setInfo(pubInfo);
|
||||
|
||||
toRegister.setProfileID(profile.getId());
|
||||
toRegister.setProfileVersion(profile.getVersion());
|
||||
toRegister.setVersion(new ComparableVersion("1.0.0"));
|
||||
|
||||
// Apply Lifecycle
|
||||
|
||||
toRegister=step(toRegister,StepExecutionRequest.Steps.ON_INIT_DOCUMENT).getResult();
|
||||
|
||||
log.debug("Going to register {} ",toRegister);
|
||||
|
||||
// Insert object
|
||||
ObjectId id =insert(asDocument(toRegister),getCollectionName());
|
||||
|
||||
log.info("Obtained id {} ",id);
|
||||
return getByID(id.toHexString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument update(String id, ProfiledDocument toSet) throws IOException, StepException {
|
||||
log.trace("Replacing {} ",toSet);
|
||||
toSet=onUpdate(toSet);
|
||||
return asProfiledDocument(replace(asDocument(toSet),getCollectionName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id,boolean force) throws DeletionException {
|
||||
log.debug("Deleting by ID {}, force {}",id,force);
|
||||
try{
|
||||
ProfiledDocument doc =getByID(id);
|
||||
|
||||
// TODO INVOKE LIFECYCLE
|
||||
|
||||
//if(!force&&isPublished(id)) throw new Exception("Cannot delete published documents. Unpublish it or use force = true");
|
||||
|
||||
try{
|
||||
// TODO CHECK PHASE AND STATUS
|
||||
// DEINDEX
|
||||
// DEMATERIALIZE
|
||||
// DELETE CONTENT
|
||||
// DELETE ENTRY
|
||||
throw new DeletionException("IMPLEMENT THIS");
|
||||
// delete(asId(id), getCollectionName());
|
||||
}catch(DeletionException e) {
|
||||
//storing updated - partially deleted
|
||||
// concessione=onUpdate(concessione);
|
||||
// replace(asDocument(concessione), collectionName);
|
||||
throw e;
|
||||
}
|
||||
}catch(Throwable t){
|
||||
throw new DeletionException("Unable to delete "+id,t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument getByID(String id) throws IOException {
|
||||
return asProfiledDocument(super.getById(asId(id),getCollectionName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Document> query(QueryRequest queryRequest) {
|
||||
log.info("Querying {} ",queryRequest);
|
||||
LinkedBlockingQueue queue=new LinkedBlockingQueue<Concessione>();
|
||||
query(queryRequest,getCollectionName()).forEach(
|
||||
(Consumer<? super Document>) (Document d)->{try{
|
||||
queue.put(d);
|
||||
}catch(Throwable t){log.warn("Unable to translate "+d);}});
|
||||
log.info("Returned {} elements ",queue.size());
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ProfiledDocument> filter(QueryRequest queryRequest) {
|
||||
log.info("Searching concessione for filter {} ",queryRequest);
|
||||
LinkedBlockingQueue queue=new LinkedBlockingQueue<Concessione>();
|
||||
query(queryRequest,getCollectionName()).forEach(
|
||||
(Consumer<? super Document>) (Document d)->{try{
|
||||
queue.put(d);
|
||||
}catch(Throwable t){log.warn("Unable to translate "+d);}});
|
||||
log.info("Returned {} elements ",queue.size());
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument materialize(String id) {
|
||||
throw new RuntimeException("TO IMPLEMENT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument dematerialize(String id) {
|
||||
throw new RuntimeException("TO IMPLEMENT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument index(String id) {
|
||||
throw new RuntimeException("TO IMPLEMENT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument deIndex(String id) {
|
||||
throw new RuntimeException("TO IMPLEMENT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument performStep(String id, String step, Document options) {
|
||||
throw new RuntimeException("TO IMPLEMENT");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ExecutionReport step(ProfiledDocument theDocument,String step) throws StepException {
|
||||
log.info("[Profile {} ] Invoking Step {} on " ,profile.getId(),step,lfManager.getDescriptor());
|
||||
StepExecutionRequest request=new StepExecutionRequest();
|
||||
request.setDocument(theDocument);
|
||||
request.setProfile(profile);
|
||||
request.setStep(StepExecutionRequest.Steps.ON_INIT_DOCUMENT);
|
||||
log.debug("Requesting Step Execution {} ",request);
|
||||
return lfManager.performStep(request);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue