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/ ...@@ -9,3 +9,4 @@ jboss/
.vscode/settings.json .vscode/settings.json
.settings/org.eclipse.core.resources.prefs .settings/org.eclipse.core.resources.prefs
pom_with_models.xml pom_with_models.xml
my_models.xml
...@@ -15,7 +15,7 @@ variables: ...@@ -15,7 +15,7 @@ variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dmaven.artifact.threads=10" MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dmaven.artifact.threads=10"
MAIN_BRANCH: "main" MAIN_BRANCH: "main"
RELEASE_BRANCH: "release" 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" TMP_PATH: "/home/deployer/gitlab_tmp"
DEPLOYMENT_PATH: "/home/wildfly/deployments" DEPLOYMENT_PATH: "/home/wildfly/deployments"
ARCHIVE_PATH: "/home/wildfly/archive" ARCHIVE_PATH: "/home/wildfly/archive"
...@@ -30,24 +30,71 @@ before_script: ...@@ -30,24 +30,71 @@ before_script:
- git config --global user.email "${GITLAB_USER_EMAIL}" - git config --global user.email "${GITLAB_USER_EMAIL}"
- echo "Get common settings" - echo "Get common settings"
- git clone $COMMON_CONFIG_REMOTE $COMMON_CONFIG_LOCAL - git clone $COMMON_CONFIG_REMOTE $COMMON_CONFIG_LOCAL
- cd $COMMON_CONFIG_LOCAL - cp $COMMON_CONFIG_LOCAL/$SETTINGS_XML .
- cp $SETTINGS_XML ../$SETTINGS_XML
- cd ..
- rm -rf $COMMON_CONFIG_LOCAL - rm -rf $COMMON_CONFIG_LOCAL
- apt-get update -y && apt-get install -y python && apt-get install -y rsync openssh-client - apt-get update -y && apt-get install -y python3 && apt-get install -y rsync openssh-client
- "python build_pom_with_models.py" - "python3 build_pom_with_models.py"
build: build-for-staging:
stage: build stage: build
script: script:
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS package -DskipTests" - "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS package -DskipTests"
tags: 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: artifacts:
paths: paths:
- target/*.war - target/*.war
rules: rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH - if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
test: test:
...@@ -55,16 +102,16 @@ test: ...@@ -55,16 +102,16 @@ test:
script: script:
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS test" - "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS test"
tags: tags:
- vips-java - java
rules: 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 - if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
deploy-to-staging: deploy-to-staging:
stage: deploy stage: deploy
script: script:
# Authentication setup # Authentication setup
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa - echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa - chmod 600 ~/.ssh/id_dsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
...@@ -83,7 +130,7 @@ deploy-to-staging: ...@@ -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'" - 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 # Deploy war file using JBoss CLI and credentials given in CI/CD variables
- echo "Deploy $WAR_FILE using JBoss CLI" - 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 # Restart should not be necessary
- echo "Restart WildFly" - echo "Restart WildFly"
- ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly" - ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
...@@ -93,9 +140,9 @@ deploy-to-staging: ...@@ -93,9 +140,9 @@ deploy-to-staging:
after_script: after_script:
- echo "Deployment complete" - echo "Deployment complete"
tags: tags:
- vips-java - java
rules: rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH - if: '$CI_COMMIT_REF_NAME == $MAIN_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
environment: environment:
name: staging name: staging
url: https://vipscore02test.nibio.no url: https://vipscore02test.nibio.no
...@@ -109,14 +156,14 @@ upload-snapshot: ...@@ -109,14 +156,14 @@ upload-snapshot:
fi fi
- "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests" - "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests"
tags: tags:
- vips-java - java
rules: rules:
- if: $CI_COMMIT_REF_NAME == $MAIN_BRANCH - if: '$CI_COMMIT_REF_NAME == $MAIN_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"'
deploy-to-production: deploy-to-production:
stage: deploy stage: deploy
script: script:
# Authentication setup # Authentication setup, for running commands on server
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa - echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa - chmod 600 ~/.ssh/id_dsa
...@@ -133,10 +180,10 @@ deploy-to-production: ...@@ -133,10 +180,10 @@ deploy-to-production:
# Find name of currently deployed application. Undeploy. # 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") - 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 - 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 # Deploy war file using JBoss CLI and credentials given in CI/CD variables
- echo "Deploy $WAR_FILE using JBoss CLI" - 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 # Restart should not be necessary
- echo "Restart WildFly" - echo "Restart WildFly"
- ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly" - ssh $SERVER_USER@$SERVER_IP "sudo systemctl restart wildfly"
...@@ -146,7 +193,7 @@ deploy-to-production: ...@@ -146,7 +193,7 @@ deploy-to-production:
after_script: after_script:
- echo "Deployment complete" - echo "Deployment complete"
tags: tags:
- vips-java - java
rules: rules:
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH - if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
environment: environment:
...@@ -157,57 +204,44 @@ upload-and-tag-release: ...@@ -157,57 +204,44 @@ upload-and-tag-release:
stage: upload stage: upload
script: script:
# Use access token given by CI/CD variable ACCESS_TOKEN to authenticate # Use access token given by CI/CD variable ACCESS_TOKEN to authenticate
- &authenticate # 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 - 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 remote set-url --push origin $NEW_REPO_URL
- git fetch origin --prune --prune-tags - git fetch origin --prune --prune-tags
# Checkout release branch # Checkout release branch
- &checkout_release - git stash -a
- git stash -a - git checkout $RELEASE_BRANCH
- git checkout $RELEASE_BRANCH - git reset --hard origin/$RELEASE_BRANCH
- git reset --hard origin/$RELEASE_BRANCH - git stash pop
- git stash pop
# Set release version and deploy. Commit, tag and push. # Set release version and deploy. Commit, tag and push.
- &release_and_tag # Change version in pom.xml - build new pom_with_models.xml - "python3 build_pom_with_models.py"
- "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DremoveSnapshot" - 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 "\[.*")
- "python build_pom_with_models.py" - export RELEASE_TAG="v${RELEASE_VERSION}"
- 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 "Version to deploy '$RELEASE_VERSION', will be tagged '$RELEASE_TAG'"
- echo "New version in release '$RELEASE_VERSION'" - "./mvnw $MAVEN_POM_WITH_MODELS $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests"
- export RELEASE_TAG="v${RELEASE_VERSION}" # NB! Wanted to use deploy:deploy-file with already built war file above, but this requires url to be specifically set
- echo "Release tag '$RELEASE_TAG'" - git tag -a $RELEASE_TAG -m "Tag release ${RELEASE_TAG}"
- export EXISTING_TAGS=$(git ls-remote --tags origin | cut -f 2 | grep "refs/tags/$RELEASE_TAG$") - git push origin $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
# Checkout main branch # Checkout main branch
- &checkout_main - git stash -a
- git stash -a - git checkout $MAIN_BRANCH
- git checkout $MAIN_BRANCH - git reset --hard origin/$MAIN_BRANCH
- git reset --hard origin/$MAIN_BRANCH - git stash pop
- git stash pop
# Merge release branch, bump patch version, push commits. # 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
- 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
# Change version in pom.xml - build new pom_with_models.xml - "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DbumpPatch"
- "./mvnw $MAVEN_CLI_OPTS $MAVEN_OPTS validate -DbumpPatch" - "python3 build_pom_with_models.py"
- "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 "\[.*")
- 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'"
- echo "New version in main '$SNAPSHOT_VERSION'" - git add pom.xml
- git add pom.xml - git commit -m "[ci skip] Set snapshot version ${SNAPSHOT_VERSION}"
- git commit -m "[ci skip] Set snapshot version ${SNAPSHOT_VERSION}" - git push origin $MAIN_BRANCH
- git push origin $MAIN_BRANCH
tags: tags:
- vips-java - java
rules: rules:
- if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH - if: $CI_COMMIT_REF_NAME == $RELEASE_BRANCH
...@@ -34,11 +34,11 @@ $ mvnw.cmd clean install ...@@ -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** **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. Deploy the build from this project in Wildfly.
Wildfly should run on Java >= 11 Wildfly should run on Java >= 17
### Adding models ### Adding models
...@@ -59,6 +59,17 @@ To build with your preferred set of models, create a new file called e.g. `my_mo ...@@ -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 $ 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 ## Implement a model
See [implement_model.md](./docs/implement_model.md) See [implement_model.md](./docs/implement_model.md)
......
...@@ -59,29 +59,53 @@ if response.status_code == 200: ...@@ -59,29 +59,53 @@ if response.status_code == 200:
models = {} 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) # Filter models and store only the most recent version (highest alphanumeric number)
for package in all_packages: for package in all_packages:
for model_prefix in model_prefixes: 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:] 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] = {}
models[model_name]["groupId"] = model_prefix.replace("/",".") models[model_name]["groupId"] = model_prefix.replace("/", ".")
models[model_name]["version"] = package["version"] models[model_name]["version"] = package["version"]
else: 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 # Build partial Maven XML
dependencies = ET.Element("dependencies") dependencies = ET.Element("dependencies")
for model_name, value in models.items(): for model_name, value in models.items():
dependency = ET.SubElement(dependencies, "dependency") 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, "artifactId").text = model_name
ET.SubElement(dependency, "version").text = value["version"] ET.SubElement(dependency, "version").text = value["version"]
# Dumps the indented XML to stdout # Dumps the indented XML to stdout
tree = ET.ElementTree(dependencies) tree = ET.ElementTree(dependencies)
ET.indent(tree, space="\t",level=0) ET.indent(tree, space="\t", level=0)
ET.dump(tree) ET.dump(tree)
#!/usr/bin/python3 #!/usr/bin/python3
''' '''
Merges pom.xml and models.xml (default) into pom_with_models.xml and Merges pom.xml and models.xml (default) into pom_with_models.xml
runs mvn clean install -f pom_with_models.xml
Copyright (C) 2023 NIBIO Copyright (C) 2023 NIBIO
...@@ -49,6 +48,6 @@ for dep in model_dep_elements: ...@@ -49,6 +48,6 @@ for dep in model_dep_elements:
pom_deps_element.appendChild(dep) pom_deps_element.appendChild(dep)
# Write the modified pom dom to file # 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_dom.writexml(pom_with_models_file)
pom_with_models_file.close() pom_with_models_file.close()
...@@ -49,7 +49,7 @@ for dep in model_dep_elements: ...@@ -49,7 +49,7 @@ for dep in model_dep_elements:
pom_deps_element.appendChild(dep) pom_deps_element.appendChild(dep)
# Write the modified pom dom to file # 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_dom.writexml(pom_with_models_file)
pom_with_models_file.close() pom_with_models_file.close()
......
...@@ -2,111 +2,116 @@ ...@@ -2,111 +2,116 @@
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>RoughageNutritionModel</artifactId> <artifactId>RoughageNutritionModel</artifactId>
<version>1.1.6-SNAPSHOT</version> <version>1.1.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>AlternariaModel</artifactId> <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>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>NaerstadModel</artifactId> <artifactId>Model_LEAFBLOTCH</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>BarleyNetBlotchModel</artifactId> <artifactId>NaerstadModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>SeptoriaHumidityModel</artifactId> <artifactId>SeptoriaHumidityModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>AppleScabModel</artifactId> <artifactId>AppleScabModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>BremiaLactucaeModel</artifactId> <artifactId>DeliaRadicumModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>DeliaRadicumFloralisObservationModel</artifactId> <artifactId>DeliaRadicumFloralisObservationModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>DeliaRadicumModel</artifactId> <artifactId>BremiaLactucaeModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency>
<dependency>
<groupId>fi.luke.vips.model</groupId>
<artifactId>FinnCerealModels</artifactId>
<version>1.1.4-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>DOWNCASTModel</artifactId> <artifactId>DOWNCASTModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency>
<dependency>
<groupId>no.nibio.vips.model</groupId>
<artifactId>LygusRugulipennisModel</artifactId>
<version>1.1.4-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>GrassDryingModel</artifactId> <artifactId>GrassDryingModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>MamestraBrassicaeModel</artifactId> <artifactId>LygusRugulipennisModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>Model_MAIZEPHENO</artifactId> <artifactId>Model_MAIZEPHENO</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>Model_LEAFBLOTCH</artifactId> <artifactId>MamestraBrassicaeModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>OatFloweringModel</artifactId> <artifactId>OatFloweringModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>PsilaRosaeObservationModel</artifactId> <artifactId>NegativePrognosisModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>NegativePrognosisModel</artifactId> <artifactId>PsilaRosaeObservationModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>PsilaRosaeTempModel</artifactId> <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>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>SeptoriaApiicolaModel</artifactId> <artifactId>SeptoriaApiicolaModel</artifactId>
<version>1.1.4-SNAPSHOT</version> <version>1.1.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>no.nibio.vips.model</groupId> <groupId>no.nibio.vips.model</groupId>
<artifactId>SeptoriaReferenceHumidityModel</artifactId> <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> </dependency>
</dependencies> </dependencies>
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
<parent> <parent>
<groupId>no.nibio.vips</groupId> <groupId>no.nibio.vips</groupId>
<artifactId>vips-parent-pom</artifactId> <artifactId>vips-parent-pom</artifactId>
<version>1.0.0</version> <version>1.1.0</version>
</parent> </parent>
<groupId>no.nibio</groupId> <groupId>no.nibio</groupId>
<artifactId>VIPSCore</artifactId> <artifactId>VIPSCore</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>2.0.5-SNAPSHOT</version> <version>3.0.1-SNAPSHOT</version>
<name>VIPSCore</name> <name>VIPSCore</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
<dependency> <dependency>
<groupId>io.github.classgraph</groupId> <groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId> <artifactId>classgraph</artifactId>
<version>4.8.165</version> <version>4.8.179</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.thetransactioncompany</groupId> <groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId> <artifactId>cors-filter</artifactId>
<version>2.10</version> <version>3.0</version>
</dependency> </dependency>
<dependency> <dependency>
...@@ -66,13 +66,7 @@ ...@@ -66,13 +66,7 @@
<dependency> <dependency>
<groupId>no.nibio.vips</groupId> <groupId>no.nibio.vips</groupId>
<artifactId>VIPSCommon</artifactId> <artifactId>VIPSCommon</artifactId>
<version>2.0.2</version> <version>3.0.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>8.0.1</version>
<type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
...@@ -80,11 +74,6 @@ ...@@ -80,11 +74,6 @@
<version>4.13.2</version> <version>4.13.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency> <dependency>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
...@@ -92,16 +81,10 @@ ...@@ -92,16 +81,10 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>jakarta.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>jakarta.servlet-api</artifactId>
<version>2.5</version> <version>6.1.0</version>
<scope>provided</scope> <scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-validator</groupId> <groupId>commons-validator</groupId>
...@@ -110,9 +93,9 @@ ...@@ -110,9 +93,9 @@
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>jakarta.platform</groupId>
<artifactId>javaee-api</artifactId> <artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.1</version> <version>10.0.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -145,8 +128,8 @@ ...@@ -145,8 +128,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version> <version>3.12.1</version>
<configuration> <configuration>
<source>11</source> <source>17</source>
<target>11</target> <target>17</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
package no.nibio.vips.core; package no.nibio.vips.core;
import java.util.Set; import java.util.Set;
import javax.ws.rs.ApplicationPath; import jakarta.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application; import jakarta.ws.rs.core.Application;
/** /**
......
...@@ -20,14 +20,14 @@ package no.nibio.vips.core.config; ...@@ -20,14 +20,14 @@ package no.nibio.vips.core.config;
import com.bedatadriven.jackson.datatype.jts.JtsModule; import com.bedatadriven.jackson.datatype.jts.JtsModule;
import com.fasterxml.jackson.databind.DeserializationFeature; 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.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule; 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 net.ipmdecisions.weather.entity.LocationWeatherData;
import no.nibio.vips.ipmdecisions.LocationWeatherDataDeserializer; import no.nibio.vips.ipmdecisions.LocationWeatherDataDeserializer;
......
...@@ -18,19 +18,20 @@ ...@@ -18,19 +18,20 @@
package no.nibio.vips.core.service; package no.nibio.vips.core.service;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import javax.ws.rs.GET; import jakarta.ws.rs.GET;
import javax.ws.rs.Path; import jakarta.ws.rs.Path;
import javax.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import javax.ws.rs.Produces; import jakarta.ws.rs.Produces;
import javax.ws.rs.WebApplicationException; import jakarta.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context; import jakarta.ws.rs.core.Context;
import javax.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import no.nibio.vips.entity.ModelConfiguration; import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result; import no.nibio.vips.entity.Result;
import no.nibio.vips.ipmdecisions.DataTransformer; import no.nibio.vips.ipmdecisions.DataTransformer;
...@@ -115,7 +116,7 @@ public class ModelResourceImpl implements ModelResource{ ...@@ -115,7 +116,7 @@ public class ModelResourceImpl implements ModelResource{
{ {
retVal.append(mF.getModelInstance(key).getModelName(language)); retVal.append(mF.getModelInstance(key).getModelName(language));
} }
catch(DuplicateModelIdException ex) catch(DuplicateModelIdException | SecurityException | NoSuchMethodException | InvocationTargetException ex)
{ {
retVal.append(ex.getMessage()); retVal.append(ex.getMessage());
} }
...@@ -149,7 +150,7 @@ public class ModelResourceImpl implements ModelResource{ ...@@ -149,7 +150,7 @@ public class ModelResourceImpl implements ModelResource{
{ {
try { try {
retVal.append(key).append(" ").append(mF.getModelInstance(key).getModelName(language)).append("\n"); 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"); retVal.append(key).append(" ").append(ex.getMessage()).append("\n");
Logger.getLogger(ModelResourceImpl.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ModelResourceImpl.class.getName()).log(Level.SEVERE, null, ex);
} }
...@@ -231,7 +232,7 @@ public class ModelResourceImpl implements ModelResource{ ...@@ -231,7 +232,7 @@ public class ModelResourceImpl implements ModelResource{
{ {
sampleConfig = ModelFactory.getInstance().getModelInstance(modelId).getSampleConfig(); sampleConfig = ModelFactory.getInstance().getModelInstance(modelId).getSampleConfig();
} }
catch(NoSuchModelException | DuplicateModelIdException ex) catch(NoSuchModelException | DuplicateModelIdException | SecurityException | NoSuchMethodException | InvocationTargetException ex)
{ {
sampleConfig = ex.getMessage(); sampleConfig = ex.getMessage();
} }
...@@ -261,7 +262,7 @@ public class ModelResourceImpl implements ModelResource{ ...@@ -261,7 +262,7 @@ public class ModelResourceImpl implements ModelResource{
} }
else throw new ModelExcecutionException("Model returned NULL Result"); 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); Logger.getLogger(ModelResourceImpl.class.getName()).log(Level.SEVERE, null, ex);
return Response.serverError().entity(ex.getMessage()).build(); return Response.serverError().entity(ex.getMessage()).build();
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
package no.nibio.vips.core.startup; package no.nibio.vips.core.startup;
import javax.servlet.ServletContextEvent; import jakarta.servlet.ServletContextEvent;
import no.nibio.vips.model.factory.ModelFactory; import no.nibio.vips.model.factory.ModelFactory;
/** /**
* This class is created and method contextInitialized called when the application * This class is created and method contextInitialized called when the application
...@@ -28,7 +27,7 @@ import no.nibio.vips.model.factory.ModelFactory; ...@@ -28,7 +27,7 @@ import no.nibio.vips.model.factory.ModelFactory;
* @copyright 2013 {@link http://www.nibio.no NIBIO} * @copyright 2013 {@link http://www.nibio.no NIBIO}
* @author Tor-Einar Skog <tor-einar.skog@nibio.no> * @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 * Called when the application
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
package no.nibio.vips.model.factory; 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.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -28,6 +25,9 @@ import java.util.Map; ...@@ -28,6 +25,9 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; 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; import no.nibio.vips.model.Model;
/** /**
...@@ -96,34 +96,6 @@ public class ModelFactory { ...@@ -96,34 +96,6 @@ public class ModelFactory {
* Builds an inventory. * Builds an inventory.
*/ */
private void init(){ 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 * Warning: This generates a WARNING from a filesystem/JARfile scan error
...@@ -131,19 +103,14 @@ public class ModelFactory { ...@@ -131,19 +103,14 @@ public class ModelFactory {
* this in log files. * 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"); 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 new ClassGraph() // Create a new ClassGraph instance
.verbose(verboseClassGraph) // If you want to enable logging to stderr .verbose(verboseClassGraph) // If you want to enable logging to stderr
.enableClassInfo() // Scan classes, methods, fields, annotations .enableClassInfo() // Scan classes, methods, fields, annotations
//.acceptPackages("com.xyz") // Scan com.xyz and subpackages //.acceptPackages("no.nibio") // Scan no.nibio and subpackages
.scan()) { // Perform the scan and return a ScanResult .scan()) { // Perform the scan and return a ScanResult
//ClassInfoList classInfoList = //ClassInfoList classInfoList =
...@@ -156,7 +123,7 @@ public class ModelFactory { ...@@ -156,7 +123,7 @@ public class ModelFactory {
/** /**
* Iterates and instantiates one object for each class * Iterates and instantiates one object for each class
*/ */
this.models = new HashMap(); this.models = new HashMap<>();
for(Class<? extends Model> subType : subTypes) for(Class<? extends Model> subType : subTypes)
{ {
try { try {
...@@ -303,7 +270,10 @@ public class ModelFactory { ...@@ -303,7 +270,10 @@ public class ModelFactory {
InstantiationException, InstantiationException,
IllegalAccessException, IllegalAccessException,
DuplicateModelIdException, DuplicateModelIdException,
NoSuchModelException NoSuchModelException,
SecurityException,
NoSuchMethodException,
InvocationTargetException
{ {
if(this.isDuplicateModelId(modelId)) if(this.isDuplicateModelId(modelId))
{ {
...@@ -313,7 +283,7 @@ public class ModelFactory { ...@@ -313,7 +283,7 @@ public class ModelFactory {
{ {
throw new NoSuchModelException("ERROR: No model found with id = " + modelId); 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) { private void addDuplicateModelId(String modelId) {
......