Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1138 from MPDL-Innovations/develop
Browse files Browse the repository at this point in the history
Input for release 3.3
  • Loading branch information
bastiensaquet committed Mar 1, 2016
2 parents d57a6fe + a10241b commit 4173222
Show file tree
Hide file tree
Showing 314 changed files with 5,993 additions and 5,121 deletions.
36 changes: 20 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
</mailingLists>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Setting this property so that generated project uses correct version
of richfaces. -->
<org.richfaces.bom.version>4.3.7.Final</org.richfaces.bom.version>
Expand Down Expand Up @@ -193,7 +193,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
</plugin>
<plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
Expand Down Expand Up @@ -322,6 +322,16 @@
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
Expand Down Expand Up @@ -425,12 +435,6 @@
<artifactId>im4java</artifactId>
<version>1.2.0</version>
</dependency>
<!-- pdf handling -->
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>pdf-renderer</artifactId>
<version>1.0.5</version>
</dependency>
<!-- image/video hanlding -->
<dependency>
<groupId>org.openimaj</groupId>
Expand Down Expand Up @@ -507,11 +511,6 @@
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>net.java.dev.webdav</groupId>
<artifactId>webdav-jaxrs</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
Expand Down Expand Up @@ -588,6 +587,11 @@
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.8.10</version>
</dependency>
</dependencies>
<profiles>
<!-- this profile is used by developers -->
Expand All @@ -598,7 +602,7 @@
encoding Cp1252, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- the jdk version to use -->
<jdk.version>1.7</jdk.version>
<jdk.version>1.8</jdk.version>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -657,7 +661,7 @@
encoding Cp1252, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- the jdk version to use -->
<jdk.version>1.7</jdk.version>
<jdk.version>1.8</jdk.version>
<project.build.finalName>imeji</project.build.finalName>
</properties>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package de.mpg.imeji.exceptions;

/**
* Exception for authentication of inactive users
*
* @author bastiens
*
*/
public class InactiveAuthenticationError extends AuthenticationError {
private static final long serialVersionUID = 7976153766697083425L;

public InactiveAuthenticationError(String message) {
super(message);
}
}
15 changes: 15 additions & 0 deletions src/main/java/de/mpg/imeji/exceptions/WorkflowException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package de.mpg.imeji.exceptions;

/**
* Exception when ann non valid workflow operation is done (for instance: release, discard)
*
* @author bastiens
*
*/
public class WorkflowException extends ImejiException {
private static final long serialVersionUID = -5279563970035349584L;

public WorkflowException(String message) {
super(message);
}
}
74 changes: 41 additions & 33 deletions src/main/java/de/mpg/imeji/logic/Imeji.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.hp.hpl.jena.tdb.sys.TDBMaker;

import de.mpg.imeji.exceptions.AlreadyExistsException;
import de.mpg.imeji.exceptions.ImejiException;
import de.mpg.imeji.exceptions.NotFoundException;
import de.mpg.imeji.logic.auth.authorization.AuthorizationPredefinedRoles;
import de.mpg.imeji.logic.concurrency.locks.LocksSurveyor;
Expand All @@ -45,6 +46,7 @@
import de.mpg.imeji.logic.vo.Space;
import de.mpg.imeji.logic.vo.Statement;
import de.mpg.imeji.logic.vo.User;
import de.mpg.imeji.presentation.beans.ConfigurationBean;
import de.mpg.imeji.presentation.util.ImejiFactory;
import de.mpg.imeji.presentation.util.PropertyReader;
import de.mpg.j2j.annotations.j2jModel;
Expand All @@ -57,7 +59,7 @@
* @version $Revision$ $LastChangedDate$
*/
public class Imeji {
private static final Logger logger = Logger.getLogger(Imeji.class);
private static final Logger LOGGER = Logger.getLogger(Imeji.class);
public static String tdbPath = null;
public static String collectionModel;
public static String albumModel;
Expand All @@ -71,6 +73,7 @@ public class Imeji {
public static MetadataProfile defaultMetadataProfile;
private static final String ADMIN_EMAIL_INIT = "admin@imeji.org";
private static final String ADMIN_PASSWORD_INIT = "admin";
public static ConfigurationBean CONFIG;
/**
* Thread to check if locked objects can be unlocked
*/
Expand All @@ -90,9 +93,10 @@ public class Imeji {
*
* @throws URISyntaxException
* @throws IOException
* @throws ImejiException
*
*/
public static void init() throws IOException, URISyntaxException {
public static void init() throws IOException, URISyntaxException, ImejiException {
tdbPath = PropertyReader.getProperty("imeji.tdb.path");
init(tdbPath);
ElasticService.start();
Expand All @@ -110,34 +114,37 @@ public static void runMigration() throws IOException {
try {
in = new FileInputStream(f);
} catch (FileNotFoundException e) {
logger.info("No" + f.getAbsolutePath() + " found, no migration runs");
LOGGER.info("No" + f.getAbsolutePath() + " found, no migration runs");
}
if (in != null) {
String migrationRequests = new String(StreamUtils.getBytes(in), "UTF-8");
logger.info("Running migration with query: ");
logger.info(migrationRequests);
LOGGER.info("Running migration with query: ");
LOGGER.info(migrationRequests);
ImejiSPARQL.execUpdate(migrationRequests);
logger.info("Migration done!");
LOGGER.info("Migration done!");
}
}

/**
* Initialize a {@link Jena} database according at one path location in filesystem
*
* @param path
* @throws ImejiException
* @throws URISyntaxException
* @throws IOException
*/
public static void init(String path) {
public static void init(String path) throws IOException, URISyntaxException, ImejiException {
if (path != null) {
File f = new File(path);
if (!f.exists()) {
f.getParentFile().mkdirs();
}
tdbPath = f.getAbsolutePath();
}
logger.info("Initializing Jena dataset (" + tdbPath + ")...");
LOGGER.info("Initializing Jena dataset (" + tdbPath + ")...");
dataset = tdbPath != null ? TDBFactory.createDataset(tdbPath) : TDBFactory.createDataset();
logger.info("... dataset done!");
logger.info("Initializing Jena models...");
LOGGER.info("... dataset done!");
LOGGER.info("Initializing Jena models...");
albumModel = getModelName(Album.class);
collectionModel = getModelName(CollectionImeji.class);
imageModel = getModelName(Item.class);
Expand All @@ -152,7 +159,8 @@ public static void init(String path) {
initModel(statementModel);
initModel(profileModel);
initModel(spaceModel);
logger.info("... models done!");
LOGGER.info("... models done!");
CONFIG = new ConfigurationBean();
initadminUser();
initDefaultMetadataProfile();
}
Expand Down Expand Up @@ -208,22 +216,22 @@ private static void initadminUser() {
try {
uc.retrieve(Imeji.adminUser.getEmail());
} catch (NotFoundException e) {
logger.info(
LOGGER.info(
"!!! IMPORTANT !!! Create admin@imeji.org as system administrator with password admin. !!! CHANGE PASSWORD !!!");
uc.create(Imeji.adminUser, USER_TYPE.ADMIN);
logger.info("Created admin user successfully:" + Imeji.adminUser.getEmail());
LOGGER.info("Created admin user successfully:" + Imeji.adminUser.getEmail());
}
} else {
logger.info("Admin user already exists:");
LOGGER.info("Admin user already exists:");
for (User admin : admins) {
logger.info(admin.getEmail() + " is admin + (" + admin.getId() + ")");
LOGGER.info(admin.getEmail() + " is admin + (" + admin.getId() + ")");
}
}
} catch (AlreadyExistsException e) {
logger.warn(Imeji.adminUser.getEmail() + " already exists");
LOGGER.warn(Imeji.adminUser.getEmail() + " already exists");
} catch (Exception e) {
if (e.getCause() instanceof AlreadyExistsException) {
logger.warn(Imeji.adminUser.getEmail() + " already exists");
LOGGER.warn(Imeji.adminUser.getEmail() + " already exists");
} else {
throw new RuntimeException("Error initializing Admin user! ", e);
}
Expand All @@ -232,50 +240,50 @@ private static void initadminUser() {

private static void initDefaultMetadataProfile() {
ProfileController pc = new ProfileController();
logger.info("Initializing default metadata profile...");
LOGGER.info("Initializing default metadata profile...");
try {
defaultMetadataProfile = pc.initDefaultMetadataProfile();
} catch (Exception e) {
logger.error("error retrieving/creating default metadata profile: ", e);
LOGGER.error("error retrieving/creating default metadata profile: ", e);
}
if (defaultMetadataProfile != null) {
logger.info("Default metadata profile is set-up to " + defaultMetadataProfile.getId());
LOGGER.info("Default metadata profile is set-up to " + defaultMetadataProfile.getId());
} else {
logger.info(
LOGGER.info(
"Checking for default metadata profile is finished: no default metadata profile has been set.");

}
}

public static void shutdown() {
logger.info("Shutting down thread executor...");
LOGGER.info("Shutting down thread executor...");
Imeji.executor.shutdown();
nightlyExecutor.stop();
logger.info("executor shutdown shutdown? " + Imeji.executor.isShutdown());
LOGGER.info("executor shutdown shutdown? " + Imeji.executor.isShutdown());
ElasticService.shutdown();
logger.info("Ending LockSurveyor...");
LOGGER.info("Ending LockSurveyor...");
locksSurveyor.terminate();
logger.info("...done");
logger.info("Closing Jena! TDB...");
LOGGER.info("...done");
LOGGER.info("Closing Jena! TDB...");
TDB.sync(Imeji.dataset);
logger.info("sync done");
LOGGER.info("sync done");
Imeji.dataset.close();
logger.info("dataset closed");
LOGGER.info("dataset closed");
TDB.closedown();
logger.info("tdb closed");
LOGGER.info("tdb closed");
TDBMaker.releaseLocation(Location.create(Imeji.tdbPath));
logger.info("location released");
logger.info("...done!");
LOGGER.info("location released");
LOGGER.info("...done!");

// This is a bug of com.hp.hpl.jena.sparql.engine.QueryExecutionBase
// implementation:
// AlarmClock is not correctly released, it leads to the memory leaks
// after tomcat stop
// see https://github.com/imeji-community/imeji/issues/966!
logger.info("Release AlarmClock...");
LOGGER.info("Release AlarmClock...");
AlarmClock alarmClock = AlarmClock.get();
alarmClock.release();
logger.info("done");
LOGGER.info("done");
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/mpg/imeji/logic/ImejiNamespaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ImejiNamespaces {
public static final String REGISTRATION_TOKEN = "http://imeji.org/terms/registrationToken";
public static final String SPACE = "http://imeji.org/terms/space";
public static final String CHECKSUM = "http://imeji.org/terms/checksum";
public static final String STORAGE_ID = "http://imeji.org/terms/storageId";


/*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/mpg/imeji/logic/ImejiTriple.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.mpg.imeji.logic;

import de.mpg.imeji.logic.auth.Authorization;
import de.mpg.imeji.logic.auth.authorization.Authorization;

/**
* An RDF Triple, which can be Checked by the {@link Authorization}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* wissenschaftlich-technische Information mbH and Max-Planck- Gesellschaft zur Förderung der
* Wissenschaft e.V. All rights reserved. Use is subject to license terms.
*/
package de.mpg.imeji.logic.auth;
package de.mpg.imeji.logic.auth.authentication;

import de.mpg.imeji.exceptions.AuthenticationError;
import de.mpg.imeji.logic.vo.User;
Expand All @@ -36,6 +36,7 @@
*/
public interface Authentication {


/**
* Log in a user with a login (email or user name) and password
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
* wissenschaftlich-technische Information mbH and Max-Planck- Gesellschaft zur Förderung der
* Wissenschaft e.V. All rights reserved. Use is subject to license terms.
*/
package de.mpg.imeji.logic.auth;
package de.mpg.imeji.logic.auth.authentication;

import javax.servlet.http.HttpServletRequest;

import de.mpg.imeji.logic.auth.authentication.HttpAuthentication;
import de.mpg.imeji.logic.auth.authentication.SimpleAuthentication;
import de.mpg.imeji.logic.auth.authentication.impl.HttpAuthentication;
import de.mpg.imeji.logic.auth.authentication.impl.DefaultAuthentication;

/**
* Factory for Authentication
Expand All @@ -37,6 +37,7 @@
* @version $Revision$ $LastChangedDate$
*/
public class AuthenticationFactory {

/**
* Factory with a login and a password
*
Expand All @@ -45,7 +46,7 @@ public class AuthenticationFactory {
* @return
*/
public static Authentication factory(String login, String pwd) {
return new SimpleAuthentication(login, pwd);
return new DefaultAuthentication(login, pwd);
}

/**
Expand Down

0 comments on commit 4173222

Please sign in to comment.