Skip to content

Commit

Permalink
Merged from staging for v2.9 release (#157)
Browse files Browse the repository at this point in the history
* SnpEff integration prototyping

* Semi-functional prototype snpEff interface

* SnpEff prototype — annotation successful

* Reorganization

* Switch to a serious implementation

* Add an interface for SnpEff annotation

* Fix annotation config and interface

* Add proper SnpEff configuration

* Beqin SnpEff database management

* Start snpEff database download

* Add automatic genome download

* Add snpEff genome installation

* Add online building of SnpEff database

* Minor change

* fix: default genome download seems ok but 1sec download genome can crash

* fix: snpeff upload from files seems ok

* fix: snpeff import ok + start seems ok

* Improvements on SnpEff integration

* Minor fix

* Split up shared code from main.js into common.js (#131)

* Embed Oracle JDK instead of Zulu JRE into bundles

* Now averaging cumulated VCF field values on #variants per interval

* Finalized calculation of VCF numeric field series as averaged

... rather than cumulated, as it used to be.

* Fixed VCF field series removal

... also set MongoDB password via placeholder in
applicationContext-data.xml, to avoiding pushing passwords to source
control

* Merge from master (#139)

* Update build.yml

* Reverted back to original build.sh

* Added missing file (possibly forgot to commmit/push it) (#136)

* added python build file to get dynamically current pom.xml dependencies, add build.sh deprecated and improve current github workflow (#138)

Co-authored-by: Dorian Grasset <[email protected]>

---------

Co-authored-by: Dorian Grasset <[email protected]>

* Added support for user email addresses

* Displaying imports in admin process list (#140)

* feat(execution-message): update GigwaModuleManager

* Finalized inclusion of import processes in admin-process list

* Finalized display of imports in admin process list

---------

Co-authored-by: Dorian Grasset <[email protected]>

* Feat/change password (#141)

* feat(change-password): added a menu for logged in users to change password

* feat(change-password): send mail code

* feat(change-password): add new services

* feat(change-password): feature implemented

* feat(change-password): handle password > 20 characters error and update email message

* feat(change-password): put reset code logic in session

* feat(change-password): add enforcedWebapRootUrl var

* Sorted out a few details on password override functionality

---------

Co-authored-by: Dorian Grasset <[email protected]>

* Merged password recovery feature

* Fixed default JavaMailSenderImpl config: no credentials if auth disabled

* Made dumpFolder checking more robust (10sec timeout)

* Minor fixes / changes

* Suggest user to enter an e-mail address if reset functionality is active

* POM.xml version update

* Added HTML version to password reset e-mail (+ skipped for SSO users)

* Better handle security exceptions

* Simplified XML context file loading + enabled global-method-security

* Update build-staging.yml

* Added forgotten class

* Made online output tools available for async-watched exports

* Fixed login issue (redirection to administration was remaining active)

* Minor fix

* add function to check if the user can edit calls and display snpclust button also for reader role

* Fixed import process cleanup

* Merge from master (#145)

* Update build.yml

* Reverted back to original build.sh

* Added missing file (possibly forgot to commmit/push it) (#136)

* added python build file to get dynamically current pom.xml dependencies, add build.sh deprecated and improve current github workflow (#138)

Co-authored-by: Dorian Grasset <[email protected]>

* Update genomes.json

Add 4 new genomes for Citrus medica, C. micrantha, C. maxima and C. reticulata

---------

Co-authored-by: Dorian Grasset <[email protected]>
Co-authored-by: droc <[email protected]>

* Export optim (#146)

* DDL is now fake (deleting file after 1 hour)

This is a counterpart for removing the need for very long timeout
settings

* Made IGV data retrieval compatible with multithreaded export

* Parallelized export functional IGV display

* Minor change

* IGV export is now handled via HapmapExportHandler

* Minor changes

* Made export file cleanup happen periodically

* Minor changes

* Minor change

* Fixed slight interface issues

* Enabled AutoUnzipFilter for DDL exports

* Enhanced export flexibility regarding ability to push to external tools

* Changed project version

* Dynamically accounting for changes in custom output tool configuration

* Minor UI fix

* Minor UI changes

* Fixed bug in reloading saved trait settings

* Worked around filtering by IDs disabling variant type filter

This is causing issues for exporting into formats that don't support all
variant types

* Reverted accidental commit

* Provided means to rearrange metadata columns' order

* Merge from master (#150)

* Update build.yml

* Reverted back to original build.sh

* Added missing file (possibly forgot to commmit/push it) (#136)

* added python build file to get dynamically current pom.xml dependencies, add build.sh deprecated and improve current github workflow (#138)

Co-authored-by: Dorian Grasset <[email protected]>

* Update genomes.json

Add 4 new genomes for Citrus medica, C. micrantha, C. maxima and C. reticulata

---------

Co-authored-by: Dorian Grasset <[email protected]>
Co-authored-by: droc <[email protected]>

* Corrected css file contents

* Provided means to set DB taxonomy thru back-office

* Fixed bug in switching from species to another level

* Minor fix

* Merged Staging & Custom look (#155)

* Added means to customize look

* Merge from master (#114)

* Moved standalone IGV download link to "Online output tools" dialog

* added OAuth token compatibility for API requests, based on an OIDC discovery file (#112)

Co-authored-by: GuilhemSempere <[email protected]>

* Revert "added OAuth token compatibility for API requests, based on an OIDC discovery file (#112)"

This reverts commit a899c7f.

---------

Co-authored-by: Peter Selby <[email protected]>

* Merge from master (#119)

* Moved standalone IGV download link to "Online output tools" dialog

* added OAuth token compatibility for API requests, based on an OIDC discovery file (#112)

Co-authored-by: GuilhemSempere <[email protected]>

* Revert "added OAuth token compatibility for API requests, based on an OIDC discovery file (#112)"

This reverts commit a899c7f.

* Caching unzoomed results for fast zoom resets

... also reduced dot size and set default number of intervals to 1000

* Fixed dialog height (set to maximum for all)

---------

Co-authored-by: Peter Selby <[email protected]>

---------

Co-authored-by: Peter Selby <[email protected]>

* Revert "Merged Staging & Custom look (#155)"

This reverts commit 9845774.

* override listReadablesDb

* Fixed position range paste issue (stripping out non-digits)

* POM version update

* Fixed minor UI issue

* Custom look (#156)

* Provided means to customize the UI

(Windows update script not tested yet)

* Fixed Windows update script

* Fixed export file cleanup rate

* Fixed missing header in IGV data table when no markers in displayed area

* Fixed scrollbar bugs, optimized initial genotype loading, ...

* Minor UI fix

* Handle uploaded files while HTTP request is valid

* Minor UI fix

* Accounted for newly added role, allowing to create DBs

* Removed forbidMongoDiskUse config parameter

* Moved VisualizationService class from Gigwa2ServiceImpl to Mgdb2Export

* Minor UI fix

* Minor UI improvements

* Minor UI improvements

* Fixed startup bug occurring when no trait data available

* Minor change

* Sorted out dodgy import UI behaviour when typing an existing DB's name

* Only check authorities if not anonymous

* Documentation update for v2.9

* Added screenshot to documentation

---------

Co-authored-by: Grégori Mignerot <[email protected]>
Co-authored-by: Yoan BIGGIO <[email protected]>
Co-authored-by: Dorian Grasset <[email protected]>
Co-authored-by: Dorian Grasset <[email protected]>
Co-authored-by: Alice Boizet <[email protected]>
Co-authored-by: droc <[email protected]>
Co-authored-by: Peter Selby <[email protected]>
  • Loading branch information
8 people authored Jan 14, 2025
1 parent fae0c87 commit e1d5d30
Show file tree
Hide file tree
Showing 59 changed files with 3,637 additions and 1,305 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-staging.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gigwa Build Staging test
name: Gigwa Staging Version Build
on:
push:
tags:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target/
/.externalToolBuilders/
/.settings/
12 changes: 9 additions & 3 deletions bundle_files/osx/updateGigwa.command
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ if [ -d "$1" ]; then

#copy configuration files from saved folder to new gigwa folder
cp -av $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-data.xml $2/WEB-INF/classes/applicationContext-data.xml
# cp -av $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-security.xml $2/WEB-INF/classes/applicationContext-security.xml
cp -av $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-MVC.xml $2/WEB-INF/classes/applicationContext-MVC.xml
cp -av $3/$backup_dir.$DATE/WEB-INF/classes/datasources.properties $2/WEB-INF/classes/datasources.properties
cp -av $3/$backup_dir.$DATE/WEB-INF/classes/users.properties $2/WEB-INF/classes/users.properties
cp -av $3/$backup_dir.$DATE/WEB-INF/classes/config.properties $2/WEB-INF/classes/config.properties
cp -av $3/$backup_dir.$DATE/WEB-INF/classes/log4j.xml $2/WEB-INF/classes/log4j.xml

# Changes specific to migration to v2.5

# Changes specific to migration to v2.5
sed -i '' 's/project\$CREATOR/SUPERVISOR/g' "$2"/WEB-INF/classes/users.properties # replace the deprecated project-CREATOR role with the new DB-level SUPERVISOR role

if [ "$(grep -c dumpFolder $2/WEB-INF/classes/config.properties)" -eq 0 ]; then
Expand All @@ -56,10 +56,16 @@ if [ -d "$1" ]; then
if [ "$(grep 'id="passwordEncoder"' $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-security.xml | grep -v '<!--')" != "$(grep 'id="passwordEncoder"' $2/WEB-INF/classes/applicationContext-security.xml | grep -v '<!--')" ]; then
sed -i '' "s/.*PasswordEncoder.*//g;s/.*Only one passwordEncoder bean should be enabled at a time.*//g;s|</secur:http>|</secur:http>\n\n\n$(grep 'id="passwordEncoder"' $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-security.xml | grep -v '<!--')|g;" $2/WEB-INF/classes/applicationContext-security.xml
fi


# Changes specific to migration to v2.9
if [ "$(grep '<context:component-scan base-package' $1/WEB-INF/classes/applicationContext-MVC.xml)" != "$(grep '<context:component-scan base-package' $2/WEB-INF/classes/applicationContext-MVC.xml)" ]; then
sed -i "s|<context:component-scan base-package.*|<context:component-scan base-package=\"fr.cirad.mgdb.service,fr.cirad.web.controller,fr.cirad.manager,fr.cirad.configuration,org.brapi.v2.api,fr.cirad.web.controller,fr.cirad.service\" />|g" $2/WEB-INF/classes/applicationContext-MVC.xml
fi
fi
fi

chmod -R 755 $2

echo -------------------------------
echo "Update complete. You may want to apply chown -R on the updated folder."
echo "Update complete. You may want to apply chown -R on the updated folder."
14 changes: 11 additions & 3 deletions bundle_files/ubuntu/updateGigwa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ if [ -d "$1" ]; then

#copy configuration files from saved folder to new gigwa folder
cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-data.xml $2/WEB-INF/classes/applicationContext-data.xml
# cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-security.xml $2/WEB-INF/classes/applicationContext-security.xml
cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-MVC.xml $2/WEB-INF/classes/applicationContext-MVC.xml
cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/datasources.properties $2/WEB-INF/classes/datasources.properties
cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/users.properties $2/WEB-INF/classes/users.properties
cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/config.properties $2/WEB-INF/classes/config.properties
cp -avr $3/$backup_dir.$DATE/WEB-INF/classes/log4j.xml $2/WEB-INF/classes/log4j.xml
cp -avr $3/$backup_dir.$DATE/custom $2/custom


# Changes specific to migration to v2.5
sed -i 's/project\$CREATOR/SUPERVISOR/g' $2/WEB-INF/classes/users.properties # replace the deprecated project-CREATOR role with the new DB-level SUPERVISOR role
Expand All @@ -54,11 +56,17 @@ if [ -d "$1" ]; then
# applicationContext-security.xml has changed much in v2.5 so we don't want to keep that of the previous version. However, still make sure we keep the same passwordEncoder we had
if [ "$(grep 'id="passwordEncoder"' $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-security.xml | grep -v '<!--')" != "$(grep 'id="passwordEncoder"' $2/WEB-INF/classes/applicationContext-security.xml | grep -v '<!--')" ]; then
sed -i "s/.*PasswordEncoder.*//g;s/.*Only one passwordEncoder bean should be enabled at a time.*//g;s|</secur:http>|</secur:http>\n\n\n$(grep 'id="passwordEncoder"' $3/$backup_dir.$DATE/WEB-INF/classes/applicationContext-security.xml | grep -v '<!--')|g;" $2/WEB-INF/classes/applicationContext-security.xml
fi
fi


# Changes specific to migration to v2.9
if [ "$(grep '<context:component-scan base-package' $1/WEB-INF/classes/applicationContext-MVC.xml)" != "$(grep '<context:component-scan base-package' $2/WEB-INF/classes/applicationContext-MVC.xml)" ]; then
sed -i "s|<context:component-scan base-package.*|<context:component-scan base-package=\"fr.cirad.mgdb.service,fr.cirad.web.controller,fr.cirad.manager,fr.cirad.configuration,org.brapi.v2.api,fr.cirad.web.controller,fr.cirad.service\" />|g" $2/WEB-INF/classes/applicationContext-MVC.xml
fi
fi
fi

chmod -R 755 $2

echo -------------------------------
echo "Update complete. You may want to apply chown -R on the updated folder."
echo "Update complete. You may want to apply chown -R on the updated folder."
8 changes: 7 additions & 1 deletion bundle_files/windows/updateGigwa.bat
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ xcopy /seyi %1 %2

::copy configuration files from saved folder to new gigwa folder
xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\applicationContext-data.xml" "%2\WEB-INF\classes\applicationContext-data.xml"
::xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\applicationContext-security.xml" "%2\WEB-INF\classes\applicationContext-security.xml"
xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\applicationContext-MVC.xml" "%2\WEB-INF\classes\applicationContext-MVC.xml"
xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\datasources.properties" "%2\WEB-INF\classes\datasources.properties"
xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\users.properties" "%2\WEB-INF\classes\users.properties"
xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\config.properties" "%2\WEB-INF\classes\config.properties"
xcopy /seyi "%3\%backup_dir%.%d%\WEB-INF\classes\log4j.xml" "%2\WEB-INF\classes\log4j.xml"
xcopy /seyi "%3\%backup_dir%.%d%\custom" "%2\custom"


:: Changes specific to migration to v2.5
powershell -Command "(gc %2\WEB-INF\classes\users.properties) -replace 'project$CREATOR', 'SUPERVISOR' | Out-File -Encoding ascii %2\WEB-INF\classes\users.properties" # replace the deprecated project-CREATOR role with the new DB-level SUPERVISOR role
Expand All @@ -71,6 +73,10 @@ powershell -Command "if ($(Select-String -Path %2\WEB-INF\classes\config.propert
:: applicationContext-security.xml has changed much in v2.5 so we don't want to keep that of the previous version. However, still make sure we keep the same passwordEncoder as in the previous version
powershell -Command "$previousPE = $(Select-String -Path %3\%backup_dir%.%d%\WEB-INF\classes\applicationContext-security.xml -Pattern 'id=\"passwordEncoder\"' | Select-String -Pattern '<!--' -NotMatch | ForEach-Object {$_.Line}); if ($(Select-String -Path %2\WEB-INF\classes\applicationContext-security.xml -Pattern 'id=\"passwordEncoder\"' | Select-String -Pattern '<!--' -NotMatch | ForEach-Object {$_.Line}) -ne $previousPE) {(gc %1\WEB-INF\classes\applicationContext-security.xml) -creplace '.*PasswordEncoder.*', '' -creplace '.*Only one passwordEncoder bean should be enabled at a time.*', '' -creplace '.*</beans>.*', '' | Out-File -Encoding ascii %2\WEB-INF\classes\applicationContext-security.xml; Add-Content -Path %2\WEB-INF\classes\applicationContext-security.xml -value $previousPE; Add-Content -Path %2\WEB-INF\classes\applicationContext-security.xml -value '</beans>'} else {Write-Host 'same'}"


:: Changes specific to migration to v2.9
powershell -Command "if ((Select-String -Path %1\WEB-INF\classes\applicationContext-MVC.xml -Pattern '<context:component-scan base-package').Line -ne (Select-String -Path %2\WEB-INF\classes\applicationContext-MVC.xml -Pattern '<context:component-scan base-package').Line) { (Get-Content %2\WEB-INF\classes\applicationContext-MVC.xml) -replace '<context:component-scan base-package.*', '<context:component-scan base-package=\"fr.cirad.mgdb.service,fr.cirad.web.controller,fr.cirad.manager,fr.cirad.configuration,org.brapi.v2.api,fr.cirad.web.controller,fr.cirad.service\" />' | Set-Content -Encoding ascii %2\WEB-INF\classes\applicationContext-MVC.xml; }"

echo -------------------------------
echo Update complete.

Expand Down
Binary file added lib/snpEff.jar
Binary file not shown.
48 changes: 33 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

<modelVersion>4.0.0</modelVersion>
<properties>
<project.version>2.8-RELEASE</project.version>
<project.version>2.9-alpha</project.version>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bundle.dir>${project.build.directory}/bundles</bundle.dir>
<bundle.dir.ubuntu>${bundle.dir}/Gigwa_V${project.version}-Ubuntu</bundle.dir.ubuntu>
<bundle.dir.osx>${bundle.dir}/Gigwa_V${project.version}-OSX</bundle.dir.osx>
<bundle.dir.windows>${bundle.dir}/Gigwa_V${project.version}-Windows</bundle.dir.windows>
<path.to.ubuntu.jre>/home/sempere/Bureau/projects/gigwa/bundle_jre/zulu17.40.19-ca-jre17.0.6-linux_x64.tar.gz</path.to.ubuntu.jre>
<path.to.osx.jre>/home/sempere/Bureau/projects/gigwa/bundle_jre/zulu17.40.19-ca-jre17.0.6-macosx_x64.tar.gz</path.to.osx.jre>
<path.to.windows.jre>/home/sempere/Bureau/projects/gigwa/bundle_jre/zulu17.40.19-ca-jre17.0.6-win_x64.tar.gz</path.to.windows.jre>
<!-- ubuntu https://cdn.azul.com/zulu/bin/zulu17.40.19-ca-jre17.0.6-linux_x64.tar.gz -->
<!-- macos https://cdn.azul.com/zulu/bin/zulu17.40.19-ca-jre17.0.6-macosx_x64.tar.gz -->
<!-- win https://cdn.azul.com/zulu/bin/zulu17.40.19-ca-jre17.0.6-win_x64.tar.gz -->
<path.to.ubuntu.jdk>/home/sempere/Bureau/projects/gigwa/bundle_jre/jdk-17_linux-x64_bin.tar.gz</path.to.ubuntu.jdk>
<path.to.osx.jdk>/home/sempere/Bureau/projects/gigwa/bundle_jre/jdk-17_macos-x64_bin.tar.gz</path.to.osx.jdk>
<path.to.windows.jdk>/home/sempere/Bureau/projects/gigwa/bundle_jre/jdk-17_windows-x64_bin.tar.gz</path.to.windows.jdk>
<!-- ubuntu https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz -->
<!-- macos https://download.oracle.com/java/17/latest/jdk-17_macos-x64_bin.tar.gz -->
<!-- win https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.zip, needs to be converted to tar.gz by hand -->
<tomcat.version>9.0.64</tomcat.version>
<mongodb.linux.file>linux-x86_64-ubuntu1804-4.2.25</mongodb.linux.file>
<mongodb.windows.file>win32-x86_64-2012plus-4.2.25</mongodb.windows.file>
Expand All @@ -30,23 +30,41 @@
<packaging>war</packaging>
<name>Gigwa</name>

<dependencies>
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.25</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>

<dependency>
<groupId>fr.cirad</groupId>
<artifactId>role_manager</artifactId>
<version>1.3.7-RELEASE</version>
<version>1.3.8-RELEASE</version>
</dependency>

<dependency>
<groupId>fr.cirad</groupId>
<artifactId>Mgdb2BrapiImpl</artifactId>
<version>1.1.7-RELEASE</version>
<version>1.1.8-RELEASE</version>
</dependency>

<dependency>
<groupId>fr.cirad</groupId>
<artifactId>Mgdb2BrapiV2Impl</artifactId>
<version>2.0.7-RELEASE</version>
<version>2.0.8-RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -71,7 +89,7 @@
<dependency>
<groupId>fr.cirad</groupId>
<artifactId>Gigwa2ServiceImpl</artifactId>
<version>2.8-RELEASE</version>
<version>2.9-RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -851,7 +869,7 @@
<workingDirectory>${bundle.dir.ubuntu}/jre</workingDirectory>
<arguments>
<argument>xvzf</argument>
<argument>${path.to.ubuntu.jre}</argument>
<argument>${path.to.ubuntu.jdk}</argument>
<argument>--strip-components=1</argument>
</arguments>
</configuration>
Expand All @@ -867,7 +885,7 @@
<workingDirectory>${bundle.dir.osx}/jre</workingDirectory>
<arguments>
<argument>xvzf</argument>
<argument>${path.to.osx.jre}</argument>
<argument>${path.to.osx.jdk}</argument>
<argument>--strip-components=1</argument>
</arguments>
</configuration>
Expand All @@ -883,7 +901,7 @@
<workingDirectory>${bundle.dir.windows}/jre</workingDirectory>
<arguments>
<argument>xvzf</argument>
<argument>${path.to.windows.jre}</argument>
<argument>${path.to.windows.jdk}</argument>
<argument>--strip-components=1</argument>
</arguments>
</configuration>
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/fr/cirad/manager/ImportProcess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package fr.cirad.manager;

import fr.cirad.tools.ProgressIndicator;

public class ImportProcess extends AbstractProcess {
private ProgressIndicator progress;

public ImportProcess(ProgressIndicator progress, String module) {
this.progress = progress;
this.module = module;
this.status = ProcessStatus.IDLE;
}

@Override
public String getProcessID() {
return progress.getProcessId();
}

@Override
public ProcessStatus getStatus() {
return progress.isAborted() ? ProcessStatus.INTERRUPTED : (progress.isComplete() ? ProcessStatus.SUCCESS : progress.getError() != null ? ProcessStatus.ERROR : ProcessStatus.RUNNING);
}

@Override
public String getStatusMessage() {
return progress.isComplete() ? "Import complete" : progress.getProgressDescription();
}

@Override
public void abort() {
progress.abort();
this.status = ProcessStatus.INTERRUPTED;
this.statusMessage = "Import process aborted";
}

@Override
public String getLog() {
return null;
}

@Override
public String getAbortWarning() {
return null;
}
}
43 changes: 40 additions & 3 deletions src/main/java/fr/cirad/manager/ScheduledTaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@
package fr.cirad.manager;

import fr.cirad.mgdb.importing.OntologyImport;
import fr.cirad.mgdb.service.GigwaGa4ghServiceImpl;
import fr.cirad.tools.AppConfig;
import fr.cirad.tools.GigwaModuleManager;
import fr.cirad.tools.mongo.MongoTemplateManager;
import fr.cirad.tools.security.TokenManager;

import java.text.ParseException;
import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;

import org.brapi.v2.api.VariantsetsApiController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.context.ServletContextAware;

/**
* class for methods that run periodically or upon server startup
Expand All @@ -37,13 +41,21 @@
*/
@Configuration
@EnableScheduling
public class ScheduledTaskManager {
public class ScheduledTaskManager implements ServletContextAware {

static private final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ScheduledTaskManager.class);

@Autowired private AppConfig appConfig;
@Autowired TokenManager tokenManager;
@Autowired private TokenManager tokenManager;
@Autowired private GigwaModuleManager moduleManager;

private ServletContext servletContext;

@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}

/**
* remove old tokens and drop associated temporary collections, executed every 6 hours
*/
Expand Down Expand Up @@ -83,4 +95,29 @@ public void onStartup() {
LOG.info("CAS authentication enabled with " + casServerURL);
}
}

/**
* Cleanup old finished import processes periodically
*/
@Scheduled(fixedRate = 1000*60*60*24 /* 1 day */)
public void cleanupCompleteImportProcesses() {
moduleManager.cleanupCompleteImportProcesses();
}

/**
* Cleanup old finished processes regularly
*/
@Scheduled(fixedRate = 1000*60*60 /* 1 hour */)
public void cleanupExpiredExportFiles() {
new Thread() {
public void run() {
try {
GigwaGa4ghServiceImpl.cleanupExpiredExportData(servletContext);
VariantsetsApiController.cleanupOldExportData(servletContext);
} catch (Exception e) {
LOG.error("Unable to cleanup expired export files", e);
}
}
}.start();
}
}
10 changes: 4 additions & 6 deletions src/main/java/fr/cirad/security/GigwaUserDetailsWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ public void setUserDetailsService(ReloadableInMemoryDaoImpl service) {
public UserDetails loadUserDetails(T authentication) throws DataAccessException {
if (authentication instanceof CasAssertionAuthenticationToken) { // CAS authentication
try {
return service.loadUserByUsernameAndMethod(authentication.getName(), METHOD_CAS);
} catch (UsernameNotFoundException exc) {
// New CAS user : create account
// TODO : Config option to create account automatically or only manually
return service.loadUserByUsername(authentication.getName());
} catch (UsernameNotFoundException exc) { // New CAS user : create account
String[] authorities = {IRoleDefinition.DUMMY_EMPTY_ROLE};
try {
service.saveOrUpdateUser(authentication.getName(), "", authorities, true, METHOD_CAS);
service.saveOrUpdateUser(authentication.getName(), "", authorities, true, METHOD_CAS, null);
} catch (IOException e) {
LOG.error(e);
throw new ExternalUserCreationFailureException("Error while creating the new CAS user", e);
}
UserDetails user = service.loadUserByUsernameAndMethod(authentication.getName(), METHOD_CAS);
UserDetails user = service.loadUserByUsername(authentication.getName());
return user;
}
} else { // Traditional authentication
Expand Down
Loading

0 comments on commit e1d5d30

Please sign in to comment.