Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
45d73b9
Removed svn reference
dietervanhoof Mar 26, 2018
a329bbe
Removed schemas
dietervanhoof Mar 26, 2018
e7a4e0d
Added simple readme
dietervanhoof Mar 26, 2018
5409691
Removed image name
dietervanhoof Mar 26, 2018
ed7405b
add licence CP-WEBSITE
evaverdoodt Apr 17, 2018
e780bec
Use dc_identifier_localid as filename if possible
dietervanhoof Apr 19, 2018
946056c
add relations
evaverdoodt Apr 20, 2018
e6e5291
remove max occur for date
evaverdoodt May 9, 2018
cb6b42f
new file: Makefile
violetina Nov 29, 2018
7bb8806
add openshift files
violetina Nov 29, 2018
aa50119
modified: Makefile
violetina Nov 29, 2018
b9a6afb
Add 'CP_id' to xsd (Fixes #1)
maartends Dec 10, 2018
89df984
add CP_id
evaverdoodt Jan 23, 2019
9334d9b
Update README.md
dietervanhoof Feb 1, 2019
2417c9e
Added XSD with optional fields
dietervanhoof Mar 22, 2019
4901051
add makefile
violetina Mar 22, 2019
b2384b2
Merge branch 'development'
violetina Mar 22, 2019
b3e07e2
fix makefile
violetina Mar 22, 2019
39e1932
update local cp ids
evaverdoodt Apr 16, 2019
bcbce16
update list local cp ids
evaverdoodt Apr 16, 2019
0c2cd96
Merge branch 'master' of https://github.com/viaacode/Mint2
violetina May 27, 2019
ac12eef
Add files via upload
evaverdoodt Sep 16, 2019
97e5426
Rename film_mint.xsd to viaa_metadatamodel_film_update.xsd
evaverdoodt Sep 16, 2019
c2f5b7c
Staging (#2)
violetina Sep 19, 2019
5b2bf63
Add full VIAA datamodel xsd
evaverdoodt Jan 15, 2020
03a2a33
remove mandatory fields
evaverdoodt Jan 15, 2020
367c638
Staging (#3)
violetina Apr 16, 2020
3a6a3e9
Merge branch 'master' of https://github.com/viaacode/Mint2
violetina Apr 16, 2020
7b954d2
fix makefile
violetina Apr 16, 2020
89a5ba9
move to ocpv4
violetina Nov 18, 2021
6b8cac0
fix label
violetina Nov 18, 2021
35b0a9b
fix test
violetina Nov 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM andreptb/tomcat:6-jdk6
# Install ANT
ENV ANT_VERSION=1.9.10
ENV ANT_HOME=/opt/ant
WORKDIR /tmp
RUN mkdir /opt
RUN wget http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz \
&& tar -zvxf apache-ant-${ANT_VERSION}-bin.tar.gz -C /opt/ \
&& ln -s /opt/apache-ant-${ANT_VERSION} /opt/ant \
&& rm -f apache-ant-${ANT_VERSION}-bin.tar.gz \
&& rm -f apache-ant-${ANT_VERSION}-bin.tar.gz.md5

# add executables to path
ENV PATH ${PATH}:/opt/ant/bin
COPY . MINT2
RUN cd MINT2 && \
ant -Dappname=MINT2 -Denv.TOMCAT_HOME=${CATALINA_HOME} && \
mv work/dist/MINT2 /usr/local/tomcat/webapps
RUN chgrp -R 0 "$CATALINA_HOME" && chgrp -R 0 ${ANT_HOME}
RUN chmod -R g=u "$CATALINA_HOME" && chmod -R g=u ${ANT_HOME}
WORKDIR $CATALINA_HOME
USER 1001
CMD ["catalina.sh", "run"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Usage
- Build the dockerfile
- Run with
```
docker run -dt \
-p 8080:8080 \
-e "CATALINA_OPTS=-DPOSTGRES_HOST=<DATABASEHOST> -DPOSTGRES_PORT=<DATABASEPORT> -DPOSTGRES_DATABASE=<DATABASE> -DPOSTGRES_USERNAME=<DATABASEUSERNAME> -DPOSTGRES_PASSWORD=<DATABASEPASSWORD>" \
<IMAGENAME>
```
## Updating the XSD
To update the XSD, update the schema located in schemas/VIAA. Once updated, the docker image must be rebuilt with the above command and pushed again to OS to deploy the new version

After the new image was deployed, MINT must register this new XSD. You can do this by logging in with a user with enough rights and clicking on 'Manage XSDs' -> 'Setup new schema' -> filling in a name and choosing the XSD that you updated in the previous step.

*Note:* All mappings are tied to an XSD. If a new XSD is added, any mappings are still tied to the older version of the XSD and migrating a mapping to a new version is not possible, thus the mapping must be made again from scratch.
27 changes: 25 additions & 2 deletions WEB-INF/src/java/gr/ntua/ivml/mint/concurrent/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gr.ntua.ivml.mint.persistent.Dataset;
import gr.ntua.ivml.mint.persistent.Item;
import gr.ntua.ivml.mint.persistent.XmlSchema;
import gr.ntua.ivml.mint.persistent.XpathHolder;
import gr.ntua.ivml.mint.util.ApplyI;
import gr.ntua.ivml.mint.util.StringUtils;

Expand All @@ -15,14 +16,21 @@
import java.io.InputStream;
import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.validation.Schema;
import javax.xml.validation.ValidatorHandler;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;

import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -284,8 +292,23 @@ private void collectValid( Item item ) {
if(!itemXml.startsWith("<?xml")) itemXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + item.getXml();
IOUtils.write(itemXml, baos, "UTF-8" );
baos.close();

write( baos.toByteArray(), datasetSubdir(dataset)+"/Item_" + item.getDbID() + ".xml", tos );
// TODO: Change all '/Item_X' to own field (dc_identifier_localid)
String filename = "Item_" + item.getDbID();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(itemXml));
Document doc = builder.parse(is);
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("/VIAA/dc_identifier_localid/text()");
filename = expr.evaluate(doc, XPathConstants.STRING).toString();
}
catch (Exception e) {
// Huehue an empty catch!
}
write( baos.toByteArray(), datasetSubdir(dataset) + "/" +filename + ".xml", tos );
} catch( Exception e ) {
log.error( "Failed to collect valid item ", e );
}
Expand Down
6 changes: 3 additions & 3 deletions WEB-INF/src/java/hibernate.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
#hibernate.connection.password db2

hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql://localhost:5432/mint2
hibernate.connection.username mint2
hibernate.connection.password mint2
hibernate.connection.url jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
hibernate.connection.username ${POSTGRES_USERNAME}
hibernate.connection.password ${POSTGRES_PASSWORD}
hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider


Expand Down
1 change: 0 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<format property="NOW" pattern="d-MMM-yyyy HH:mm:ss" locale="en,UK"/>
</tstamp>
<echo file="build.properties" message="svn-revision=" />
<exec executable="svnversion" output="build.properties" append="true"/>
<echo file="build.properties" append="true" >appname=${appname}
deploy_target=${deploy_target}
build-time=${NOW}</echo>
Expand Down
201 changes: 201 additions & 0 deletions openshift/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
pipeline {
agent {
kubernetes {
defaultContainer 'default'
yaml """\
apiVersion: v1
kind: Pod
metadata:
labels:
component: builder
lang: java6
app: mint2
spec:
containers:
- name: default
image: ${getImageFromDockerfile()}
command:
- cat
tty: true
- name: oc
image: image-registry.openshift-image-registry.svc:5000/ci-cd/py:3.7
command:
- cat
tty: true
imagePullPolicy: Always
""".stripIndent()
}
}
options {
timeout(time: 45, unit: 'MINUTES')
disableConcurrentBuilds()
}
environment {
OC_PROJECT = 'etl'
BASE_IMG = "${getImageFromDockerfile()}"
BASE_IMG_NAME = "${getBaseImageName()}"
OC_URL = 'https://c113-e.private.eu-de.containers.cloud.ibm.com:30227'
JIRA_URL = 'meemoo.atlassian.net'
APP_NAME = 'mint2'
}

stages {
stage('Calculate extra ENV vars') {
steps {
container('oc') {
script {
env.GIT_SHORT_COMMIT = sh(script: "printf \$(git rev-parse --short ${GIT_COMMIT})", returnStdout: true)
env.IMAGE_TAG = sh(script: 'git describe --tags || echo latest', returnStdout: true)
// The name used for the build config based on the image tag
// Replace '.' with '_' as '.' is not allowed.
env.BUILD_CONFIG_NAME = sh(script: 'echo "${IMAGE_TAG}" | sed -r "s/\\./\\-/g"', returnStdout: true)
}
}
}
}
stage('Test code') {
steps {
sh 'echo no tests sorry'
}
}
stage('Build code') {
when {
not {
buildingTag()
}
}
steps {
container('oc') {
script {
sh '''#!/bin/bash
oc project $OC_PROJECT
oc import-image $BASE_IMG --confirm
oc set image-lookup $BASE_IMG_NAME
oc new-build -l ref=$BRANCH_NAME --strategy=docker --name $APP_NAME-$GIT_SHORT_COMMIT --to $APP_NAME:$GIT_SHORT_COMMIT --binary --context-dir="" || echo "Probably already exists, start new build"
sleep 3
oc annotate --overwrite buildconfig/$APP_NAME-$GIT_SHORT_COMMIT ref=$BRANCH_NAME shortcommit=$GIT_SHORT_COMMIT
oc start-build $APP_NAME-$GIT_SHORT_COMMIT --from-dir=. --wait=true
'''
}
}
}
}
stage('Deploy INT') {
when {
anyOf {
changeRequest target: 'master'
changeRequest target: 'main'
}
}
steps {
container('oc') {
tagNewImage('int')
}
}
post {
always {
script {
env.BRANCH_NAME = env.CHANGE_BRANCH
}
jiraSendDeploymentInfo site: "${JIRA_URL}", environmentId: 'int', environmentName: 'int', environmentType: 'testing'
}
}
}
stage('Deploy QAS') {
when {
anyOf { branch 'master'; branch 'main' }
}
steps {
container('oc') {
tagNewImage('qas')
}
}
post {
always {
jiraSendDeploymentInfo site: "${JIRA_URL}", environmentId: 'qas', environmentName: 'qas', environmentType: 'staging'
}
}
}
stage('Deploy PRD') {
when {
buildingTag()
}
steps {
container('oc') {
tagNewImage('prd')
}
}
post {
always {
script {
previous_tag = sh(script: 'git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`', returnStdout: true).trim()
echo getAllCommitsBetweenTags(previous_tag, env.TAG_NAME)
}
jiraSendDeploymentInfo site: "${JIRA_URL}", environmentId: 'prd', environmentName: 'prd', environmentType: 'production'
}
}
}
}
post {
success {
script {
if (env.BRANCH_NAME.startsWith('PR')) {
setGitHubBuildStatus('Build', 'SUCCESS')
}
}
}
failure {
script {
if (env.BRANCH_NAME.startsWith('PR')) {
setGitHubBuildStatus('Build', 'FAILURE')
}
}
}
always {
jiraSendBuildInfo site: "${JIRA_URL}"
container('default') {
// Archive tets results
script {
if (fileExists('./tests/test_results.xml')) {
junit 'tests/test_results.xml'
} else {
echo 'No test results found'
}
}
}
}
}
}

void getImageFromDockerfile() {
return 'andreptb/tomcat:6-jdk6'
}
void getBaseImageName() {
return getImageFromDockerfile().split(':')[0]
}

void setGitHubBuildStatus(String message, String state) {
step([
$class: 'GitHubCommitStatusSetter',
reposSource: [$class: 'ManuallyEnteredRepositorySource', url: "${GIT_URL}"],
commitShaSource: [$class: 'ManuallyEnteredShaSource', sha: "${GIT_COMMIT}"],
errorHandlers: [[$class: 'ChangingBuildStatusErrorHandler', result: 'UNSTABLE']],
statusResultSource: [ $class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', message: message, state: state]] ]
])
}

void getAllCommitsBetweenTags(String from, String to) {
commit_messages = sh(script: "git log ${from}...${to} --merges --format=%b", returnStdout: true)

return commit_messages
}

void tagNewImage(String environment) {
echo "Deploying to ${environment}"
sh """#!/bin/bash
oc project $OC_PROJECT
oc tag $APP_NAME:$GIT_SHORT_COMMIT $APP_NAME:${environment}
# Check the status of the rollout
oc rollout status deployment/$APP_NAME-${environment} --watch=true
"""
}
7 changes: 7 additions & 0 deletions openshift/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.ONESHELL:
SHELL = /bin/bash

.PHONY: all test

test:
echo Testing not implemented
Loading