Ported to git, Removed HomeLibrary dependency

This commit is contained in:
Massimiliano Assante 2021-10-28 11:47:57 +02:00
parent cb093f81d5
commit d2c2c4e1cf
15 changed files with 509 additions and 977 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/reports-manager-portlet-6.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/reports-manager-portlet-6.2.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/reports-manager-portlet-6.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/reports-manager-portlet-6.2.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -15,11 +15,13 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
@ -39,5 +41,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/reports-manager-portlet-6.2.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/reports-manager-portlet-6.2.1-SNAPSHOT/WEB-INF/classes"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

View File

@ -7,6 +7,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,17 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="reports-portlet">
<wb-module deploy-name="reports-manager-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="storagehub-icons-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/storagehub-icons-library/storagehub-icons-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="gcube-reporting-library-3.6.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-reporting-library/gcube-reporting-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="reports-manager-portlet"/>
</wb-module>
</project-modules>

View File

@ -1 +1,17 @@
{"ide":{"scriptPaths":[]},"plugins":{"aui":{},"liferay":{},"yui":{}},"libs":["ecma5","browser"]}
{
"plugins": {
"aui": {
},
"liferay": {
},
"yui": {
}
},
"libs": [
"ecma5",
"browser"
]
}

42
CHANGELOG.md Normal file
View File

@ -0,0 +1,42 @@
# Changelog for VRE Manager Portlet
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v6.2.1-SNAPSHOT] - 2021-10-13
- Ported to git
- Removed HomeLibrary dependency
## [v5-1-0] - 2015-12-11
- Fix for Incident #1511 - deactivating window.alert deactivates commit facility - Need for internal dialog
- Fix for Incident #1828 - Reports Manager of production contacting the dev RSG Webservice
- Added info alert shpwing to which Reports Store Gateway is connected in case of VME-DB
## [v4-8-0] - 2014-02-10
- Implemented Support for FAO Vulnerable Marine Ecosystem (VME) Update Scenario
- Implemented Support for FAO Vulnerable Marine Ecosystem (VME) Delete Scenario
- Added possibility of Deletion of content of the first entry
- Close report on commit when in FAO Vulnerable Marine Ecosystem (VME) Mode
## [v4-7-0] - 2013-12-19
- Added Support for FAO Vulnerable Marine Ecosystem (VME) Scenario
## [v4-2-0] - 2013-04-19
- Lots of improvements in the UI
- Embedded images in reports
## [v3-4-0] - 2012-05-04
- adapted to new Workspace Tree and home Library

26
FUNDING.md Normal file
View File

@ -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);

311
LICENSE.md Normal file
View File

@ -0,0 +1,311 @@
#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 Licensees 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

42
README.md Normal file
View File

@ -0,0 +1,42 @@
# gCube System - VRE Manager Portlet
This component is a Liferay 6.2.6 CE Porlet which iinteracts with the VRE Modeler service to manager VRE Deployments and Undeployments
## Structure of the project
* The source code is present in the src folder.
## Built With
* [OpenJDK](https://openjdk.java.net/) - The JDK used
* [Maven](https://maven.apache.org/) - Dependency Management
## Documentation
* No Documentation is provided
## Change log
See [Releases](https://code-repo.d4science.org/gCubeSystem/vre-manager-portlet/releases).
## Authors
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
## Maintainers
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
## 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 see [FUNDING.md](FUNDING.md)

84
pom.xml
View File

@ -1,36 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<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>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<version>1.1.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>reports-manager-portlet</artifactId>
<packaging>war</packaging>
<version>6.2.0-SNAPSHOT</version>
<version>6.2.1-SNAPSHOT</version>
<name>gCube Reports Manager</name>
<description>
gCube Reports Portlet.
</description>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</url>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- Set Scope to provided when deploying release, compile for offline
cersion -->
<setScope>provided</setScope>
<setClassifier>online</setClassifier>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -43,7 +39,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<version>3.6.3-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -171,18 +167,15 @@
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<scope>provided</scope>
<artifactId>storagehub-client-library</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<scope>provided</scope>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-model</artifactId>
<scope>provided</scope>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
@ -250,12 +243,10 @@
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
@ -271,55 +262,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.8</target>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<!-- SA Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-profile</id>
<id>generate-doc</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
<goal>jar</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

View File

@ -10,7 +10,6 @@ import org.gcube.portlets.user.reportgenerator.client.Presenter.CommonCommands;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import org.gcube.portlets.user.reportgenerator.client.dialog.ImporterDialog;
import org.gcube.portlets.user.reportgenerator.client.dialog.PagePropertiesDialog;
import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationType;
import org.gcube.portlets.user.reportgenerator.client.model.TemplateModel;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
@ -105,7 +104,6 @@ public class Headerbar extends Composite{
MenuBar menuBar = new MenuBar();
MenuItem fileMenu;
MenuItem viewMenu;
MenuItem sectionsMenu;
MenuItem biblioMenu;
@ -127,8 +125,6 @@ public class Headerbar extends Composite{
menuBar.setAutoOpen(false);
// menuBar.setWidth("100px");
menuBar.setAnimationEnabled(true);
fileMenu = getFileMenu();
menuBar.addItem(fileMenu);
separator1 = menuBar.addSeparator();
viewMenu = getViewMenu();
menuBar.addItem(viewMenu);
@ -190,7 +186,6 @@ public class Headerbar extends Composite{
public void setMenuForWorkflowDocument(boolean canUpdate) {
presenter.setMenuForWorkflowDocument(true);
menuBar.removeItem(fileMenu);
menuBar.removeItem(viewMenu);
menuBar.removeItem(sectionsMenu);
menuBar.removeItem(biblioMenu);

View File

@ -1,29 +1,12 @@
package org.gcube.portlets.user.reportgenerator.server.servlet;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.homelibary.model.items.type.FolderItemType;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.Report;
import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
import org.gcube.common.homelibrary.util.encryption.EncryptionUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
@SuppressWarnings("serial")
public class DownloadEncryptedReport extends HttpServlet {
@ -32,71 +15,7 @@ public class DownloadEncryptedReport extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
FolderItem item = null;
File tmpFile = File.createTempFile("report", "texz");
String fileName = null;
InputStream data = null;
try {
Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession(request).getUsername());
item = (FolderItem)workspace.getItem(request.getParameter("itemId"));
if (item.getFolderItemType() == FolderItemType.REPORT) {
Report report = (Report)item;
data = report.getData();
} else {
ReportTemplate template = (ReportTemplate)item;
data = template.getData();
response.getWriter().write("Not supported");
}
fileName = item.getName() + ".texz";
EncryptionUtil util = new EncryptionUtil();
FileOutputStream out = new FileOutputStream(tmpFile);
util.encrypt(data, out);
} catch (Exception e) {
throw new ServletException(e);
}
int length = 0;
ServletOutputStream outStream = response.getOutputStream();
String mimetype = "application/octet-stream";
response.setContentType(mimetype);
response.setContentLength((int)tmpFile.length());
// sets HTTP header
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
byte[] byteBuffer = new byte[1024];
DataInputStream in = new DataInputStream(new FileInputStream(tmpFile));
// reads the file's bytes and writes them to the response stream
while ((in != null) && ((length = in.read(byteBuffer)) != -1))
{
outStream.write(byteBuffer,0,length);
}
in.close();
outStream.close();
}
/**
* the current ASLSession
* @return .
*/
private ASLSession getASLSession(HttpServletRequest request) {
String sessionID = request.getSession().getId();
String user = (String) request.getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (user == null) {
user = "massimiliano.assante";
request.getSession().setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec");
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
}

View File

@ -1,30 +1,15 @@
package org.gcube.portlets.user.reportgenerator.server.servlet;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
import org.gcube.common.homelibrary.util.MimeTypeUtil;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
/**
* Servlet implementation class DownloadImageServlet
@ -44,67 +29,15 @@ public class DownloadImageServlet extends HttpServlet {
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String itemId = req.getParameter("id");
if(itemId==null || itemId.isEmpty()){
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null");
resp.getWriter().write("Not supported");
return;
}
Workspace wa;
WorkspaceItem item;
try{
wa = getWorkspaceArea(req.getSession());
item = wa.getItem(itemId);
ExternalImage externalImage = (ExternalImage) item;
String mimeType = externalImage.getMimeType();
String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
resp.setHeader( "Content-Disposition", "inline; filename=\"" + itemName + "\"" );
resp.setContentType(externalImage.getMimeType());
resp.setContentLength((int) externalImage.getLength());
OutputStream out = resp.getOutputStream();
InputStream is = externalImage.getData();
IOUtils.copy(is, out);
is.close();
out.close();
return;
} catch (Exception e) {
_log.error("Error during item retrieving "+itemId,e);
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during image retrieving: "+e.getMessage());
return;
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { }
/**
*
* @return
* @throws WorkspaceFolderNotFoundException
* @throws InternalErrorException
* @throws HomeNotFoundException
*/
protected Workspace getWorkspaceArea(HttpSession session) throws WorkspaceFolderNotFoundException, InternalErrorException, HomeNotFoundException {
String user = (String) session.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
String currScope = ScopeProvider.instance.get();
if (currScope == null) {
String scope2Set = "/"+PortalContext.getConfiguration().getInfrastructureName();
ScopeProvider.instance.set(scope2Set);
_log.warn("Found scope null, setting infrastructure scope="+scope2Set);
}
if (user == null) {
user = ReportServiceImpl.TEST_USER;
ScopeProvider.instance.set(ReportServiceImpl.TEST_SCOPE);
_log.warn("User is null in session, setting dev user = " + user);
}
Workspace toReturn = HomeLibrary.getUserWorkspace(user);
return toReturn;
}
protected void sendError(HttpServletResponse response, String resultMessage) throws IOException {

View File

@ -1,10 +1,5 @@
package org.gcube.portlets.user.reportgenerator.server.servlet;
import org.gcube.common.homelibary.model.items.type.FolderItemType;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
public class ImagesUtil {
public static final String GIF = "image/gif";
@ -19,22 +14,10 @@ public class ImagesUtil {
* @param bi the basketItem
* @return a string for the file extension given a mimetype
*/
public static String getImageExtension(FolderItem bi) {
public static String getImageExtension() {
String mimetype = "";
if (bi.getFolderItemType()==FolderItemType.EXTERNAL_IMAGE){
ExternalImage image = (ExternalImage) bi;
mimetype = image.getMimeType();
}
if (bi.getFolderItemType()==FolderItemType.IMAGE_DOCUMENT){
GCubeItem image = (GCubeItem) bi;
try {
mimetype = image.getMimeType();
} catch (InternalErrorException e) {
e.printStackTrace();
}
}
if (mimetype.equals(GIF))
return "gif";

View File

@ -3,26 +3,20 @@ package org.gcube.portlets.user.reportgenerator.server.servlet;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.bind.DatatypeConverter;
import org.apache.commons.io.IOUtils;
import org.apache.tika.config.TikaConfig;
@ -43,23 +37,7 @@ import org.gcube.application.rsg.service.dto.response.ServiceResponseMessage;
import org.gcube.application.rsg.support.builder.exceptions.ReportBuilderException;
import org.gcube.application.rsg.support.builder.impl.ReportManagerReportBuilder;
import org.gcube.application.rsg.support.model.components.impl.CompiledReport;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.homelibary.model.items.type.FolderItemType;
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.Report;
import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries;
import org.gcube.common.encryption.encrypter.StringEncrypter;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
@ -67,12 +45,8 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.d4sreporting.common.server.ServiceUtil;
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
import org.gcube.portlets.d4sreporting.common.shared.BasicSection;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.Model;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.TableCell;
import org.gcube.portlets.user.reportgenerator.client.ReportConstants;
@ -174,7 +148,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
public String getDevelopmentUser() {
String user = TEST_USER;
// user = "andrea.rossi";
return user;
}
/**
@ -258,148 +231,8 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*
*/
public Model readModel(String templateName, String templateObjectID, boolean isTemplate, boolean isImporting) {
ServiceUtil myUtil = new ServiceUtil(getASLSession());
_log.debug("Reading " + templateName);
Workspace root = null;
WorkspaceItem item = null;
try {
root = getWorkspaceArea();
item = root.getItem(templateObjectID);
if (! isImporting)
storeReportItemIDInSession(templateObjectID);
_log.debug("** -> getItem, id: " + templateObjectID + " Name: " + item.getName());
} catch (Exception e) {
e.printStackTrace();
}
String zipToExtract = "";
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
_log.debug("Item is a FolderItem - OK... next step check if is a templet or a report");
FolderItem bi = (FolderItem) item;
boolean fromBasket = false;
if (isTemplate) {
if (bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
ReportTemplate zippedTemplate = (ReportTemplate) bi;
String zipFilename = "";
if (! isTemplate) {//then is a report
zipFilename = templateName + "-report.zip"; //gCube report
_log.debug("********************** Reading template -----------------");
}
else
zipFilename = templateName + ".zip"; //gCube template
String zipPath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
fromBasket = getTemplateFromBasket(zippedTemplate, zipPath, zipFilename);
zipToExtract = zipPath + zipFilename;
}
}
if (bi.getFolderItemType() == FolderItemType.REPORT) {
_log.debug("Item is a REPORT");
Report zippedTemplate = (Report) bi;
String zipFilename = "";
if (! isTemplate) {//then is a report
zipFilename = templateName + "-report.zip"; //gCube report
_log.debug(" Reading report -----------------");
}
else
zipFilename = templateName + ".zip"; //d4science template
File toDelete = new File(zipFilename);
toDelete.delete();
String zipPath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
fromBasket = getReportFromBasket(zippedTemplate, zipPath, zipFilename);
zipToExtract = zipPath + zipFilename;
}
_log.info("\n\n** zipToExtract: " + zipToExtract);
if (bi.getFolderItemType() == FolderItemType.REPORT || bi.getFolderItemType() == FolderItemType.REPORT_TEMPLATE) {
if (fromBasket) {
File toExtract = new File(zipToExtract);
File outputDir = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()) );
ZipUtil.unzipArchive(toExtract, outputDir);
String templatePath = myUtil.getTemplatePath(templateName, getVreName(), getUsername());
String modelFilename = "";
try {
modelFilename = seekModel(templatePath, templateName);
} catch (FileNotFoundException e) { e.printStackTrace(); }
String fileToRead = templatePath + modelFilename + ".d4st" ;
_log.debug("Loading fileToRead from Disk -> " + fileToRead);
Model toReturn = null;
Model toConvert = null;
FileInputStream fis = null;
ObjectInputStream in = null;
try {
fis = new FileInputStream(fileToRead);
in = new ObjectInputStream(fis);
toConvert = (Model) in.readObject();
in.close();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
_log.debug("Converting fileToRead to Serializable object");
toReturn = (toConvert);
// changes the template name model
toReturn.setTemplateName(templateName);
File toDelete = new File(fileToRead); //to delete the file extracted from the workspace
File toDelete1 = new File( myUtil.getTemplatePath(templateName, getVreName(), getUsername()));
boolean deleted1 = toDelete1.delete();
File toDelete2 = new File(zipToExtract);
boolean deleted2 = toDelete2.delete();
boolean deleted = toDelete.delete();
_log.debug("deleting extracted file: " + fileToRead + " result: " + deleted);
_log.debug("dirToDelete: " + toDelete1 + " result: " + deleted1);
_log.debug("dirToDelete: " + toDelete2 + " result: " + deleted2);
//**** IMPORTANT ****
if (! isImporting) {
storeTemplateInSession(toReturn);
_log.debug("storeTemplateInSession DONE");
}
if (! isTemplate) {
try {
ModelReader reader = new ModelReader(toReturn);
System.out.println(reader);
} catch (Exception e) {
_log.warn("ModelReader fails to read this report, continue...");
}
}
return toReturn;
}
}
_log.error("FAILED TO READ RETURING EMPTY Serializable Template");
return new Model();
}
_log.error("FAILED TO READ FROM BASKET RETURING EMPTY Serializable Template");
return new Model();
}
/**
@ -407,51 +240,9 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*/
@Override
public ReportImage getUploadedImageUrlById(String fileName, String absolutePathOnServer) {
if (absolutePathOnServer == null)
return null;
try {
_log.trace("trying read: "+absolutePathOnServer);
WorkspaceFolder imagesFolder = getImagesFolder();
// Read from an input stream
InputStream imageData = new BufferedInputStream(new FileInputStream(absolutePathOnServer));
String itemName = fileName;
int i = 1;
while (imagesFolder.exists(itemName)) {
String[] splitted = fileName.split("\\.");
itemName = splitted[0]+"_"+i+"."+splitted[splitted.length-1];
i++;
}
ExternalImage image = imagesFolder.createExternalImageItem(itemName, "automatically uploaded by Reports Manager", getMimeType(imageData, fileName), imageData);
_log.trace("Created external image with name " + image.getName());
//delete the temp file
File toDelete = new File(absolutePathOnServer);
toDelete.delete();
return new ReportImage(image.getId(), buildImageServiceUrl(image.getId()), image.getWidth(), image.getHeight());
} catch (Exception e) {
_log.error("Error in server get image by id", e);
e.printStackTrace();
}
return null;
}
/**
* @return the images folder of the workspace, create it if not exist.
*/
private WorkspaceFolder getImagesFolder() {
Workspace ws = null;
WorkspaceFolder reportFolder = null;
try {
ws = getWorkspaceArea();
if (! ws.getRoot().exists(REPORT_IMAGES_FOLDER)) {
reportFolder = ws.getRoot().createFolder(REPORT_IMAGES_FOLDER, "This folder hosts the images uploaded by the Reports Manager");
} else {
reportFolder = (WorkspaceFolder) ws.getRoot().find(REPORT_IMAGES_FOLDER);
}
} catch (Exception e) {
e.printStackTrace();
}
return reportFolder;
}
/**
*
* @param is
@ -475,25 +266,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*/
@Override
public ReportImage getImageUrlById(String identifier) {
if (identifier == null)
return null;
try {
Workspace workspace = getWorkspaceArea();
_log.trace("get image URL by id: "+identifier);
WorkspaceItem item = workspace.getItem(identifier); //get item from workspace
//ACCOUNTING READ
item.markAsRead(true);
_log.trace("item name " + item.getName());
ExternalImage image = (ExternalImage) item; //Cast External Document
return new ReportImage(image.getId(), buildImageServiceUrl(image.getId()), image.getWidth(), image.getHeight());
} catch (Exception e) {
_log.error("Error in server get image by id", e);
e.printStackTrace();
}
return null;
}
@ -511,118 +283,11 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
/**
* handles the case that the user has changed the template name in the basket
* @param templatePath
* @param templateName
* @return
* @throws FileNotFoundException
*/
private String seekModel(String templatePath, String templateName) throws FileNotFoundException {
_log.debug("seekModel: tPath=" + templatePath);
String fileToSeek = templatePath + templateName + ".d4st";
File toSeek = new File(fileToSeek);
if (toSeek.exists()) {
_log.debug("seekModel: modelName is the SAME returning");
return templateName;
}
else {
_log.debug("seekModel: modelName DIFFERENT upgrading");
File dirToLookIn = new File(templatePath);
File[] innerFiles = dirToLookIn.listFiles();
for (int i = 0; i < innerFiles.length; i++) {
_log.debug("scanning files in extracted folder: " + innerFiles[i].getName());
if (innerFiles[i].getName().endsWith(".d4st")) {
String toReturn = innerFiles[i].getName();
toReturn = toReturn.substring(0, toReturn.length()-5);
_log.debug("seekModel: returning.. =" + toReturn);
return toReturn;
}
}
}
throw new FileNotFoundException();
}
/**
* get the template instance from the Basket
* @param repTmp
* @return
*/
private boolean getTemplateFromBasket(ReportTemplate repTmp, String pathToFile, String filename) {
try {
File dir = new File(pathToFile);
_log.debug("DIR: " + pathToFile);
if (! dir.exists() )
dir.mkdirs();
File f = new File(pathToFile+filename);
InputStream inputStream = null;
try {
inputStream = repTmp.getData();
} catch (InternalErrorException e) {
e.printStackTrace();
return false;
}
OutputStream out = new FileOutputStream(f);
byte buf[] = new byte[1024];
int len;
while((len = inputStream.read(buf))>0)
out.write(buf,0,len);
out.close();
inputStream.close();
_log.info("Successfully got ReportTemplate from Basket: " + pathToFile);
return true;
}
catch (IOException e){
e.printStackTrace();
return false;
}
}
/**
* get the report instance from the Basket
* @param repTmp .
* @param pathToFile the directory where to save the file
* @param filename the filename to give to the newly created file
* @return
*/
private boolean getReportFromBasket(Report repTmp, String pathToFile, String filename) {
try {
File dir = new File(pathToFile);
_log.debug("DIR: " + pathToFile);
if (! dir.exists() )
dir.mkdirs();
File f = new File(pathToFile+filename);
InputStream inputStream = null;
try {
inputStream = repTmp.getData();
} catch (InternalErrorException e) {
e.printStackTrace();
return false;
}
OutputStream out = new FileOutputStream(f);
byte buf[] = new byte[1024];
int len;
while((len = inputStream.read(buf))>0)
out.write(buf,0,len);
out.close();
inputStream.close();
_log.info("Successfully got ReportTemplate from HL: " + pathToFile);
return true;
}
catch (IOException e){
e.printStackTrace();
return false;
}
}
/**
*
@ -688,82 +353,14 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
if (rsgAp != null)
_log.trace("setting RSG WS address to " + rsgAp.getRestUrl());
}
/**
*
* @return
* @throws WorkspaceFolderNotFoundException
* @throws InternalErrorException
* @throws HomeNotFoundException
*/
protected Workspace getWorkspaceArea() throws WorkspaceFolderNotFoundException, InternalErrorException, HomeNotFoundException {
return HomeLibrary.getUserWorkspace(getASLSession().getUsername());
}
/**
* reads from the file system and returns the user workspace as TreeNode object
*
* @return the Default folder if if there is no basket in session, else the folder in session id
*/
public String getRootFolder() {
try {
Workspace workspaceArea = getWorkspaceArea();
WorkspaceFolder basket = workspaceArea.getRoot();
return basket.getId();
} catch (Exception e) { e.printStackTrace();
}
return "Coud not open default folder";
}
/**
*
* @return the model previously stored in the session
*/
public Model readTemplateFromSession() {
ASLSession d4Session = getASLSession();
String templateid = (String) d4Session.getAttribute("idreport");
String templateName = "";
_log.debug("TEMPLATE ID==NULL " + (templateid == null));
if (templateid != null) {
if (! templateid.equals("")) {
_log.debug("READING SESSION VARIABLE FOR REPORT ID... " + templateid);
//reset the value
d4Session.setAttribute("idreport", "");
Workspace root = null;
WorkspaceItem item = null;
try {
root = getWorkspaceArea();
item = root.getItem(templateid);
_log.info("READ REPORT FROM WP... " + item.getName());
templateName = item.getName();
} catch (WorkspaceFolderNotFoundException e) {e.printStackTrace();
} catch (InternalErrorException e) { e.printStackTrace();
} catch (HomeNotFoundException e) { e.printStackTrace();
} catch (ItemNotFoundException e) { e.printStackTrace();}
Model toReturn = readModel(templateName, templateid, false, false);
return toReturn;
}
if (d4Session.getAttribute(CURRENT_REPORT_INSTANCE) != null)
return (Model) d4Session.getAttribute(CURRENT_REPORT_INSTANCE) ;
return null;
}
else {
if (d4Session.getAttribute(CURRENT_REPORT_INSTANCE) != null) {
_log.debug("getAttribute(\"CURRENT_REPORT_INSTANCE\")...");
Model model = (Model) d4Session.getAttribute(CURRENT_REPORT_INSTANCE) ;
_log.debug(model.getTemplateName());
return model;
}
}
ServiceUtil myUtil = new ServiceUtil(getASLSession());
String dirToClean = myUtil.getTemplateFolder(getVreName(), getUsername());
_log.info("No data on session for Reports, cleaning temp dir: " + dirToClean);
delTemplateDir(new File(dirToClean));
return null;
}
@ -796,86 +393,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
private void convertDynamicImagesFromHL(Model model) {
_log.debug("model == NULL " + (model == null));
Vector<BasicSection> sections = model.getSections();
for (BasicSection section : sections) {
for (BasicComponent component : section.getComponents()) {
if (component.getType() == ComponentType.DYNA_IMAGE) {
_log.debug("Found Simple Image: " + component.getPossibleContent());
if (component.getId() != null) { // you need to convert only new images that stay in the HL Workspace, this is the check
String imageID = component.getId();
component.setPossibleContent(getdDataImagebase64(imageID));
_log.trace("Image converted base 64 OK: " + component.getPossibleContent());
}
}
if (component.getType() == ComponentType.REPEAT_SEQUENCE || component.getType() == ComponentType.BODY_TABLE_IMAGE) { //there could be images inside
RepeatableSequence res = (RepeatableSequence) component.getPossibleContent();
for (BasicComponent co : res.getGroupedComponents()) {
if (component.getType() == ComponentType.DYNA_IMAGE) {
_log.debug("Found Image IN SEQUENCE, type is: " + component.getType());
if (co.getId() != null) { // you need to convert only new images that stay in the HL Workspace, this is the check
String imageID = co.getId();
co.setPossibleContent(getdDataImagebase64(imageID));
_log.trace("Image converted base 64 OK, in SEQUENCE: " + co.getPossibleContent());
}
}
}
}
}
}
}
/**
* convert the image into a String encoded base 64
* @param imageIDinWorkspace the id of the image in workspace
* @return the string representing the image converted to be put in the img src attribute e.g. data:image/ong;base64,a...z
*/
private String getdDataImagebase64(String imageIDinWorkspace) {
Workspace root = null;
try {
root = getWorkspaceArea();
WorkspaceItem item = null;
item = root.getItem(imageIDinWorkspace);
if (item.getType() == WorkspaceItemType.FOLDER_ITEM) {
_log.debug("Item is a Folder Item");
FolderItem imageItem = (FolderItem) item;
InputStream data = null;
if (imageItem.getFolderItemType()==FolderItemType.EXTERNAL_IMAGE){
_log.debug("EXTERNAL_IMAGE -|- " + item.getType() + " itemId=" + item.getId());
ExternalImage image = (ExternalImage)item;
_log.debug("EXTERNAL_IMAGE Name= " + item.getName() + " Asking InputStream ..");
data = image.getData();
_log.debug("Got inputStream");
}
else if (imageItem.getFolderItemType()==FolderItemType.IMAGE_DOCUMENT){
GCubeItem image = (GCubeItem)item;
if (image.getMimeType().equals("image/tiff"))
// image.getProperties().getProperties().get(NodeProperty.THUMBNAIL_DATA); //this is a problem
// else
data = image.getData();
}
if (data != null) {
_log.debug("Encoding image in base64");
byte[] imageBytes = IOUtils.toByteArray(data);
String extension = ImagesUtil.getImageExtension(imageItem);
String srcAttrValue = "data:image/"+extension+";base64,"+DatatypeConverter.printBase64Binary(imageBytes);
_log.debug("Encoded image=" + srcAttrValue);
return srcAttrValue;
}
return null;
}
else
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* @param reportItemid the report itemd id in basket to store in the session
*/
@ -899,30 +416,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
* used to save the report in the same folder
*/
public void saveReport(Model toSave) {
Workspace root = null;
try {
root = getWorkspaceArea();
} catch (Exception e) { e.printStackTrace();}
WorkspaceItem item = null;
String folderid = "";
String itemName = "";
try {
if (getReportItemIDFromSession().equals("")) {
folderid = getRootFolder();
}
else {
item = root.getItem(getReportItemIDFromSession());
folderid = item.getParent().getId();
itemName = item.getName();
}
} catch (ItemNotFoundException e) {
_log.error("ITEM NOT FOUND -> " + getReportItemIDFromSession());
} catch (InternalErrorException e) {
e.printStackTrace();
}
saveReport(toSave, folderid, itemName);
_log.warn("saveReport Not supported anymore");
}
@ -932,134 +426,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
*
*/
public void saveReport(Model toSave, String folderid, String newname) {
Model model = toSave;
storeTemplateInSession(toSave);
_log.info("Serializing Model in folder: " + folderid );
_log.info("Trying to convert dynamic images ... ");
convertDynamicImagesFromHL(model);
ServiceUtil myUtil = new ServiceUtil(getASLSession());
boolean result = myUtil.writeModel(model, "CURRENT_OPEN", getVreName(), getUsername());
try {
ModelReader reader = new ModelReader(model);
System.out.println(reader);
} catch (Exception e) {
_log.warn("ModelReader fails to read this report, continue...");
}
if (!result) {
_log.debug("Could not save report, serializing failed");
}
else {
String templatePath = myUtil.getTemplateFolder(getVreName(), getUsername()) + "CURRENT_OPEN";
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
_log.debug("Trying to zip folder: " + templatePath);
String folderToZip = templatePath;
String outZip = templatePath+"-report.zip";
try {
ZipUtil.zipDir(outZip, folderToZip);
} catch (IOException e) {
_log.error("Could not zip template, serializing failed");
e.printStackTrace();
}
_log.info("Folder zipped, result: "+ outZip);
InputStream isZip = null;
WorkspaceFolder toSaveIn = null;
try {
isZip = new BufferedInputStream(new FileInputStream(outZip));
toSaveIn = getRootFolder(folderid);
String templateName = newname;
boolean isUpdate = false;
if (templateName.endsWith("d4sR") ) {
if (toSaveIn.exists(templateName)) {
_log.warn("Item exists already, updating");
//toSaveIn.removeChild(toSaveIn.find(templateName));
isUpdate = true;
}
}
if (toSaveIn.exists(templateName + ".d4sR")) {
_log.warn("Item exists already, updating");
//toSaveIn.removeChild(toSaveIn.find(templateName + ".d4sR"));
isUpdate = true;
}
//remove the template extension
String templateToInsert = templateName.replace(".d4sT", "");
if (! templateToInsert.endsWith(".d4sR"))
templateToInsert+=".d4sR";
Report rep = null;
if (isUpdate) {
rep = (Report) toSaveIn.find(templateName);
getWorkspaceArea().updateItem(rep.getId(), isZip);
} else { //is new
Calendar dateCreated = Calendar.getInstance();
dateCreated.setTime(model.getDateCreated());
Calendar lastEdit = Calendar.getInstance();
lastEdit.setTime(model.getLastEdit());
rep = toSaveIn.createReportItem(templateToInsert, templateToInsert, dateCreated, lastEdit,
model.getAuthor(), model.getLastEditBy(), templateToInsert, model.getSections().size(), "no-status", isZip);
}
storeReportItemIDInSession(rep.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* Return an instance of the root folder
* @param folderId
* @return
* @throws ItemNotFoundException
*/
private WorkspaceFolder getRootFolder(String folderId) throws ItemNotFoundException {
Workspace root = null;
try {
root = getWorkspaceArea();
} catch (WorkspaceFolderNotFoundException e) {e.printStackTrace();
} catch (InternalErrorException e) { e.printStackTrace();
} catch (HomeNotFoundException e) { e.printStackTrace();
}
WorkspaceItem item = null;
try {
item = root.getItem(folderId);
} catch (ItemNotFoundException e) {
_log.info("Folder : " + folderId + " NOT FOUND RETURNING DEFAULT ONE");
return(WorkspaceFolder)root.getItem(getRootFolder());
}
if (item.getType() == WorkspaceItemType.FOLDER || item.getType() == WorkspaceItemType.SHARED_FOLDER) {
return (WorkspaceFolder) item;
}
_log.error("The item id does not belong to a valid folder id:" + folderId);
return null;
_log.warn("saveReport Not supported anymore");
}
/*
/**
* return a sample of the given TS to the client
@ -1067,61 +437,10 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
* @return .
*/
public Table getSampleTimeSeries(RepTimeSeries sTS) {
File csvTS = getTimeSeriesFromWorkspace(sTS);
Table toReturn = null;
try {
toReturn = parseCSV(csvTS, sTS);
} catch (ParseException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace();
} catch (ProcessingException e) { e.printStackTrace();
}
return toReturn;
}
/**
* retrieve the given TS csv representation and writes it into /tmp returning the File
* @param sTS serializable TS
* @return a File csv
*/
private File getTimeSeriesFromWorkspace(RepTimeSeries sTS) {
try {
String timeSeriesBasketID = sTS.getTsMetadata().getId();
Workspace root = null;
try {
root = getWorkspaceArea();
} catch (WorkspaceFolderNotFoundException e) {e.printStackTrace();
} catch (InternalErrorException e) { e.printStackTrace();
} catch (HomeNotFoundException e) { e.printStackTrace();
}
WorkspaceItem item = null;
try {
item = root.getItem(timeSeriesBasketID);
} catch (ItemNotFoundException e) {
e.printStackTrace();
}
_log.debug("Got Item TS From HL, Item Type: "+item.getType());
if (item.getType() != WorkspaceItemType.FOLDER_ITEM) {
_log.debug("The item id does not belong to a timeseries, id:" + timeSeriesBasketID);
return null;
}
FolderItem bItem = (FolderItem) item;
if (bItem.getFolderItemType() != FolderItemType.TIME_SERIES) {
_log.debug("The basket item does not belong to a timeseries, id:" + timeSeriesBasketID);
return null;
}
TimeSeries ts = (TimeSeries) bItem;
return getTSFromBasket(ts);
}
catch (NullPointerException e) {
_log.error("No TS was dragged in the Area returning NULL");
return null;
}
}
/**
*
@ -1211,43 +530,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
/**
* get the TS from the Basket
* @param ts
* @return a csv file
*/
private File getTSFromBasket(TimeSeries ts) {
try {
File temp = File.createTempFile(ts.getName(), ".csv");
InputStream inputStream = null;
try {
inputStream = ts.getData();
} catch (InternalErrorException e) {
e.printStackTrace();
return null;
}
OutputStream out = new FileOutputStream(temp);
byte buf[] = new byte[1024];
int len;
while((len = inputStream.read(buf))>0)
out.write(buf,0,len);
out.close();
inputStream.close();
_log.debug("Successfully got TimeSeries from Basket: \n" + temp.getAbsolutePath());
return temp;
}
catch (IOException e){
e.printStackTrace();
return null;
} catch (InternalErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
/**