Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • VIPS/VIPSCore
1 result
Select Git revision
Show changes
Commits on Source (123)
......@@ -9,3 +9,4 @@ jboss/
.vscode/settings.json
.settings/org.eclipse.core.resources.prefs
pom_with_models.xml
my_models.xml
......@@ -15,7 +15,7 @@ variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dmaven.artifact.threads=10"
MAIN_BRANCH: "main"
RELEASE_BRANCH: "release"
CLI_PATH: "/disks/data01/wildfly/wildfly-26.1.3.Final/bin"
CLI_PATH: "/disks/data01/wildfly/wildfly-34.0.1.Final/bin"
TMP_PATH: "/home/deployer/gitlab_tmp"
DEPLOYMENT_PATH: "/home/wildfly/deployments"
ARCHIVE_PATH: "/home/wildfly/archive"
......@@ -30,24 +30,71 @@ before_script:
- git config --global user.email "${GITLAB_USER_EMAIL}"
- echo "Get common settings"
- git clone $COMMON_CONFIG_REMOTE $COMMON_CONFIG_LOCAL
- cd $COMMON_CONFIG_LOCAL
- cp $SETTINGS_XML ../$SETTINGS_XML
- cd ..
- cp $COMMON_CONFIG_LOCAL/$SETTINGS_XML .
- rm -rf $COMMON_CONFIG_LOCAL
- apt-get update -y && apt-get install -y python && apt-get install -y rsync openssh-client
- "python build_pom_with_models.py"
- apt-get update -y && apt-get install -y python3 && apt-get install -y rsync openssh-client
- "python3 build_pom_with_models.py"
build:
build-for-staging:
stage: build
script:
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS package -DskipTests"
tags:
- vips-java
- java
artifacts:
paths:
- target/*.war
rules:
- if: '$CI_COMMIT_REF_NAME == $MAIN_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
build-for-production:
stage: build
script:
# Use access token given by CI/CD variable ACCESS_TOKEN to authenticate
# This is necessary in order to push changes to git
- &authenticate
- export NEW_REPO_URL=https://root:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git
- git remote set-url --push origin $NEW_REPO_URL
- git fetch origin --prune --prune-tags
# Checkout release branch
- &checkout_release
- git stash -a
- git checkout $RELEASE_BRANCH
- git reset --hard origin/$RELEASE_BRANCH
- git stash pop
# Set release version. Commit and push if tag for release version does not already exist.
- "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DremoveSnapshot"
- "python3 build_pom_with_models.py"
- export RELEASE_VERSION=$(./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS --batch-mode --no-transfer-progress --non-recursive help:evaluate -Dexpression=project.version | grep -v "\[.*")
- echo "New version in release '$RELEASE_VERSION'"
# If tag for new release version already exist, exit with error
- export RELEASE_TAG="v${RELEASE_VERSION}"
- echo "Release tag '$RELEASE_TAG'"
- export EXISTING_TAGS=$(git ls-remote --tags origin | cut -f 2 | grep "refs/tags/$RELEASE_TAG$")
- echo "Existing tags '$EXISTING_TAGS'"
- if [ -n "$EXISTING_TAGS" ]; then
echo "Tag $RELEASE_TAG already exists"; exit 1;
fi
# If release tag does not already exist, commit and push pom with new version
- git add pom.xml
- |
if git diff --cached --quiet -- pom.xml; then
echo "No changes to commit for pom.xml, skipping commit and push"
else
git commit -m "[ci skip] Set release version ${RELEASE_VERSION}"
git push origin $RELEASE_BRANCH
fi
# Build new war file
- echo "Build war file with version '$RELEASE_VERSION'"
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS package -DskipTests"
tags:
- java
artifacts:
paths:
- target/*.war
rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
test:
......@@ -55,16 +102,16 @@ test:
script:
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS test"
tags:
- vips-java
- java
rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
- if: '$CI_COMMIT_REF_NAME == $MAIN_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
deploy-to-staging:
stage: deploy
script:
# Authentication setup
- mkdir -p ~/.ssh
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
......@@ -83,7 +130,7 @@ deploy-to-staging:
- ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --command='undeploy $CURRENTLY_DEPLOYED'"
# Deploy war file using JBoss CLI and credentials given in CI/CD variables
- echo "Deploy $WAR_FILE using JBoss CLI"
- ssh $SERVER_USER@$SERVER_IP "/disks/data01/wildfly/wildfly-25.0.1.Final/bin/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli" > deployment.log 2>&1
- ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli" > deployment.log 2>&1
# Restart should not be necessary
- echo "Restart WildFly"
- ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
......@@ -93,9 +140,9 @@ deploy-to-staging:
after_script:
- echo "Deployment complete"
tags:
- vips-java
- java
rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
- if: '$CI_COMMIT_REF_NAME == $MAIN_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
environment:
name: staging
url: https://vipscore02test.nibio.no
......@@ -109,14 +156,14 @@ upload-snapshot:
fi
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests"
tags:
- vips-java
- java
rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
- if: '$CI_COMMIT_REF_NAME == $MAIN_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
deploy-to-production:
stage: deploy
script:
# Authentication setup
# Authentication setup, for running commands on server
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa
......@@ -133,10 +180,10 @@ deploy-to-production:
# Find name of currently deployed application. Undeploy.
- CURRENTLY_DEPLOYED=$(ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --commands=ls\ deployment | tr ' ' '\n' | grep VIPSCore-.*war")
- echo $CURRENTLY_DEPLOYED
- ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --command='undeploy $CURRENTLY_DEPLOYED'"
- if [ -n "$CURRENTLY_DEPLOYED" ]; then ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --command='undeploy $CURRENTLY_DEPLOYED'"; fi
# Deploy war file using JBoss CLI and credentials given in CI/CD variables
- echo "Deploy $WAR_FILE using JBoss CLI"
- ssh $SERVER_USER@$SERVER_IP "/disks/data01/wildfly/wildfly-25.0.1.Final/bin/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli" > deployment.log 2>&1
- ssh $SERVER_USER@$SERVER_IP "$CLI_PATH/jboss-cli.sh --user=$WILDFLY_ADMIN_USERNAME --password=$WILDFLY_ADMIN_PASSWORD --connect --file=$TMP_PATH/deploy.cli" > deployment.log 2>&1
# Restart should not be necessary
- echo "Restart WildFly"
- ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
......@@ -146,7 +193,7 @@ deploy-to-production:
after_script:
- echo "Deployment complete"
tags:
- vips-java
- java
rules:
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
environment:
......@@ -157,57 +204,44 @@ upload-and-tag-release:
stage: upload
script:
# Use access token given by CI/CD variable ACCESS_TOKEN to authenticate
- &authenticate
- export NEW_REPO_URL=https://root:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git
- git remote set-url --push origin $NEW_REPO_URL
- git fetch origin --prune --prune-tags
# This is necessary in order to push changes to git
- export NEW_REPO_URL=https://root:$ACCESS_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git
- git remote set-url --push origin $NEW_REPO_URL
- git fetch origin --prune --prune-tags
# Checkout release branch
- &checkout_release
- git stash -a
- git checkout $RELEASE_BRANCH
- git reset --hard origin/$RELEASE_BRANCH
- git stash pop
- git stash -a
- git checkout $RELEASE_BRANCH
- git reset --hard origin/$RELEASE_BRANCH
- git stash pop
# Set release version and deploy. Commit, tag and push.
- &release_and_tag # Change version in pom.xml - build new pom_with_models.xml
- "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DremoveSnapshot"
- "python build_pom_with_models.py"
- export RELEASE_VERSION=$(./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS --batch-mode --no-transfer-progress --non-recursive help:evaluate -Dexpression=project.version | grep -v "\[.*")
- echo "New version in release '$RELEASE_VERSION'"
- export RELEASE_TAG="v${RELEASE_VERSION}"
- echo "Release tag '$RELEASE_TAG'"
- export EXISTING_TAGS=$(git ls-remote --tags origin | cut -f 2 | grep "refs/tags/$RELEASE_TAG$")
- echo "Existing tags '$EXISTING_TAGS'"
- if [ -n "$EXISTING_TAGS" ]; then
echo "Tag $RELEASE_TAG already exists"; exit 1;
fi
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests"
- git add pom.xml
- git commit -m "[ci skip] Set release version ${RELEASE_VERSION}"
- git tag -a $RELEASE_TAG -m "Tag release ${RELEASE_TAG}"
- git push origin $RELEASE_TAG
- git push origin $RELEASE_BRANCH
- "python3 build_pom_with_models.py"
- export RELEASE_VERSION=$(./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS --batch-mode --no-transfer-progress --non-recursive help:evaluate -Dexpression=project.version | grep -v "\[.*")
- export RELEASE_TAG="v${RELEASE_VERSION}"
- echo "Version to deploy '$RELEASE_VERSION', will be tagged '$RELEASE_TAG'"
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests"
# NB! Wanted to use deploy:deploy-file with already built war file above, but this requires url to be specifically set
- git tag -a $RELEASE_TAG -m "Tag release ${RELEASE_TAG}"
- git push origin $RELEASE_TAG
# Checkout main branch
- &checkout_main
- git stash -a
- git checkout $MAIN_BRANCH
- git reset --hard origin/$MAIN_BRANCH
- git stash pop
- git stash -a
- git checkout $MAIN_BRANCH
- git reset --hard origin/$MAIN_BRANCH
- git stash pop
# Merge release branch, bump patch version, push commits.
- &merge_and_bump
- git merge -m "[ci skip] Merge branch '${RELEASE_BRANCH}' into ${MAIN_BRANCH}" --no-ff $RELEASE_BRANCH
# Change version in pom.xml - build new pom_with_models.xml
- "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DbumpPatch"
- "python build_pom_with_models.py"
- export SNAPSHOT_VERSION=$(./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS --batch-mode --no-transfer-progress --non-recursive help:evaluate -Dexpression=project.version | grep -v "\[.*")
- echo "New version in main '$SNAPSHOT_VERSION'"
- git add pom.xml
- git commit -m "[ci skip] Set snapshot version ${SNAPSHOT_VERSION}"
- git push origin $MAIN_BRANCH
- git merge -m "[ci skip] Merge branch '${RELEASE_BRANCH}' into ${MAIN_BRANCH}" --no-ff $RELEASE_BRANCH
# Change version in pom.xml - build new pom_with_models.xml
- "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DbumpPatch"
- "python3 build_pom_with_models.py"
- export SNAPSHOT_VERSION=$(./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS --batch-mode --no-transfer-progress --non-recursive help:evaluate -Dexpression=project.version | grep -v "\[.*")
- echo "New version in main '$SNAPSHOT_VERSION'"
- git add pom.xml
- git commit -m "[ci skip] Set snapshot version ${SNAPSHOT_VERSION}"
- git push origin $MAIN_BRANCH
tags:
- vips-java
- java
rules:
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
......@@ -34,11 +34,11 @@ $ mvnw.cmd clean install
**PLEASE NOTE that this builds the package without any models. See "Adding models" below for more information**
Download and install [WildFly](https://www.wildfly.org/) >= 25.0.1
Download and install [WildFly](https://www.wildfly.org/) == 34.0.1
Deploy the build from this project in Wildfly.
Wildfly should run on Java >= 11
Wildfly should run on Java >= 17
### Adding models
......@@ -59,6 +59,17 @@ To build with your preferred set of models, create a new file called e.g. `my_mo
$ build_with_models.py my_models.xml
```
To create Maven `<dependencies/>` XML with the latest versions of all models on NIBIO's GitLab, use the `build_models_xml.py` script, like this:
```bash
# Write latest production version dependency elements XML to my_models.xml
$ ./build_models_xml.py > my_models.xml
# Write latest SNAPSHOT version dependency elements XML to my_models.xml
$ ./build_models_xml.py -s > my_models.xml
```
## Implement a model
See [implement_model.md](./docs/implement_model.md)
......
......@@ -59,29 +59,53 @@ if response.status_code == 200:
models = {}
model_prefixes = ["no/nibio/vips/model","fi/luke/vips/model"]
model_prefixes = ["no/nibio/vips/model", "fi/luke/vips/model"]
# Returns -1 if number_a < number_b, 1 if number_a > number_b, 0 if equal
def compare_version_numbers(number_a, number_b):
# Make sure we remove "-SNAPSHOT"
number_a = number_a.split("-")[0]
number_b = number_b.split("-")[0]
number_a_parts = list(map(int,number_a.split(".")))
number_b_parts = list(map(int,number_b.split(".")))
for idx in range(len(number_a_parts)):
if idx > len(number_b_parts) -1:
# Versions are equal so far, but number_b is out of parts. Thus: number_a must be a greater version
return 1
if number_a_parts[idx] < number_b_parts[idx]:
return -1
elif number_a_parts[idx] > number_b_parts[idx]:
return 1
# No differences found in the parts that number_a and number_b have in common.
# If number_a and number_b have same number of parts, they must be equal
# If number_b still has parts left, it must be greater
return -1 if len(number_b_parts) > len(number_a_parts) else 0
# Filter models and store only the most recent version (highest alphanumeric number)
for package in all_packages:
for model_prefix in model_prefixes:
if package["name"].find(model_prefix) >=0 and ((snapshot and package["version"].find("SNAPSHOT")>=0) or (not snapshot and package["version"].find("SNAPSHOT")<0)):
if package["name"].find(model_prefix) >= 0 and ((snapshot and package["version"].find("SNAPSHOT") >= 0) or (not snapshot and package["version"].find("SNAPSHOT") < 0)):
model_name = package["name"][len(model_prefix) + 1:]
if models.get(model_name, None) == None:
if models.get(model_name, None) is None:
models[model_name] = {}
models[model_name]["groupId"] = model_prefix.replace("/",".")
models[model_name]["groupId"] = model_prefix.replace("/", ".")
models[model_name]["version"] = package["version"]
else:
models[model_name]["version"] = package["version"] if package["version"] > models[model_name]["version"] else models[model_name]["version"]
# Compare models so that 1.1.10 > 1.1.9
models[model_name]["version"] = package["version"] if compare_version_numbers(package["version"], models[model_name]["version"]) > 0 else models[model_name]["version"]
#models[model_name]["version"] = package["version"] if package["version"] > models[model_name]["version"] else models[model_name]["version"]
#print("%s %s" % (model_name, package["version"]))
# Build partial Maven XML
dependencies = ET.Element("dependencies")
for model_name, value in models.items():
dependency = ET.SubElement(dependencies, "dependency")
ET.SubElement(dependency,"groupId").text = value["groupId"]
ET.SubElement(dependency, "groupId").text = value["groupId"]
ET.SubElement(dependency, "artifactId").text = model_name
ET.SubElement(dependency, "version").text = value["version"]
# Dumps the indented XML to stdout
tree = ET.ElementTree(dependencies)
ET.indent(tree, space="\t",level=0)
ET.indent(tree, space="\t", level=0)
ET.dump(tree)
#!/usr/bin/python3
'''
Merges pom.xml and models.xml (default) into pom_with_models.xml and
runs mvn clean install -f pom_with_models.xml
Merges pom.xml and models.xml (default) into pom_with_models.xml
Copyright (C) 2023 NIBIO
......@@ -49,6 +48,6 @@ for dep in model_dep_elements:
pom_deps_element.appendChild(dep)
# Write the modified pom dom to file
pom_with_models_file = open(merged_pom_filename,"w")
pom_with_models_file = open(merged_pom_filename, "w")
pom_dom.writexml(pom_with_models_file)
pom_with_models_file.close()
......@@ -49,7 +49,7 @@ for dep in model_dep_elements:
pom_deps_element.appendChild(dep)
# Write the modified pom dom to file
pom_with_models_file = open(merged_pom_filename,"w")
pom_with_models_file = open(merged_pom_filename, "w")
pom_dom.writexml(pom_with_models_file)
pom_with_models_file.close()
......
......@@ -2,111 +2,116 @@
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>RoughageNutritionModel</artifactId>
<version>1.1.6-SNAPSHOT</version>
<version>1.1.13</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>AlternariaModel</artifactId>
<version>1.1.5-SNAPSHOT</version>
<version>1.1.15</version>
</dependency>
<dependency>
<groupId>fi.luke.vips.model</groupId>
<artifactId>FinnCerealModels</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>NaerstadModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>Model_LEAFBLOTCH</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>BarleyNetBlotchModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>NaerstadModel</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>SeptoriaHumidityModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>AppleScabModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>BremiaLactucaeModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>DeliaRadicumModel</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>DeliaRadicumFloralisObservationModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>DeliaRadicumModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fi.luke.vips.model</groupId>
<artifactId>FinnCerealModels</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>BremiaLactucaeModel</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>DOWNCASTModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>LygusRugulipennisModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>GrassDryingModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>MamestraBrassicaeModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>LygusRugulipennisModel</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>Model_MAIZEPHENO</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>Model_LEAFBLOTCH</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>MamestraBrassicaeModel</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>OatFloweringModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>PsilaRosaeObservationModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>NegativePrognosisModel</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>NegativePrognosisModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<artifactId>PsilaRosaeObservationModel</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>PsilaRosaeTempModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>BarleyNetBlotchModel</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>SeptoriaApiicolaModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>SeptoriaReferenceHumidityModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>DayDegreesModel</artifactId>
<version>0.1.2</version>
</dependency>
</dependencies>
......@@ -4,12 +4,12 @@
<parent>
<groupId>no.nibio.vips</groupId>
<artifactId>vips-parent-pom</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>
<groupId>no.nibio</groupId>
<artifactId>VIPSCore</artifactId>
<packaging>war</packaging>
<version>2.0.5-SNAPSHOT</version>
<version>3.0.1-SNAPSHOT</version>
<name>VIPSCore</name>
<url>http://maven.apache.org</url>
......@@ -32,12 +32,12 @@
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.165</version>
<version>4.8.179</version>
</dependency>
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.10</version>
<version>3.0</version>
</dependency>
<dependency>
......@@ -66,13 +66,7 @@
<dependency>
<groupId>no.nibio.vips</groupId>
<artifactId>VIPSCommon</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>8.0.1</version>
<type>jar</type>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
......@@ -80,11 +74,6 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
......@@ -92,16 +81,10 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
......@@ -110,9 +93,9 @@
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -145,8 +128,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<source>11</source>
<target>11</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
......
......@@ -20,8 +20,8 @@
package no.nibio.vips.core;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
/**
......
......@@ -20,14 +20,14 @@ package no.nibio.vips.core.config;
import com.bedatadriven.jackson.datatype.jts.JtsModule;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.ext.ContextResolver;
import jakarta.ws.rs.ext.Provider;
import net.ipmdecisions.weather.entity.LocationWeatherData;
import no.nibio.vips.ipmdecisions.LocationWeatherDataDeserializer;
......
......@@ -18,19 +18,20 @@
package no.nibio.vips.core.service;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result;
import no.nibio.vips.ipmdecisions.DataTransformer;
......@@ -115,7 +116,7 @@ public class ModelResourceImpl implements ModelResource{
{
retVal.append(mF.getModelInstance(key).getModelName(language));
}
catch(DuplicateModelIdException ex)
catch(DuplicateModelIdException | SecurityException | NoSuchMethodException | InvocationTargetException ex)
{
retVal.append(ex.getMessage());
}
......@@ -149,7 +150,7 @@ public class ModelResourceImpl implements ModelResource{
{
try {
retVal.append(key).append(" ").append(mF.getModelInstance(key).getModelName(language)).append("\n");
} catch (InstantiationException | IllegalAccessException | NoSuchModelException | DuplicateModelIdException ex) {
} catch (InstantiationException | IllegalAccessException | NoSuchModelException | DuplicateModelIdException | SecurityException | NoSuchMethodException | InvocationTargetException ex) {
retVal.append(key).append(" ").append(ex.getMessage()).append("\n");
Logger.getLogger(ModelResourceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
......@@ -231,7 +232,7 @@ public class ModelResourceImpl implements ModelResource{
{
sampleConfig = ModelFactory.getInstance().getModelInstance(modelId).getSampleConfig();
}
catch(NoSuchModelException | DuplicateModelIdException ex)
catch(NoSuchModelException | DuplicateModelIdException | SecurityException | NoSuchMethodException | InvocationTargetException ex)
{
sampleConfig = ex.getMessage();
}
......@@ -261,7 +262,7 @@ public class ModelResourceImpl implements ModelResource{
}
else throw new ModelExcecutionException("Model returned NULL Result");
}
catch(InstantiationException | IllegalAccessException | ConfigValidationException | ModelExcecutionException | NoSuchModelException | DuplicateModelIdException ex)
catch(InstantiationException | IllegalAccessException | ConfigValidationException | ModelExcecutionException | NoSuchModelException | DuplicateModelIdException | SecurityException | NoSuchMethodException | InvocationTargetException ex)
{
Logger.getLogger(ModelResourceImpl.class.getName()).log(Level.SEVERE, null, ex);
return Response.serverError().entity(ex.getMessage()).build();
......
......@@ -18,8 +18,7 @@
package no.nibio.vips.core.startup;
import javax.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextEvent;
import no.nibio.vips.model.factory.ModelFactory;
/**
* This class is created and method contextInitialized called when the application
......@@ -28,7 +27,7 @@ import no.nibio.vips.model.factory.ModelFactory;
* @copyright 2013 {@link http://www.nibio.no NIBIO}
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public class StartupListener implements javax.servlet.ServletContextListener{
public class StartupListener implements jakarta.servlet.ServletContextListener{
/**
* Called when the application
......
......@@ -18,9 +18,6 @@
package no.nibio.vips.model.factory;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.HashSet;
......@@ -28,6 +25,9 @@ import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult;
import no.nibio.vips.model.Model;
/**
......@@ -96,34 +96,6 @@ public class ModelFactory {
* Builds an inventory.
*/
private void init(){
/*
* Reflections API insists on using at least one package prefix. So we scan
* through all TLDs. List is compiled from
* http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
*/
String[] defaultTopDomains = {
"aero","asia","biz","cat","com","coop","info","int","jobs","mobi",
"museum","name","net","org","post","pro","tel","travel","edu","gov",
"ac","ad","ae","af","ag","ai","al","am","an","ao","aq","ar","as","at",
"au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","bj","bm",
"bn","bo","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg",
"ch","ci","ck","cl","cm","cn","co","cr","cs","cu","cv","cx","cy","cz",
"dd","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et",
"eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh",
"gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm",
"hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it",
"je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky",
"kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc",
"md","me","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt",
"mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no",
"np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn",
"pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc",
"sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st",
"su","sv","sx","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm",
"tn","to","tp","tr","tt","tv","tw","tz","ua","ug","uk","us","uy","uz",
"va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","yu","za","zm",
"zw",
};
/**
* Warning: This generates a WARNING from a filesystem/JARfile scan error
......@@ -131,19 +103,14 @@ public class ModelFactory {
* this in log files.
*/
Set<Class<? extends Model>> subTypes = new HashSet();
Set<Class<? extends Model>> subTypes = new HashSet<>();
/*for(String topDomain: defaultTopDomains)
{
reflections = new Reflections(topDomain);
subTypes.addAll(reflections.getSubTypesOf(Model.class));
}*/
boolean verboseClassGraph = System.getProperty("no.nibio.vips.core.VERBOSE_CLASSGRAPH") != null && System.getProperty("no.nibio.vips.core.VERBOSE_CLASSGRAPH").equals("true");
try (ScanResult scanResult = // Assign scanResult in try-with-resources
try (ScanResult scanResult = // Assign scanResult in try-with-resources
new ClassGraph() // Create a new ClassGraph instance
.verbose(verboseClassGraph) // If you want to enable logging to stderr
.enableClassInfo() // Scan classes, methods, fields, annotations
//.acceptPackages("com.xyz") // Scan com.xyz and subpackages
.verbose(verboseClassGraph) // If you want to enable logging to stderr
.enableClassInfo() // Scan classes, methods, fields, annotations
//.acceptPackages("no.nibio") // Scan no.nibio and subpackages
.scan()) { // Perform the scan and return a ScanResult
//ClassInfoList classInfoList =
......@@ -156,7 +123,7 @@ public class ModelFactory {
/**
* Iterates and instantiates one object for each class
*/
this.models = new HashMap();
this.models = new HashMap<>();
for(Class<? extends Model> subType : subTypes)
{
try {
......@@ -303,7 +270,10 @@ public class ModelFactory {
InstantiationException,
IllegalAccessException,
DuplicateModelIdException,
NoSuchModelException
NoSuchModelException,
SecurityException,
NoSuchMethodException,
InvocationTargetException
{
if(this.isDuplicateModelId(modelId))
{
......@@ -313,7 +283,7 @@ public class ModelFactory {
{
throw new NoSuchModelException("ERROR: No model found with id = " + modelId);
}
return this.models.get(modelId).getClass().newInstance();
return this.models.get(modelId).getClass().getDeclaredConstructor().newInstance();
}
private void addDuplicateModelId(String modelId) {
......