diff --git a/.gitignore b/.gitignore index 7ff327c6..4f35f1f4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ tmp/ local.properties .settings/ .loadpath +.classpath +.project # Locally stored "Eclipse launch configurations" *.launch diff --git a/README.md b/README.md index 10ffa4aa..ccf42881 100644 --- a/README.md +++ b/README.md @@ -4,29 +4,67 @@ CRCE is an experimental repository, designed to support research into component- ## Prerequisities -- **JDK 7** set in `JAVA_HOME` environment variable before starting CRCE (there is a problem with running web UI on JDK 8, need to update dependencies), tested on 1.7.0_80 +- **JDK 11** set in `JAVA_HOME` environment variable before starting CRCE, tested on OpenJDK 11.0.4 - **MongoDB**, tested on v2.6.10, v3.4.10 - **Maven 3**, tested on 3.5.2 -On linux, switching to JDK 7 for development/build can be done via `sudo update-alternatives --config java`. +On linux, switching to JDK 11 for development/build can be done via `sudo update-alternatives --config java`. ## Build +Build process consists of two parts. Compiling and building the code itself and building the docker image. + +### Build CRCE + +This process can be done automatically by running the `build-code.bash` script placed in the project root directory. + 1. `crce-parent` in `/pom` directory 2. `shared-build-settings` in `/build` 3. everything in `/third-party` (bash: `.../third-party$ for d in * ; do cd $d; mvn clean install; cd .. ; done`) 4. `crce-core-reactor` in `/core` 5. `crce-modules-reactor` in `/modules` +6. `provision-reactor` in `/deploy` On linux, step 3. can be perfomed via `.../third-party$ for d in * ; do cd $d ; mvn clean install ; cd .. ; done`. In case of maven error "Received fatal alert: protocol_version", use `mvn -Dhttps.protocols=TLSv1.2 ...` after https://stackoverflow.com/a/50924208/261891. + +### Build docker image + +Docker image is placed in directory `/deploy` but before it can be used, bundles must be collected. +Bundles can be collected by running the following commands in `/deploy` directory: + +```bash +mvn clean pax:directory +./prepare-bundles.sh + +``` + +The `prepare-bundles.sh` script is needed due to the issues further described in the Issues section. + +To finally build the image itself, execute the following commnad in `/deploy` directory: + +```bash +docker build . -t ${image-tag} +``` + ## Start up -Run CRCE using Maven plugin for pax in `crce-modules-reactor` module (i.e. `/modules` directory): +Assuimg the dokcer image is already build, run it by following command: -`mvn pax:provision` +```bash +docker run -it \ + -p 8080:8080 \ + --add-host mongoserver:172.17.0.1 \ + -v /felix/deploy:/felix/deploy \ + ${image-tag} +``` -The output log should write up some info about dependencies terminated by lines similar to the following: +The `-p` parameter maps the port of docker virual machine to the real port on the computer. +The `--add-host` allows docker to connect to the Mongo database running locally (Docker *usually* uses 172.17.0.1 ip to access localhost from the container). The app expects the database to be listening on port 27017 by default. +The `-v` parameter maps directory in container to the real directory in the host machine so that it can be used to install new bundles via CLI. + + +If everything works, the output log should write up some info about dependencies terminated by lines similar to the following: ``` Listening for transport dt_socket at address: 65505 @@ -47,17 +85,58 @@ The cause of the latter is a badly loaded binary of mathematical solver which do Started up, the application is accessible at: -- web UI: http://localhost:8080/crce +- web UI: http://localhost:8080/crce-webui - REST web services: http://localhost:8080/rest/v2/ Updated (more or less) REST WS documentation is available at [Apiary](https://crceapi.docs.apiary.io/). +### MongoDB + +Mongo DB can either be run locally or in docker using following command: + +```bash +sudo docker run -d -p 27017:27017 -v ~/data:/data/db mongo +``` + +Where `~/data` is directory on host machine to be used as a storage by Mongo. + ### lpsolve installation To solve the issue with mathematical solver, you need to install [lpsolve library](https://sourceforge.net/projects/lpsolve/) to your computer. To do that, follow [their guide](http://lpsolve.sourceforge.net/5.5/Java/README.html#install) step by step. > Note that on Windows, you do not have to place the libs to `\WINDOWS` or `\WINDOWS\SYSTEM32` as the guide states. Put it wherever you wish and add the directory to your `Path`. +## Debugging + +Remote debugging is possible when running CRCE in Docker. To enable remote debug, application needs to be started with following flags: + +```bash +-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 +``` + +And expose the port 5005 by adding `-p 5005:5005` to the `docker run` command. + +Check the `deploy/Dockerfile` to see the difference between running the app in normal and debug mode. + ## Code updates After modifying a part of code, only the parental module needs to be rebuilt (no need to rebuild all). After that, the pax process must be restarted. + +## Configuration + +Configuration is done via OSGI service called [Configuration Admin](https://osgi.org/specification/osgi.cmpn/7.0.0/service.cm.html). +Details on how it's implemented in Felix can be found in [Apache Felix Configuration Admin Service](https://felix.apache.org/documentation/subprojects/apache-felix-config-admin.html). + +By default, Felix will look into the `config` directory for possible configuration (example of such directory can be found in `deploy/conf.default`) + + +## Issues + +### Required runtime environment capability in some bundles + +Some bundles (mostly those from the third parties) either require a particular version of OSGi runtime environment or require the capability `osgi.ee` to be set to a specific value. This may or may not work with newer version of Java and to avoid runtime problems, these requirements need to be removed. + +To remove them, it is necessary to edit manifest (`META-INF/MANIFEST.MF`) of such bundle and remove lines containing: +`Require-Capability: osgi.ee;` or `Bundle-RequiredExecutionEnvironment: J2SE-`. This is done in the `deploy/prepare-bundles.sh` script. + +An ideal solution would be to either found newer version of such bundles or replace them with different bundles with same functionality. This however may introduce compatibility issues (as some other bundles may depend on the current versions) or may not even be possible (replacement bundle does not exist). diff --git a/arch/.gitignore b/arch/.gitignore new file mode 100644 index 00000000..a14f836d --- /dev/null +++ b/arch/.gitignore @@ -0,0 +1,8 @@ +#ignore vim +*.swp + +#ignore tex build +*.aux +*.gz +*.log + diff --git a/arch/IndexerApi.png b/arch/IndexerApi.png new file mode 100644 index 00000000..f4866fcf Binary files /dev/null and b/arch/IndexerApi.png differ diff --git a/arch/Modules.png b/arch/Modules.png new file mode 100644 index 00000000..716645ac Binary files /dev/null and b/arch/Modules.png differ diff --git a/arch/crce.eap b/arch/crce.eap new file mode 100644 index 00000000..fed3f7dc Binary files /dev/null and b/arch/crce.eap differ diff --git a/arch/favlogo.jpg b/arch/favlogo.jpg new file mode 100644 index 00000000..b70db908 Binary files /dev/null and b/arch/favlogo.jpg differ diff --git a/arch/sar-2018.pdf b/arch/sar-2018.pdf new file mode 100644 index 00000000..828a3fad Binary files /dev/null and b/arch/sar-2018.pdf differ diff --git a/arch/sar-2018.tex b/arch/sar-2018.tex new file mode 100644 index 00000000..f9fb7bf8 --- /dev/null +++ b/arch/sar-2018.tex @@ -0,0 +1,172 @@ +\documentclass[12pt, a4paper]{article} +\usepackage[utf8]{inputenc} +\usepackage[IL2]{fontenc} +\usepackage[czech]{babel} +\usepackage{graphicx} + +\begin{document} +\begin{figure}[h!] +\centering +\includegraphics[bb= 0 0 820 445 , width=75mm]{favlogo.jpg} +\end{figure} + +\vspace{5cm} + +{\centering +{\huge Architektura CRCE}\\[1em] +{\large KIV/SAR - semestrální práce}\\[7,5cm] +} + +\begin{tabular}{l r} +student: & Radek VAIS, Zdeněk VALEŠ\\ +mail: & vaisr@students.zcu.cz, valesz@students.zcu.cz\\ +datum: & 1.1.2019\\ +\end{tabular} + +\thispagestyle{empty} +\newpage + +%======================================== +%======================================== +%======================================== +%======================================== +%======================================== +\section{Zadání} %===================================================================================================== + +CRCE\footnote{Component Repository supporting Compatibility Evaluation} je komponentové úložiště vyvíjené v rámci výzkumu na Katedře informatiky a výpočetní techniky na Západočeské univerzitě v Plzni. Jeho hlavní vlastností je podpora kontroly kompatibility verzí různých OSGi komponent nebo webových api. + +\subsection{Motivace} + +Vývoj projektu probíhá již několik let a vystřídalo se na něm mnoho vývojářů, což způsobilo zanesení větších či menších architektonických dluhů. Projekt již můžeme klasifikovat jako velký. Existuje potřeba, aby střídající se vývojáři (např. v rámci bakalářských prací) snadno a rychle zprovoznili základní instalaci a získali tak prostředí, pro rychlý vývoj nových částí. + +\subsection{Cíle projektu} + +\begin{itemize} + \item Unifikovat proces sestavení aplikace a spuštění. + \item Zdokumentovat současnou architekturu aplikace. + \item Analyzovat závislosti modulů v projektu a ověřit, zda některé moduly mají být součástí jádra. + \item Připravit Docker image pro vývojáře. +\end{itemize} + +\newpage +%======================================== +%======================================== +%======================================== +%======================================== +%======================================== +\section{Analýza~architektury} %============================================================================================ + +Celý projekt je rozdělen do čtyř hlavních modulů: sdílené nastavení sestavení, jádro, moduly a knihovny třetích stran. Ne zcela jasné je začlenění mechanismu pro nasazení a spuštění v modulu \texttt{CRCE modules} (jedná se o komponentu \texttt{provision}). Závislostí modulů na jádře pozorujeme dva typy. Prvním typem je závislost na agregačním modulu jádra, druhým je jmenovitá závislost na komponentách jádra. Tyto skutečnosti jsou patrné na celkovém diagramu na Obrázku \ref{fig:wholeCRCE}. + +\begin{figure}[h!] +\centering +\includegraphics[width=135mm]{wholeCRCE.png} +\caption{Diagram závislostí všech maven komponent projektu CRCE před provedenými úpravami.} +\label{fig:wholeCRCE} +\end{figure} + +Během analýzy modulu pro moduly CRCE jsme identifikovali několik kandidátů na přesun do jádra. Za kandidáty jsme volili takové komponenty, které využívá velká část ostatních modulů a zároveň tyto moduly mají závislosti do jádra. Komponenta webového rozhraní (\texttt{crce-webui}) tomuto pravidlu sice odporuje, představuje ale základní komponentu, bez které by úložiště nešlo použít. Přesouvané komponenty jsou: \texttt{crce-compatibility-api}, \texttt{crce-webui}, \texttt{crce-concurrency} (graficky znázorněno na Obrázku \ref{fig:modulesCRCE}). + +Po identifikace kandidátů jsme z přesunu vyřadili komponentu metadata-osgi-bundle, kvůli nedostatečné obecnosti. Komponenta je schopna indexovat pouze OSGI komponenty -- přesun do jádra by byl možný, pokud by uměla indexovat obecné JAR. Komponenta \texttt{crce-webui} bohužel obsahuje silnou závislost na této komponentě, která brání přesunu \texttt{crce-webui} do jádra. Závislost spočívá v použití několika konstant, které jsou v definované v metadata-osgi-bundle. Navrhli jsme tedy přidání metody do rozhraní indexeru pro zjištění jaké elementy indexer zpracovává a silnou závislost jsme nahradili slabou závislostí. + +\begin{figure}[h!] +\centering +\includegraphics[width=135mm]{modules.png} +\label{fig:modulesCRCE} +\caption{Diagram původních závislostí uvnitř modulu moduly CRCE. Zeleně jsou označeny přesouvané komponenty. Červeně je označena nevhodná závislost.} +\end{figure} + +%======================================== +%======================================== +%======================================== +%======================================== +%======================================== +\section{Provedené~změny} %======================================================================================= + +V projektu jsme provedli několik změn, které by měly vést k zjednodušení práce budoucích vývojářů. Pro přehlednost dodávám, že v této sekci pojem \textit{modul} značí maven modul v kořenovém adresáři CRCE a pojem \textit{komponenta} značí jeden z maven modulů obsahující konkrétní implementaci (\textit{crce-webui}, \textit{crce-metadata-api}, ...). + +\subsection{Nový modul pro sestavení} +Do kořene CRCE byl přidán nový modul \textit{deploy}, do kterého byla přesunuta komponenta \textit{provision}, používaná ke spouštění CRCE. Jsou zde agregovány všechny komponenty z jádra a komponenty z modulu \textit{modules}, které jsou zachycené v \textit{crce-default-modules}. + +Nově přidaná komponenta \textit{crce-default-modules} tedy slouží jako agregátor komponent z modulu \textit{modules}, které mají být použité ve výsledné distribuci. + +V rámci přípravy modulu pro sestavení a spuštění byla povýšena verze Felix na 5.0.0. Starší verze způsobovala problémy se spuštěním interaktivního shellu při spuštění pomocí Dockeru. + +\subsection{Přesun vybraných modulů do jádra} +Do jádra byly z modulu \textit{modules} přesunuty komponenty: \textit{crce-compatibility-api}, \textit{crce-webui} a \textit{crce-concurrency}. V případě \textit{crce-webui} bylo nutné odstranit závislost na \textit{crce-core} (jinak by se jednalo o kruhovou závislost) a nahradit ji jednotlivými závislostmi na vybraných komponentách z jádra. + +V komponentě \textit{crce-compatibility-api} bylo nutné přidat výchozí (prázdnou) implementaci rozhraní \textit{Compatibility} a \textit{Diff}. Pro tyto implementace byl přidán unit test. + +Součástí přesunu komponent do jádra bylo přidání unit testu do \textit{crce-metadata-osgi-bundle}, který dokazuje schopnost této komponenty indexovat pouze OSGI bundly a ne obecné JAR. + +\subsubsection{Nahrazení silné závislosti v komponentě crce-webui} +Komponenta \textit{crce-webui} obsahovala silnou závislost na komponentě \textit{crce-metadata-osgi-bundle}. Tato závislost spočívala v použití několika konstant, označujících indexované elementy, definovaných v rozhraní \textit{NsOsgiIdentity}. Konstanty byly použity ve třídě \textit{ResourceServlet} k filtrování zobrazovaných OSGI bundlů. + +Po dohodě s vyučujícím jsme tuto závislost nahradili slabou závislostí -- konstanty stejného typu jsme dodefinovali i v komponentě \textit{crce-webui}. Silná závislost byla odstraněna, nicméně pokud se v budoucnu změní komponenta \textit{crce-metadata-osgi-bundle}, bude nutné kontrolovat, zda změna neovlivnila \textit{crce-webui} a případné nesrovnalosti opravit. + +Aby bylo podobným závislostem v budoucnosti zamezeno, rozhraní indexeru bylo rozšířeno o metodu, která vrací elementy, jež je indexer schopen detekovat. V rámci této práce byla vytvořena defaultní implementace této vlastnosti v AbstractIndexer, která vrací pouze prázdný seznam. Projekt lze bezpečně přeložit, ale momentálně novou funkci rozhraní plně využívá jen OSGiIndexer. + +\begin{figure}[h!] +\centering +\includegraphics[width=135mm]{indexerApi.png} +\label{fig:indexerApi} +\caption{Diagram ukazuje upravené rozhraní indexeru, které nově obsahuje metodu getIndexedAttributes, která slouží k získání seznamu vlastností, které daný indexer zpracovává. Dále naznačuje možnost umístit implementaci indexeru do modulu crce-core nebo crce-modules (fiktivní indexery JarIndexer a AnotherIndexer).} +\end{figure} + +\subsubsection{Načítání connection stringu} + +Součástí příprav pro dockerizaci bylo přidání konfigurace připojení k databázi MongoDB. Ke konfiguraci připojení lze nyní využít proměnnou prostředí \textit{mongo\_connection}, kde aplikace očekává MongoDB connection string\footnote{viz dokumentace: https://docs.mongodb.com/manual/reference/connection-string/}. V případě, že tato proměnná není nastavena, použije se výchozí hodnota (\textit{mongodb://localhost:27017}, která nese připojení k databázi běžící na localhostu a standardním portu. Výhodou tohoto přístupu je možnost konfigurovat connection string v Dockerfile a při změně pouze znovu sestavit image. + + +\section{Dockerizace projektu} +Do modulu \textit{deploy} byl přidán Dockerfile, kterým je možné sestavit docker image obsahující spustitelnou verzi CRCE. Do takto spuštěného CRCE lze doinstalovávat nové OSGI komponenty a není nutné celý projekt znovu sestavovat. + + + +%======================================== +%======================================== +%======================================== +%======================================== +%======================================== +\section{Uživatelská~příručka} %====================================================================================== + +Provedené změny ovlivnily základní používání projektu při vývoji. + +Pro sestavení na platformě Linux lze použít bash script \textit{build.bash}\footnote{Teoreticky není nutná platforma Linux. Pro uživatele Windows by měl být dostačující bash interpret nebo Linux subsystem. Tato možnost nebyla testována.}, který automaticky spustí jednotlivé kroky sestavení pomocí nástroje Maven. Script vždy vykonává všechny kroky od začátku, v případě selhání je vhodné po opravě pokračovat v buildu manuálně. + +V případě, že databáze neběží na localhostu, nebo standardním portu, je možné nastavit připojení skrze proměnnou prostředí \textit{mongo\_connection}. Tato proměnná by v případě použití měla obsahovat celý connection string. Pokud není nastavená, pro připojení k databázi bude použita výchozí hodnota: \textit{mongodb://localhost:27017}. + +\subsection{Docker} +K sestavení Docker image je možné použít Dockerfile, který se nachází v modulu \textit{deploy}. Sestavení image je provedeno příkazem: + +\begin{verbatim} +docker build . -t crce-docker +\end{verbatim} + +Výsledný image obsahuje distribuci Apache Felix 5.0.0, JDK 1.7 a všechny OSGI bundly z CRCE. Spuštění lze provést příkazem: + +\begin{verbatim} +docker run -it \ + -p 8080:8080 \ + --add-host mongoserver:172.17.0.1 \ + -v /felix/deploy:/felix/deploy \ + crce-docker +\end{verbatim} + +Parametr \textit{add-host} slouží k přidání záznamu do /etc/hosts v kontejneru a image se pak může k databázi běžící na hostovacím stroji dostat pomocí hostname \textit{mongoserver}. IP adresa 172.17.0.1 je adresa, kterou docker přiřazuje hostovacímu stroji. Do adresáře \textit{/felix/deploy} na hostovacím stroji je možné vložit OSGI bundly a ty následně nainstalovat a spustit skrze Gogo shell. K běžící instanci je možné přistoupit na adrese \textit{http://localhost:8080/crce}. + +Před spuštěním docker image je třeba spustit instanci MongoDB. Není podstatné, zda bude spuštěna prostřednictvím Dockeru (např. image 3.4-jessie), lokálním stroji nebo na serveru. Jen je třeba před sestavením ověřit nastavení connection string. Není připravena konfigurace docker-compose, protože se nám v rámci konfigurace a testů nepodařilo zprovoznit GoGo shell při použití compose mechanismu, uživatel by byl ochuzen o diagnostické možnosti OSGi runtime. + +%======================================== +%======================================== +%======================================== +%======================================== +%======================================== +\newpage +\section{Závěr} %====================================================================================================== + +V rámci projektu jsme naplnili cíl usnadnit novým vývojářům spuštění výchozí aplikace, především přípravou docker image. Nepodařilo se nám zjednodušit proces sestavení celé aplikace na jeden Maven příkaz nicméně pro prostředí Linux jsme vytvořili script, který úkony nutné pro sestavení provede automaticky. +Dále jsme přesunuli několik modulů do jádra CRCE z důvodu jejich provázanosti s ostatními nebo nutnosti pro používání. + + +\end{document} \ No newline at end of file diff --git a/arch/wholeCRCE.png b/arch/wholeCRCE.png new file mode 100644 index 00000000..02a9b475 Binary files /dev/null and b/arch/wholeCRCE.png differ diff --git a/artifact-list.txt b/artifact-list.txt new file mode 100755 index 00000000..fa1c63a6 --- /dev/null +++ b/artifact-list.txt @@ -0,0 +1,49 @@ +c:\users\valesz\documents\crce: crce-reactor +c:\users\valesz\documents\crce\build: crce-parent -> shared-build-settings +c:\users\valesz\documents\crce\build\compiled: shared-build-settings -> compiled-bundle-settings +c:\users\valesz\documents\crce\build\wrappers: shared-build-settings -> wrapper-bundle-settings +c:\users\valesz\documents\crce\core: crce-core-reactor +c:\users\valesz\documents\crce\core\crce-core: crce-parent -> crce-core +c:\users\valesz\documents\crce\core\crce-metadata-api: compiled-bundle-settings -> crce-metadata-api +c:\users\valesz\documents\crce\core\crce-metadata-dao-api: compiled-bundle-settings -> crce-metadata-dao-api +c:\users\valesz\documents\crce\core\crce-metadata-dao-impl: compiled-bundle-settings -> crce-metadata-dao-impl +c:\users\valesz\documents\crce\core\crce-metadata-dao-mongodb: compiled-bundle-settings -> crce-metadata-dao-mongodb +c:\users\valesz\documents\crce\core\crce-metadata-impl: compiled-bundle-settings -> crce-metadata-impl +c:\users\valesz\documents\crce\core\crce-metadata-indexer-api: compiled-bundle-settings -> crce-metadata-indexer-api +c:\users\valesz\documents\crce\core\crce-metadata-indexer-impl: compiled-bundle-settings -> crce-metadata-indexer-impl +c:\users\valesz\documents\crce\core\crce-metadata-json-api: compiled-bundle-settings -> crce-metadata-json-api +c:\users\valesz\documents\crce\core\crce-metadata-json-impl: compiled-bundle-settings -> crce-metadata-json-impl +c:\users\valesz\documents\crce\core\crce-metadata-service-api: compiled-bundle-settings -> crce-metadata-service-api +c:\users\valesz\documents\crce\core\crce-metadata-service-impl: compiled-bundle-settings -> crce-metadata-service-impl +c:\users\valesz\documents\crce\core\crce-plugin-api: compiled-bundle-settings -> crce-plugin-api +c:\users\valesz\documents\crce\core\crce-repository-api: compiled-bundle-settings -> crce-repository-api +c:\users\valesz\documents\crce\core\crce-repository-impl: compiled-bundle-settings -> crce-repository-impl +c:\users\valesz\documents\crce\core\crce-resolver-api: compiled-bundle-settings -> crce-resolver-api +c:\users\valesz\documents\crce\core\crce-resolver-impl: compiled-bundle-settings -> crce-resolver-impl +c:\users\valesz\documents\crce\modules: crce-modules-parent -> crce-modules-reactor +c:\users\valesz\documents\crce\modules\crce-compatibility-api: crce-modules-parent -> crce-compatibility-api +c:\users\valesz\documents\crce\modules\crce-compatibility-dao-api: crce-modules-parent -> crce-compatibility-dao-api +c:\users\valesz\documents\crce\modules\crce-compatibility-dao-mongodb: crce-modules-parent -> crce-compatibility-dao-mongodb +c:\users\valesz\documents\crce\modules\crce-concurrency: crce-modules-parent -> crce-concurrency +c:\users\valesz\documents\crce\modules\crce-handler-metrics: crce-modules-parent -> crce-handler-metrics +c:\users\valesz\documents\crce\modules\crce-integration-tests: crce-modules-parent -> crce-integration-tests +c:\users\valesz\documents\crce\modules\crce-metadata-osgi-bundle: crce-modules-parent -> crce-metadata-osgi-bundle +c:\users\valesz\documents\crce\modules\crce-optimizer-functions: crce-modules-parent -> crce-optimizer-functions +c:\users\valesz\documents\crce\modules\crce-repository-maven-impl: crce-modules-parent -> crce-repository-maven-impl +c:\users\valesz\documents\crce\modules\crce-rest: crce-modules-parent -> crce-rest +c:\users\valesz\documents\crce\modules\crce-rest-v2: crce-modules-parent -> crce-rest-v2 +c:\users\valesz\documents\crce\modules\crce-restimpl-indexer: crce-modules-parent -> crce-restimpl-indexer +c:\users\valesz\documents\crce\modules\crce-target: crce-modules-parent -> crce-target +c:\users\valesz\documents\crce\modules\crce-vo: crce-modules-parent -> crce-vo +c:\users\valesz\documents\crce\modules\crce-webservices-indexer: crce-modules-parent -> crce-webservices-indexer +c:\users\valesz\documents\crce\modules\crce-webui: crce-modules-parent -> crce-webui +c:\users\valesz\documents\crce\modules\pom: compiled-bundle-settings -> crce-modules-parent +c:\users\valesz\documents\crce\modules\provision: crce-modules-parent -> provision +c:\users\valesz\documents\crce\pom: crce-parent +c:\users\valesz\documents\crce\third-party\httpclient: wrapper-bundle-settings -> org.apache.httpcomponents.httpclient +c:\users\valesz\documents\crce\third-party\httpcore: wrapper-bundle-settings -> org.apache.httpcomponents.httpcore +c:\users\valesz\documents\crce\third-party\jna-platform: wrapper-bundle-settings -> net.java.dev.jna.jna-platform +c:\users\valesz\documents\crce\third-party\lpsolve: compiled-bundle-settings -> com.datumbox.lpsolve +c:\users\valesz\documents\crce\third-party\plexus-component-annotations: wrapper-bundle-settings -> org.codehaus.plexus.plexus-component-annotations +c:\users\valesz\documents\crce\third-party\plexus-interpolation: wrapper-bundle-settings -> org.codehaus.plexus.plexus-interpolation +c:\users\valesz\documents\crce\third-party\plexus-utils: wrapper-bundle-settings -> org.codehaus.plexus.plexus-utils diff --git a/build-code.bash b/build-code.bash new file mode 100755 index 00000000..703b8e56 --- /dev/null +++ b/build-code.bash @@ -0,0 +1,61 @@ +#!/bin/bash + +echo "Building crce-parent in ./pom" +cd pom +mvn clean install +retVal=$? +cd .. +if [ $retVal -ne 0 ]; then + echo "Error"; + exit $retVal; +fi + +#============================================================== + +echo "Building shared-build-settings in ./build" +cd build +mvn clean install +retVal=$? +cd .. +if [ $retVal -ne 0 ]; then + echo "Error"; + exit $retVal; +fi + +#============================================================== + +echo "Building third party libraries in ./third-party" +cd third-party +for d in * ; do cd $d ; mvn clean install ; cd .. ; done +retVal=$? +cd .. +if [ $retVal -ne 0 ]; then + echo "Error"; + exit $retVal; +fi + +#============================================================== + +echo "Building crce-core-reactor in ./core" +cd core +mvn clean install +retVal=$? +cd .. +if [ $retVal -ne 0 ]; then + echo "Error"; + exit $retVal; +fi + +#============================================================== + +echo "Building crce-modules-reactor in ./modules" +cd modules +mvn clean install +retVal=$? +cd .. +if [ $retVal -ne 0 ]; then + echo "Error"; + exit $retVal; +fi + +echo "Done building" diff --git a/build/compiled/pom.xml b/build/compiled/pom.xml index c0ceda26..43761936 100644 --- a/build/compiled/pom.xml +++ b/build/compiled/pom.xml @@ -29,6 +29,10 @@ org.apache.maven.plugins maven-compiler-plugin + + 10 + 10 + <_include>-osgi.bnd + <_noee>true @@ -75,6 +80,8 @@ findbugs-maven-plugin true + true + @@ -125,6 +132,20 @@ true provided + + + + javax.ws.rs + javax.ws.rs-api + + + org.glassfish.jersey.containers + jersey-container-servlet-core + + + org.glassfish.jersey.media + jersey-media-multipart + diff --git a/build/pom.xml b/build/pom.xml index 64f28433..6e8db05f 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce crce-parent - 2.1.0 + 2.1.1-SNAPSHOT @@ -19,17 +19,21 @@ cz.zcu.kiv.crce - 1.7 + 11 3.0.4 2.13.3 0.8.1-incubator 4.3.1 - 3.0.3 + 7.3.3 1.0.0.Final 3.2.0 - 2.6.1 + 3.2.0 + 2.9.9 + 2.29 1.9.13 1.7.7 + 4.14 + 2.29 @@ -50,7 +54,7 @@ org.ops4j maven-pax-plugin - 1.5 + 1.6.0 true org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.8.0 ${version.jdk} ${version.jdk} + ${version.jdk} ${project.build.sourceEncoding} + + + org.ow2.asm + asm + 7.1 + + org.apache.maven.plugins @@ -106,7 +119,7 @@ - ${version.jdk} + 10 ${version.maven} @@ -118,17 +131,19 @@ maven-war-plugin - 2.5 + 2.6 org.apache.maven.plugins maven-pmd-plugin - 3.1 + 3.11.0 + + org.codehaus.mojo findbugs-maven-plugin - 3.0.0 + 3.0.5 org.apache.felix @@ -161,17 +176,22 @@ - + + + javax.ws.rs + javax.ws.rs-api + 2.0 + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${version.jersey} + + + org.glassfish.jersey.media + jersey-media-multipart + ${version.jersey} + @@ -203,29 +223,41 @@ - org.ops4j.pax.web - pax-web-extender-war - ${version.org.ops4j.pax.web} - provided - - - org.ops4j.pax.web - pax-web-jetty-bundle - ${version.org.ops4j.pax.web} - provided - - - org.ops4j.pax.web - pax-web-jsp - ${version.org.ops4j.pax.web} + javax.servlet + servlet-api + 2.5 provided - org.ops4j.pax.web - pax-web-spi - ${version.org.ops4j.pax.web} - provided - + org.ops4j.pax.web + pax-web-jetty-bundle + ${version.org.ops4j.pax.web} + provided + + + org.ops4j.pax.web + pax-web-spi + ${version.org.ops4j.pax.web} + provided + + + org.ops4j.pax.web + pax-web-api + ${version.org.ops4j.pax.web} + provided + + + org.ops4j.pax.web + pax-web-extender-war + ${version.org.ops4j.pax.web} + provided + + + org.ops4j.pax.web + pax-web-descriptor + ${version.org.ops4j.pax.web} + provided + @@ -307,13 +339,12 @@ org.apache.felix org.apache.felix.dependencymanager.shell ${version.org.apache.felix.dependencymanager} - provided org.apache.felix org.apache.felix.dependencymanager.annotation - ${version.org.apache.felix.dependencymanager} + ${version.org.apache.felix.dependencymanager.annotation} compile @@ -387,21 +418,6 @@ true - - - - javax.servlet - servlet-api - 2.5 - provided - - - javax.servlet - jsp-api - 2.0 - provided - - org.apache.ace @@ -501,8 +517,8 @@ org.ow2.asm - asm-all - 4.1 + asm + 7.1 org.apache.servicemix.bundles @@ -558,17 +574,21 @@ 20080701 provided - + + + org.apache.xbean xbean-finder - 3.13 - + ${version.xbean} provided org.apache.xbean xbean-bundleutils - 3.13 + ${version.xbean} @@ -671,6 +691,13 @@ test + + + org.json + json + 20180813 + + diff --git a/modules/crce-compatibility-api/osgi.bnd b/core/crce-compatibility-api/osgi.bnd similarity index 97% rename from modules/crce-compatibility-api/osgi.bnd rename to core/crce-compatibility-api/osgi.bnd index fb96e5f2..cf6ca00e 100644 --- a/modules/crce-compatibility-api/osgi.bnd +++ b/core/crce-compatibility-api/osgi.bnd @@ -1,5 +1,5 @@ -#----------------------------------------------------------------- -# Use this file to add customized Bnd instructions for the bundle -#----------------------------------------------------------------- - -Private-Package: +#----------------------------------------------------------------- +# Use this file to add customized Bnd instructions for the bundle +#----------------------------------------------------------------- + +Private-Package: diff --git a/core/crce-compatibility-api/pom.xml b/core/crce-compatibility-api/pom.xml new file mode 100644 index 00000000..8b20177b --- /dev/null +++ b/core/crce-compatibility-api/pom.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + + + + cz.zcu.kiv.crce + compiled-bundle-settings + 2.1.2-SNAPSHOT + + + + crce-compatibility-api + bundle + + CRCE - Compatibility API + + + ${namespace}.compatibility.api + ${namespace}.compatibility + + + + + + ${project.groupId} + crce-metadata-api + 3.0.1-SNAPSHOT + + + + + + + javax.xml.bind + jaxb-api + 2.3.0 + + + + junit + junit + test + + + + \ No newline at end of file diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Compatibility.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Compatibility.java similarity index 100% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Compatibility.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Compatibility.java diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityFactory.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityFactory.java similarity index 90% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityFactory.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityFactory.java index a8070374..5b432d0e 100644 --- a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityFactory.java +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityFactory.java @@ -1,9 +1,9 @@ package cz.zcu.kiv.crce.compatibility; -import java.util.List; - import cz.zcu.kiv.crce.metadata.type.Version; +import java.util.List; + /** * Factory interface for Compatibility. * @@ -15,7 +15,7 @@ public interface CompatibilityFactory { /** * - * Factory method for complete initialization of Compability implementation. + * Factory method for complete initialization of Compatibility implementation. * * @param id unique id * @param resourceName compared resource name (crce.identity) @@ -32,7 +32,7 @@ Compatibility createCompatibility(String id, String resourceName, Version resour /** * - * Factory method for complete initialization of Compability implementation. Base name is set to the same + * Factory method for complete initialization of Compatibility implementation. Base name is set to the same * value as resource name. * * @param id unique id diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityVersionComparator.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityVersionComparator.java similarity index 100% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityVersionComparator.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/CompatibilityVersionComparator.java diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Contract.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Contract.java similarity index 90% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Contract.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Contract.java index 16f9e25c..4fa8652a 100644 --- a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Contract.java +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Contract.java @@ -14,7 +14,7 @@ public enum Contract { private final String value; - private Contract(String value) { + Contract(String value) { this.value = value; } diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Diff.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Diff.java similarity index 100% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Diff.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Diff.java diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Difference.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Difference.java similarity index 98% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Difference.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Difference.java index 933e95de..45eae19b 100644 --- a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Difference.java +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/Difference.java @@ -31,7 +31,7 @@ public enum Difference { private String name; - private Difference(String name) { + Difference(String name) { this.name = name; } diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceLevel.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceLevel.java similarity index 95% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceLevel.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceLevel.java index ddacf7a1..f9b8b9c0 100644 --- a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceLevel.java +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceLevel.java @@ -31,7 +31,7 @@ public enum DifferenceLevel { private final String value; - private DifferenceLevel(String value) { + DifferenceLevel(String value) { this.value = value; } diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceRole.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceRole.java similarity index 93% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceRole.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceRole.java index 3fd10d45..32c45d0b 100644 --- a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceRole.java +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/DifferenceRole.java @@ -21,7 +21,7 @@ public enum DifferenceRole { private final String value; - private DifferenceRole(String value) { + DifferenceRole(String value) { this.value = value; } diff --git a/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultCompatibilityFactoryImpl.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultCompatibilityFactoryImpl.java new file mode 100644 index 00000000..45afe423 --- /dev/null +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultCompatibilityFactoryImpl.java @@ -0,0 +1,27 @@ +package cz.zcu.kiv.crce.compatibility.impl; + +import cz.zcu.kiv.crce.compatibility.*; +import cz.zcu.kiv.crce.metadata.type.Version; + +import java.util.List; + +/** + * Factory which creates default implementations of Compatibility interfaces. + */ +public class DefaultCompatibilityFactoryImpl implements CompatibilityFactory { + + @Override + public Compatibility createCompatibility(String id, String resourceName, Version resourceVersion, String baseName, Version baseVersion, Difference diffValue, List diffValues, Contract contract) { + return new DefaultCompatibilityImpl(id, resourceName, resourceVersion, baseName, baseVersion, diffValue, diffValues, contract); + } + + @Override + public Compatibility createCompatibility(String id, String resourceName, Version resourceVersion, Version baseVersion, Difference diffValue, List diffValues, Contract contract) { + return new DefaultCompatibilityImpl(id, resourceName, resourceVersion, resourceName, baseVersion, diffValue, diffValues, contract); + } + + @Override + public Diff createEmptyDiff() { + return new DefaultDiffImpl(); + } +} diff --git a/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultCompatibilityImpl.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultCompatibilityImpl.java new file mode 100644 index 00000000..f82d5a5a --- /dev/null +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultCompatibilityImpl.java @@ -0,0 +1,167 @@ +package cz.zcu.kiv.crce.compatibility.impl; + +import cz.zcu.kiv.crce.compatibility.Compatibility; +import cz.zcu.kiv.crce.compatibility.Contract; +import cz.zcu.kiv.crce.compatibility.Diff; +import cz.zcu.kiv.crce.compatibility.Difference; +import cz.zcu.kiv.crce.metadata.type.Version; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +/** + * Default implementation of Compatibility interface. Serves as a starting point + * for other implementations. + */ +public class DefaultCompatibilityImpl implements Compatibility { + + private String id; + private String resourceName; + private Version resourceVersion; + private String baseResourceName; + private Version baseResourceVersion; + private Difference diffValue; + private List diffDetails; + private Contract contract; + + /** + * Default constructor. Leaves all fields empty. + */ + public DefaultCompatibilityImpl() { + } + + /** + * Fully initialized instance. + * @param id + * @param resourceName + * @param resourceVersion + * @param baseResourceName + * @param baseResourceVersion + * @param diffValue + * @param diffDetails + * @param contract + */ + public DefaultCompatibilityImpl(String id, String resourceName, Version resourceVersion, String baseResourceName, Version baseResourceVersion, Difference diffValue, List diffDetails, Contract contract) { + this.id = id; + this.resourceName = resourceName; + this.resourceVersion = resourceVersion; + this.baseResourceName = baseResourceName; + this.baseResourceVersion = baseResourceVersion; + this.diffValue = diffValue; + this.diffDetails = diffDetails; + this.contract = contract; + } + + @Override + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Nonnull + @Override + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + @Nonnull + @Override + public Version getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(Version resourceVersion) { + this.resourceVersion = resourceVersion; + } + + @Nullable + @Override + public String getBaseResourceName() { + return baseResourceName; + } + + public void setBaseResourceName(String baseResourceName) { + this.baseResourceName = baseResourceName; + } + + @Nonnull + @Override + public Version getBaseResourceVersion() { + return baseResourceVersion; + } + + public void setBaseResourceVersion(Version baseResourceVersion) { + this.baseResourceVersion = baseResourceVersion; + } + + @Nonnull + @Override + public Difference getDiffValue() { + return diffValue; + } + + public void setDiffValue(Difference diffValue) { + this.diffValue = diffValue; + } + + @Nullable + @Override + public List getDiffDetails() { + return diffDetails; + } + + public void setDiffDetails(List diffDetails) { + this.diffDetails = diffDetails; + } + + @Nonnull + @Override + public Contract getContract() { + return contract; + } + + public void setContract(Contract contract) { + this.contract = contract; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DefaultCompatibilityImpl that = (DefaultCompatibilityImpl) o; + + if (baseResourceName != null ? !baseResourceName.equals(that.baseResourceName) : that.baseResourceName != null) + return false; + if (baseResourceVersion != null ? !baseResourceVersion.equals(that.baseResourceVersion) : that.baseResourceVersion != null) + return false; + if (diffDetails != null ? !diffDetails.equals(that.diffDetails) : that.diffDetails != null) return false; + if (diffValue != that.diffValue) return false; + if (contract != that.contract) return false; + if (resourceName != null ? !resourceName.equals(that.resourceName) : that.resourceName != null) return false; + if (resourceVersion != null ? !resourceVersion.equals(that.resourceVersion) : that.resourceVersion != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = resourceName != null ? resourceName.hashCode() : 0; + result = 31 * result + (resourceVersion != null ? resourceVersion.hashCode() : 0); + result = 31 * result + (baseResourceName != null ? baseResourceName.hashCode() : 0); + result = 31 * result + (baseResourceVersion != null ? baseResourceVersion.hashCode() : 0); + result = 31 * result + (diffValue != null ? diffValue.hashCode() : 0); + result = 31 * result + (diffDetails != null ? diffDetails.hashCode() : 0); + result = 31 * result + (contract != null ? contract.hashCode() : 0); + return result; + } +} diff --git a/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultDiffImpl.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultDiffImpl.java new file mode 100644 index 00000000..e465914a --- /dev/null +++ b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/impl/DefaultDiffImpl.java @@ -0,0 +1,115 @@ +package cz.zcu.kiv.crce.compatibility.impl; + +import cz.zcu.kiv.crce.compatibility.Diff; +import cz.zcu.kiv.crce.compatibility.Difference; +import cz.zcu.kiv.crce.compatibility.DifferenceLevel; +import cz.zcu.kiv.crce.compatibility.DifferenceRole; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +/** + * Default implementation of Diff interface. Serves as a starting point for future + * implementations. + */ +public class DefaultDiffImpl implements Diff { + + private String name; + private Difference value; + private DifferenceLevel level; + private DifferenceRole role; + private List children; + private String namespace; + private String syntax; + + public DefaultDiffImpl() { + this.children = new ArrayList<>(); + this.name = ""; + this.value = Difference.UNK; + this.level = DifferenceLevel.UNKNOWN; + } + + @Nonnull + @Override + public DifferenceLevel getLevel() { + return level; + } + + @Override + public void setLevel(@Nonnull DifferenceLevel level) { + this.level = level; + } + + @Nonnull + @Override + public String getName() { + return name; + } + + @Override + public void setName(@Nonnull String name) { + this.name = name; + } + + @Nonnull + @Override + public Difference getValue() { + return value; + } + + @Override + public void setValue(@Nonnull Difference value) { + this.value = value; + } + + @Nonnull + @Override + public List getChildren() { + return children; + } + + @Override + public void addChild(@Nonnull Diff child) { + this.children.add(child); + } + + @Override + public void addChildren(@Nonnull List children) { + this.children.addAll(children); + } + + @Nullable + @Override + public DifferenceRole getRole() { + return role; + } + + @Override + public void setRole(@Nullable DifferenceRole role) { + this.role = role; + } + + @Nullable + @Override + public String getNamespace() { + return namespace; + } + + @Override + public void setNamespace(@Nullable String namespace) { + this.namespace = namespace; + } + + @Nullable + @Override + public String getSyntax() { + return syntax; + } + + @Override + public void setSyntax(@Nullable String syntax) { + this.syntax = syntax; + } +} diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/namespace/NsCrceCompatibility.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/namespace/NsCrceCompatibility.java similarity index 100% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/namespace/NsCrceCompatibility.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/namespace/NsCrceCompatibility.java diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilitySearchService.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilitySearchService.java similarity index 100% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilitySearchService.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilitySearchService.java diff --git a/modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilityService.java b/core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilityService.java similarity index 100% rename from modules/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilityService.java rename to core/crce-compatibility-api/src/main/java/cz/zcu/kiv/crce/compatibility/service/CompatibilityService.java diff --git a/modules/crce-compatibility-api/src/main/resources/cz/zcu/kiv/crce/compatibility/schema/v1_0_0/compatibility.xsd b/core/crce-compatibility-api/src/main/resources/cz/zcu/kiv/crce/compatibility/schema/v1_0_0/compatibility.xsd similarity index 100% rename from modules/crce-compatibility-api/src/main/resources/cz/zcu/kiv/crce/compatibility/schema/v1_0_0/compatibility.xsd rename to core/crce-compatibility-api/src/main/resources/cz/zcu/kiv/crce/compatibility/schema/v1_0_0/compatibility.xsd diff --git a/core/crce-compatibility-api/src/test/java/cz.zcu.kiv.crce.compatibility/DefaultCompatibilityImplTest.java b/core/crce-compatibility-api/src/test/java/cz.zcu.kiv.crce.compatibility/DefaultCompatibilityImplTest.java new file mode 100644 index 00000000..32842b09 --- /dev/null +++ b/core/crce-compatibility-api/src/test/java/cz.zcu.kiv.crce.compatibility/DefaultCompatibilityImplTest.java @@ -0,0 +1,72 @@ +package cz.zcu.kiv.crce.compatibility; + +import cz.zcu.kiv.crce.compatibility.impl.DefaultCompatibilityFactoryImpl; +import cz.zcu.kiv.crce.compatibility.impl.DefaultDiffImpl; +import cz.zcu.kiv.crce.metadata.type.Version; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * Test of default implementation of {@link Compatibility} interface. + */ +public class DefaultCompatibilityImplTest { + + private static CompatibilityFactory factory; + + @BeforeClass + public static void beforeClass() { + factory = new DefaultCompatibilityFactoryImpl(); + } + + /** + * Test that factory returns correct compatibility. + */ + @Test + public void factoryTest() { + final String id = "id"; + final String resourceName = "resourceName"; + final Version resourceVersion = new Version(1,0,0); + final String baseName = "baseName"; + final Version baseVersion = new Version(1,0,0); + final Difference diffValue = Difference.NON; + final List diffValues = new ArrayList<>(); + diffValues.add(new DefaultDiffImpl()); + final Contract contract = Contract.SYNTAX; + + // create compatibilities + Compatibility c1 = factory.createCompatibility(id, + resourceName, resourceVersion, baseName, + baseVersion, diffValue, diffValues, contract); + + Compatibility c2 = factory.createCompatibility(id, + resourceName, resourceVersion, baseVersion, + diffValue, diffValues, contract); + + // checks + checkCompatibility(c1, id, resourceName, resourceVersion, baseName, + baseVersion, diffValue, diffValues, contract); + checkCompatibility(c2, id, resourceName, resourceVersion, resourceName, + baseVersion, diffValue, diffValues, contract); + } + + /** + * Checks that the compatibility is not null and all necessary fields are set correctly. + */ + private void checkCompatibility(Compatibility toCheck, String id, String resourceName, Version resourceVersion, String baseName, + Version baseVersion, Difference diffValue, List diffValues, Contract contract) { + assertNotNull("Compatibility is null!", toCheck ); + assertEquals("Wrong id!", id, toCheck.getId()); + assertEquals("Wrong resource name!", resourceName, toCheck.getResourceName()); + assertEquals("Wrong base name!", baseName, toCheck.getBaseResourceName()); + assertEquals("Wrong base version!", baseVersion, toCheck.getBaseResourceVersion()); + assertEquals("Wrong difference value!", diffValue, toCheck.getDiffValue()); + assertEquals("Wrong number of difference values!", diffValues.size(), toCheck.getDiffDetails().size()); + assertEquals("Wrong contract!", contract, toCheck.getContract()); + } +} diff --git a/modules/crce-concurrency/osgi.bnd b/core/crce-concurrency/osgi.bnd similarity index 100% rename from modules/crce-concurrency/osgi.bnd rename to core/crce-concurrency/osgi.bnd diff --git a/modules/crce-concurrency/pom.xml b/core/crce-concurrency/pom.xml similarity index 61% rename from modules/crce-concurrency/pom.xml rename to core/crce-concurrency/pom.xml index 48c4f427..aa87e2f1 100644 --- a/modules/crce-concurrency/pom.xml +++ b/core/crce-concurrency/pom.xml @@ -2,12 +2,24 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + - ../pom - cz.zcu.kiv.crce - crce-modules-parent - 2.1.1-SNAPSHOT + cz.zcu.kiv.crce + compiled-bundle-settings + 2.1.2-SNAPSHOT + crce-concurrency diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/Activator.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/Activator.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/Activator.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/Activator.java diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunner.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunner.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunner.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunner.java diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/ChainableTask.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/ChainableTask.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/ChainableTask.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/ChainableTask.java diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/Task.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/Task.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/Task.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/Task.java diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/TaskState.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/TaskState.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/TaskState.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/model/TaskState.java diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/TaskRunnerService.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/TaskRunnerService.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/TaskRunnerService.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/TaskRunnerService.java diff --git a/modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/internal/TaskRunnerServiceImpl.java b/core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/internal/TaskRunnerServiceImpl.java similarity index 100% rename from modules/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/internal/TaskRunnerServiceImpl.java rename to core/crce-concurrency/src/main/java/cz/zcu/kiv/crce/concurrency/service/internal/TaskRunnerServiceImpl.java diff --git a/modules/crce-concurrency/src/main/resources/OSGi-INF/service.xml b/core/crce-concurrency/src/main/resources/OSGi-INF/service.xml similarity index 100% rename from modules/crce-concurrency/src/main/resources/OSGi-INF/service.xml rename to core/crce-concurrency/src/main/resources/OSGi-INF/service.xml diff --git a/modules/crce-concurrency/src/test/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunnerTest.java b/core/crce-concurrency/src/test/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunnerTest.java similarity index 100% rename from modules/crce-concurrency/src/test/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunnerTest.java rename to core/crce-concurrency/src/test/java/cz/zcu/kiv/crce/concurrency/internal/TaskRunnerTest.java diff --git a/core/crce-core/pom.xml b/core/crce-core/pom.xml index 1811c2a2..e9cfac4e 100644 --- a/core/crce-core/pom.xml +++ b/core/crce-core/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce crce-parent - 2.1.0 + 2.1.1-SNAPSHOT @@ -47,22 +47,22 @@ ${project.groupId} crce-metadata-indexer-impl - 2.1.0 + 2.1.1-SNAPSHOT ${project.groupId} crce-metadata-indexer-api - 2.1.0 + 2.1.1-SNAPSHOT ${project.groupId} crce-metadata-json-api - 2.1.0 + 2.1.1-SNAPSHOT ${project.groupId} crce-metadata-json-impl - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} @@ -99,6 +99,17 @@ crce-resolver-impl 2.2.0-SNAPSHOT + + ${project.groupId} + crce-compatibility-api + 2.1.2-SNAPSHOT + + + + + + + diff --git a/core/crce-metadata-api/.classpath b/core/crce-metadata-api/.classpath new file mode 100644 index 00000000..83fc9ed7 --- /dev/null +++ b/core/crce-metadata-api/.classpath @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-api/.project b/core/crce-metadata-api/.project new file mode 100644 index 00000000..12b7d3a4 --- /dev/null +++ b/core/crce-metadata-api/.project @@ -0,0 +1,55 @@ + + + crce-metadata-api + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-metadata-api/pom.xml b/core/crce-metadata-api/pom.xml index 303c5ec3..2bc3821e 100644 --- a/core/crce-metadata-api/pom.xml +++ b/core/crce-metadata-api/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -47,6 +47,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + diff --git a/core/crce-metadata-api/src/main/java/cz/zcu/kiv/crce/metadata/Operator.java b/core/crce-metadata-api/src/main/java/cz/zcu/kiv/crce/metadata/Operator.java index 750b735c..75d52bad 100644 --- a/core/crce-metadata-api/src/main/java/cz/zcu/kiv/crce/metadata/Operator.java +++ b/core/crce-metadata-api/src/main/java/cz/zcu/kiv/crce/metadata/Operator.java @@ -19,7 +19,7 @@ public enum Operator { private final String value; - private Operator(String value) { + Operator(String value) { this.value = value; } diff --git a/core/crce-metadata-dao-api/.classpath b/core/crce-metadata-dao-api/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-metadata-dao-api/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-dao-api/.project b/core/crce-metadata-dao-api/.project new file mode 100644 index 00000000..7b6f96fd --- /dev/null +++ b/core/crce-metadata-dao-api/.project @@ -0,0 +1,55 @@ + + + crce-metadata-dao-api + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-metadata-dao-api/pom.xml b/core/crce-metadata-dao-api/pom.xml index 483bcd54..f18db8d3 100644 --- a/core/crce-metadata-dao-api/pom.xml +++ b/core/crce-metadata-dao-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1-SNAPSHOT + 2.1.2-SNAPSHOT @@ -35,7 +47,7 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT diff --git a/core/crce-metadata-dao-impl/pom.xml b/core/crce-metadata-dao-impl/pom.xml index 84a14837..46ca58d3 100644 --- a/core/crce-metadata-dao-impl/pom.xml +++ b/core/crce-metadata-dao-impl/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT diff --git a/core/crce-metadata-dao-mongodb/.classpath b/core/crce-metadata-dao-mongodb/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-metadata-dao-mongodb/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-dao-mongodb/.project b/core/crce-metadata-dao-mongodb/.project new file mode 100644 index 00000000..b4cc7d47 --- /dev/null +++ b/core/crce-metadata-dao-mongodb/.project @@ -0,0 +1,55 @@ + + + crce-metadata-dao-mongodb + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-metadata-dao-mongodb/pom.xml b/core/crce-metadata-dao-mongodb/pom.xml index 44029c5f..4fc28439 100644 --- a/core/crce-metadata-dao-mongodb/pom.xml +++ b/core/crce-metadata-dao-mongodb/pom.xml @@ -34,6 +34,14 @@ org.apache.felix org.apache.felix.dependencymanager.annotation + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + diff --git a/core/crce-metadata-dao-mongodb/src/main/java/cz/zcu/kiv/crce/metadata/dao/mongodb/DbContext.java b/core/crce-metadata-dao-mongodb/src/main/java/cz/zcu/kiv/crce/metadata/dao/mongodb/DbContext.java index c2599b61..a0752f50 100644 --- a/core/crce-metadata-dao-mongodb/src/main/java/cz/zcu/kiv/crce/metadata/dao/mongodb/DbContext.java +++ b/core/crce-metadata-dao-mongodb/src/main/java/cz/zcu/kiv/crce/metadata/dao/mongodb/DbContext.java @@ -1,8 +1,9 @@ package cz.zcu.kiv.crce.metadata.dao.mongodb; -import java.net.UnknownHostException; - import com.mongodb.MongoClient; +import com.mongodb.MongoClientURI; + +import java.net.UnknownHostException; /** * Context class responsible for connection management to MongoDB. @@ -20,17 +21,37 @@ public class DbContext { */ public static final String DEFAULT_DB_NAME = "crce"; + /** + * Default connection string for mongo database. + */ + private static final String DEFAULT_CONNECTION = "mongodb://localhost:27017"; + + /** + * Name of environment variable to store connection string. + */ + private static final String ENV_CONNECTION = "mongo_connection"; + + /** + * Field for cache client instance + */ private static MongoClient client; /** * Singleton instance of Mongo connection driver. Client holds its own connection pool and therefore - * should be used as singleton within the application - */ + * should be used as singleton within the application. + * Method try to read environment property which contains connection string {@link DbContext#ENV_CONNECTION} + * for database. + * @see MongoClientURI + * */ public static MongoClient getConnection() throws UnknownHostException { if (client == null) { - client = new MongoClient("localhost", 27017); + String connectionString = DEFAULT_CONNECTION; + if(System.getenv().containsKey(ENV_CONNECTION)) { + connectionString = System.getenv().get(ENV_CONNECTION); + } + MongoClientURI connectionParams = new MongoClientURI(connectionString); + client = new MongoClient(connectionParams); } - return client; } diff --git a/core/crce-metadata-impl/.classpath b/core/crce-metadata-impl/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-metadata-impl/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-impl/.project b/core/crce-metadata-impl/.project new file mode 100644 index 00000000..851b7d39 --- /dev/null +++ b/core/crce-metadata-impl/.project @@ -0,0 +1,55 @@ + + + crce-metadata-impl + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-metadata-impl/pom.xml b/core/crce-metadata-impl/pom.xml index 1f6c4228..070f3042 100644 --- a/core/crce-metadata-impl/pom.xml +++ b/core/crce-metadata-impl/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -34,6 +34,14 @@ org.apache.felix org.apache.felix.dependencymanager.annotation + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + @@ -46,7 +54,7 @@ ${project.groupId} crce-metadata-json-api - 2.1.0 + 2.1.1-SNAPSHOT true diff --git a/core/crce-metadata-indexer-api/.classpath b/core/crce-metadata-indexer-api/.classpath new file mode 100644 index 00000000..b8b4abe0 --- /dev/null +++ b/core/crce-metadata-indexer-api/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-indexer-api/.project b/core/crce-metadata-indexer-api/.project new file mode 100644 index 00000000..8bf2e807 --- /dev/null +++ b/core/crce-metadata-indexer-api/.project @@ -0,0 +1,30 @@ + + + crce-metadata-indexer-api + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/core/crce-metadata-indexer-api/pom.xml b/core/crce-metadata-indexer-api/pom.xml index 3524afeb..92ae2340 100644 --- a/core/crce-metadata-indexer-api/pom.xml +++ b/core/crce-metadata-indexer-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -32,12 +44,12 @@ ${project.groupId} crce-plugin-api - 2.1.0 + 2.1.1-SNAPSHOT ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT diff --git a/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/AbstractResourceIndexer.java b/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/AbstractResourceIndexer.java index 843e74d3..3eed5a59 100644 --- a/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/AbstractResourceIndexer.java +++ b/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/AbstractResourceIndexer.java @@ -1,9 +1,11 @@ package cz.zcu.kiv.crce.metadata.indexer; +import cz.zcu.kiv.crce.metadata.AttributeType; +import cz.zcu.kiv.crce.plugin.AbstractPlugin; + import java.util.Collections; import java.util.List; - -import cz.zcu.kiv.crce.plugin.AbstractPlugin; +import java.util.Map; /** * Abstract implementation of ResourceIndexer which can be extended @@ -31,4 +33,9 @@ public List getPluginKeywords() { public String getPluginDescription() { return "ResourceIndexer plugin implementation"; } + + @Override + public Map> getIndexedAttributes() { + return Collections.emptyMap(); + } } diff --git a/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/ResourceIndexer.java b/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/ResourceIndexer.java index 5e1b251f..f1369ecf 100644 --- a/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/ResourceIndexer.java +++ b/core/crce-metadata-indexer-api/src/main/java/cz/zcu/kiv/crce/metadata/indexer/ResourceIndexer.java @@ -1,13 +1,14 @@ package cz.zcu.kiv.crce.metadata.indexer; -import java.io.InputStream; -import java.util.List; - -import javax.annotation.ParametersAreNonnullByDefault; - +import cz.zcu.kiv.crce.metadata.AttributeType; import cz.zcu.kiv.crce.metadata.Resource; import cz.zcu.kiv.crce.plugin.Plugin; +import javax.annotation.ParametersAreNonnullByDefault; +import java.io.InputStream; +import java.util.List; +import java.util.Map; + /** * Resource indexer indexes content of an artifact and stores obtained metadata * into Resource object. @@ -56,4 +57,12 @@ public interface ResourceIndexer extends Plugin { * @return */ List getRequiredCategories(); + + /** + * Returns a map of namespaces and relevant attributes this components indexes. + * + * @return Collection of attributes this component is capable of indexing. Each collection + * is mapped to its respective namespace. + */ + Map> getIndexedAttributes(); } diff --git a/core/crce-metadata-indexer-impl/.classpath b/core/crce-metadata-indexer-impl/.classpath new file mode 100644 index 00000000..b8b4abe0 --- /dev/null +++ b/core/crce-metadata-indexer-impl/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-indexer-impl/.project b/core/crce-metadata-indexer-impl/.project new file mode 100644 index 00000000..0daf5752 --- /dev/null +++ b/core/crce-metadata-indexer-impl/.project @@ -0,0 +1,30 @@ + + + crce-metadata-indexer-impl + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/core/crce-metadata-indexer-impl/pom.xml b/core/crce-metadata-indexer-impl/pom.xml index 4e115979..f52fb9a2 100644 --- a/core/crce-metadata-indexer-impl/pom.xml +++ b/core/crce-metadata-indexer-impl/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -32,22 +44,22 @@ ${project.groupId} crce-plugin-api - 2.1.0 + 2.1.1-SNAPSHOT ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} crce-metadata-service-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} crce-metadata-indexer-api - 2.1.0 + 2.1.1-SNAPSHOT diff --git a/core/crce-metadata-json-api/.classpath b/core/crce-metadata-json-api/.classpath new file mode 100644 index 00000000..b8b4abe0 --- /dev/null +++ b/core/crce-metadata-json-api/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-json-api/.project b/core/crce-metadata-json-api/.project new file mode 100644 index 00000000..88425d52 --- /dev/null +++ b/core/crce-metadata-json-api/.project @@ -0,0 +1,30 @@ + + + crce-metadata-json-api + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/core/crce-metadata-json-api/pom.xml b/core/crce-metadata-json-api/pom.xml index 60b02a3c..b860c353 100644 --- a/core/crce-metadata-json-api/pom.xml +++ b/core/crce-metadata-json-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1-SNAPSHOT + 2.1.2-SNAPSHOT @@ -32,7 +44,7 @@ ${project.groupId} crce-metadata-api - 2.1.0 + 3.0.1-SNAPSHOT diff --git a/core/crce-metadata-json-impl/.classpath b/core/crce-metadata-json-impl/.classpath new file mode 100644 index 00000000..b8b4abe0 --- /dev/null +++ b/core/crce-metadata-json-impl/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-json-impl/.project b/core/crce-metadata-json-impl/.project new file mode 100644 index 00000000..4cb3aeed --- /dev/null +++ b/core/crce-metadata-json-impl/.project @@ -0,0 +1,30 @@ + + + crce-metadata-json-impl + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/core/crce-metadata-json-impl/pom.xml b/core/crce-metadata-json-impl/pom.xml index ed874835..9f230303 100644 --- a/core/crce-metadata-json-impl/pom.xml +++ b/core/crce-metadata-json-impl/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -34,6 +34,14 @@ org.apache.felix org.apache.felix.dependencymanager.annotation + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + @@ -55,12 +63,12 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} crce-metadata-json-api - 2.1.0 + 2.1.1-SNAPSHOT diff --git a/core/crce-metadata-service-api/.classpath b/core/crce-metadata-service-api/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-metadata-service-api/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-service-api/.project b/core/crce-metadata-service-api/.project new file mode 100644 index 00000000..70e77ad8 --- /dev/null +++ b/core/crce-metadata-service-api/.project @@ -0,0 +1,55 @@ + + + crce-metadata-service-api + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-metadata-service-api/pom.xml b/core/crce-metadata-service-api/pom.xml index 9205a403..d2b11fe6 100644 --- a/core/crce-metadata-service-api/pom.xml +++ b/core/crce-metadata-service-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -32,7 +44,7 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT diff --git a/core/crce-metadata-service-impl/.classpath b/core/crce-metadata-service-impl/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-metadata-service-impl/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-metadata-service-impl/.project b/core/crce-metadata-service-impl/.project new file mode 100644 index 00000000..a50b870e --- /dev/null +++ b/core/crce-metadata-service-impl/.project @@ -0,0 +1,55 @@ + + + crce-metadata-service-impl + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-metadata-service-impl/pom.xml b/core/crce-metadata-service-impl/pom.xml index 64ccfaad..57ba8d95 100644 --- a/core/crce-metadata-service-impl/pom.xml +++ b/core/crce-metadata-service-impl/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -34,6 +34,14 @@ org.apache.felix org.apache.felix.dependencymanager.annotation + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + @@ -44,7 +52,7 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} diff --git a/core/crce-plugin-api/.classpath b/core/crce-plugin-api/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-plugin-api/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-plugin-api/.project b/core/crce-plugin-api/.project new file mode 100644 index 00000000..b8fae5ac --- /dev/null +++ b/core/crce-plugin-api/.project @@ -0,0 +1,55 @@ + + + crce-plugin-api + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-plugin-api/pom.xml b/core/crce-plugin-api/pom.xml index 7a20350d..68618484 100644 --- a/core/crce-plugin-api/pom.xml +++ b/core/crce-plugin-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1-SNAPSHOT + 2.1.2-SNAPSHOT diff --git a/core/crce-repository-api/.classpath b/core/crce-repository-api/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-repository-api/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-repository-api/.project b/core/crce-repository-api/.project new file mode 100644 index 00000000..dbe9c738 --- /dev/null +++ b/core/crce-repository-api/.project @@ -0,0 +1,55 @@ + + + crce-repository-api + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-repository-api/pom.xml b/core/crce-repository-api/pom.xml index df6f9e58..f68bcbdf 100644 --- a/core/crce-repository-api/pom.xml +++ b/core/crce-repository-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -35,12 +47,12 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} crce-plugin-api - 2.1.0 + 2.1.1-SNAPSHOT diff --git a/core/crce-repository-impl/.classpath b/core/crce-repository-impl/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-repository-impl/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-repository-impl/.project b/core/crce-repository-impl/.project new file mode 100644 index 00000000..823a8880 --- /dev/null +++ b/core/crce-repository-impl/.project @@ -0,0 +1,55 @@ + + + crce-repository-impl + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-repository-impl/pom.xml b/core/crce-repository-impl/pom.xml index dc50f4aa..6b4675e6 100644 --- a/core/crce-repository-impl/pom.xml +++ b/core/crce-repository-impl/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -34,6 +34,14 @@ org.apache.felix org.apache.felix.dependencymanager.annotation + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + @@ -58,12 +66,12 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} crce-metadata-service-api - 3.0.0 + 3.0.1-SNAPSHOT ${project.groupId} @@ -73,7 +81,7 @@ ${project.groupId} crce-plugin-api - 2.1.0 + 2.1.1-SNAPSHOT ${project.groupId} @@ -88,7 +96,7 @@ ${project.groupId} crce-metadata-indexer-api - 2.1.0 + 2.1.1-SNAPSHOT diff --git a/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/BufferImpl.java b/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/BufferImpl.java index e66271b6..e7903997 100644 --- a/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/BufferImpl.java +++ b/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/BufferImpl.java @@ -421,6 +421,6 @@ private boolean isInBuffer(Resource resource) { if (!"file".equals(uri.getScheme())) { return false; } - return new File(uri).getPath().startsWith(baseDir.getAbsolutePath()); + return true; // rpesek edit: return new File(uri).getPath().startsWith(baseDir.getAbsolutePath()); } } diff --git a/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/FilebasedStoreImpl.java b/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/FilebasedStoreImpl.java index 668bc101..d787f0a9 100644 --- a/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/FilebasedStoreImpl.java +++ b/core/crce-repository-impl/src/main/java/cz/zcu/kiv/crce/repository/filebased/internal/FilebasedStoreImpl.java @@ -285,7 +285,9 @@ public Resource getResource(String uid, boolean withDetails) { @Override public synchronized List getResources() { try { - return metadataDao.loadResources(repository, false); + // Edit rpesek - For webui-v2 retrieval of resources including details (capabilities, requirements) + // return metadataDao.loadResources(repository, false); + return metadataDao.loadResources(repository, true); } catch (IOException e) { logger.error("Could not load resources of repository {}.", baseDir.toURI(), e); } diff --git a/core/crce-resolver-api/.classpath b/core/crce-resolver-api/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-resolver-api/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-resolver-api/.project b/core/crce-resolver-api/.project new file mode 100644 index 00000000..11cff5eb --- /dev/null +++ b/core/crce-resolver-api/.project @@ -0,0 +1,55 @@ + + + crce-resolver-api + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-resolver-api/pom.xml b/core/crce-resolver-api/pom.xml index 1f77b8a8..83cc5426 100644 --- a/core/crce-resolver-api/pom.xml +++ b/core/crce-resolver-api/pom.xml @@ -2,11 +2,23 @@ 4.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + + + cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -35,7 +47,7 @@ ${project.groupId} crce-metadata-api - 3.0.0 + 3.0.1-SNAPSHOT diff --git a/core/crce-resolver-impl/.classpath b/core/crce-resolver-impl/.classpath new file mode 100644 index 00000000..dfdb3d58 --- /dev/null +++ b/core/crce-resolver-impl/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/crce-resolver-impl/.project b/core/crce-resolver-impl/.project new file mode 100644 index 00000000..4dec77e2 --- /dev/null +++ b/core/crce-resolver-impl/.project @@ -0,0 +1,55 @@ + + + crce-resolver-impl + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.fusesource.ide.project.RiderProjectBuilder + + + + + org.jboss.tools.jst.web.kb.kbbuilder + + + + + org.jboss.tools.cdi.core.cdibuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.pde.PluginNature + org.fusesource.ide.project.RiderProjectNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.jboss.tools.jst.web.kb.kbnature + org.jboss.tools.cdi.core.cdinature + + diff --git a/core/crce-resolver-impl/pom.xml b/core/crce-resolver-impl/pom.xml index 6e0e1cb1..b0e0d0f3 100644 --- a/core/crce-resolver-impl/pom.xml +++ b/core/crce-resolver-impl/pom.xml @@ -6,7 +6,7 @@ cz.zcu.kiv.crce compiled-bundle-settings - 2.1.1 + 2.1.2-SNAPSHOT @@ -34,6 +34,14 @@ org.apache.felix org.apache.felix.dependencymanager.annotation + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + diff --git a/modules/crce-webui/osgi.bnd b/core/crce-webui/osgi.bnd similarity index 100% rename from modules/crce-webui/osgi.bnd rename to core/crce-webui/osgi.bnd diff --git a/modules/crce-webui/pom.xml b/core/crce-webui/pom.xml similarity index 76% rename from modules/crce-webui/pom.xml rename to core/crce-webui/pom.xml index 12df6c30..8cd9e1d8 100644 --- a/modules/crce-webui/pom.xml +++ b/core/crce-webui/pom.xml @@ -4,13 +4,14 @@ 4.0.0 - ../pom cz.zcu.kiv.crce - crce-modules-parent - 2.1.1-SNAPSHOT + compiled-bundle-settings + 2.1.2-SNAPSHOT + crce-webui + 2.1.2-SNAPSHOT war CRCE - Web UI @@ -18,6 +19,7 @@ ${namespace}.webui ${namespace}.webui + 2.1.2-SNAPSHOT @@ -87,6 +89,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 10 + 10 + + @@ -132,21 +142,37 @@ + + + + + + + ${project.groupId} - crce-core - pom + crce-compatibility-api + ${compatibility.api.version} - - ${project.groupId} - crce-metadata-osgi-bundle - ${project.version} + cz.zcu.kiv.crce + crce-metadata-dao-api + 3.0.0-SNAPSHOT - ${project.groupId} - crce-compatibility-api - ${project.version} + cz.zcu.kiv.crce + crce-plugin-api + 2.1.1-SNAPSHOT + + + cz.zcu.kiv.crce + crce-repository-api + 2.2.0-SNAPSHOT + + + cz.zcu.kiv.crce + crce-metadata-service-api + 3.0.1-SNAPSHOT @@ -167,14 +193,21 @@ javax.ws.rs javax.ws.rs-api + 2.0 org.glassfish.jersey.containers jersey-container-servlet-core + 2.9.1 org.glassfish.jersey.media jersey-media-multipart + 2.9.1 + + + org.apache.felix + org.apache.felix.bundlerepository diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Activator.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Activator.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Activator.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Activator.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/CheckServlet.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/CheckServlet.java similarity index 97% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/CheckServlet.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/CheckServlet.java index 124026df..f075e75f 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/CheckServlet.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/CheckServlet.java @@ -1,80 +1,80 @@ -package cz.zcu.kiv.crce.webui.internal; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -//import cz.zcu.kiv.crce.metadata.Resolver; -import cz.zcu.kiv.crce.metadata.Resource; -//import cz.zcu.kiv.crce.metadata.ResourceCreator; - -public class CheckServlet extends HttpServlet { - - private static final Logger logger = LoggerFactory.getLogger(CheckServlet.class); - - private static final long serialVersionUID = -6116518932972052481L; - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - List res = chooseFrom(req); - if (res == null) { - req.getRequestDispatcher("resource").forward(req, resp); - } else { - String source = (String) req.getSession().getAttribute("source"); - req.getSession().setAttribute(source, res); - req.getSession().removeAttribute("source"); - req.getRequestDispatcher("jsp/" + source + ".jsp").forward(req, resp); - } - - } - - private List chooseFrom(HttpServletRequest req) { - String source = (String) req.getSession().getAttribute("source"); - if (source == null) { - return null; - } else if (source.equals("buffer")) { - return doCheck(Activator.instance().getBuffer(req).getResources()); - } else if (source.equals("store")) { - return doCheck(Activator.instance().getStore(null).getResources()); - } else { - return null; - } - } - - private List doCheck(List resources) { - logger.warn("Resolver is not designed yet in new Metadata API, returning empty list of resources. Checked resource: {}", resources); -// Resource[] resources = repository.getResources(); -// Resource[] cloned = new Resource[resources.length]; -// System.arraycopy(resources, 0, cloned, 0, resources.length); -// ArrayList ext = new ArrayList<>(); -// HashMap extMap = new HashMap<>(); -// ResourceCreator rc = Activator.instance().getCreator(); -// Resolver resolver = rc.createResolver(repository); -// for (Resource r : cloned) { -// resolver.add(r); -// r.getUri(); -// extMap.put(r.getUri(), new ResourceExt(r)); -// ext.add(new ResourceExt(r)); -// } -// if (!resolver.resolve()) { -// for (Reason r : resolver.getUnsatisfiedRequirements()) { -// if (extMap.containsKey(r.getResource().getUri())) { -// extMap.get(r.getResource().getUri()).addRequirement(r.getRequirement()); -// } -// -// } -// return extMap.values().toArray(new Resource[extMap.values().size()]); -// } else { -// return resources; -// } - return Collections.emptyList(); - } -} +package cz.zcu.kiv.crce.webui.internal; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +//import cz.zcu.kiv.crce.metadata.Resolver; +import cz.zcu.kiv.crce.metadata.Resource; +//import cz.zcu.kiv.crce.metadata.ResourceCreator; + +public class CheckServlet extends HttpServlet { + + private static final Logger logger = LoggerFactory.getLogger(CheckServlet.class); + + private static final long serialVersionUID = -6116518932972052481L; + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + List res = chooseFrom(req); + if (res == null) { + req.getRequestDispatcher("resource").forward(req, resp); + } else { + String source = (String) req.getSession().getAttribute("source"); + req.getSession().setAttribute(source, res); + req.getSession().removeAttribute("source"); + req.getRequestDispatcher("jsp/" + source + ".jsp").forward(req, resp); + } + + } + + private List chooseFrom(HttpServletRequest req) { + String source = (String) req.getSession().getAttribute("source"); + if (source == null) { + return null; + } else if (source.equals("buffer")) { + return doCheck(Activator.instance().getBuffer(req).getResources()); + } else if (source.equals("store")) { + return doCheck(Activator.instance().getStore(null).getResources()); + } else { + return null; + } + } + + private List doCheck(List resources) { + logger.warn("Resolver is not designed yet in new Metadata API, returning empty list of resources. Checked resource: {}", resources); +// Resource[] resources = repository.getResources(); +// Resource[] cloned = new Resource[resources.length]; +// System.arraycopy(resources, 0, cloned, 0, resources.length); +// ArrayList ext = new ArrayList<>(); +// HashMap extMap = new HashMap<>(); +// ResourceCreator rc = Activator.instance().getCreator(); +// Resolver resolver = rc.createResolver(repository); +// for (Resource r : cloned) { +// resolver.add(r); +// r.getUri(); +// extMap.put(r.getUri(), new ResourceExt(r)); +// ext.add(new ResourceExt(r)); +// } +// if (!resolver.resolve()) { +// for (Reason r : resolver.getUnsatisfiedRequirements()) { +// if (extMap.containsKey(r.getResource().getUri())) { +// extMap.get(r.getResource().getUri()).addRequirement(r.getRequirement()); +// } +// +// } +// return extMap.values().toArray(new Resource[extMap.values().size()]); +// } else { +// return resources; +// } + return Collections.emptyList(); + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/DownloadServlet.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/DownloadServlet.java similarity index 97% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/DownloadServlet.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/DownloadServlet.java index 0f68ce99..983e1328 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/DownloadServlet.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/DownloadServlet.java @@ -1,132 +1,132 @@ -package cz.zcu.kiv.crce.webui.internal; - -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; - -import javax.servlet.ServletContext; -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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import cz.zcu.kiv.crce.metadata.Resource; -import cz.zcu.kiv.crce.webui.internal.custom.ResourceExt; - -public class DownloadServlet extends HttpServlet { - - private static final long serialVersionUID = 6399102910617353070L; - - private static final Logger logger = LoggerFactory.getLogger(DownloadServlet.class); - - private static final int BUFSIZE = 128; - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - boolean success; - String message; - @SuppressWarnings("unchecked") - List buffer = (List) req.getSession().getAttribute("buffer"); - List list = Activator.instance().getBuffer(req).commit(true); - if (list.size() == buffer.size()) { - success = true; - message = "All resources commited successfully"; - } else { - success = false; - message = "Not all resources commited successfully"; - } - req.getSession().setAttribute("source", "commit"); - ResourceServlet.setError(req.getSession(), success, message); - req.getRequestDispatcher("resource?link=store").forward(req, resp); - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - boolean failed = false; - String message; - if (req.getParameter("uri") != null) { - String link = (String) req.getSession().getAttribute("source"); - String uri = req.getParameter("uri"); - try { - URI fileUri = new URI(uri); - if (link != null) { - switch (link) { - case "store": { - List resources = Activator.instance().getStore(null).getResources(); - Resource found = EditServlet.findResource(fileUri, resources); - doDownload(req, resp, found); - break; - } - case "buffer": { - List resources = Activator.instance().getBuffer(req).getResources(); - Resource found = EditServlet.findResource(fileUri, resources); - logger.debug("Found!" + Activator.instance().getMetadataService().getPresentationName(found)); - doDownload(req, resp, found); - break; - } - default: - failed = true; - break; - } - } else { - failed = true; - } - - } catch (IOException e) { - failed = true; - logger.error("Failed to download resource: {}", uri, e); - } catch (URISyntaxException e) { - failed = true; - logger.error("Failed to download resource, invalid URI: {}", uri, e); - } - } else { - failed = true; - } - - if (failed) { - message = "Download failed"; - } else { - message = "Download successful"; - } - ResourceServlet.setError(req.getSession(), !failed, message); - - } - - private void doDownload(HttpServletRequest req, HttpServletResponse resp, Resource found) throws IOException { // NOPMD req would be used in the future - - File f = new File(Activator.instance().getMetadataService().getUri(found)); - int length = 0; - try (ServletOutputStream op = resp.getOutputStream()) { - ServletContext context = getServletConfig().getServletContext(); - String mimetype = context.getMimeType(Activator.instance().getMetadataService().getUri(found).toString()); - - // - // Set the response and go! - // - // - resp.setContentType((mimetype != null) ? mimetype : "application/octet-stream"); - resp.setContentLength((int) f.length()); - resp.setHeader("Content-Disposition", "attachment; filename=\"" + Activator.instance().getMetadataService().getFileName(found) + "\""); - - // - // Stream to the requester. - // - byte[] bbuf = new byte[BUFSIZE]; - try (DataInputStream in = new DataInputStream(new FileInputStream(f))) { - while (in != null && (length = in.read(bbuf)) != -1) { - op.write(bbuf, 0, length); - } - op.flush(); - } - } - } -} +package cz.zcu.kiv.crce.webui.internal; + +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import javax.servlet.ServletContext; +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cz.zcu.kiv.crce.metadata.Resource; +import cz.zcu.kiv.crce.webui.internal.custom.ResourceExt; + +public class DownloadServlet extends HttpServlet { + + private static final long serialVersionUID = 6399102910617353070L; + + private static final Logger logger = LoggerFactory.getLogger(DownloadServlet.class); + + private static final int BUFSIZE = 128; + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + boolean success; + String message; + @SuppressWarnings("unchecked") + List buffer = (List) req.getSession().getAttribute("buffer"); + List list = Activator.instance().getBuffer(req).commit(true); + if (list.size() == buffer.size()) { + success = true; + message = "All resources commited successfully"; + } else { + success = false; + message = "Not all resources commited successfully"; + } + req.getSession().setAttribute("source", "commit"); + ResourceServlet.setError(req.getSession(), success, message); + req.getRequestDispatcher("resource?link=store").forward(req, resp); + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + boolean failed = false; + String message; + if (req.getParameter("uri") != null) { + String link = (String) req.getSession().getAttribute("source"); + String uri = req.getParameter("uri"); + try { + URI fileUri = new URI(uri); + if (link != null) { + switch (link) { + case "store": { + List resources = Activator.instance().getStore(null).getResources(); + Resource found = EditServlet.findResource(fileUri, resources); + doDownload(req, resp, found); + break; + } + case "buffer": { + List resources = Activator.instance().getBuffer(req).getResources(); + Resource found = EditServlet.findResource(fileUri, resources); + logger.debug("Found!" + Activator.instance().getMetadataService().getPresentationName(found)); + doDownload(req, resp, found); + break; + } + default: + failed = true; + break; + } + } else { + failed = true; + } + + } catch (IOException e) { + failed = true; + logger.error("Failed to download resource: {}", uri, e); + } catch (URISyntaxException e) { + failed = true; + logger.error("Failed to download resource, invalid URI: {}", uri, e); + } + } else { + failed = true; + } + + if (failed) { + message = "Download failed"; + } else { + message = "Download successful"; + } + ResourceServlet.setError(req.getSession(), !failed, message); + + } + + private void doDownload(HttpServletRequest req, HttpServletResponse resp, Resource found) throws IOException { // NOPMD req would be used in the future + + File f = new File(Activator.instance().getMetadataService().getUri(found)); + int length = 0; + try (ServletOutputStream op = resp.getOutputStream()) { + ServletContext context = getServletConfig().getServletContext(); + String mimetype = context.getMimeType(Activator.instance().getMetadataService().getUri(found).toString()); + + // + // Set the response and go! + // + // + resp.setContentType((mimetype != null) ? mimetype : "application/octet-stream"); + resp.setContentLength((int) f.length()); + resp.setHeader("Content-Disposition", "attachment; filename=\"" + Activator.instance().getMetadataService().getFileName(found) + "\""); + + // + // Stream to the requester. + // + byte[] bbuf = new byte[BUFSIZE]; + try (DataInputStream in = new DataInputStream(new FileInputStream(f))) { + while (in != null && (length = in.read(bbuf)) != -1) { + op.write(bbuf, 0, length); + } + op.flush(); + } + } + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/EditServlet.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/EditServlet.java similarity index 97% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/EditServlet.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/EditServlet.java index 801e5898..3121fba0 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/EditServlet.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/EditServlet.java @@ -1,1023 +1,1023 @@ -package cz.zcu.kiv.crce.webui.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.Map; - -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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import cz.zcu.kiv.crce.metadata.Attribute; -import cz.zcu.kiv.crce.metadata.Capability; -import cz.zcu.kiv.crce.metadata.Requirement; -import cz.zcu.kiv.crce.metadata.Resource; -import cz.zcu.kiv.crce.metadata.impl.GenericAttributeType; -import cz.zcu.kiv.crce.webui.internal.legacy.Type; - -public class EditServlet extends HttpServlet { - - private static final long serialVersionUID = -4949620462179710290L; - - private static final Logger logger = LoggerFactory.getLogger(EditServlet.class); - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - - boolean success = false; - Map, ?> parameters = req.getParameterMap(); - String form = null; - - if (parameters.containsKey("form")) { - form = ((String[]) parameters.get("form"))[0]; - } - if (form != null) { - switch (form) { - case "addCategory": - if (addCategory(req, resp, parameters)) { - success = editCategories(req, resp); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add category."); - success = true; - } - } else { - ResourceServlet.setError(req.getSession(), false, "Cannot add category."); - success = true; - } - break; - - case "requirements": - if (saveRequirements(req, resp, parameters)) { - success = editRequirements(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot save requirements."); - success = true; - } - } - break; - - case "addRequirement": - if (!addRequirementForm(req, resp, parameters)) { - ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); - } - success = editRequirements(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); - success = true; - } - break; - - case "capabilities": - if (saveCapabilities(req, resp, parameters)) { - success = editCapabilities(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot save capabilities."); - success = true; - } - - } else { - ResourceServlet.setError(req.getSession(), false, "Cannot save capabilities."); - success = true; - } - break; - - case "capability": - if (saveCapability(req, resp, parameters)) { - success = editCapabilities(req, resp, parameters, true); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); - success = true; - } - } else { - ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); - success = true; - } - break; - - case "property": - if (!saveProperty(req, resp, parameters)) { - ResourceServlet.setError(req.getSession(), false, "Cannot add property."); - } - success = editCapabilities(req, resp, parameters, true); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Error while loading capabilities."); - success = true; - } - break; - - case "editProperties": - if (!saveResourceProperty(req, resp, parameters)) { - ResourceServlet.setError(req.getSession(), false, "Cannot change properties."); - } - success = editProperties(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Error while loading capabilities."); - success = true; - } - break; - - default: - } - } - if (!success) { - resp.sendError(HttpServletResponse.SC_ACCEPTED, "NOT FOUND OR FAILED TO PROCEED"); - } - } - - private boolean saveResourceProperty(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - String uri; - if (parameters.containsKey("uri")) { - uri = ((String[]) parameters.get("uri"))[0]; - } else { - return false; - } - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List resources = getResources(req, link); - if (resources == null) { - return false; - } - Resource resource = findResource(resURI, resources); - // TODO why was the following here: -// String symbolicName = ((String[]) parameters.get("symbolicName"))[0]; -// String version = ((String[]) parameters.get("version"))[0]; - -// LegacyMetadataHelper.setVersion(Activator.instance().getMetadataFactory(), resource, new Version(version)); -// LegacyMetadataHelper.setSymbolicName(Activator.instance().getMetadataFactory(), resource, symbolicName); - - Activator.instance().getMetadataDao().saveResource(resource); - } catch (URISyntaxException e) { - logger.warn("Can't save resource property: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't save resource property, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't save resource property", e); - return false; - } - - return true; - } - - private boolean saveProperty(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - String uri; - String id; - if (parameters.containsKey("uri") && parameters.containsKey("capabilityId")) { - uri = ((String[]) parameters.get("uri"))[0]; - id = ((String[]) parameters.get("capabilityId"))[0]; - } else { - return false; - } - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - Resource resource = findResource(resURI, array); - Capability capability = resource.getCapabilities().get(Integer.parseInt(id) - 1); - String name = ((String[]) parameters.get("name"))[0]; - String type = ((String[]) parameters.get("propertyType"))[0]; - Object value = ((String[]) parameters.get("value"))[0]; - - try { - capability.setAttribute(new GenericAttributeType(name, type), value); - } catch (IllegalArgumentException e) { - return false; - } - Activator.instance().getMetadataDao().saveResource(resource); - - } catch (URISyntaxException e) { - logger.warn("Can't save property: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't save property, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't save property", e); - return false; - } - - return true; - } - - private boolean editCapabilities(HttpServletRequest req, - HttpServletResponse resp, Map, ?> parameters) { - return editCapabilities(req, resp, parameters, false); - } - - private boolean saveCapability(HttpServletRequest req, - HttpServletResponse resp, Map, ?> parameters) { - String uri; - String capabilityName; - if (parameters.containsKey("uri") - && parameters.containsKey("capability")) { - uri = ((String[]) parameters.get("uri"))[0]; - capabilityName = ((String[]) parameters.get("capability"))[0]; - } else { - return false; - } - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - Resource resource = findResource(resURI, array); - int lengthBefore = resource.getCapabilities().size(); - resource.addCapability(Activator.instance().getMetadataFactory().createCapability(capabilityName)); - if (lengthBefore == resource.getCapabilities().size()) { - resp.sendRedirect("resource"); - return false; - } - - Activator.instance().getMetadataDao().saveResource(resource); - - req.setAttribute("capabilityId", String.valueOf(resource.getCapabilities().size())); - } catch (URISyntaxException e) { - logger.warn("Can't save capability: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't save capability, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't save capability", e); - return false; - } - - return true; - } - - private boolean addRequirementForm(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - String uri; - if (parameters.containsKey("uri")) { - uri = ((String[]) parameters.get("uri"))[0]; - } else { - return false; - } - - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - Resource resource = findResource(resURI, array); - String name = null; - Requirement requir = null; - String filter = null; - boolean multiple = false; - boolean extend = false; - boolean optional = false; - Requirement requirBefore = null; - if (parameters.containsKey("name") - && parameters.containsKey("filter")) { - name = ((String[]) parameters.get("name"))[0]; - filter = ((String[]) parameters.get("filter"))[0]; - if (parameters.containsKey("multiple")) { - multiple = ((String[]) parameters.get("multiple"))[0].equals("on"); - } - if (parameters.containsKey("optional")) { - optional = ((String[]) parameters.get("optional"))[0].equals("on"); - } - if (parameters.containsKey("extend")) { - extend = ((String[]) parameters.get("extend"))[0].equals("on"); - } - String comment = null; - if (parameters.containsKey("comment")) { - comment = ((String[]) parameters.get("comment"))[0]; - } - int lengthBefore = resource.getRequirements().size(); - requir = Activator.instance().getMetadataFactory().createRequirement(name); - resource.addRequirement(requir); - if (lengthBefore == resource.getRequirements().size()) { - req.getSession().setAttribute("success", false); - req.getSession().setAttribute("message", "Cannot add requirement."); - return false; - } - try { - logger.warn("OSGi filter is not supported yet with new Metadata API, setting as a directive to track it's usage: {}", filter); - requir.setDirective("filter", filter); - } catch (IllegalArgumentException e) { - resource.removeRequirement(requir); - resource.addRequirement(requirBefore); - } - requir.setDirective("multiple", String.valueOf(multiple)); - requir.setDirective("optional", String.valueOf(optional)); - requir.setDirective("extend", String.valueOf(extend)); - requir.setDirective("comment", comment); - } - Activator.instance().getMetadataDao().saveResource(resource); - } catch (URISyntaxException e) { - logger.warn("Can't add requirement: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't add requirement, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't requirement", e); - return false; - } - - req.getSession().setAttribute("success", true); - return true; - - } - - private boolean saveCapabilities(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - int capabilityId = -1; - String uri; - if (parameters.containsKey("uri") && parameters.containsKey("capabilityId")) { - uri = ((String[]) parameters.get("uri"))[0]; - capabilityId = Integer.parseInt(((String[]) parameters.get("capabilityId"))[0]); - } else { - return false; - } - - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - Resource resource = findResource(resURI, array); - - Capability capability = resource.getCapabilities().get(capabilityId - 1); - List extends Attribute>> attributes = capability.getAttributes(); -// Property[] properties = capability.getProperties(); - for (int i = 0; i < attributes.size(); i++) { - String name = ((String[]) parameters.get("name_" + (i + 1)))[0]; - String type = ((String[]) parameters.get("type_" + (i + 1)))[0]; - String value = ((String[]) parameters.get("value_" + (i + 1)))[0]; - Attribute> propBefore = attributes.get(i); - int propertiesLengthBefore = attributes.size(); - capability.removeAttribute(attributes.get(i).getAttributeType()); - - if (propertiesLengthBefore == capability.getAttributes().size()) { - req.getSession().setAttribute("success", false); - req.getSession().setAttribute("message", "Cannot change property."); - logger.debug("Cannot change property, resource: {}", resource); - continue; - } - - try { - capability.setAttribute(new GenericAttributeType(name, type), value); - } catch (IllegalArgumentException e) { - capability.setAttribute(propBefore); - req.getSession().setAttribute("success", false); - req.getSession().setAttribute("message", "Cannot change property."); - logger.warn("Cannot change property, resource: {}, capability: {}", resource, capability); - } - } - Activator.instance().getMetadataDao().saveResource(resource); - } catch (URISyntaxException e) { - logger.warn("Can't save capabilities: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't save capabilities, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't save capabilities", e); - return false; - } - return true; - } - - private boolean saveRequirements(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - String uri; - if (parameters.containsKey("uri")) { - uri = ((String[]) parameters.get("uri"))[0]; - } else { - return false; - } - - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - Resource resource = findResource(resURI, array); - - List requirements = resource.getRequirements(); - int requirLengthBefore = 0; - String name = null; - Requirement requir = null; - String filter = null; - String comment = null; - boolean multiple = false; - boolean extend = false; - boolean optional = false; - Requirement requirBefore = null; - for (int i = 0; i < requirements.size(); i++) { - - if (parameters.containsKey("name_" + (i + 1)) - && parameters.containsKey("filter_" + (i + 1))) { - - name = ((String[]) parameters.get("name_" + (i + 1)))[0]; - filter = ((String[]) parameters.get("filter_" + (i + 1)))[0]; - - if (parameters.containsKey("multiple_" + (i + 1))) { - multiple = ((String[]) parameters.get("multiple_" + (i + 1)))[0].equals("on"); - } - if (parameters.containsKey("optional_" + (i + 1))) { - optional = ((String[]) parameters.get("optional_" + (i + 1)))[0].equals("on"); - } - if (parameters.containsKey("extend_" + (i + 1))) { - extend = ((String[]) parameters.get("extend_" + (i + 1)))[0].equals("on"); - } - if (parameters.containsKey("comment_" + (i + 1))) { - comment = ((String[]) parameters.get("comment_" + (i + 1)))[0]; - } -// requirBefore = requirements[i]; - requirLengthBefore = requirements.size(); - resource.removeRequirement(requirements.get(i)); - if (requirLengthBefore == resource.getRequirements().size()) { -//TODO req.getSession().setAttribute("success", false); -//TODO req.getSession().setAttribute("message", "Cannot change requirement."); - continue; - } - requir = Activator.instance().getMetadataFactory().createRequirement(name); - resource.addRequirement(requir); - try { - logger.warn("OSGi filter is not supported yet with new Metadata API, setting as a directive to track it's usage: {}", filter); - requir.setDirective("filter", filter); - } catch (IllegalArgumentException e) { -//TODO req.getSession().setAttribute("success", false); -//TODO req.getSession().setAttribute("message", "Cannot change requirement."); - resource.removeRequirement(requir); - resource.addRequirement(requirBefore); - continue; - } - requir.setDirective("multiple", String.valueOf(multiple)); - requir.setDirective("optional", String.valueOf(optional)); - requir.setDirective("extend", String.valueOf(extend)); - requir.setDirective("comment", comment); -// resource.addRequirement(requir); - } - } - Activator.instance().getMetadataDao().saveResource(resource); - } catch (URISyntaxException e) { - logger.warn("Can't save requirements: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't save requirements, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't save requirements", e); - return false; - } - return true; - } - - private boolean addCategory(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - String category = null; - String uri = null; - if (parameters.containsKey("category") - && parameters.containsKey("uri")) { - category = ((String[]) parameters.get("category"))[0]; - uri = ((String[]) parameters.get("uri"))[0]; - - } else { - return false; - } - - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - Resource resource = findResource(resURI, array); - - - int categoriesLengthBefore = Activator.instance().getMetadataService().getCategories(resource).size(); - Activator.instance().getMetadataService().addCategory(resource, category); - - // check that category was really added - if (categoriesLengthBefore >= Activator.instance().getMetadataService().getCategories(resource).size()) { - req.getSession().setAttribute("success", false); - req.getSession().setAttribute("message", "Cannot add category."); - } - - Activator.instance().getMetadataDao().saveResource(resource); - - } catch (URISyntaxException e) { - logger.warn("Can't add category: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't add category, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't add category", e); - return false; - } - return true; - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - cleanSession(req.getSession()); - - req.getSession().removeAttribute("success"); - boolean success = false; - Map, ?> parameters = (Map, ?>) req.getParameterMap(); - - String type = null; - if (parameters.containsKey("type")) { - type = ((String[]) parameters.get("type"))[0]; - } - if (type != null) { - switch (type) { - case "deleteCompoment": - success = deleteComponent(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot delete component."); - success = true; - } - break; - - case "category": - success = editCategories(req, resp); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot edit category."); - success = true; - } - break; - - case "deleteCategory": - if (!deleteCategory(req, resp, parameters)) { - ResourceServlet.setError(req.getSession(), false, "Cannot delete category."); - success = true; - } - success = editCategories(req, resp); - break; - - case "addCategory": - success = addCategories(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add category."); - success = true; - } - break; - - case "addCapability": - success = addCapabilities(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); - success = true; - } - break; - - case "addCapabilityProperty": - success = addCapabilityProperty(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); - success = true; - } - break; - - case "capability": - success = editCapabilities(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot edit capabilities."); - success = true; - } - break; - - case "requirement": - success = editRequirements(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot edit requirements."); - success = true; - } - break; - - case "addRequirement": - success = addRequirement(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); - success = true; - } - break; - - case "properties": - success = editProperties(req, resp, parameters); - if (!success) { - ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); - success = true; - } - break; - default: - success = false; - break; - } - } - if (!success) { - resp.sendError(HttpServletResponse.SC_ACCEPTED, "NOT FOUND OR FAILED TO PROCEED"); - } - } - - private boolean editProperties(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - String uri = req.getParameter("uri"); - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getRequestDispatcher("jsp/forms/propertiesForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't edit properties: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't edit properties, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't edit properties", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - return true; - } - - private boolean addCapabilityProperty(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - String uri = req.getParameter("uri"); - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getSession().setAttribute("capabilityId", req.getParameter("capabilityId")); - req.getRequestDispatcher("jsp/forms/propertyForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't add capability property: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't add capability property, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't add capability property", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - - return true; - } - - private boolean addRequirement(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future - - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - String uri = req.getParameter("uri"); - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getRequestDispatcher("jsp/forms/requirementForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't add requirement: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't add requirement, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't add requirement", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - - return true; - } - - private boolean editRequirements(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future - - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - - String uri = req.getParameter("uri"); - - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getRequestDispatcher("jsp/forms/requirementsForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't edit requirement: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't edit requirement, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't edit requirement", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - return true; - } - - private boolean addCapabilities(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - - String uri = req.getParameter("uri"); - - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getSession().setAttribute("types", Type.values()); - req.getRequestDispatcher("jsp/forms/capabilityForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't add capabilities: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't add capabilities, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't add capabilities", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - - return true; - } - - private boolean editCapabilities(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters, boolean b) { - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - - String uri = null; - try { - String id = null; - if (b && parameters.containsKey("uri") && req.getAttribute("capabilityId") != null) { - uri = ((String[]) parameters.get("uri"))[0]; - id = (String) req.getAttribute("capabilityId"); - } else if (parameters.containsKey("capabilityId") && parameters.containsKey("uri")) { - uri = ((String[]) parameters.get("uri"))[0]; - id = ((String[]) parameters.get("capabilityId"))[0]; - } else { - return false; - } - Resource resource = findResource(new URI(uri), array); - - req.getSession().setAttribute("resource", resource); - req.getSession().setAttribute("types", Type.values()); - req.getSession().setAttribute("capability", resource.getCapabilities().get(Integer.parseInt(id) - 1)); - req.getSession().setAttribute("capabilityId", id); - req.getRequestDispatcher("jsp/forms/capabilitiesForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't edit capabilities: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't edit capabilities, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't edit capabilities", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - - return true; - } - - private boolean addCategories(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future - - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - - String uri = req.getParameter("uri"); - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getRequestDispatcher("jsp/forms/categoryForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't add capabilities: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't add capabilities, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't add capabilities", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - - return true; - } - - private boolean editCategories(HttpServletRequest req, HttpServletResponse resp) { - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - - String uri = req.getParameter("uri"); - try { - URI resURI = new URI(uri); - Resource resource = findResource(resURI, array); - req.getSession().setAttribute("resource", resource); - req.getRequestDispatcher("jsp/forms/categoriesForm.jsp").forward(req, resp); // FIXME hardcoded - } catch (URISyntaxException e) { - logger.warn("Can't edit categories: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't edit categories, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't edit categories", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - - return true; - } - - private boolean deleteCategory(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future - String category = null; - String uri = null; - if (parameters.containsKey("category") - && parameters.containsKey("uri")) { - category = ((String[]) parameters.get("category"))[0]; - uri = ((String[]) parameters.get("uri"))[0]; - - } else { - return false; - } - try { - URI resURI = new URI(uri); - String link = (String) req.getSession().getAttribute("source"); - List array = getResources(req, link); - if (array == null) { - return false; - } - - Resource resource = findResource(resURI, array); - - int categoriesLengthBefore = Activator.instance().getMetadataService().getCategories(resource).size(); - Activator.instance().getMetadataService().removeCategory(resource, category); - -// Zjištění zda kategorie byla odstraněna. - if (categoriesLengthBefore == Activator.instance().getMetadataService().getCategories(resource).size()) { - return false; - } - - Activator.instance().getMetadataDao().saveResource(resource); - - } catch (URISyntaxException e) { - logger.warn("Can't delete category: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't delete category, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't delete category", e); - return false; - } - - return true; - } - - private boolean deleteComponent(HttpServletRequest req, HttpServletResponse resp, final Map, ?> parameters) { - String link = null; - String uri = null; - if (parameters.containsKey("link") - && parameters.containsKey("uri")) { - link = ((String[]) parameters.get("link"))[0]; - uri = ((String[]) parameters.get("uri"))[0]; - - } else { - return false; - } - try { - URI fileUri = new URI(uri); - if ("store".equals(link)) { - List array = Activator.instance().getStore(getRepositoryId(req)).getResources(); - Resource found = findResource(fileUri, array); - Activator.instance().getStore(getRepositoryId(req)).remove(found); - } else if ("buffer".equals(link)) { - List array = Activator.instance().getBuffer(req).getResources(); - Resource found = findResource(fileUri, array); - if (!Activator.instance().getBuffer(req).remove(found)) { - logger.warn("Buffer didn't contain removed resource: {}", found); - } - } else { - return false; - } - - req.getRequestDispatcher("resource").forward(req, resp); - - } catch (URISyntaxException e) { - logger.warn("Can't delete component: {}", e.getMessage()); - return false; - } catch (FileNotFoundException e) { - logger.error("Can't delete component, file not found: {}", uri); - return false; - } catch (IOException e) { - logger.error("Can't delete component", e); - return false; - } catch (ServletException e) { - logger.error("Can't forward", e); - return false; - } - return true; - } - - public static Resource findResource(URI uri, List array) throws FileNotFoundException { - Resource found = null; - for (Resource r : array) { - if (Activator.instance().getMetadataService().getUri(r).equals(uri)) { - found = r; - break; - } - } - if (found == null) { - throw new FileNotFoundException(); - } - return found; - } - - private static void cleanSession(HttpSession session) { - session.removeAttribute("resource"); - } - - private List getResources(HttpServletRequest req, String link) { - switch (link) { - case "store": - return Activator.instance().getStore(getRepositoryId(req)).getResources(); - case "buffer": - return Activator.instance().getBuffer(req).getResources(); - default: - return null; - } - } - - private String getRepositoryId(HttpServletRequest req) { - String id = req.getParameter("repositoryId"); - if (id == null) { - Map stores = Activator.instance().getRepositories(); - if (stores.isEmpty()) { - return null; - } - id = stores.keySet().iterator().next(); - logger.trace("Store ID not specified, using the first store found: " + id); - } - return id; - } -} +package cz.zcu.kiv.crce.webui.internal; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Map; + +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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cz.zcu.kiv.crce.metadata.Attribute; +import cz.zcu.kiv.crce.metadata.Capability; +import cz.zcu.kiv.crce.metadata.Requirement; +import cz.zcu.kiv.crce.metadata.Resource; +import cz.zcu.kiv.crce.metadata.impl.GenericAttributeType; +import cz.zcu.kiv.crce.webui.internal.legacy.Type; + +public class EditServlet extends HttpServlet { + + private static final long serialVersionUID = -4949620462179710290L; + + private static final Logger logger = LoggerFactory.getLogger(EditServlet.class); + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + + boolean success = false; + Map, ?> parameters = req.getParameterMap(); + String form = null; + + if (parameters.containsKey("form")) { + form = ((String[]) parameters.get("form"))[0]; + } + if (form != null) { + switch (form) { + case "addCategory": + if (addCategory(req, resp, parameters)) { + success = editCategories(req, resp); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add category."); + success = true; + } + } else { + ResourceServlet.setError(req.getSession(), false, "Cannot add category."); + success = true; + } + break; + + case "requirements": + if (saveRequirements(req, resp, parameters)) { + success = editRequirements(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot save requirements."); + success = true; + } + } + break; + + case "addRequirement": + if (!addRequirementForm(req, resp, parameters)) { + ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); + } + success = editRequirements(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); + success = true; + } + break; + + case "capabilities": + if (saveCapabilities(req, resp, parameters)) { + success = editCapabilities(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot save capabilities."); + success = true; + } + + } else { + ResourceServlet.setError(req.getSession(), false, "Cannot save capabilities."); + success = true; + } + break; + + case "capability": + if (saveCapability(req, resp, parameters)) { + success = editCapabilities(req, resp, parameters, true); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); + success = true; + } + } else { + ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); + success = true; + } + break; + + case "property": + if (!saveProperty(req, resp, parameters)) { + ResourceServlet.setError(req.getSession(), false, "Cannot add property."); + } + success = editCapabilities(req, resp, parameters, true); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Error while loading capabilities."); + success = true; + } + break; + + case "editProperties": + if (!saveResourceProperty(req, resp, parameters)) { + ResourceServlet.setError(req.getSession(), false, "Cannot change properties."); + } + success = editProperties(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Error while loading capabilities."); + success = true; + } + break; + + default: + } + } + if (!success) { + resp.sendError(HttpServletResponse.SC_ACCEPTED, "NOT FOUND OR FAILED TO PROCEED"); + } + } + + private boolean saveResourceProperty(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + String uri; + if (parameters.containsKey("uri")) { + uri = ((String[]) parameters.get("uri"))[0]; + } else { + return false; + } + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List resources = getResources(req, link); + if (resources == null) { + return false; + } + Resource resource = findResource(resURI, resources); + // TODO why was the following here: +// String symbolicName = ((String[]) parameters.get("symbolicName"))[0]; +// String version = ((String[]) parameters.get("version"))[0]; + +// LegacyMetadataHelper.setVersion(Activator.instance().getMetadataFactory(), resource, new Version(version)); +// LegacyMetadataHelper.setSymbolicName(Activator.instance().getMetadataFactory(), resource, symbolicName); + + Activator.instance().getMetadataDao().saveResource(resource); + } catch (URISyntaxException e) { + logger.warn("Can't save resource property: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't save resource property, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't save resource property", e); + return false; + } + + return true; + } + + private boolean saveProperty(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + String uri; + String id; + if (parameters.containsKey("uri") && parameters.containsKey("capabilityId")) { + uri = ((String[]) parameters.get("uri"))[0]; + id = ((String[]) parameters.get("capabilityId"))[0]; + } else { + return false; + } + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + Resource resource = findResource(resURI, array); + Capability capability = resource.getCapabilities().get(Integer.parseInt(id) - 1); + String name = ((String[]) parameters.get("name"))[0]; + String type = ((String[]) parameters.get("propertyType"))[0]; + Object value = ((String[]) parameters.get("value"))[0]; + + try { + capability.setAttribute(new GenericAttributeType(name, type), value); + } catch (IllegalArgumentException e) { + return false; + } + Activator.instance().getMetadataDao().saveResource(resource); + + } catch (URISyntaxException e) { + logger.warn("Can't save property: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't save property, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't save property", e); + return false; + } + + return true; + } + + private boolean editCapabilities(HttpServletRequest req, + HttpServletResponse resp, Map, ?> parameters) { + return editCapabilities(req, resp, parameters, false); + } + + private boolean saveCapability(HttpServletRequest req, + HttpServletResponse resp, Map, ?> parameters) { + String uri; + String capabilityName; + if (parameters.containsKey("uri") + && parameters.containsKey("capability")) { + uri = ((String[]) parameters.get("uri"))[0]; + capabilityName = ((String[]) parameters.get("capability"))[0]; + } else { + return false; + } + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + Resource resource = findResource(resURI, array); + int lengthBefore = resource.getCapabilities().size(); + resource.addCapability(Activator.instance().getMetadataFactory().createCapability(capabilityName)); + if (lengthBefore == resource.getCapabilities().size()) { + resp.sendRedirect("resource"); + return false; + } + + Activator.instance().getMetadataDao().saveResource(resource); + + req.setAttribute("capabilityId", String.valueOf(resource.getCapabilities().size())); + } catch (URISyntaxException e) { + logger.warn("Can't save capability: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't save capability, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't save capability", e); + return false; + } + + return true; + } + + private boolean addRequirementForm(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + String uri; + if (parameters.containsKey("uri")) { + uri = ((String[]) parameters.get("uri"))[0]; + } else { + return false; + } + + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + Resource resource = findResource(resURI, array); + String name = null; + Requirement requir = null; + String filter = null; + boolean multiple = false; + boolean extend = false; + boolean optional = false; + Requirement requirBefore = null; + if (parameters.containsKey("name") + && parameters.containsKey("filter")) { + name = ((String[]) parameters.get("name"))[0]; + filter = ((String[]) parameters.get("filter"))[0]; + if (parameters.containsKey("multiple")) { + multiple = ((String[]) parameters.get("multiple"))[0].equals("on"); + } + if (parameters.containsKey("optional")) { + optional = ((String[]) parameters.get("optional"))[0].equals("on"); + } + if (parameters.containsKey("extend")) { + extend = ((String[]) parameters.get("extend"))[0].equals("on"); + } + String comment = null; + if (parameters.containsKey("comment")) { + comment = ((String[]) parameters.get("comment"))[0]; + } + int lengthBefore = resource.getRequirements().size(); + requir = Activator.instance().getMetadataFactory().createRequirement(name); + resource.addRequirement(requir); + if (lengthBefore == resource.getRequirements().size()) { + req.getSession().setAttribute("success", false); + req.getSession().setAttribute("message", "Cannot add requirement."); + return false; + } + try { + logger.warn("OSGi filter is not supported yet with new Metadata API, setting as a directive to track it's usage: {}", filter); + requir.setDirective("filter", filter); + } catch (IllegalArgumentException e) { + resource.removeRequirement(requir); + resource.addRequirement(requirBefore); + } + requir.setDirective("multiple", String.valueOf(multiple)); + requir.setDirective("optional", String.valueOf(optional)); + requir.setDirective("extend", String.valueOf(extend)); + requir.setDirective("comment", comment); + } + Activator.instance().getMetadataDao().saveResource(resource); + } catch (URISyntaxException e) { + logger.warn("Can't add requirement: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't add requirement, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't requirement", e); + return false; + } + + req.getSession().setAttribute("success", true); + return true; + + } + + private boolean saveCapabilities(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + int capabilityId = -1; + String uri; + if (parameters.containsKey("uri") && parameters.containsKey("capabilityId")) { + uri = ((String[]) parameters.get("uri"))[0]; + capabilityId = Integer.parseInt(((String[]) parameters.get("capabilityId"))[0]); + } else { + return false; + } + + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + Resource resource = findResource(resURI, array); + + Capability capability = resource.getCapabilities().get(capabilityId - 1); + List extends Attribute>> attributes = capability.getAttributes(); +// Property[] properties = capability.getProperties(); + for (int i = 0; i < attributes.size(); i++) { + String name = ((String[]) parameters.get("name_" + (i + 1)))[0]; + String type = ((String[]) parameters.get("type_" + (i + 1)))[0]; + String value = ((String[]) parameters.get("value_" + (i + 1)))[0]; + Attribute> propBefore = attributes.get(i); + int propertiesLengthBefore = attributes.size(); + capability.removeAttribute(attributes.get(i).getAttributeType()); + + if (propertiesLengthBefore == capability.getAttributes().size()) { + req.getSession().setAttribute("success", false); + req.getSession().setAttribute("message", "Cannot change property."); + logger.debug("Cannot change property, resource: {}", resource); + continue; + } + + try { + capability.setAttribute(new GenericAttributeType(name, type), value); + } catch (IllegalArgumentException e) { + capability.setAttribute(propBefore); + req.getSession().setAttribute("success", false); + req.getSession().setAttribute("message", "Cannot change property."); + logger.warn("Cannot change property, resource: {}, capability: {}", resource, capability); + } + } + Activator.instance().getMetadataDao().saveResource(resource); + } catch (URISyntaxException e) { + logger.warn("Can't save capabilities: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't save capabilities, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't save capabilities", e); + return false; + } + return true; + } + + private boolean saveRequirements(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + String uri; + if (parameters.containsKey("uri")) { + uri = ((String[]) parameters.get("uri"))[0]; + } else { + return false; + } + + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + Resource resource = findResource(resURI, array); + + List requirements = resource.getRequirements(); + int requirLengthBefore = 0; + String name = null; + Requirement requir = null; + String filter = null; + String comment = null; + boolean multiple = false; + boolean extend = false; + boolean optional = false; + Requirement requirBefore = null; + for (int i = 0; i < requirements.size(); i++) { + + if (parameters.containsKey("name_" + (i + 1)) + && parameters.containsKey("filter_" + (i + 1))) { + + name = ((String[]) parameters.get("name_" + (i + 1)))[0]; + filter = ((String[]) parameters.get("filter_" + (i + 1)))[0]; + + if (parameters.containsKey("multiple_" + (i + 1))) { + multiple = ((String[]) parameters.get("multiple_" + (i + 1)))[0].equals("on"); + } + if (parameters.containsKey("optional_" + (i + 1))) { + optional = ((String[]) parameters.get("optional_" + (i + 1)))[0].equals("on"); + } + if (parameters.containsKey("extend_" + (i + 1))) { + extend = ((String[]) parameters.get("extend_" + (i + 1)))[0].equals("on"); + } + if (parameters.containsKey("comment_" + (i + 1))) { + comment = ((String[]) parameters.get("comment_" + (i + 1)))[0]; + } +// requirBefore = requirements[i]; + requirLengthBefore = requirements.size(); + resource.removeRequirement(requirements.get(i)); + if (requirLengthBefore == resource.getRequirements().size()) { +//TODO req.getSession().setAttribute("success", false); +//TODO req.getSession().setAttribute("message", "Cannot change requirement."); + continue; + } + requir = Activator.instance().getMetadataFactory().createRequirement(name); + resource.addRequirement(requir); + try { + logger.warn("OSGi filter is not supported yet with new Metadata API, setting as a directive to track it's usage: {}", filter); + requir.setDirective("filter", filter); + } catch (IllegalArgumentException e) { +//TODO req.getSession().setAttribute("success", false); +//TODO req.getSession().setAttribute("message", "Cannot change requirement."); + resource.removeRequirement(requir); + resource.addRequirement(requirBefore); + continue; + } + requir.setDirective("multiple", String.valueOf(multiple)); + requir.setDirective("optional", String.valueOf(optional)); + requir.setDirective("extend", String.valueOf(extend)); + requir.setDirective("comment", comment); +// resource.addRequirement(requir); + } + } + Activator.instance().getMetadataDao().saveResource(resource); + } catch (URISyntaxException e) { + logger.warn("Can't save requirements: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't save requirements, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't save requirements", e); + return false; + } + return true; + } + + private boolean addCategory(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + String category = null; + String uri = null; + if (parameters.containsKey("category") + && parameters.containsKey("uri")) { + category = ((String[]) parameters.get("category"))[0]; + uri = ((String[]) parameters.get("uri"))[0]; + + } else { + return false; + } + + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + Resource resource = findResource(resURI, array); + + + int categoriesLengthBefore = Activator.instance().getMetadataService().getCategories(resource).size(); + Activator.instance().getMetadataService().addCategory(resource, category); + + // check that category was really added + if (categoriesLengthBefore >= Activator.instance().getMetadataService().getCategories(resource).size()) { + req.getSession().setAttribute("success", false); + req.getSession().setAttribute("message", "Cannot add category."); + } + + Activator.instance().getMetadataDao().saveResource(resource); + + } catch (URISyntaxException e) { + logger.warn("Can't add category: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't add category, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't add category", e); + return false; + } + return true; + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + cleanSession(req.getSession()); + + req.getSession().removeAttribute("success"); + boolean success = false; + Map, ?> parameters = (Map, ?>) req.getParameterMap(); + + String type = null; + if (parameters.containsKey("type")) { + type = ((String[]) parameters.get("type"))[0]; + } + if (type != null) { + switch (type) { + case "deleteCompoment": + success = deleteComponent(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot delete component."); + success = true; + } + break; + + case "category": + success = editCategories(req, resp); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot edit category."); + success = true; + } + break; + + case "deleteCategory": + if (!deleteCategory(req, resp, parameters)) { + ResourceServlet.setError(req.getSession(), false, "Cannot delete category."); + success = true; + } + success = editCategories(req, resp); + break; + + case "addCategory": + success = addCategories(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add category."); + success = true; + } + break; + + case "addCapability": + success = addCapabilities(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); + success = true; + } + break; + + case "addCapabilityProperty": + success = addCapabilityProperty(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add capability."); + success = true; + } + break; + + case "capability": + success = editCapabilities(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot edit capabilities."); + success = true; + } + break; + + case "requirement": + success = editRequirements(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot edit requirements."); + success = true; + } + break; + + case "addRequirement": + success = addRequirement(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); + success = true; + } + break; + + case "properties": + success = editProperties(req, resp, parameters); + if (!success) { + ResourceServlet.setError(req.getSession(), false, "Cannot add requirement."); + success = true; + } + break; + default: + success = false; + break; + } + } + if (!success) { + resp.sendError(HttpServletResponse.SC_ACCEPTED, "NOT FOUND OR FAILED TO PROCEED"); + } + } + + private boolean editProperties(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + String uri = req.getParameter("uri"); + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getRequestDispatcher("jsp/forms/propertiesForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't edit properties: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't edit properties, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't edit properties", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + return true; + } + + private boolean addCapabilityProperty(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + String uri = req.getParameter("uri"); + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getSession().setAttribute("capabilityId", req.getParameter("capabilityId")); + req.getRequestDispatcher("jsp/forms/propertyForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't add capability property: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't add capability property, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't add capability property", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + + return true; + } + + private boolean addRequirement(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future + + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + String uri = req.getParameter("uri"); + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getRequestDispatcher("jsp/forms/requirementForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't add requirement: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't add requirement, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't add requirement", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + + return true; + } + + private boolean editRequirements(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future + + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + + String uri = req.getParameter("uri"); + + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getRequestDispatcher("jsp/forms/requirementsForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't edit requirement: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't edit requirement, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't edit requirement", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + return true; + } + + private boolean addCapabilities(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + + String uri = req.getParameter("uri"); + + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getSession().setAttribute("types", Type.values()); + req.getRequestDispatcher("jsp/forms/capabilityForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't add capabilities: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't add capabilities, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't add capabilities", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + + return true; + } + + private boolean editCapabilities(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters, boolean b) { + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + + String uri = null; + try { + String id = null; + if (b && parameters.containsKey("uri") && req.getAttribute("capabilityId") != null) { + uri = ((String[]) parameters.get("uri"))[0]; + id = (String) req.getAttribute("capabilityId"); + } else if (parameters.containsKey("capabilityId") && parameters.containsKey("uri")) { + uri = ((String[]) parameters.get("uri"))[0]; + id = ((String[]) parameters.get("capabilityId"))[0]; + } else { + return false; + } + Resource resource = findResource(new URI(uri), array); + + req.getSession().setAttribute("resource", resource); + req.getSession().setAttribute("types", Type.values()); + req.getSession().setAttribute("capability", resource.getCapabilities().get(Integer.parseInt(id) - 1)); + req.getSession().setAttribute("capabilityId", id); + req.getRequestDispatcher("jsp/forms/capabilitiesForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't edit capabilities: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't edit capabilities, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't edit capabilities", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + + return true; + } + + private boolean addCategories(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD parameters would be used in the future + + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + + String uri = req.getParameter("uri"); + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getRequestDispatcher("jsp/forms/categoryForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't add capabilities: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't add capabilities, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't add capabilities", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + + return true; + } + + private boolean editCategories(HttpServletRequest req, HttpServletResponse resp) { + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + + String uri = req.getParameter("uri"); + try { + URI resURI = new URI(uri); + Resource resource = findResource(resURI, array); + req.getSession().setAttribute("resource", resource); + req.getRequestDispatcher("jsp/forms/categoriesForm.jsp").forward(req, resp); // FIXME hardcoded + } catch (URISyntaxException e) { + logger.warn("Can't edit categories: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't edit categories, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't edit categories", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + + return true; + } + + private boolean deleteCategory(HttpServletRequest req, HttpServletResponse resp, Map, ?> parameters) { // NOPMD resp would be used in the future + String category = null; + String uri = null; + if (parameters.containsKey("category") + && parameters.containsKey("uri")) { + category = ((String[]) parameters.get("category"))[0]; + uri = ((String[]) parameters.get("uri"))[0]; + + } else { + return false; + } + try { + URI resURI = new URI(uri); + String link = (String) req.getSession().getAttribute("source"); + List array = getResources(req, link); + if (array == null) { + return false; + } + + Resource resource = findResource(resURI, array); + + int categoriesLengthBefore = Activator.instance().getMetadataService().getCategories(resource).size(); + Activator.instance().getMetadataService().removeCategory(resource, category); + +// Zjištění zda kategorie byla odstraněna. + if (categoriesLengthBefore == Activator.instance().getMetadataService().getCategories(resource).size()) { + return false; + } + + Activator.instance().getMetadataDao().saveResource(resource); + + } catch (URISyntaxException e) { + logger.warn("Can't delete category: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't delete category, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't delete category", e); + return false; + } + + return true; + } + + private boolean deleteComponent(HttpServletRequest req, HttpServletResponse resp, final Map, ?> parameters) { + String link = null; + String uri = null; + if (parameters.containsKey("link") + && parameters.containsKey("uri")) { + link = ((String[]) parameters.get("link"))[0]; + uri = ((String[]) parameters.get("uri"))[0]; + + } else { + return false; + } + try { + URI fileUri = new URI(uri); + if ("store".equals(link)) { + List array = Activator.instance().getStore(getRepositoryId(req)).getResources(); + Resource found = findResource(fileUri, array); + Activator.instance().getStore(getRepositoryId(req)).remove(found); + } else if ("buffer".equals(link)) { + List array = Activator.instance().getBuffer(req).getResources(); + Resource found = findResource(fileUri, array); + if (!Activator.instance().getBuffer(req).remove(found)) { + logger.warn("Buffer didn't contain removed resource: {}", found); + } + } else { + return false; + } + + req.getRequestDispatcher("resource").forward(req, resp); + + } catch (URISyntaxException e) { + logger.warn("Can't delete component: {}", e.getMessage()); + return false; + } catch (FileNotFoundException e) { + logger.error("Can't delete component, file not found: {}", uri); + return false; + } catch (IOException e) { + logger.error("Can't delete component", e); + return false; + } catch (ServletException e) { + logger.error("Can't forward", e); + return false; + } + return true; + } + + public static Resource findResource(URI uri, List array) throws FileNotFoundException { + Resource found = null; + for (Resource r : array) { + if (Activator.instance().getMetadataService().getUri(r).equals(uri)) { + found = r; + break; + } + } + if (found == null) { + throw new FileNotFoundException(); + } + return found; + } + + private static void cleanSession(HttpSession session) { + session.removeAttribute("resource"); + } + + private List getResources(HttpServletRequest req, String link) { + switch (link) { + case "store": + return Activator.instance().getStore(getRepositoryId(req)).getResources(); + case "buffer": + return Activator.instance().getBuffer(req).getResources(); + default: + return null; + } + } + + private String getRepositoryId(HttpServletRequest req) { + String id = req.getParameter("repositoryId"); + if (id == null) { + Map stores = Activator.instance().getRepositories(); + if (stores.isEmpty()) { + return null; + } + id = stores.keySet().iterator().next(); + logger.trace("Store ID not specified, using the first store found: " + id); + } + return id; + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Helper.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Helper.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Helper.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/Helper.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/ResourceServlet.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/ResourceServlet.java similarity index 95% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/ResourceServlet.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/ResourceServlet.java index 77aef538..3919ecfd 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/ResourceServlet.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/ResourceServlet.java @@ -15,6 +15,8 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import cz.zcu.kiv.crce.metadata.AttributeType; +import cz.zcu.kiv.crce.metadata.impl.SimpleAttributeType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,7 +24,6 @@ import cz.zcu.kiv.crce.compatibility.CompatibilityVersionComparator; import cz.zcu.kiv.crce.metadata.Requirement; import cz.zcu.kiv.crce.metadata.Resource; -import cz.zcu.kiv.crce.metadata.osgi.namespace.NsOsgiIdentity; import cz.zcu.kiv.crce.metadata.type.Version; import cz.zcu.kiv.crce.plugin.Plugin; import cz.zcu.kiv.crce.webui.internal.bean.Category; @@ -34,6 +35,13 @@ public class ResourceServlet extends HttpServlet { private static final Logger logger = LoggerFactory.getLogger(ResourceServlet.class); + // loose coupling with crce-metadata-osgi-bundle module + // see namespace package in crce-metadata-osgi-bundle + // same variables are declared there + private static final String OSG_IDENTITY_NAMESPACE = "osgi.identity"; + private static final AttributeType ATTRIBUTE_SYMBOLIC_NAME = new SimpleAttributeType<>("symbolic-name", String.class); + public static final AttributeType ATTRIBUTE_VERSION = new SimpleAttributeType<>(org.apache.felix.bundlerepository.Resource.VERSION, Version.class); + @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -230,10 +238,10 @@ private boolean fillSession(String link, HttpServletRequest req, Requirement fil } session.setAttribute("nodata", false); - Requirement resFilter = Activator.instance().getMetadataFactory().createRequirement(NsOsgiIdentity.NAMESPACE__OSGI_IDENTITY); - resFilter.addAttribute(NsOsgiIdentity.ATTRIBUTE__SYMBOLIC_NAME, name); + Requirement resFilter = Activator.instance().getMetadataFactory().createRequirement(OSG_IDENTITY_NAMESPACE); + resFilter.addAttribute(ATTRIBUTE_SYMBOLIC_NAME, name); Version v = new Version(version); - resFilter.addAttribute(NsOsgiIdentity.ATTRIBUTE__VERSION, v); + resFilter.addAttribute(ATTRIBUTE_VERSION, v); List res = Activator.instance().getStore(id).getResources(resFilter, false); if (!res.isEmpty()) { diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/RuntimeServlet.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/RuntimeServlet.java similarity index 97% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/RuntimeServlet.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/RuntimeServlet.java index d0bace62..9c3dabf9 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/RuntimeServlet.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/RuntimeServlet.java @@ -1,111 +1,111 @@ -package cz.zcu.kiv.crce.webui.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; - -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.slf4j.Logger; -import org.slf4j.LoggerFactory; -import cz.zcu.kiv.crce.metadata.Resource; -import cz.zcu.kiv.crce.repository.plugins.Executable; - -public class RuntimeServlet extends HttpServlet { - - private static final Logger logger = LoggerFactory.getLogger(RuntimeServlet.class); - - /** - * - */ - private static final long serialVersionUID = 1L; - private String message = null; - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - if (isStoreBufferAction(req)) { - if (setSessionForForm(req)) { - req.getRequestDispatcher("jsp/forms/testForm.jsp").forward(req, resp); // FIXME hardcoded - } else { - message = "No bundles selected"; - logger.warn(message); - ResourceServlet.setError(req.getSession(), false, message); - req.getRequestDispatcher("jsp/" + req.getSession().getAttribute("source") + ".jsp").forward(req, resp); - } - } - ResourceServlet.setError(req.getSession(), false, "Wrong params!"); - req.getRequestDispatcher("resource").forward(req, resp); - - } - - private boolean setSessionForForm(HttpServletRequest req) { - Resource[] toTest = parseParams(req); - if (toTest == null) { - return false; - } else { - HttpSession session = req.getSession(); - ResourceServlet.cleanSession(session); - session.setAttribute("resources", toTest); - List testPlugins = Activator.instance().getPluginManager().getPlugins(Executable.class); - // Executable is not Serializable so this workaround is needed - List testPluginIds = new ArrayList<>(testPlugins.size()); - for (Executable executable : testPlugins) { - testPluginIds.add(executable.getPluginId()); - } - session.setAttribute("tests", testPluginIds); - return true; - } - } - - private List fetchRightResources(String source, HttpServletRequest req) { - Activator a = Activator.instance(); - if (source.equals("store")) { - return a.getStore(null).getResources(); - } else { - return a.getBuffer(req).getResources(); - } - } - - private Resource[] parseParams(HttpServletRequest req) { - - - String[] uris = req.getParameterValues("check"); - if (uris == null || uris.length == 0) { - return null; - } - List resources = fetchRightResources((String) req.getSession().getAttribute("source"), req); - Resource[] toTest = new Resource[uris.length]; - for (int i = 0; i < uris.length; i++) { - try { - toTest[i] = EditServlet.findResource(new URI(uris[i]), resources); - } catch (FileNotFoundException e) { - message = "File not found! Please try again!"; - return null; - } catch (URISyntaxException e) { - message = "Malformed URI cant make URI from param!"; - return null; - } - - } - return toTest; - } - - private boolean isStoreBufferAction(HttpServletRequest req) { - String source = (String) req.getSession().getAttribute("source"); - logger.debug("Runtime servlet POST source: {}", source); - if ("buffer".equals(source) || "store".equals(source)) { - return true; - } else { - return false; - } - } -} +package cz.zcu.kiv.crce.webui.internal; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; + +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.slf4j.Logger; +import org.slf4j.LoggerFactory; +import cz.zcu.kiv.crce.metadata.Resource; +import cz.zcu.kiv.crce.repository.plugins.Executable; + +public class RuntimeServlet extends HttpServlet { + + private static final Logger logger = LoggerFactory.getLogger(RuntimeServlet.class); + + /** + * + */ + private static final long serialVersionUID = 1L; + private String message = null; + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + if (isStoreBufferAction(req)) { + if (setSessionForForm(req)) { + req.getRequestDispatcher("jsp/forms/testForm.jsp").forward(req, resp); // FIXME hardcoded + } else { + message = "No bundles selected"; + logger.warn(message); + ResourceServlet.setError(req.getSession(), false, message); + req.getRequestDispatcher("jsp/" + req.getSession().getAttribute("source") + ".jsp").forward(req, resp); + } + } + ResourceServlet.setError(req.getSession(), false, "Wrong params!"); + req.getRequestDispatcher("resource").forward(req, resp); + + } + + private boolean setSessionForForm(HttpServletRequest req) { + Resource[] toTest = parseParams(req); + if (toTest == null) { + return false; + } else { + HttpSession session = req.getSession(); + ResourceServlet.cleanSession(session); + session.setAttribute("resources", toTest); + List testPlugins = Activator.instance().getPluginManager().getPlugins(Executable.class); + // Executable is not Serializable so this workaround is needed + List testPluginIds = new ArrayList<>(testPlugins.size()); + for (Executable executable : testPlugins) { + testPluginIds.add(executable.getPluginId()); + } + session.setAttribute("tests", testPluginIds); + return true; + } + } + + private List fetchRightResources(String source, HttpServletRequest req) { + Activator a = Activator.instance(); + if (source.equals("store")) { + return a.getStore(null).getResources(); + } else { + return a.getBuffer(req).getResources(); + } + } + + private Resource[] parseParams(HttpServletRequest req) { + + + String[] uris = req.getParameterValues("check"); + if (uris == null || uris.length == 0) { + return null; + } + List resources = fetchRightResources((String) req.getSession().getAttribute("source"), req); + Resource[] toTest = new Resource[uris.length]; + for (int i = 0; i < uris.length; i++) { + try { + toTest[i] = EditServlet.findResource(new URI(uris[i]), resources); + } catch (FileNotFoundException e) { + message = "File not found! Please try again!"; + return null; + } catch (URISyntaxException e) { + message = "Malformed URI cant make URI from param!"; + return null; + } + + } + return toTest; + } + + private boolean isStoreBufferAction(HttpServletRequest req) { + String source = (String) req.getSession().getAttribute("source"); + logger.debug("Runtime servlet POST source: {}", source); + if ("buffer".equals(source) || "store".equals(source)) { + return true; + } else { + return false; + } + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/SessionListener.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/SessionListener.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/SessionListener.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/SessionListener.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/UploadServlet.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/UploadServlet.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/UploadServlet.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/UploadServlet.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/VersionInfo.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/VersionInfo.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/VersionInfo.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/VersionInfo.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/bean/Category.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/bean/Category.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/bean/Category.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/bean/Category.java diff --git a/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/CapabilityImpl.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/CapabilityImpl.java new file mode 100644 index 00000000..33c8e0e6 --- /dev/null +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/CapabilityImpl.java @@ -0,0 +1,131 @@ +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.Attribute; +import cz.zcu.kiv.crce.metadata.Capability; +import cz.zcu.kiv.crce.metadata.Property; +import cz.zcu.kiv.crce.metadata.type.Version; +import cz.zcu.kiv.crce.webui.internal.legacy.NewProperty; +import cz.zcu.kiv.crce.webui.internal.legacy.Type; + +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class CapabilityImpl implements cz.zcu.kiv.crce.webui.internal.legacy.Capability { + + private final Capability capability; + + public CapabilityImpl(Capability capability) { + this.capability = capability; + } + + @Override + public String getName() { + return capability.getNamespace(); + } + + @Override + public NewProperty[] getNewProperties() { + List extends Property> newProperties = capability.getProperties(); + NewProperty[] properties = new NewProperty[newProperties.size()]; + int i = 0; + for (Property newProperty : newProperties) { + properties[i++] = new NewPropertyImpl(newProperty); + } + return properties; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Property[] getProperties() { + List extends Attribute>> attributes = capability.getAttributes(); + cz.zcu.kiv.crce.webui.internal.legacy.Property[] properties = new cz.zcu.kiv.crce.webui.internal.legacy.Property[attributes.size()]; + int i = 0; + for (Attribute> attribute : attributes) { + properties[i++] = new PropertyImpl(attribute); + } + return properties; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Property getProperty(String name) { + Attribute> attribute = capability.getAttributesMap().get(name); + if (attribute != null) { + return new PropertyImpl(attribute); + } + return null; + } + + @Override + public String getPropertyString(String name) { + Attribute> attribute = capability.getAttributesMap().get(name); + if (attribute != null) { + return attribute.getStringValue(); + } + return null; + } + + @Override + @SuppressWarnings("unchecked") + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(cz.zcu.kiv.crce.webui.internal.legacy.Property property) { + capability.setAttribute(property.getName(), (Class) property.getType().getTypeClass(), property.getConvertedValue()); + return this; + } + + @Override + @SuppressWarnings("unchecked") + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, String value, Type type) { + capability.setAttribute(name, (Class) type.getTypeClass(), Type.propertyValueFromString(type, value)); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, String value) { + capability.setAttribute(name, String.class, value); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, Version version) { + capability.setAttribute(name, Version.class, version); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, URL url) { + capability.setAttribute(name, String.class, url.toString()); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, URI uri) { + capability.setAttribute(name, String.class, uri.toString()); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, long llong) { + capability.setAttribute(name, Long.class, llong); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, double ddouble) { + capability.setAttribute(name, Double.class, ddouble); + return this; + } + + @Override + @SuppressWarnings("unchecked") + public cz.zcu.kiv.crce.webui.internal.legacy.Capability setProperty(String name, Set values) { + capability.setAttribute(name, List.class, new ArrayList<>(values)); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability unsetProperty(String name) { + capability.removeAttribute(name); + return this; + } +} diff --git a/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/NewPropertyImpl.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/NewPropertyImpl.java new file mode 100644 index 00000000..1a9c086d --- /dev/null +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/NewPropertyImpl.java @@ -0,0 +1,120 @@ +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.Attribute; +import cz.zcu.kiv.crce.metadata.type.Version; +import cz.zcu.kiv.crce.webui.internal.legacy.NewProperty; +import cz.zcu.kiv.crce.webui.internal.legacy.Property; +import cz.zcu.kiv.crce.webui.internal.legacy.Type; + +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +public class NewPropertyImpl implements NewProperty { + + private final cz.zcu.kiv.crce.metadata.Property property; + + public NewPropertyImpl(cz.zcu.kiv.crce.metadata.Property property) { + this.property = property; + } + + @Override + public String getName() { + return property.getNamespace(); + } + + @Override + public Property[] getProperties() { + List extends Attribute>> attributes = property.getAttributes(); + Property[] properties = new Property[attributes.size()]; + int i = 0; + for (Attribute> attribute : attributes) { + properties[i++] = new PropertyImpl(attribute); + } + return properties; + } + + @Override + public Property getProperty(String name) { + Attribute> attribute = property.getAttributesMap().get(name); + if (attribute != null) { + return new PropertyImpl(attribute); + } + return null; + } + + @Override + public String getPropertyString(String name) { + Attribute> attribute = property.getAttributesMap().get(name); + if (attribute != null) { + return attribute.getStringValue(); + } + return null; + } + + @SuppressWarnings("unchecked") + @Override + public NewProperty setProperty(Property property) { + this.property.setAttribute(property.getName(), (Class) property.getType().getTypeClass(), property.getConvertedValue()); + return this; + } + + @SuppressWarnings("unchecked") + @Override + public NewProperty setProperty(String name, String value, Type type) { + this.property.setAttribute(name, (Class) type.getTypeClass(), Type.propertyValueFromString(type, value)); + return this; + } + + @Override + public NewProperty setProperty(String name, String string) { + this.property.setAttribute(name, String.class, string); + return this; + } + + @Override + public NewProperty setProperty(String name, Version version) { + this.property.setAttribute(name, Version.class, version); + return this; + } + + @Override + public NewProperty setProperty(String name, URL url) { + this.property.setAttribute(name, String.class, url.toString()); + return this; + } + + @Override + public NewProperty setProperty(String name, URI uri) { + this.property.setAttribute(name, String.class, uri.toString()); + return this; + } + + @Override + public NewProperty setProperty(String name, long llong) { + this.property.setAttribute(name, Long.class, llong); + return this; + } + + @Override + public NewProperty setProperty(String name, double ddouble) { + this.property.setAttribute(name, Double.class, ddouble); + return this; + } + + @SuppressWarnings("unchecked") + @Override + public NewProperty setProperty(String name, Set values) { + this.property.setAttribute(name, List.class, new ArrayList<>(values)); + return this; + } + + @Override + public NewProperty unsetProperty(String name) { + this.property.removeAttribute(name); + return this; + } + +} \ No newline at end of file diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/Plugin.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/Plugin.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/Plugin.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/Plugin.java diff --git a/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/PropertyImpl.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/PropertyImpl.java new file mode 100644 index 00000000..a62a6933 --- /dev/null +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/PropertyImpl.java @@ -0,0 +1,45 @@ +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.Attribute; +import cz.zcu.kiv.crce.webui.internal.legacy.Property; +import cz.zcu.kiv.crce.webui.internal.legacy.Type; + +public class PropertyImpl implements Property { + + private final Attribute> attribute; + + public PropertyImpl(Attribute> attribute) { + this.attribute = attribute; + } + + @Override + public String getName() { + return attribute.getAttributeType().getName(); + } + + @Override + public Type getType() { + return Type.getValue(attribute.getAttributeType().getType().getSimpleName()); + } + + @Override + public String getValue() { + + Object value = attribute.getValue(); + if (value instanceof Double) { + return String.format("%.3f", value); + } + + return attribute.getStringValue(); + } + + @Override + public Object getConvertedValue() { + return attribute.getValue(); + } + + @Override + public boolean isWritable() { + return true; + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementAdapter.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementAdapter.java similarity index 95% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementAdapter.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementAdapter.java index 47307bb0..2fe19dba 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementAdapter.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementAdapter.java @@ -1,85 +1,85 @@ -package cz.zcu.kiv.crce.webui.internal.custom; - -import cz.zcu.kiv.crce.webui.internal.legacy.Capability; -import cz.zcu.kiv.crce.webui.internal.legacy.Requirement; - -public class RequirementAdapter implements Requirement { - - @Override - public String getName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getFilter() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isMultiple() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isOptional() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isExtend() { - // TODO Auto-generated method stub - return false; - } - - @Override - public String getComment() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isWritable() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isSatisfied(Capability capability) { - // TODO Auto-generated method stub - return false; - } - - @Override - public Requirement setFilter(String filter) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement setMultiple(boolean multiple) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement setOptional(boolean optional) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement setExtend(boolean extend) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement setComment(String comment) { - // TODO Auto-generated method stub - return null; - } -} +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.webui.internal.legacy.Capability; +import cz.zcu.kiv.crce.webui.internal.legacy.Requirement; + +public class RequirementAdapter implements Requirement { + + @Override + public String getName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getFilter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isMultiple() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isOptional() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isExtend() { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getComment() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isWritable() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isSatisfied(Capability capability) { + // TODO Auto-generated method stub + return false; + } + + @Override + public Requirement setFilter(String filter) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement setMultiple(boolean multiple) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement setOptional(boolean optional) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement setExtend(boolean extend) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement setComment(String comment) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementExt.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementExt.java similarity index 95% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementExt.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementExt.java index fb7b57bc..10f68e53 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementExt.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementExt.java @@ -1,21 +1,21 @@ -package cz.zcu.kiv.crce.webui.internal.custom; - -import cz.zcu.kiv.crce.metadata.Requirement; - -public class RequirementExt extends RequirementsWrap { - - private boolean satisfied; - - public RequirementExt(Requirement r) { - super(r); - satisfied = false; - } - - public void setSatisfied(boolean satisfied) { - this.satisfied = satisfied; - } - - public boolean getSatisfied() { - return satisfied; - } -} +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.Requirement; + +public class RequirementExt extends RequirementsWrap { + + private boolean satisfied; + + public RequirementExt(Requirement r) { + super(r); + satisfied = false; + } + + public void setSatisfied(boolean satisfied) { + this.satisfied = satisfied; + } + + public boolean getSatisfied() { + return satisfied; + } +} diff --git a/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementImpl.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementImpl.java new file mode 100644 index 00000000..57797067 --- /dev/null +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementImpl.java @@ -0,0 +1,88 @@ +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.Requirement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; + +public class RequirementImpl implements cz.zcu.kiv.crce.webui.internal.legacy.Requirement { + private static final Logger logger = LoggerFactory.getLogger(RequirementImpl.class); + + private final Requirement requirement; + + public RequirementImpl(@Nonnull Requirement requirement) { + this.requirement = requirement; + } + + @Override + public String getName() { + return requirement.getNamespace(); + } + + @Override + public String getFilter() { + return requirement.getDirective("filter"); + } + + @Override + public boolean isMultiple() { + return Boolean.valueOf(requirement.getDirective("multiple")); + } + + @Override + public boolean isOptional() { + return Boolean.valueOf(requirement.getDirective("optional")); + } + + @Override + public boolean isExtend() { + return Boolean.valueOf(requirement.getDirective("extend")); + } + + @Override + public String getComment() { + return requirement.getDirective("comment"); + } + + @Override + public boolean isWritable() { + return true; + } + + @Override + public boolean isSatisfied(cz.zcu.kiv.crce.webui.internal.legacy.Capability capability) { + logger.warn("Method isSatisfied is not supported by new Metadata API, returning false for Capability: {}, Requirement: {}", capability, requirement); + return false; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Requirement setFilter(String filter) { + requirement.setDirective("filter", filter); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Requirement setMultiple(boolean multiple) { + requirement.setDirective("multiple", String.valueOf(multiple)); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Requirement setOptional(boolean optional) { + requirement.setDirective("optional", String.valueOf(optional)); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Requirement setExtend(boolean extend) { + requirement.setDirective("extend", String.valueOf(extend)); + return this; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Requirement setComment(String comment) { + requirement.setDirective("comment", String.valueOf(comment)); + return this; + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementsWrap.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementsWrap.java similarity index 95% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementsWrap.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementsWrap.java index a87d1338..2dec5c03 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementsWrap.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/RequirementsWrap.java @@ -1,42 +1,42 @@ -package cz.zcu.kiv.crce.webui.internal.custom; - -import cz.zcu.kiv.crce.metadata.Requirement; - -public class RequirementsWrap extends RequirementAdapter { - - protected Requirement requirement; - - public RequirementsWrap(Requirement r) { - this.requirement = r; - } - - @Override - public String getName() { - return requirement.getNamespace(); - } - - @Override - public String getFilter() { - return requirement.getDirective("filter"); // TODO filter is not supported yet - } - - @Override - public boolean isExtend() { - return Boolean.valueOf(requirement.getDirective("extend")); - } - - @Override - public boolean isMultiple() { - return Boolean.valueOf(requirement.getDirective("multiple")); - } - - @Override - public boolean isOptional() { - return Boolean.valueOf(requirement.getDirective("optional")); - } - - @Override - public boolean isWritable() { - return true; - } -} +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.Requirement; + +public class RequirementsWrap extends RequirementAdapter { + + protected Requirement requirement; + + public RequirementsWrap(Requirement r) { + this.requirement = r; + } + + @Override + public String getName() { + return requirement.getNamespace(); + } + + @Override + public String getFilter() { + return requirement.getDirective("filter"); // TODO filter is not supported yet + } + + @Override + public boolean isExtend() { + return Boolean.valueOf(requirement.getDirective("extend")); + } + + @Override + public boolean isMultiple() { + return Boolean.valueOf(requirement.getDirective("multiple")); + } + + @Override + public boolean isOptional() { + return Boolean.valueOf(requirement.getDirective("optional")); + } + + @Override + public boolean isWritable() { + return true; + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceAdapter.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceAdapter.java similarity index 94% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceAdapter.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceAdapter.java index 47e4e54d..b7f8f204 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceAdapter.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceAdapter.java @@ -1,341 +1,341 @@ -package cz.zcu.kiv.crce.webui.internal.custom; - -import java.net.URI; -import java.net.URL; -import java.util.Map; -import java.util.Set; - -import cz.zcu.kiv.crce.metadata.type.Version; - -import cz.zcu.kiv.crce.webui.internal.legacy.Capability; -import cz.zcu.kiv.crce.webui.internal.legacy.NewProperty; -import cz.zcu.kiv.crce.webui.internal.legacy.Property; -import cz.zcu.kiv.crce.webui.internal.legacy.Requirement; -import cz.zcu.kiv.crce.webui.internal.legacy.Resource; -import cz.zcu.kiv.crce.webui.internal.legacy.Type; - -public class ResourceAdapter implements Resource { - - @Override - public Property[] getProperties() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Property getProperty(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPropertyString(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(Property property) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, String value, Type type) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, String string) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, Version version) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, URL url) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, URI uri) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, long llong) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, double ddouble) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource setProperty(String name, Set values) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource unsetProperty(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getId() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getSymbolicName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Version getVersion() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getPresentationName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public URI getUri() { - // TODO Auto-generated method stub - return null; - } - - @Override - public URI getRelativeUri() { - // TODO Auto-generated method stub - return null; - } - - @Override - public NewProperty[] getNewProperties() { - // TODO Auto-generated method stub - return null; - } - - @Override - public long getSize() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String[] getCategories() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Capability[] getCapabilities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Capability[] getCapabilities(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement[] getRequirements() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement[] getRequirements(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Map getPropertiesMap() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean hasCategory(String category) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean hasCapability(Capability capability) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean hasRequirement(Requirement requirement) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void setSymbolicName(String name) { - // TODO Auto-generated method stub - - } - - @Override - public void setSymbolicName(String name, boolean isStatic) { - // TODO Auto-generated method stub - - } - - @Override - public void setPresentationName(String name) { - // TODO Auto-generated method stub - - } - - @Override - public void setVersion(Version version) { - // TODO Auto-generated method stub - - } - - @Override - public void setVersion(Version version, boolean isStatic) { - // TODO Auto-generated method stub - - } - - @Override - public void setVersion(String version) { - // TODO Auto-generated method stub - - } - - @Override - public void setVersion(String version, boolean isStatic) { - // TODO Auto-generated method stub - - } - - @Override - public void addCategory(String category) { - // TODO Auto-generated method stub - - } - - @Override - public void addCapability(Capability capability) { - // TODO Auto-generated method stub - - } - - @Override - public void addRequirement(Requirement requirement) { - // TODO Auto-generated method stub - - } - - @Override - public Capability createCapability(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Requirement createRequirement(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void unsetCategory(String category) { - // TODO Auto-generated method stub - - } - - @Override - public void unsetCapability(Capability capability) { - // TODO Auto-generated method stub - - } - - @Override - public void unsetRequirement(Requirement requirement) { - // TODO Auto-generated method stub - - } - - @Override - public void setSize(long size) { - // TODO Auto-generated method stub - - } - - @Override - public void setUri(URI uri) { - // TODO Auto-generated method stub - - } - - @Override - public boolean isWritable() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void unsetWritable() { - // TODO Auto-generated method stub - - } - - @Override - public boolean isVersionStatic() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isSymbolicNameStatic() { - // TODO Auto-generated method stub - return false; - } - - @Override - public String asString() { - // TODO Auto-generated method stub - return null; - } - -// @Override -// public Repository getRepository() { -// // TODO Auto-generated method stub -// return null; -// } -// -// @Override -// public void setRepository(WritableRepository repository) { -// // TODO Auto-generated method stub -// } -} +package cz.zcu.kiv.crce.webui.internal.custom; + +import java.net.URI; +import java.net.URL; +import java.util.Map; +import java.util.Set; + +import cz.zcu.kiv.crce.metadata.type.Version; + +import cz.zcu.kiv.crce.webui.internal.legacy.Capability; +import cz.zcu.kiv.crce.webui.internal.legacy.NewProperty; +import cz.zcu.kiv.crce.webui.internal.legacy.Property; +import cz.zcu.kiv.crce.webui.internal.legacy.Requirement; +import cz.zcu.kiv.crce.webui.internal.legacy.Resource; +import cz.zcu.kiv.crce.webui.internal.legacy.Type; + +public class ResourceAdapter implements Resource { + + @Override + public Property[] getProperties() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Property getProperty(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getPropertyString(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(Property property) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, String value, Type type) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, String string) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, Version version) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, URL url) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, URI uri) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, long llong) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, double ddouble) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource setProperty(String name, Set values) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Resource unsetProperty(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getSymbolicName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Version getVersion() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getPresentationName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public URI getUri() { + // TODO Auto-generated method stub + return null; + } + + @Override + public URI getRelativeUri() { + // TODO Auto-generated method stub + return null; + } + + @Override + public NewProperty[] getNewProperties() { + // TODO Auto-generated method stub + return null; + } + + @Override + public long getSize() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public String[] getCategories() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Capability[] getCapabilities() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Capability[] getCapabilities(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement[] getRequirements() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement[] getRequirements(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map getPropertiesMap() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasCategory(String category) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean hasCapability(Capability capability) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean hasRequirement(Requirement requirement) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setSymbolicName(String name) { + // TODO Auto-generated method stub + + } + + @Override + public void setSymbolicName(String name, boolean isStatic) { + // TODO Auto-generated method stub + + } + + @Override + public void setPresentationName(String name) { + // TODO Auto-generated method stub + + } + + @Override + public void setVersion(Version version) { + // TODO Auto-generated method stub + + } + + @Override + public void setVersion(Version version, boolean isStatic) { + // TODO Auto-generated method stub + + } + + @Override + public void setVersion(String version) { + // TODO Auto-generated method stub + + } + + @Override + public void setVersion(String version, boolean isStatic) { + // TODO Auto-generated method stub + + } + + @Override + public void addCategory(String category) { + // TODO Auto-generated method stub + + } + + @Override + public void addCapability(Capability capability) { + // TODO Auto-generated method stub + + } + + @Override + public void addRequirement(Requirement requirement) { + // TODO Auto-generated method stub + + } + + @Override + public Capability createCapability(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Requirement createRequirement(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void unsetCategory(String category) { + // TODO Auto-generated method stub + + } + + @Override + public void unsetCapability(Capability capability) { + // TODO Auto-generated method stub + + } + + @Override + public void unsetRequirement(Requirement requirement) { + // TODO Auto-generated method stub + + } + + @Override + public void setSize(long size) { + // TODO Auto-generated method stub + + } + + @Override + public void setUri(URI uri) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isWritable() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void unsetWritable() { + // TODO Auto-generated method stub + + } + + @Override + public boolean isVersionStatic() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isSymbolicNameStatic() { + // TODO Auto-generated method stub + return false; + } + + @Override + public String asString() { + // TODO Auto-generated method stub + return null; + } + +// @Override +// public Repository getRepository() { +// // TODO Auto-generated method stub +// return null; +// } +// +// @Override +// public void setRepository(WritableRepository repository) { +// // TODO Auto-generated method stub +// } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceExt.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceExt.java similarity index 96% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceExt.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceExt.java index c5e991c0..8229291b 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceExt.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceExt.java @@ -1,45 +1,45 @@ -package cz.zcu.kiv.crce.webui.internal.custom; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import cz.zcu.kiv.crce.metadata.Resource; -import cz.zcu.kiv.crce.metadata.service.MetadataService; - -public class ResourceExt extends ResourceWrap { - - private static final Logger logger = LoggerFactory.getLogger(ResourceExt.class); - - private boolean satisfied; - - public ResourceExt(Resource r, MetadataService metadataService) { - super(r, metadataService); - this.satisfied = true; - } - - public boolean getSatisfied() { - return satisfied; - } - - @Override - public void addRequirement(cz.zcu.kiv.crce.webui.internal.legacy.Requirement requirement) { - satisfied = false; - logger.warn("Adding legacy requirements is not supported yet with new Metadata API: {}", requirement); // TODO fix functionality -// resource.unsetRequirement(requirement); -// RequirementExt rext = new RequirementExt(requirement); -// resource.addRequirement(rext); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof cz.zcu.kiv.crce.webui.internal.legacy.Resource) { - return this.getUri().equals(((cz.zcu.kiv.crce.webui.internal.legacy.Resource) obj).getUri()); - } - return super.equals(obj); - } - - @Override - public int hashCode() { - return resource.hashCode(); - } -} +package cz.zcu.kiv.crce.webui.internal.custom; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cz.zcu.kiv.crce.metadata.Resource; +import cz.zcu.kiv.crce.metadata.service.MetadataService; + +public class ResourceExt extends ResourceWrap { + + private static final Logger logger = LoggerFactory.getLogger(ResourceExt.class); + + private boolean satisfied; + + public ResourceExt(Resource r, MetadataService metadataService) { + super(r, metadataService); + this.satisfied = true; + } + + public boolean getSatisfied() { + return satisfied; + } + + @Override + public void addRequirement(cz.zcu.kiv.crce.webui.internal.legacy.Requirement requirement) { + satisfied = false; + logger.warn("Adding legacy requirements is not supported yet with new Metadata API: {}", requirement); // TODO fix functionality +// resource.unsetRequirement(requirement); +// RequirementExt rext = new RequirementExt(requirement); +// resource.addRequirement(rext); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof cz.zcu.kiv.crce.webui.internal.legacy.Resource) { + return this.getUri().equals(((cz.zcu.kiv.crce.webui.internal.legacy.Resource) obj).getUri()); + } + return super.equals(obj); + } + + @Override + public int hashCode() { + return resource.hashCode(); + } +} diff --git a/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceWrap.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceWrap.java new file mode 100644 index 00000000..4cc59615 --- /dev/null +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/custom/ResourceWrap.java @@ -0,0 +1,127 @@ +package cz.zcu.kiv.crce.webui.internal.custom; + +import cz.zcu.kiv.crce.metadata.*; +import cz.zcu.kiv.crce.metadata.impl.SimpleAttributeType; +import cz.zcu.kiv.crce.metadata.service.MetadataService; +import cz.zcu.kiv.crce.metadata.type.Version; +import cz.zcu.kiv.crce.webui.internal.legacy.NewProperty; + +import java.net.URI; +import java.util.Collections; +import java.util.List; + +abstract class ResourceWrap extends ResourceAdapter { + + // loose coupling with crce-metadata-osgi-bundle module + private static final String OSG_IDENTITY_NAMESPACE = "osgi.identity"; + private static final AttributeType ATTRIBUTE_SYMBOLIC_NAME = new SimpleAttributeType<>("symbolic-name", String.class); + public static final AttributeType ATTRIBUTE_VERSION = new SimpleAttributeType<>(org.apache.felix.bundlerepository.Resource.VERSION, Version.class); + + protected Resource resource; + private final MetadataService metadataService; + + protected ResourceWrap(Resource r, MetadataService metadataService) { + this.resource = r; + this.metadataService = metadataService; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Property[] getProperties() { + cz.zcu.kiv.crce.webui.internal.legacy.Property[] properties; + List crceCapabilities = Collections.singletonList(metadataService.getIdentity(resource)); + + int crceSize = crceCapabilities.isEmpty() ? 0 : crceCapabilities.get(0).getAttributes().size(); + + properties = new cz.zcu.kiv.crce.webui.internal.legacy.Property[crceSize]; + int i = 0; + if (crceSize > 0) { + for (Attribute> atr : crceCapabilities.get(0).getAttributes()) { + properties[i++] = new PropertyImpl(atr); + } + } + return properties; + } + + @Override + public NewProperty[] getNewProperties() { + List extends Property> newProperties = resource.getProperties(); + NewProperty[] properties = new NewProperty[newProperties.size()]; + int i = 0; + for (Property newProperty : newProperties) { + properties[i++] = new NewPropertyImpl(newProperty); + } + return properties; + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Capability[] getCapabilities() { + List capabilities = resource.getCapabilities(); + cz.zcu.kiv.crce.webui.internal.legacy.Capability[] result = new cz.zcu.kiv.crce.webui.internal.legacy.Capability[capabilities.size()]; + int i = 0; + for (Capability capability : capabilities) { + result[i++] = new CapabilityImpl(capability); + } + return result; + } + + @Override + public String[] getCategories() { + return metadataService.getCategories(resource).toArray(new String[0]); + } + + @Override + public cz.zcu.kiv.crce.webui.internal.legacy.Requirement[] getRequirements() { + List requirements = resource.getRequirements(); + cz.zcu.kiv.crce.webui.internal.legacy.Requirement[] result = new cz.zcu.kiv.crce.webui.internal.legacy.Requirement[requirements.size()]; + int i = 0; + for (Requirement requirement : requirements) { + result[i++] = new RequirementImpl(requirement); + } + return result; + } + + @Override + public String getSymbolicName() { + String name = "unknown-symbolic-name"; + List capabilities = resource.getCapabilities(OSG_IDENTITY_NAMESPACE); + if (!capabilities.isEmpty()) { + name = capabilities.get(0).getAttributeValue(ATTRIBUTE_SYMBOLIC_NAME); + } + return name; + } + + @Override + public String getId() { + return resource.getId(); + } + + @Override + public Version getVersion() { + Version version = null; + List capabilities = resource.getCapabilities(OSG_IDENTITY_NAMESPACE); + if (!capabilities.isEmpty()) { + version = capabilities.get(0).getAttributeValue(ATTRIBUTE_VERSION); + } + return version; + } + + @Override + public String getPresentationName() { + return metadataService.getPresentationName(resource); + } + + @Override + public URI getUri() { + return metadataService.getUri(resource); + } + + @Override + public URI getRelativeUri() { + return metadataService.getUri(resource); + } + + @Override + public long getSize() { + return metadataService.getSize(resource); + } +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/filter/CompatibilityAvailabilityFilter.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/filter/CompatibilityAvailabilityFilter.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/filter/CompatibilityAvailabilityFilter.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/filter/CompatibilityAvailabilityFilter.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Capability.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Capability.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Capability.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Capability.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/NewProperty.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/NewProperty.java similarity index 96% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/NewProperty.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/NewProperty.java index 1f2b5e1d..c989b1d2 100644 --- a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/NewProperty.java +++ b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/NewProperty.java @@ -1,13 +1,13 @@ -package cz.zcu.kiv.crce.webui.internal.legacy; - -/** - * A property that can be set to a Resource or a Capability. - * - * This Property corresponds to cz.zcu.kiv.crce.metadata.Property - * - * @author Jan Smajcl (smajcl@students.zcu.cz) - */ -public interface NewProperty extends PropertyProvider { - - String getName(); -} +package cz.zcu.kiv.crce.webui.internal.legacy; + +/** + * A property that can be set to a Resource or a Capability. + * + * This Property corresponds to cz.zcu.kiv.crce.metadata.Property + * + * @author Jan Smajcl (smajcl@students.zcu.cz) + */ +public interface NewProperty extends PropertyProvider { + + String getName(); +} diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Property.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Property.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Property.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Property.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/PropertyProvider.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/PropertyProvider.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/PropertyProvider.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/PropertyProvider.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Requirement.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Requirement.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Requirement.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Requirement.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Resource.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Resource.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Resource.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Resource.java diff --git a/modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Type.java b/core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Type.java similarity index 100% rename from modules/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Type.java rename to core/crce-webui/src/main/java/cz/zcu/kiv/crce/webui/internal/legacy/Type.java diff --git a/modules/crce-webui/src/main/webapp/META-INF/MANIFEST.MF b/core/crce-webui/src/main/webapp/META-INF/MANIFEST.MF similarity index 92% rename from modules/crce-webui/src/main/webapp/META-INF/MANIFEST.MF rename to core/crce-webui/src/main/webapp/META-INF/MANIFEST.MF index 5e949512..254272e1 100644 --- a/modules/crce-webui/src/main/webapp/META-INF/MANIFEST.MF +++ b/core/crce-webui/src/main/webapp/META-INF/MANIFEST.MF @@ -1,3 +1,3 @@ -Manifest-Version: 1.0 -Class-Path: - +Manifest-Version: 1.0 +Class-Path: + diff --git a/modules/crce-webui/src/main/webapp/WEB-INF/web.xml b/core/crce-webui/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from modules/crce-webui/src/main/webapp/WEB-INF/web.xml rename to core/crce-webui/src/main/webapp/WEB-INF/web.xml diff --git a/modules/crce-webui/src/main/webapp/crce.png b/core/crce-webui/src/main/webapp/crce.png similarity index 100% rename from modules/crce-webui/src/main/webapp/crce.png rename to core/crce-webui/src/main/webapp/crce.png diff --git a/modules/crce-webui/src/main/webapp/css/styl.css b/core/crce-webui/src/main/webapp/css/styl.css similarity index 94% rename from modules/crce-webui/src/main/webapp/css/styl.css rename to core/crce-webui/src/main/webapp/css/styl.css index 7d9d8879..c19c4c94 100644 --- a/modules/crce-webui/src/main/webapp/css/styl.css +++ b/core/crce-webui/src/main/webapp/css/styl.css @@ -1,612 +1,612 @@ -/* CSS Document */ - -body { - margin: 0 auto; - text-align: center; - font-family: Verdana; -} - -img { - border: 0; -} - -a { - color: #666; -} - -a:hover { - color: #BBB; -} - -p { - padding: 0 0 5px 15px; -} - -h2 { - color: #464A47; - padding: 0 0 0 10px; - font-size: 1.1em; - font-weight: bold; -} - -h3 { - padding: 0 0 0 15px; - font-size: 0.9em; - font-weight: normal; - color: #464A47; -} - -.konec { - clear: both; - width: 0; - visibility: hidden; - height: 0; - font-size: 0; - display: block; -} - -#stranka { - width: 902px; - margin: 0 auto; - margin-top: 20px; - border: 1px solid #AAA; -} - -/*--------------------HLAVICKA----------------------------------------*/ - -#hlavicka { - /*border: 1px solid black;*/ - width: 100%; - background: url('../graphic/hlavicka_bg.png') no-repeat; - text-align: left; - padding: 26px 0px; -} - -#hlavicka .loga_h { - height: 90px; - background: url('../graphic/hlavicka_loga.png') no-repeat; -} - -#hlavicka .logo_img { - float: left; - width: 600px; - color: red; - /*border: 1px solid black;*/ - margin: 10px 0px 0px 12px; -} - -#hlavicka .nazev { - float: left; - width: 600px; - color: #666; - font-weight: bold; - font-size: 1.6em; - /*border: 1px solid black;*/ - margin: 5px 0px 5px 12px; -} - -#hlavicka .vyhledavani { - float: right; - width: 250px; - text-align: right; - border: 1px solid black; - margin: 10px 15px 0 0; -} - -#hlavicka .vyhledavani .text { - width: 150px; - color: #222; - background-color: #EEE; - border: 1px solid #AAA; -} - -#hlavicka .vyhledavani .tlacitko { - width: 55px; - background-color: #666; - border: 1px solid #AAA; - color: #FFF; - font-weight: bold; -} - -#hlavicka .vyhledavani .tlacitko:hover { - color: #222; - background-color: #BBB; - border: 1px solid #AAA; -} - -/*--------------------MENU----------------------------------------*/ - -#menu .vyhledavani_h { - float: right; - width: 450px; - height: 24px; - /*line-height: 20px;*/ - text-align: right; - margin-right: 6px; - -} - -#menu .vyhledavani_h .text { - width: 150px; - height: 16px; - color: #565c59; - background-color: white; - border: 1px solid black; - margin-top: 2px; - -} - -#menu .vyhledavani_h .tlacitko { - width: 25px; - height: 18px; - background-color: #eeeee5; - color: black; - font-family: Verdana; - font-weight: normal; - line-height: 16px; - font-size: 8pt; -} - -#menu .vyhledavani_h .repository_selection { - width: 250px; -} - -#menu { - background: url('../graphic/menu_bg.png') repeat-x; - height: 24px; - -} - -#menu ul { - padding: 0px; - margin: 0px; - float: left; -} - -#menu li { - display: inline; - list-style: none; - padding: 0px 10px; -} - -#menu li a:link, -#menu li a:visited, -#menu li a:active, -#menu li a:hover { - - text-decoration: none; - color: white; - font-weight: bold; - font-size: 0.7em; -} - -#menu li a:hover { - text-decoration: underline; -} - -#menu li a.aktivni { - color: #c0c0a0; -} - -/* Vycisteni menu */ -.vycisteni:after { - display: block; - clear: both; - visibility: hidden; - height: 0; - font-size: 0; - content: ' '; -} - -.vycisteni { - min-height: 1px; -} - -.vycisteni { - display: inline-block; -} - -/* Backslash hack - nemel by to videt IE/Mac \*/ -.vycisteni { - display: block; -} - -/* Konec hacku */ - -/*-------------------------ZPRAVA USPECH NEUSPECH---------------------------------*/ -#zprava { - color: #FFF; - text-align: center; - width: 100%; - margin: 0 auto; - padding: 3px 0px; - font-weight: bold; - font-size: 0.7em; -} - -.uspech { - background-color: #b2c980; -} - -.neuspech { - background-color: #f86965; -} - -/*--------------------TELO----------------------------------------*/ -#telo { - width: 100%; - padding: 10px 0 10px 0; - text-align: left; - margin: 0 auto; - background-color: #EEEEE5; -} - -.pridat { - width: 880px; - margin: 0 auto; - padding: 10px 0 10px 0; -} - -.komponenta { - width: 880px; - margin: 0 auto; - border: 1px solid #AAA; - overflow: hidden; -} - -.komponenta div.nadpis { - /*border: 1px solid black;*/ - background: url('../graphic/heading-bg.png') repeat-x; - height: 21px; - line-height: 21px; - padding: 0px 10px 0px 10px; - font-weight: bold; - font-size: 0.7em; -} - -.komponenta .nadpis .popis { - width: 740px; - height: 21px; - line-height: 21px; - float: left; - border: 0px solid black; -} - -.komponenta .nadpis .popis a { - width: 100%; - /*padding: 0 0 0 10px;*/ - text-decoration: none; - - /*color: #222;*/ - /*border: 1px solid black;*/ -} - -.komponenta .nadpis .popis a:hover { - text-decoration: underline; -} - -.komponenta .nadpis:hover { - /*background-color: #777;*/ -} - -.komponenta .nadpis .popis .sName { - color: #7b847c; - font-style: italic; - margin-left: 10px; - font-size: 0.9em; -} - -.komponenta .nadpis .popis .version { - color: #464a47; - margin-left: 10px; -} - -.komponenta .nadpis .popis .version_obsah { - color: #7b847c; -} - -.komponenta .nadpis .popis .pName { - color: #464a47; - -} - -.komponenta .nadpis .popis .category { - color: #464a47; -} - -.komponenta .nadpis .popis .category_obsah { - color: #7b847c; -} - -.komponenta .nadpis .nabidka { - float: right; - text-align: right; - margin: 2px 0 0 0; - border: 0px solid black; - width: 120px; - height: 19px; - line-height: 19px; -} - -.komponenta .informace { - /*border: 1px solid black;*/ - /*background-color: #EEE;*/ - padding: 5px 10px 5px 10px; - font-size: 0.8em; -} - -.komponenta .polozka { - color: #464a47; - padding-bottom: 10px; -} - -.komponenta .polozka li { - font-size: 0.9em; -} - -.komponenta a.edit, -.edit-addnew { - text-decoration: underline; - font-size: 0.8em; - color: #464a47; -} - -.komponenta a.edit:hover, -.edit-addnew { - text-decoration: none; -} - -.komponenta .polozka .inline { - margin-bottom: 10px; -} - -.komponenta .polozka .inline li { - float: left; - padding-left: 5px; - list-style: none; -} - -.vsechnykategorie { - /*float:left;*/ - margin-bottom: 20px; -} - -.kategorie { - width: 100px; - margin: 5px 2px 2px 2px; - border: 1px solid #AAA; - overflow: hidden; - height: 21px; - line-height: 21px; - padding: 0px 10px 0px 10px; - font-weight: bold; - font-size: 0.7em; -} - -.komponenty .komponenta { - /*width: 760px;*/ -} - -.komponenty .komponenta .nadpis .popis { - /*width: 640px;*/ -} - -/*--------------------POSKYTUJE-------------------------*/ - -.poskytuje { - padding: 5px; - width: 100%; - margin: 0 auto; - -} - -.poskytuje th { - text-align: left; - font-weight: bold; - -} - -.poskytuje .text { - width: 98%; -} - -.poskytuje .jmeno { - -} - -.poskytuje .typ { - width: 90px; -} - -.poskytuje .hodnota { - max-width: 580px; - width: 580px; -} - -/*-------------------------VYZADUJE------------------------------*/ -.vyzaduje { - padding: 10px; - width: 100%; - margin: 0 auto; - font-size: 0.9em; -} - -.komponenta .vyzaduje { - padding: 0px; - width: 830px; -} - -.vyzaduje input { - width: 98%; - margin: 0 auto; -} - -.vyzaduje th { - text-align: left; - font-weight: bold; - /*background: #f5f5f1;*/ -} - -.vyzaduje .text { - width: 98%; - margin: 0 auto; -} - -.vyzaduje .tlacitko { - width: 150px; -} - -.vyzaduje .komentar { - width: 98%; - padding: 0 0 10px 0; - font-size: 0.9em; - font-style: italic; -} - -.vyzaduje .jmeno { - width: 100px; -} - -.vyzaduje .filter { - width: 600px; -} - -.vyzaduje td.req-neuspech { - color: #f86965; -} - -/*---------------ANIMACNI_ODKAZY---------------------------------------*/ -#animacni_odkazy { - width: 880px; - margin: 0 auto; - font-size: 0.8em; - padding-top: 5px; - text-align: right; - border: 0px solid black; - -} - -/*--------------------PATICKA----------------------------------------*/ -#paticka { - padding-top: 3px; - width: 904px; - font-size: 0.6em; - margin: 0 auto; - /*border: 1px solid black;*/ - background-color: #EEE; - color: #333; -} - -/*-------------TLACITKO----------------------------------------------*/ - -.tlacitko { - text-align: center; - /*background-color: #666;*/ - background: #ddddca; - /*border: 1px solid #AAA;*/ - border: 1px solid #c8b8b5; - color: #000; - font-size: 0.8em; - -} - -.tlacitko:hover { - /*color: #222;*/ - background-color: #FFF; -} - -div.tlac { - float: left; - margin-right: 5px; -} - -/*----------------UPLOAD---------------------------------------------*/ - -div.upload { - background-color: #999; - margin-bottom: 10px; - padding: 5px; -} - -table.upload { - - /*width: 880px;*/ - /*margin: 0 auto;*/ - -} - -.upload td { - text-align: left; - width: 100%; -} - -.upload .text { - width: 400px; - color: #222; - background-color: #FFF; - border: 1px solid #AAA; -} - -.upload .tlacitko { - /*width: 200px;*/ - font-size: 0.8em; -} - -/*--------------------FORMULAR----------------------------------------*/ - -.formular { - padding: 10px; - width: 100%; - text-align: left; - -} - -.formular th { - font-weight: bold; - font-size: 0.8em; - color: #464a47; -} - -.formular td { - text-align: left; - margin: 0 auto; -} - -.formular .text { - width: 500px; - color: #222; - background-color: #FFF; - border: 1px solid #AAA; -} - -.formular .chyba { - color: red; - font-weight: bold; - padding: 0 10px 0 10px; -} - -.formular .tlacitko { - margin: 10px 0 0 0; -} - -.formy th { - font-size: 0.8em; - color: #464a47; -} - -.categorie-edit-ul li { - font-size: 0.8em; - color: #464a47; - -} - -/*-----------------EXECUTE_COMMIT-------------------------*/ - -.execute_commit .tlacitko { - margin: 0 0 10px 10px; -} - -/*------------------COMPATIBILITY-------------------------*/ -.pivot { - background-color: #FCFC55; +/* CSS Document */ + +body { + margin: 0 auto; + text-align: center; + font-family: Verdana; +} + +img { + border: 0; +} + +a { + color: #666; +} + +a:hover { + color: #BBB; +} + +p { + padding: 0 0 5px 15px; +} + +h2 { + color: #464A47; + padding: 0 0 0 10px; + font-size: 1.1em; + font-weight: bold; +} + +h3 { + padding: 0 0 0 15px; + font-size: 0.9em; + font-weight: normal; + color: #464A47; +} + +.konec { + clear: both; + width: 0; + visibility: hidden; + height: 0; + font-size: 0; + display: block; +} + +#stranka { + width: 902px; + margin: 0 auto; + margin-top: 20px; + border: 1px solid #AAA; +} + +/*--------------------HLAVICKA----------------------------------------*/ + +#hlavicka { + /*border: 1px solid black;*/ + width: 100%; + background: url('../graphic/hlavicka_bg.png') no-repeat; + text-align: left; + padding: 26px 0px; +} + +#hlavicka .loga_h { + height: 90px; + background: url('../graphic/hlavicka_loga.png') no-repeat; +} + +#hlavicka .logo_img { + float: left; + width: 600px; + color: red; + /*border: 1px solid black;*/ + margin: 10px 0px 0px 12px; +} + +#hlavicka .nazev { + float: left; + width: 600px; + color: #666; + font-weight: bold; + font-size: 1.6em; + /*border: 1px solid black;*/ + margin: 5px 0px 5px 12px; +} + +#hlavicka .vyhledavani { + float: right; + width: 250px; + text-align: right; + border: 1px solid black; + margin: 10px 15px 0 0; +} + +#hlavicka .vyhledavani .text { + width: 150px; + color: #222; + background-color: #EEE; + border: 1px solid #AAA; +} + +#hlavicka .vyhledavani .tlacitko { + width: 55px; + background-color: #666; + border: 1px solid #AAA; + color: #FFF; + font-weight: bold; +} + +#hlavicka .vyhledavani .tlacitko:hover { + color: #222; + background-color: #BBB; + border: 1px solid #AAA; +} + +/*--------------------MENU----------------------------------------*/ + +#menu .vyhledavani_h { + float: right; + width: 450px; + height: 24px; + /*line-height: 20px;*/ + text-align: right; + margin-right: 6px; + +} + +#menu .vyhledavani_h .text { + width: 150px; + height: 16px; + color: #565c59; + background-color: white; + border: 1px solid black; + margin-top: 2px; + +} + +#menu .vyhledavani_h .tlacitko { + width: 25px; + height: 18px; + background-color: #eeeee5; + color: black; + font-family: Verdana; + font-weight: normal; + line-height: 16px; + font-size: 8pt; +} + +#menu .vyhledavani_h .repository_selection { + width: 250px; +} + +#menu { + background: url('../graphic/menu_bg.png') repeat-x; + height: 24px; + +} + +#menu ul { + padding: 0px; + margin: 0px; + float: left; +} + +#menu li { + display: inline; + list-style: none; + padding: 0px 10px; +} + +#menu li a:link, +#menu li a:visited, +#menu li a:active, +#menu li a:hover { + + text-decoration: none; + color: white; + font-weight: bold; + font-size: 0.7em; +} + +#menu li a:hover { + text-decoration: underline; +} + +#menu li a.aktivni { + color: #c0c0a0; +} + +/* Vycisteni menu */ +.vycisteni:after { + display: block; + clear: both; + visibility: hidden; + height: 0; + font-size: 0; + content: ' '; +} + +.vycisteni { + min-height: 1px; +} + +.vycisteni { + display: inline-block; +} + +/* Backslash hack - nemel by to videt IE/Mac \*/ +.vycisteni { + display: block; +} + +/* Konec hacku */ + +/*-------------------------ZPRAVA USPECH NEUSPECH---------------------------------*/ +#zprava { + color: #FFF; + text-align: center; + width: 100%; + margin: 0 auto; + padding: 3px 0px; + font-weight: bold; + font-size: 0.7em; +} + +.uspech { + background-color: #b2c980; +} + +.neuspech { + background-color: #f86965; +} + +/*--------------------TELO----------------------------------------*/ +#telo { + width: 100%; + padding: 10px 0 10px 0; + text-align: left; + margin: 0 auto; + background-color: #EEEEE5; +} + +.pridat { + width: 880px; + margin: 0 auto; + padding: 10px 0 10px 0; +} + +.komponenta { + width: 880px; + margin: 0 auto; + border: 1px solid #AAA; + overflow: hidden; +} + +.komponenta div.nadpis { + /*border: 1px solid black;*/ + background: url('../graphic/heading-bg.png') repeat-x; + height: 21px; + line-height: 21px; + padding: 0px 10px 0px 10px; + font-weight: bold; + font-size: 0.7em; +} + +.komponenta .nadpis .popis { + width: 740px; + height: 21px; + line-height: 21px; + float: left; + border: 0px solid black; +} + +.komponenta .nadpis .popis a { + width: 100%; + /*padding: 0 0 0 10px;*/ + text-decoration: none; + + /*color: #222;*/ + /*border: 1px solid black;*/ +} + +.komponenta .nadpis .popis a:hover { + text-decoration: underline; +} + +.komponenta .nadpis:hover { + /*background-color: #777;*/ +} + +.komponenta .nadpis .popis .sName { + color: #7b847c; + font-style: italic; + margin-left: 10px; + font-size: 0.9em; +} + +.komponenta .nadpis .popis .version { + color: #464a47; + margin-left: 10px; +} + +.komponenta .nadpis .popis .version_obsah { + color: #7b847c; +} + +.komponenta .nadpis .popis .pName { + color: #464a47; + +} + +.komponenta .nadpis .popis .category { + color: #464a47; +} + +.komponenta .nadpis .popis .category_obsah { + color: #7b847c; +} + +.komponenta .nadpis .nabidka { + float: right; + text-align: right; + margin: 2px 0 0 0; + border: 0px solid black; + width: 120px; + height: 19px; + line-height: 19px; +} + +.komponenta .informace { + /*border: 1px solid black;*/ + /*background-color: #EEE;*/ + padding: 5px 10px 5px 10px; + font-size: 0.8em; +} + +.komponenta .polozka { + color: #464a47; + padding-bottom: 10px; +} + +.komponenta .polozka li { + font-size: 0.9em; +} + +.komponenta a.edit, +.edit-addnew { + text-decoration: underline; + font-size: 0.8em; + color: #464a47; +} + +.komponenta a.edit:hover, +.edit-addnew { + text-decoration: none; +} + +.komponenta .polozka .inline { + margin-bottom: 10px; +} + +.komponenta .polozka .inline li { + float: left; + padding-left: 5px; + list-style: none; +} + +.vsechnykategorie { + /*float:left;*/ + margin-bottom: 20px; +} + +.kategorie { + width: 100px; + margin: 5px 2px 2px 2px; + border: 1px solid #AAA; + overflow: hidden; + height: 21px; + line-height: 21px; + padding: 0px 10px 0px 10px; + font-weight: bold; + font-size: 0.7em; +} + +.komponenty .komponenta { + /*width: 760px;*/ +} + +.komponenty .komponenta .nadpis .popis { + /*width: 640px;*/ +} + +/*--------------------POSKYTUJE-------------------------*/ + +.poskytuje { + padding: 5px; + width: 100%; + margin: 0 auto; + +} + +.poskytuje th { + text-align: left; + font-weight: bold; + +} + +.poskytuje .text { + width: 98%; +} + +.poskytuje .jmeno { + +} + +.poskytuje .typ { + width: 90px; +} + +.poskytuje .hodnota { + max-width: 580px; + width: 580px; +} + +/*-------------------------VYZADUJE------------------------------*/ +.vyzaduje { + padding: 10px; + width: 100%; + margin: 0 auto; + font-size: 0.9em; +} + +.komponenta .vyzaduje { + padding: 0px; + width: 830px; +} + +.vyzaduje input { + width: 98%; + margin: 0 auto; +} + +.vyzaduje th { + text-align: left; + font-weight: bold; + /*background: #f5f5f1;*/ +} + +.vyzaduje .text { + width: 98%; + margin: 0 auto; +} + +.vyzaduje .tlacitko { + width: 150px; +} + +.vyzaduje .komentar { + width: 98%; + padding: 0 0 10px 0; + font-size: 0.9em; + font-style: italic; +} + +.vyzaduje .jmeno { + width: 100px; +} + +.vyzaduje .filter { + width: 600px; +} + +.vyzaduje td.req-neuspech { + color: #f86965; +} + +/*---------------ANIMACNI_ODKAZY---------------------------------------*/ +#animacni_odkazy { + width: 880px; + margin: 0 auto; + font-size: 0.8em; + padding-top: 5px; + text-align: right; + border: 0px solid black; + +} + +/*--------------------PATICKA----------------------------------------*/ +#paticka { + padding-top: 3px; + width: 904px; + font-size: 0.6em; + margin: 0 auto; + /*border: 1px solid black;*/ + background-color: #EEE; + color: #333; +} + +/*-------------TLACITKO----------------------------------------------*/ + +.tlacitko { + text-align: center; + /*background-color: #666;*/ + background: #ddddca; + /*border: 1px solid #AAA;*/ + border: 1px solid #c8b8b5; + color: #000; + font-size: 0.8em; + +} + +.tlacitko:hover { + /*color: #222;*/ + background-color: #FFF; +} + +div.tlac { + float: left; + margin-right: 5px; +} + +/*----------------UPLOAD---------------------------------------------*/ + +div.upload { + background-color: #999; + margin-bottom: 10px; + padding: 5px; +} + +table.upload { + + /*width: 880px;*/ + /*margin: 0 auto;*/ + +} + +.upload td { + text-align: left; + width: 100%; +} + +.upload .text { + width: 400px; + color: #222; + background-color: #FFF; + border: 1px solid #AAA; +} + +.upload .tlacitko { + /*width: 200px;*/ + font-size: 0.8em; +} + +/*--------------------FORMULAR----------------------------------------*/ + +.formular { + padding: 10px; + width: 100%; + text-align: left; + +} + +.formular th { + font-weight: bold; + font-size: 0.8em; + color: #464a47; +} + +.formular td { + text-align: left; + margin: 0 auto; +} + +.formular .text { + width: 500px; + color: #222; + background-color: #FFF; + border: 1px solid #AAA; +} + +.formular .chyba { + color: red; + font-weight: bold; + padding: 0 10px 0 10px; +} + +.formular .tlacitko { + margin: 10px 0 0 0; +} + +.formy th { + font-size: 0.8em; + color: #464a47; +} + +.categorie-edit-ul li { + font-size: 0.8em; + color: #464a47; + +} + +/*-----------------EXECUTE_COMMIT-------------------------*/ + +.execute_commit .tlacitko { + margin: 0 0 10px 10px; +} + +/*------------------COMPATIBILITY-------------------------*/ +.pivot { + background-color: #FCFC55; } \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/graphic/add.png b/core/crce-webui/src/main/webapp/graphic/add.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/add.png rename to core/crce-webui/src/main/webapp/graphic/add.png diff --git a/modules/crce-webui/src/main/webapp/graphic/check.png b/core/crce-webui/src/main/webapp/graphic/check.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/check.png rename to core/crce-webui/src/main/webapp/graphic/check.png diff --git a/modules/crce-webui/src/main/webapp/graphic/commit.png b/core/crce-webui/src/main/webapp/graphic/commit.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/commit.png rename to core/crce-webui/src/main/webapp/graphic/commit.png diff --git a/modules/crce-webui/src/main/webapp/graphic/crce.png b/core/crce-webui/src/main/webapp/graphic/crce.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/crce.png rename to core/crce-webui/src/main/webapp/graphic/crce.png diff --git a/modules/crce-webui/src/main/webapp/graphic/del.png b/core/crce-webui/src/main/webapp/graphic/del.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/del.png rename to core/crce-webui/src/main/webapp/graphic/del.png diff --git a/modules/crce-webui/src/main/webapp/graphic/edit.png b/core/crce-webui/src/main/webapp/graphic/edit.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/edit.png rename to core/crce-webui/src/main/webapp/graphic/edit.png diff --git a/modules/crce-webui/src/main/webapp/graphic/heading-bg.png b/core/crce-webui/src/main/webapp/graphic/heading-bg.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/heading-bg.png rename to core/crce-webui/src/main/webapp/graphic/heading-bg.png diff --git a/modules/crce-webui/src/main/webapp/graphic/hlavicka_bg.png b/core/crce-webui/src/main/webapp/graphic/hlavicka_bg.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/hlavicka_bg.png rename to core/crce-webui/src/main/webapp/graphic/hlavicka_bg.png diff --git a/modules/crce-webui/src/main/webapp/graphic/hlavicka_loga.png b/core/crce-webui/src/main/webapp/graphic/hlavicka_loga.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/hlavicka_loga.png rename to core/crce-webui/src/main/webapp/graphic/hlavicka_loga.png diff --git a/modules/crce-webui/src/main/webapp/graphic/logo.png b/core/crce-webui/src/main/webapp/graphic/logo.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/logo.png rename to core/crce-webui/src/main/webapp/graphic/logo.png diff --git a/modules/crce-webui/src/main/webapp/graphic/menu_bg.png b/core/crce-webui/src/main/webapp/graphic/menu_bg.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/menu_bg.png rename to core/crce-webui/src/main/webapp/graphic/menu_bg.png diff --git a/modules/crce-webui/src/main/webapp/graphic/save.png b/core/crce-webui/src/main/webapp/graphic/save.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/save.png rename to core/crce-webui/src/main/webapp/graphic/save.png diff --git a/modules/crce-webui/src/main/webapp/graphic/zoom.png b/core/crce-webui/src/main/webapp/graphic/zoom.png similarity index 100% rename from modules/crce-webui/src/main/webapp/graphic/zoom.png rename to core/crce-webui/src/main/webapp/graphic/zoom.png diff --git a/modules/crce-webui/src/main/webapp/index.jsp b/core/crce-webui/src/main/webapp/index.jsp similarity index 95% rename from modules/crce-webui/src/main/webapp/index.jsp rename to core/crce-webui/src/main/webapp/index.jsp index d2d4d35d..778705d7 100644 --- a/modules/crce-webui/src/main/webapp/index.jsp +++ b/core/crce-webui/src/main/webapp/index.jsp @@ -4,19 +4,15 @@ Author : kalwi --%> -<%@page import="cz.zcu.kiv.crce.metadata.Attribute"%> -<%@page import="java.util.List"%> +<%@page import="cz.zcu.kiv.crce.metadata.*"%> +<%@page import="cz.zcu.kiv.crce.plugin.Plugin"%> <% response.sendRedirect("resource"); %> -<%@page import="cz.zcu.kiv.crce.plugin.Plugin"%> -<%@page import="cz.zcu.kiv.crce.metadata.Requirement"%> -<%@page import="cz.zcu.kiv.crce.metadata.Property"%> -<%@page import="cz.zcu.kiv.crce.metadata.Capability"%> <%@page import="cz.zcu.kiv.crce.repository.Buffer"%> <%@page import="cz.zcu.kiv.crce.webui.internal.Activator"%> -<%@page import="cz.zcu.kiv.crce.metadata.Resource"%> +<%@page import="java.util.List"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> diff --git a/modules/crce-webui/src/main/webapp/js/jquery-1.5.1.js b/core/crce-webui/src/main/webapp/js/jquery-1.5.1.js similarity index 100% rename from modules/crce-webui/src/main/webapp/js/jquery-1.5.1.js rename to core/crce-webui/src/main/webapp/js/jquery-1.5.1.js diff --git a/modules/crce-webui/src/main/webapp/js/plus_minus_form.js b/core/crce-webui/src/main/webapp/js/plus_minus_form.js similarity index 96% rename from modules/crce-webui/src/main/webapp/js/plus_minus_form.js rename to core/crce-webui/src/main/webapp/js/plus_minus_form.js index 535f5fdf..53d96e75 100644 --- a/modules/crce-webui/src/main/webapp/js/plus_minus_form.js +++ b/core/crce-webui/src/main/webapp/js/plus_minus_form.js @@ -1,49 +1,49 @@ -var element_id = 2; - -function plus() { - var x = document.getElementById('options'); - - var name = document.createElement('input'); - name.setAttribute('name', 'name_' + element_id ); - name.setAttribute('type', 'text'); - - var value = document.createElement('input'); - value.setAttribute('name', 'value_' + element_id ); - value.setAttribute('class', 'text'); - value.setAttribute('type', 'text'); - - var nameText = document.createTextNode('Name: '); - var valueText = document.createTextNode('Value: '); - - var tr = document.createElement('tr'); - tr.setAttribute('id', 'option_' + element_id); - var thName = document.createElement('th'); - var thValue = document.createElement('th'); - var tdName = document.createElement('td'); - var tdValue = document.createElement('td'); - - thName.appendChild(nameText); - tdName.appendChild(name); - thValue.appendChild(valueText); - tdValue.appendChild(value); - - tr.appendChild(thName); - tr.appendChild(tdName); - tr.appendChild(thValue); - tr.appendChild(tdValue); - - x.appendChild(tr); - - element_id = element_id + 1; -} - -function minus(){ - if( element_id <= 2 ) - return; - - element_id = element_id - 1; - var d = document.getElementById('options'); - var olddiv = document.getElementById( 'option_' + element_id ); - - d.removeChild(olddiv); +var element_id = 2; + +function plus() { + var x = document.getElementById('options'); + + var name = document.createElement('input'); + name.setAttribute('name', 'name_' + element_id ); + name.setAttribute('type', 'text'); + + var value = document.createElement('input'); + value.setAttribute('name', 'value_' + element_id ); + value.setAttribute('class', 'text'); + value.setAttribute('type', 'text'); + + var nameText = document.createTextNode('Name: '); + var valueText = document.createTextNode('Value: '); + + var tr = document.createElement('tr'); + tr.setAttribute('id', 'option_' + element_id); + var thName = document.createElement('th'); + var thValue = document.createElement('th'); + var tdName = document.createElement('td'); + var tdValue = document.createElement('td'); + + thName.appendChild(nameText); + tdName.appendChild(name); + thValue.appendChild(valueText); + tdValue.appendChild(value); + + tr.appendChild(thName); + tr.appendChild(tdName); + tr.appendChild(thValue); + tr.appendChild(tdValue); + + x.appendChild(tr); + + element_id = element_id + 1; +} + +function minus(){ + if( element_id <= 2 ) + return; + + element_id = element_id - 1; + var d = document.getElementById('options'); + var olddiv = document.getElementById( 'option_' + element_id ); + + d.removeChild(olddiv); } \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/js/slide.js b/core/crce-webui/src/main/webapp/js/slide.js similarity index 96% rename from modules/crce-webui/src/main/webapp/js/slide.js rename to core/crce-webui/src/main/webapp/js/slide.js index b9843914..dda091b8 100644 --- a/modules/crce-webui/src/main/webapp/js/slide.js +++ b/core/crce-webui/src/main/webapp/js/slide.js @@ -1,19 +1,19 @@ -$(document).ready(function(){ - $(".informace").hide(); - - $(".popis").click(function(){ - $(this).parent().next(".informace").slideToggle(500) - return false; - }); - - $(".rozbalit").click(function(){ - $(".informace").slideDown(500) - return false; - }); - - $(".sbalit").click(function(){ - $(".informace").slideUp(500) - return false; - }); - +$(document).ready(function(){ + $(".informace").hide(); + + $(".popis").click(function(){ + $(this).parent().next(".informace").slideToggle(500) + return false; + }); + + $(".rozbalit").click(function(){ + $(".informace").slideDown(500) + return false; + }); + + $(".sbalit").click(function(){ + $(".informace").slideUp(500) + return false; + }); + }); \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/buffer.jsp b/core/crce-webui/src/main/webapp/jsp/buffer.jsp similarity index 100% rename from modules/crce-webui/src/main/webapp/jsp/buffer.jsp rename to core/crce-webui/src/main/webapp/jsp/buffer.jsp diff --git a/modules/crce-webui/src/main/webapp/jsp/compatibility.jsp b/core/crce-webui/src/main/webapp/jsp/compatibility.jsp similarity index 100% rename from modules/crce-webui/src/main/webapp/jsp/compatibility.jsp rename to core/crce-webui/src/main/webapp/jsp/compatibility.jsp index 48e91628..8a33ad76 100644 --- a/modules/crce-webui/src/main/webapp/jsp/compatibility.jsp +++ b/core/crce-webui/src/main/webapp/jsp/compatibility.jsp @@ -1,5 +1,5 @@ -<%@ page import="cz.zcu.kiv.typescmp.Difference" %> <%@ page import="cz.zcu.kiv.crce.compatibility.Compatibility" %> +<%@ page import="cz.zcu.kiv.typescmp.Difference" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/capabilitiesForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/capabilitiesForm.jsp similarity index 97% rename from modules/crce-webui/src/main/webapp/jsp/forms/capabilitiesForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/capabilitiesForm.jsp index 7bf9d7f5..d89513e4 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/capabilitiesForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/capabilitiesForm.jsp @@ -1,47 +1,47 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Capabilities form - - Resource: ${resource.presentationName} - ${resource.version} - Capability: ${capability.name} - - - - [add new property] - - - - - - - - - NameTypeValue - - - - - - - - selected="selected">${type} - - - - - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Capabilities form + + Resource: ${resource.presentationName} - ${resource.version} + Capability: ${capability.name} + + + + [add new property] + + + + + + + + + NameTypeValue + + + + + + + + selected="selected">${type} + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/capabilityForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/capabilityForm.jsp similarity index 96% rename from modules/crce-webui/src/main/webapp/jsp/forms/capabilityForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/capabilityForm.jsp index b4f589b1..8cc6df49 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/capabilityForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/capabilityForm.jsp @@ -1,31 +1,31 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Add new capability - - Resource: ${resource.presentationName} - ${resource.version} - - - - - - - Capability name: - - ${capabilityError} - - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Add new capability + + Resource: ${resource.presentationName} - ${resource.version} + + + + + + + Capability name: + + ${capabilityError} + + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/categoriesForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/categoriesForm.jsp similarity index 97% rename from modules/crce-webui/src/main/webapp/jsp/forms/categoriesForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/categoriesForm.jsp index 05846f97..78c82ee7 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/categoriesForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/categoriesForm.jsp @@ -1,25 +1,25 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Existing categories - - Resource: ${resource.presentationName} - ${resource.version} - - - - ${category} [remove] - - - - - [add new category] - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Existing categories + + Resource: ${resource.presentationName} - ${resource.version} + + + + ${category} [remove] + + + + + [add new category] + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/categoryForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/categoryForm.jsp similarity index 96% rename from modules/crce-webui/src/main/webapp/jsp/forms/categoryForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/categoryForm.jsp index 54247ce4..4c0d7028 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/categoryForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/categoryForm.jsp @@ -1,31 +1,31 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Add new category - - Resource: ${resource.presentationName} - ${resource.version} - - - - - - - - Category name: - - ${categoryError} - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Add new category + + Resource: ${resource.presentationName} - ${resource.version} + + + + + + + + Category name: + + ${categoryError} + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/pluginForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/pluginForm.jsp similarity index 96% rename from modules/crce-webui/src/main/webapp/jsp/forms/pluginForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/pluginForm.jsp index 52a5c48e..fc150f19 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/pluginForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/pluginForm.jsp @@ -1,35 +1,35 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Plugin form - - Plugin: ${plugin.pluginId} - - - - - - - Priority: - - ${priorityError} - - - Keywords: - - ${keywordsError} - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Plugin form + + Plugin: ${plugin.pluginId} + + + + + + + Priority: + + ${priorityError} + + + Keywords: + + ${keywordsError} + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/propertiesForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/propertiesForm.jsp similarity index 97% rename from modules/crce-webui/src/main/webapp/jsp/forms/propertiesForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/propertiesForm.jsp index aae302b8..86fa9856 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/propertiesForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/propertiesForm.jsp @@ -1,58 +1,58 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Properties form - - Resource: ${resource.presentationName} - ${resource.version} - - - - - - - - - Symbolic name: - - ${symbolicNameError} - - - - Version: - - ${versionError} - - - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Properties form + + Resource: ${resource.presentationName} - ${resource.version} + + + + + + + + + Symbolic name: + + ${symbolicNameError} + + + + Version: + + ${versionError} + + + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/propertyForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/propertyForm.jsp similarity index 97% rename from modules/crce-webui/src/main/webapp/jsp/forms/propertyForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/propertyForm.jsp index 1f9b03aa..83a6b418 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/propertyForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/propertyForm.jsp @@ -1,49 +1,49 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Add new property - - Resource: ${resource.presentationName} - ${resource.version} - - - - - - - - - Name: - - ${nameError} - - - Type: - - - - - ${type} - - - - ${typeError} - - - Value: - - ${valueError} - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Add new property + + Resource: ${resource.presentationName} - ${resource.version} + + + + + + + + + Name: + + ${nameError} + + + Type: + + + + + ${type} + + + + ${typeError} + + + Value: + + ${valueError} + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/requirementForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/requirementForm.jsp similarity index 97% rename from modules/crce-webui/src/main/webapp/jsp/forms/requirementForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/requirementForm.jsp index 5308fa02..16b74252 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/requirementForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/requirementForm.jsp @@ -1,56 +1,56 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Add new requirement - - Resource: ${resource.presentationName} - ${resource.version} - - - - - - - - Name: - - ${nameError} - - - Filter: - ${requirement.filter} - ${filterError} - - - Comment: - ${requirement.comment} - ${commentError} - - - Multiple: - checked="checked" /> - ${multipleError} - - - Optional: - checked="checked" /> - ${optionalError} - - - Extend: - checked="checked" /> - ${extendError} - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Add new requirement + + Resource: ${resource.presentationName} - ${resource.version} + + + + + + + + Name: + + ${nameError} + + + Filter: + ${requirement.filter} + ${filterError} + + + Comment: + ${requirement.comment} + ${commentError} + + + Multiple: + checked="checked" /> + ${multipleError} + + + Optional: + checked="checked" /> + ${optionalError} + + + Extend: + checked="checked" /> + ${extendError} + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/requirementsForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/requirementsForm.jsp similarity index 98% rename from modules/crce-webui/src/main/webapp/jsp/forms/requirementsForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/requirementsForm.jsp index 6921279f..09c993f9 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/requirementsForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/requirementsForm.jsp @@ -1,40 +1,40 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Requirements form - - Resource: ${resource.presentationName} - ${resource.version} - - - [add new requirement] - - - - - - - - NameFilterMultipleOptionalExtend - Comment - - - - - checked="checked" /> - checked="checked" /> - checked="checked" /> - - - - - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Requirements form + + Resource: ${resource.presentationName} - ${resource.version} + + + [add new requirement] + + + + + + + + NameFilterMultipleOptionalExtend + Comment + + + + + checked="checked" /> + checked="checked" /> + checked="checked" /> + + + + + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/forms/testForm.jsp b/core/crce-webui/src/main/webapp/jsp/forms/testForm.jsp similarity index 96% rename from modules/crce-webui/src/main/webapp/jsp/forms/testForm.jsp rename to core/crce-webui/src/main/webapp/jsp/forms/testForm.jsp index d1cbfaa1..4339f5a1 100644 --- a/modules/crce-webui/src/main/webapp/jsp/forms/testForm.jsp +++ b/core/crce-webui/src/main/webapp/jsp/forms/testForm.jsp @@ -1,66 +1,66 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - - - - - - - - Test form - - - - Resources - - - ${resource.symbolicName} - - - - - No resources selected! - - - - - - Test plugins - - - - - - ${test} - - - - - Test parameters: - - - Name: - - Value: - - - - - - Add parameter - Remove parameter - - - - - - - - - - No test plugins enabled! - - - - - +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + + + + + + Test form + + + + Resources + + + ${resource.symbolicName} + + + + + No resources selected! + + + + + + Test plugins + + + + + + ${test} + + + + + Test parameters: + + + Name: + + Value: + + + + + + Add parameter + Remove parameter + + + + + + + + + + No test plugins enabled! + + + + + \ No newline at end of file diff --git a/modules/crce-webui/src/main/webapp/jsp/include/footer.jsp b/core/crce-webui/src/main/webapp/jsp/include/footer.jsp similarity index 97% rename from modules/crce-webui/src/main/webapp/jsp/include/footer.jsp rename to core/crce-webui/src/main/webapp/jsp/include/footer.jsp index d777bcf4..49d96735 100644 --- a/modules/crce-webui/src/main/webapp/jsp/include/footer.jsp +++ b/core/crce-webui/src/main/webapp/jsp/include/footer.jsp @@ -1,11 +1,11 @@ -<%@ page import="cz.zcu.kiv.crce.webui.internal.VersionInfo" %> - -<% VersionInfo versionInfo = VersionInfo.getVersionInfo(getServletContext()); %> - -CRCE version <%= versionInfo.getProductVersion() %> build rev. <%= versionInfo.getBuildRevision() %> - © 2011-2015 University of West Bohemia, Department of Computer Science -- -ReliSA research group - - - -
ResourceIndexer
Resource
cz.zcu.kiv.crce.metadata.Property
- [add new property] -
+ [add new property] +
- [add new category] -
+ [add new category] +
- [add new requirement] -
+ [add new requirement] +
- Add parameter - Remove parameter -
- -
+ Add parameter + Remove parameter +
+ +