TSK-967: Extract module taskana-data to distribute data for tests and examples
This commit is contained in:
parent
3401d9ee04
commit
75c9354f56
|
@ -16,6 +16,7 @@
|
|||
|
||||
<modules>
|
||||
<module>taskana-core</module>
|
||||
<module>taskana-data</module>
|
||||
<module>taskana-cdi</module>
|
||||
<module>taskana-spring</module>
|
||||
<module>taskana-cdi-example</module>
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
</dependency>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package pro.taskana.sampledata;
|
||||
|
||||
import org.apache.ibatis.datasource.pooled.PooledDataSource;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import pro.taskana.configuration.DbSchemaCreator;
|
||||
|
||||
/**
|
||||
* Test SampleDataGenerator.
|
||||
*/
|
||||
class SampleDataGeneratorTest {
|
||||
|
||||
@Test
|
||||
void getScriptsValidSql() {
|
||||
PooledDataSource pooledDataSource = new PooledDataSource("org.h2.Driver",
|
||||
"jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA", "sa", "sa");
|
||||
Assertions.assertDoesNotThrow(() -> new DbSchemaCreator(pooledDataSource, "TASKANA").run());
|
||||
Assertions.assertDoesNotThrow(() -> new SampleDataGenerator(pooledDataSource).generateSampleData("TASKANA"));
|
||||
pooledDataSource.forceCloseAll();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>taskana-data</artifactId>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<description>The helper module to import data for testing.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-lib-parent</artifactId>
|
||||
<version>1.1.6-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>${version.mybatis}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${version.slf4j}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${version.h2}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,8 +1,6 @@
|
|||
package pro.taskana.sampledata;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
|
@ -13,6 +11,7 @@ import java.time.LocalDateTime;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -24,8 +23,6 @@ import org.apache.ibatis.jdbc.ScriptRunner;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
|
||||
/**
|
||||
* This class generates sample data for manual testing purposes.
|
||||
*/
|
||||
|
@ -72,8 +69,7 @@ public class SampleDataGenerator {
|
|||
runner.runScript(
|
||||
selectSchemaScript(dataSource.getConnection().getMetaData().getDatabaseProductName(), schemaName));
|
||||
runner.setStopOnError(false);
|
||||
runner.runScript(new BufferedReader(
|
||||
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8)));
|
||||
runner.runScript(getScriptBufferedStream(CLEAR));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("caught Exception {}", e);
|
||||
}
|
||||
|
@ -86,7 +82,6 @@ public class SampleDataGenerator {
|
|||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Stream.of(script)
|
||||
.map(this.getClass()::getResourceAsStream)
|
||||
.map(s -> SampleDataGenerator.parseAndReplace(now, s))
|
||||
.map(StringReader::new)
|
||||
.map(BufferedReader::new)
|
||||
|
@ -125,18 +120,8 @@ public class SampleDataGenerator {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String parseAndReplace(LocalDateTime now, InputStream stream) {
|
||||
try (
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
|
||||
return replaceRelativeTimeFunction(now,
|
||||
bufferedReader.lines().collect(Collectors.joining(System.lineSeparator())));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private StringReader selectSchemaScript(String dbProductName, String schemaName) {
|
||||
return new StringReader(TaskanaEngineImpl.isPostgreSQL(dbProductName)
|
||||
return new StringReader(isPostgreSQL(dbProductName)
|
||||
? "SET search_path TO " + schemaName + ";"
|
||||
: "SET SCHEMA " + schemaName + ";");
|
||||
}
|
||||
|
@ -146,20 +131,36 @@ public class SampleDataGenerator {
|
|||
* @return a array with the corresponding scripts files
|
||||
*/
|
||||
private String[] getScriptList() {
|
||||
String[] script = {WORKBASKET, DISTRIBUTION_TARGETS, CLASSIFICATION, TASK, ATTACHMENT, WORKBASKET_ACCESS_LIST,
|
||||
OBJECT_REFERENCE};
|
||||
ArrayList<String> scriptsList = new ArrayList<>(Arrays.asList(script));
|
||||
ArrayList<String> scriptsList = getDefaultScripts();
|
||||
|
||||
try {
|
||||
runner.runScript(new BufferedReader(
|
||||
new InputStreamReader(this.getClass().getResourceAsStream(CHECK_HISTORY_EVENT_EXIST),
|
||||
StandardCharsets.UTF_8)));
|
||||
runner.runScript(new BufferedReader(
|
||||
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR_HISTORY_EVENTS), StandardCharsets.UTF_8)));
|
||||
runner.runScript(getScriptBufferedStream(CHECK_HISTORY_EVENT_EXIST));
|
||||
runner.runScript(getScriptBufferedStream(CLEAR_HISTORY_EVENTS));
|
||||
scriptsList.add(HISTORY_EVENT);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("The HISTORY_EVENTS table is not created");
|
||||
}
|
||||
return scriptsList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
static String parseAndReplace(LocalDateTime now, String script) {
|
||||
return replaceRelativeTimeFunction(now,
|
||||
getScriptBufferedStream(script).lines().collect(Collectors.joining(System.lineSeparator())));
|
||||
}
|
||||
|
||||
static BufferedReader getScriptBufferedStream(String script) {
|
||||
return Optional.ofNullable(SampleDataGenerator.class.getResourceAsStream(script)).map(
|
||||
inputStream -> new BufferedReader(
|
||||
new InputStreamReader(inputStream, StandardCharsets.UTF_8))).orElse(null);
|
||||
}
|
||||
|
||||
static ArrayList<String> getDefaultScripts() {
|
||||
String[] script = {WORKBASKET, DISTRIBUTION_TARGETS, CLASSIFICATION, TASK, ATTACHMENT, WORKBASKET_ACCESS_LIST,
|
||||
OBJECT_REFERENCE};
|
||||
return new ArrayList<>(Arrays.asList(script));
|
||||
}
|
||||
|
||||
private static boolean isPostgreSQL(String databaseProductName) {
|
||||
return "PostgreSQL".equals(databaseProductName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package pro.taskana.sampledata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test SampleDataGenerator.
|
||||
*/
|
||||
class SampleDataGeneratorTest {
|
||||
|
||||
@Test
|
||||
void getScriptsNotEmpty() {
|
||||
ArrayList<String> scripts = SampleDataGenerator.getDefaultScripts();
|
||||
Assertions.assertNotNull(scripts);
|
||||
Assertions.assertTrue(scripts.size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getScriptsFileExists() {
|
||||
ArrayList<String> scripts = SampleDataGenerator.getDefaultScripts();
|
||||
for (String script : scripts) {
|
||||
Assertions.assertNotNull(SampleDataGenerator.getScriptBufferedStream(script));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -14,13 +14,28 @@
|
|||
<version>1.1.6-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${version.spring.boot}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-rest-spring</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
@ -39,7 +54,6 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
<version>${version.spring.core}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
|
@ -70,6 +84,30 @@
|
|||
<version>${version.spring}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<version>${version.junit.jupiter}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package pro.taskana;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.hateoas.hal.Jackson2HalModule;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
/**
|
||||
* Helps to simplify rest api testing.
|
||||
*/
|
||||
@Component
|
||||
public class RestHelper {
|
||||
|
||||
@Autowired
|
||||
Environment environment;
|
||||
|
||||
public static RestTemplate template = getRestTemplate();
|
||||
|
||||
public String toUrl(String relativeUrl, Object... uriVariables) {
|
||||
return UriComponentsBuilder.fromPath(relativeUrl)
|
||||
.scheme("http")
|
||||
.host("127.0.0.1")
|
||||
.port(environment.getProperty("local.server.port"))
|
||||
.build(uriVariables)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public HttpEntity<String> defaultRequest() {
|
||||
return new HttpEntity<>(getHeaders());
|
||||
}
|
||||
|
||||
public HttpHeaders getHeaders() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersAdmin() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", "Basic YWRtaW46YWRtaW4="); // admin:admin
|
||||
headers.add("Content-Type", "application/hal+json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a REST template which is capable of dealing with responses in HAL format.
|
||||
*
|
||||
* @return RestTemplate
|
||||
*/
|
||||
public static RestTemplate getRestTemplate() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
mapper.registerModule(new Jackson2HalModule());
|
||||
|
||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
|
||||
converter.setObjectMapper(mapper);
|
||||
|
||||
RestTemplate template = new RestTemplate();
|
||||
//important to add first to ensure priority
|
||||
template.getMessageConverters().add(0, converter);
|
||||
return template;
|
||||
}
|
||||
}
|
|
@ -10,12 +10,16 @@ import java.util.List;
|
|||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -23,9 +27,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import pro.taskana.Classification;
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.rest.Mapping;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||
import pro.taskana.rest.resource.TaskResource;
|
||||
|
@ -34,7 +38,9 @@ import pro.taskana.rest.resource.TaskResourceAssembler;
|
|||
/**
|
||||
* Test async updates.
|
||||
*/
|
||||
@TaskanaSpringBootTest
|
||||
@ActiveProfiles({"test"})
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class AsyncUpdateJobIntTest {
|
||||
|
||||
private static final String CLASSIFICATION_ID = "CLI:100000000000000000000000000000000003";
|
|
@ -5,18 +5,24 @@ import static org.junit.Assert.assertEquals;
|
|||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.rest.RestConfiguration;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
|
||||
/**
|
||||
* Test Ldap attachment.
|
||||
*
|
||||
*/
|
||||
@TaskanaSpringBootTest
|
||||
@ActiveProfiles({"test"})
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class LdapTest {
|
||||
|
||||
@Autowired
|
|
@ -10,24 +10,30 @@ import java.util.List;
|
|||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
|
||||
/**
|
||||
* Test AccessIdValidation.
|
||||
*/
|
||||
@TaskanaSpringBootTest
|
||||
|
||||
@ActiveProfiles({"test"})
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class AccessIdValidationControllerIntTest {
|
||||
|
||||
@Autowired RestHelper restHelper;
|
|
@ -0,0 +1,74 @@
|
|||
package pro.taskana.rest;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import pro.taskana.jobs.TransactionalJobsConfiguration;
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.ldap.LdapClient;
|
||||
import pro.taskana.ldap.LdapConfiguration;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
|
||||
/**
|
||||
* Example Application showing the implementation of taskana-rest-spring.
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@ComponentScan(basePackages = "pro.taskana")
|
||||
@Import({TransactionalJobsConfiguration.class, LdapConfiguration.class, RestConfiguration.class, WebMvcConfig.class})
|
||||
public class ExampleRestApplication {
|
||||
|
||||
@Value("${taskana.schemaName:TASKANA}")
|
||||
public String schemaName;
|
||||
|
||||
@Value("${generateSampleData:true}")
|
||||
public boolean generateSampleData;
|
||||
|
||||
@Autowired
|
||||
private SampleDataGenerator sampleDataGenerator;
|
||||
|
||||
@Autowired
|
||||
private LdapClient ldapClient;
|
||||
|
||||
@Autowired private LdapCacheTestImpl ldapCacheTest;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExampleRestApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PlatformTransactionManager txManager(DataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@DependsOn("getTaskanaEngine") // generate sample data after schema was inserted
|
||||
public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException {
|
||||
sampleDataGenerator = new SampleDataGenerator(dataSource);
|
||||
return sampleDataGenerator;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
if (!ldapClient.useLdap()) {
|
||||
AccessIdController.setLdapCache(ldapCacheTest);
|
||||
}
|
||||
if (generateSampleData) {
|
||||
sampleDataGenerator.generateSampleData(schemaName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
logging.level.pro.taskana=INFO
|
||||
### logging.level.org.springframework=DEBUG
|
||||
######## Taskana DB #######
|
||||
datasource.url=jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0
|
||||
datasource.driverClassName=org.h2.Driver
|
||||
datasource.username=sa
|
||||
datasource.password=sa
|
||||
taskana.schemaName=TASKANA
|
||||
####### property that control rest api security deploy use true for no security.
|
||||
devMode=false
|
||||
|
||||
####### Property that informs about the Taskana's version. This version is shown the application web
|
||||
version=@project.version@
|
||||
|
||||
####### control LDAP usage
|
||||
taskana.ldap.useLdap=false
|
||||
####### properties to connect to LDAP
|
||||
taskana.ldap.serverUrl=ldap://localhost:10389
|
||||
taskana.ldap.bindDn=uid=admin,ou=system
|
||||
taskana.ldap.bindPassword=secret
|
||||
taskana.ldap.baseDn=o=TaskanaTest
|
||||
####### properties that control search for users and groups
|
||||
taskana.ldap.userSearchBase=ou=people
|
||||
taskana.ldap.userSearchFilterName=objectclass
|
||||
taskana.ldap.userSearchFilterValue=person
|
||||
taskana.ldap.userFirstnameAttribute=givenName
|
||||
taskana.ldap.userLastnameAttribute=sn
|
||||
taskana.ldap.userIdAttribute=uid
|
||||
taskana.ldap.groupSearchBase=ou=groups
|
||||
taskana.ldap.groupSearchFilterName=objectclass
|
||||
taskana.ldap.groupSearchFilterValue=groupOfUniqueNames
|
||||
taskana.ldap.groupNameAttribute=cn
|
||||
taskana.ldap.minSearchForLength=3
|
||||
taskana.ldap.maxNumberOfReturnedAccessIds=50
|
||||
####### JobScheduler cron expression that specifies when the JobSchedler runs
|
||||
taskana.jobscheduler.async.cron=0 0 * * * *
|
||||
####### cache static resources properties
|
||||
spring.resources.cache.cachecontrol.cache-private=true
|
||||
####### tomcat is not detecting the x-forward headers from bluemix as a trustworthy proxy
|
||||
server.tomcat.internal-proxies=.*
|
||||
server.use-forward-headers=true
|
|
@ -0,0 +1,14 @@
|
|||
taskana.roles.user = group1 | group2|teamlead_1 |teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone
|
||||
taskana.roles.Admin=name=konrad,Organisation=novatec|admin
|
||||
taskana.roles.businessadmin=max|Moritz|businessadmin
|
||||
taskana.roles.monitor=john|teamlead_2 | monitor
|
||||
taskana.domains=DOMAIN_A,DOMAIN_B,DOMAIN_C
|
||||
taskana.classification.types=TASK,DOCUMENT
|
||||
taskana.classification.categories.task= EXTERNAL, manual, autoMAtic, Process
|
||||
taskana.classification.categories.document= EXTERNAL
|
||||
|
||||
taskana.jobs.maxRetries=3
|
||||
taskana.jobs.batchSize=50
|
||||
taskana.jobs.cleanup.runEvery=P1D
|
||||
taskana.jobs.cleanup.firstRunAt=2018-07-25T08:00:00Z
|
||||
taskana.jobs.cleanup.minimumAge=P14D
|
|
@ -31,7 +31,13 @@
|
|||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-rest-spring-example-common</artifactId>
|
||||
<artifactId>taskana-data</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pro.taskana</groupId>
|
||||
<artifactId>taskana-rest-spring</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -0,0 +1,392 @@
|
|||
package pro.taskana.ldap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
|
||||
/**
|
||||
* Implementation of LdapCache used for Unit tests.
|
||||
*
|
||||
* @author bbr
|
||||
*/
|
||||
public class LdapCacheTestImpl implements LdapCache {
|
||||
|
||||
/**
|
||||
* Dictionary is a {@link Map} collection that contains {@link AccessIdResource} as key (user)
|
||||
* and {@link List<AccessIdResource>} as value (groups of which the user is a member) .
|
||||
*/
|
||||
private static Map<AccessIdResource, List<AccessIdResource>> users;
|
||||
private static List<AccessIdResource> accessIds = new ArrayList<>(Arrays.asList(
|
||||
new AccessIdResource("Martin, Rojas Miguel Angel", "user_1_1"),
|
||||
new AccessIdResource("Zorgati, Mustapha", "user_2_1"),
|
||||
new AccessIdResource("Behrendt, Maximilian", "max"),
|
||||
new AccessIdResource("Bert, Ali", "teamlead_5"),
|
||||
new AccessIdResource("Hagen, Holger", "teamlead_3"),
|
||||
new AccessIdResource("Breier, Bernd", "user_2_2"),
|
||||
new AccessIdResource("Fielmalz, Anke", "user017"),
|
||||
new AccessIdResource("Mente, Maximilian", "max_mente"),
|
||||
new AccessIdResource("Theke, Bernd", "user_2_3"),
|
||||
new AccessIdResource("Ferrante, Elena", "elena"),
|
||||
new AccessIdResource("Mueller, Simone", "simone"),
|
||||
new AccessIdResource("Sirup, Aaron", "user001"),
|
||||
new AccessIdResource("Nacho, recuerda", "user_1_2"),
|
||||
new AccessIdResource("Lass, Ada", "user003"),
|
||||
new AccessIdResource("Tion, Addi", "user004"),
|
||||
new AccessIdResource("Lette, Adi", "user005"),
|
||||
new AccessIdResource("Admin", "teamlead_2"),
|
||||
new AccessIdResource("Native, Alter", "user006"),
|
||||
new AccessIdResource("Herum, Albert", "user007"),
|
||||
new AccessIdResource("Meyer, Dominik", "teamlead_1"),
|
||||
new AccessIdResource("Mente, Ali", "user009"),
|
||||
new AccessIdResource("Nach, Alma", "user011"),
|
||||
new AccessIdResource("Gehzauch, Anders", "user012"),
|
||||
new AccessIdResource("Theke, Andi", "user013"),
|
||||
new AccessIdResource("Kreuz, Andreas", "user014"),
|
||||
new AccessIdResource("Tiefsee, Anka", "user016"),
|
||||
new AccessIdResource("Fassen, Ann", "user018"),
|
||||
new AccessIdResource("Probe, Ann", "user019"),
|
||||
new AccessIdResource("Bolika, Anna", "user020"),
|
||||
new AccessIdResource("Ecke, Anna", "user021"),
|
||||
new AccessIdResource("Hosi, Anna", "user022"),
|
||||
new AccessIdResource("Kronis-Tisch, Anna", "user023"),
|
||||
new AccessIdResource("Logie, Anna", "user024"),
|
||||
new AccessIdResource("Luehse, Anna", "user025"),
|
||||
new AccessIdResource("Nass, Anna", "user026"),
|
||||
new AccessIdResource("Thalb, Anna", "user027"),
|
||||
new AccessIdResource("Tomie, Anna", "user028"),
|
||||
new AccessIdResource("Donnich, Anne", "user029"),
|
||||
new AccessIdResource("Kaffek, Anne", "user030"),
|
||||
new AccessIdResource("Thek, Anne", "user031"),
|
||||
new AccessIdResource("Matoer, Anni", "user032"),
|
||||
new AccessIdResource("Ragentor, Ansgar", "user033"),
|
||||
new AccessIdResource("Stoteles, Ari", "user034"),
|
||||
new AccessIdResource("Thmetik, Ari", "user035"),
|
||||
new AccessIdResource("Nuehm, Arno", "user036"),
|
||||
new AccessIdResource("Schocke, Artie", "user037"),
|
||||
new AccessIdResource("Stoppel, Bart", "user038"),
|
||||
new AccessIdResource("Beitung, Bea", "user039"),
|
||||
new AccessIdResource("Ildich, Bea", "user040"),
|
||||
new AccessIdResource("Vista, Bella", "user041"),
|
||||
new AccessIdResource("Utzer, Ben", "user042"),
|
||||
new AccessIdResource("Zien, Ben", "user043"),
|
||||
new AccessIdResource("Stein, Bernd", "user044"),
|
||||
new AccessIdResource("Deramen, Bill", "user045"),
|
||||
new AccessIdResource("Honig, Bine", "user046"),
|
||||
new AccessIdResource("Densatz, Bo", "user047"),
|
||||
new AccessIdResource("Densee, Bo", "user048"),
|
||||
new AccessIdResource("Lerwagen, Bo", "user049"),
|
||||
new AccessIdResource("Tail, Bob", "user050"),
|
||||
new AccessIdResource("Ketta, Bruce", "user051"),
|
||||
new AccessIdResource("Terrie, Bud", "user052"),
|
||||
new AccessIdResource("Biener-Haken, Cara", "user053"),
|
||||
new AccessIdResource("Ass, Caro", "user054"),
|
||||
new AccessIdResource("Kaffee, Caro", "user055"),
|
||||
new AccessIdResource("Linger, Caro", "user056"),
|
||||
new AccessIdResource("tenSaft, Caro", "user057"),
|
||||
new AccessIdResource("Antheme, Chris", "user058"),
|
||||
new AccessIdResource("Baum, Chris", "user059"),
|
||||
new AccessIdResource("Tall, Chris", "user060"),
|
||||
new AccessIdResource("Reiniger, Claas", "user061"),
|
||||
new AccessIdResource("Grube, Claire", "user062"),
|
||||
new AccessIdResource("Fall, Clara", "user063"),
|
||||
new AccessIdResource("Korn, Clara", "user064"),
|
||||
new AccessIdResource("Lenriff, Cora", "user065"),
|
||||
new AccessIdResource("Schiert, Cora", "user066"),
|
||||
new AccessIdResource("Hose, Cord", "user067"),
|
||||
new AccessIdResource("Onbleu, Cord", "user068"),
|
||||
new AccessIdResource("Umkleide, Damon", "user069"),
|
||||
new AccessIdResource("Affier, Dean", "user070"),
|
||||
new AccessIdResource("Orm, Dean", "user071"),
|
||||
new AccessIdResource("Platz, Dennis", "user072"),
|
||||
new AccessIdResource("Milch, Dick", "user073"),
|
||||
new AccessIdResource("Mow, Dina", "user074"),
|
||||
new AccessIdResource("Keil, Donna", "user075"),
|
||||
new AccessIdResource("Littchen, Donna", "user076"),
|
||||
new AccessIdResource("Wetter, Donna", "user077"),
|
||||
new AccessIdResource("Was, Ed", "user078"),
|
||||
new AccessIdResource("Khar, Ede", "user079"),
|
||||
new AccessIdResource("Nut, Ella", "user080"),
|
||||
new AccessIdResource("Stisch, Ella", "user081"),
|
||||
new AccessIdResource("Diel, Emma", "user082"),
|
||||
new AccessIdResource("Herdamit, Emma", "user083"),
|
||||
new AccessIdResource("Mitter-Uhe, Emma", "user084"),
|
||||
new AccessIdResource("Tatt, Erich", "user085"),
|
||||
new AccessIdResource("Drigend, Ernie", "user086"),
|
||||
new AccessIdResource("Poly, Esther", "user087"),
|
||||
new AccessIdResource("Trautz, Eugen", "user088"),
|
||||
new AccessIdResource("Quiert, Eva", "user089"),
|
||||
new AccessIdResource("Inurlaub, Fatma", "user090"),
|
||||
new AccessIdResource("Land, Finn", "user091"),
|
||||
new AccessIdResource("Sternis, Finn", "user092"),
|
||||
new AccessIdResource("Furt, Frank", "user093"),
|
||||
new AccessIdResource("Reich, Frank", "user094"),
|
||||
new AccessIdResource("Iskaner, Franz", "user095"),
|
||||
new AccessIdResource("Nerr, Franziska", "user096"),
|
||||
new AccessIdResource("Zafen, Friedrich", "user097"),
|
||||
new AccessIdResource("Pomm, Fritz", "user098"),
|
||||
new AccessIdResource("deWegs, Gera", "user099"),
|
||||
new AccessIdResource("Staebe, Gitta", "user100"),
|
||||
new AccessIdResource("Zend, Glenn", "user101"),
|
||||
new AccessIdResource("Fisch, Grete", "user102"),
|
||||
new AccessIdResource("Zucker, Gus", "user103"),
|
||||
new AccessIdResource("Muhn, Hanni", "user104"),
|
||||
new AccessIdResource("Fermesse, Hanno", "user105"),
|
||||
new AccessIdResource("Aplast, Hans", "user106"),
|
||||
new AccessIdResource("Eart, Hans", "user107"),
|
||||
new AccessIdResource("Back, Hardy", "user108"),
|
||||
new AccessIdResource("Beau, Harry", "user109"),
|
||||
new AccessIdResource("Kraut, Heide", "user110"),
|
||||
new AccessIdResource("Witzka, Heide", "user111"),
|
||||
new AccessIdResource("Buchen, Hein", "user112"),
|
||||
new AccessIdResource("Lichkeit, Hein", "user113"),
|
||||
new AccessIdResource("Suchung, Hein", "user114"),
|
||||
new AccessIdResource("Ellmann, Heinz", "user115"),
|
||||
new AccessIdResource("Ketchup, Heinz", "user116"),
|
||||
new AccessIdResource("Zeim, Hilde", "user117"),
|
||||
new AccessIdResource("Bilien, Immo", "user118"),
|
||||
new AccessIdResource("Her, Inge", "user119"),
|
||||
new AccessIdResource("Wahrsam, Inge", "user120"),
|
||||
new AccessIdResource("Flamm, Ingo", "user121"),
|
||||
new AccessIdResource("Enzien, Ingrid", "user122"),
|
||||
new AccessIdResource("Rohsch, Inken", "user123"),
|
||||
new AccessIdResource("Ihr, Insa", "user124"),
|
||||
new AccessIdResource("Nerda, Iska", "user125"),
|
||||
new AccessIdResource("Eitz, Jens", "user126"),
|
||||
new AccessIdResource("Nastik, Jim", "user127"),
|
||||
new AccessIdResource("Gurt, Jo", "user128"),
|
||||
new AccessIdResource("Kurrth, Jo", "user129"),
|
||||
new AccessIdResource("Kolade, Joe", "user130"),
|
||||
new AccessIdResource("Iter, Johann", "user131"),
|
||||
new AccessIdResource("Tick, Joyce", "user132"),
|
||||
new AccessIdResource("Case, Justin", "user133"),
|
||||
new AccessIdResource("Time, Justin", "user134"),
|
||||
new AccessIdResource("Komp, Jutta", "user135"),
|
||||
new AccessIdResource("Mauer, Kai", "user136"),
|
||||
new AccessIdResource("Pirinja, Kai", "user137"),
|
||||
new AccessIdResource("Serpfalz, Kai", "user138"),
|
||||
new AccessIdResource("Auer, Karl", "user139"),
|
||||
new AccessIdResource("Ielauge, Karl", "user140"),
|
||||
new AccessIdResource("Ifornjen, Karl", "user141"),
|
||||
new AccessIdResource("Radi, Karl", "user142"),
|
||||
new AccessIdResource("Verti, Karl", "user143"),
|
||||
new AccessIdResource("Sery, Karo", "user144"),
|
||||
new AccessIdResource("Lisator, Katha", "user145"),
|
||||
new AccessIdResource("Flo, Kati", "user146"),
|
||||
new AccessIdResource("Schenn, Knut", "user147"),
|
||||
new AccessIdResource("Achse, Kurt", "user148"),
|
||||
new AccessIdResource("Zepause, Kurt", "user149"),
|
||||
new AccessIdResource("Zerr, Kurt", "user150"),
|
||||
new AccessIdResource("Reden, Lasse", "user151"),
|
||||
new AccessIdResource("Metten, Lee", "user152"),
|
||||
new AccessIdResource("Arm, Lene", "user153"),
|
||||
new AccessIdResource("Thur, Linnea", "user154"),
|
||||
new AccessIdResource("Bonn, Lisa", "user155"),
|
||||
new AccessIdResource("Sembourg, Luc", "user156"),
|
||||
new AccessIdResource("Rung, Lucky", "user157"),
|
||||
new AccessIdResource("Zafen, Ludwig", "user158"),
|
||||
new AccessIdResource("Hauden, Lukas", "user159"),
|
||||
new AccessIdResource("Hose, Lutz", "user160"),
|
||||
new AccessIdResource("Tablette, Lutz", "user161"),
|
||||
new AccessIdResource("Fehr, Luzie", "user162"),
|
||||
new AccessIdResource("Nalyse, Magda", "user163"),
|
||||
new AccessIdResource("Ehfer, Maik", "user164"),
|
||||
new AccessIdResource("Sehr, Malte", "user165"),
|
||||
new AccessIdResource("Thon, Mara", "user166"),
|
||||
new AccessIdResource("Quark, Marga", "user167"),
|
||||
new AccessIdResource("Nade, Marie", "user168"),
|
||||
new AccessIdResource("Niert, Marie", "user169"),
|
||||
new AccessIdResource("Neese, Mario", "user170"),
|
||||
new AccessIdResource("Nette, Marion", "user171"),
|
||||
new AccessIdResource("Nesium, Mark", "user172"),
|
||||
new AccessIdResource("Thalle, Mark", "user173"),
|
||||
new AccessIdResource("Diven, Marle", "user174"),
|
||||
new AccessIdResource("Fitz, Marle", "user175"),
|
||||
new AccessIdResource("Pfahl, Marta", "user176"),
|
||||
new AccessIdResource("Zorn, Martin", "user177"),
|
||||
new AccessIdResource("Krissmes, Mary", "user178"),
|
||||
new AccessIdResource("Jess, Matt", "user179"),
|
||||
new AccessIdResource("Strammer, Max", "user180"),
|
||||
new AccessIdResource("Mumm, Maxi", "user181"),
|
||||
new AccessIdResource("Morphose, Meta", "user182"),
|
||||
new AccessIdResource("Uh, Mia", "user183"),
|
||||
new AccessIdResource("Rofon, Mike", "user184"),
|
||||
new AccessIdResource("Rosoft, Mike", "user185"),
|
||||
new AccessIdResource("Liter, Milli", "user186"),
|
||||
new AccessIdResource("Thär, Milli", "user187"),
|
||||
new AccessIdResource("Welle, Mirko", "user188"),
|
||||
new AccessIdResource("Thorat, Mo", "user189"),
|
||||
new AccessIdResource("Thor, Moni", "user190"),
|
||||
new AccessIdResource("Kinolta, Monika", "user191"),
|
||||
new AccessIdResource("Mundhaar, Monika", "user192"),
|
||||
new AccessIdResource("Munter, Monika", "user193"),
|
||||
new AccessIdResource("Zwerg, Nat", "user194"),
|
||||
new AccessIdResource("Elmine, Nick", "user195"),
|
||||
new AccessIdResource("Thien, Niko", "user196"),
|
||||
new AccessIdResource("Pferd, Nils", "user197"),
|
||||
new AccessIdResource("Lerweise, Norma", "user198"),
|
||||
new AccessIdResource("Motor, Otto", "user199"),
|
||||
new AccessIdResource("Totol, Otto", "user200"),
|
||||
new AccessIdResource("Nerr, Paula", "user201"),
|
||||
new AccessIdResource("Imeter, Peer", "user202"),
|
||||
new AccessIdResource("Serkatze, Peer", "user203"),
|
||||
new AccessIdResource("Gogisch, Peter", "user204"),
|
||||
new AccessIdResource("Silje, Peter", "user205"),
|
||||
new AccessIdResource("Harmonie, Phil", "user206"),
|
||||
new AccessIdResource("Ihnen, Philip", "user207"),
|
||||
new AccessIdResource("Uto, Pia", "user208"),
|
||||
new AccessIdResource("Kothek, Pina", "user209"),
|
||||
new AccessIdResource("Zar, Pit", "user210"),
|
||||
new AccessIdResource("Zeih, Polly", "user211"),
|
||||
new AccessIdResource("Tswan, Puh", "user212"),
|
||||
new AccessIdResource("Zufall, Rainer", "user213"),
|
||||
new AccessIdResource("Lien, Rita", "user214"),
|
||||
new AccessIdResource("Held, Roman", "user215"),
|
||||
new AccessIdResource("Haar, Ross", "user216"),
|
||||
new AccessIdResource("Dick, Roy", "user217"),
|
||||
new AccessIdResource("Enplaner, Ruth", "user218"),
|
||||
new AccessIdResource("Kommen, Ryan", "user219"),
|
||||
new AccessIdResource("Philo, Sophie", "user220"),
|
||||
new AccessIdResource("Matisier, Stig", "user221"),
|
||||
new AccessIdResource("Loniki, Tessa", "user222"),
|
||||
new AccessIdResource("Tralisch, Thea", "user223"),
|
||||
new AccessIdResource("Logie, Theo", "user224"),
|
||||
new AccessIdResource("Ister, Thorn", "user225"),
|
||||
new AccessIdResource("Buktu, Tim", "user226"),
|
||||
new AccessIdResource("Ate, Tom", "user227"),
|
||||
new AccessIdResource("Pie, Udo", "user228"),
|
||||
new AccessIdResource("Aloe, Vera", "user229"),
|
||||
new AccessIdResource("Hausver, Walter", "user230"),
|
||||
new AccessIdResource("Schuh, Wanda", "user231"),
|
||||
new AccessIdResource("Rahm, Wolf", "user232"),
|
||||
|
||||
new AccessIdResource("businessadmin", "cn=businessadmin,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("UsersGroup", "cn=usersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("DevelopersGroup", "cn=developersgroup,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("businessadmin", "cn=customersgroup,ou=groups,o=taskanatest"),
|
||||
|
||||
new AccessIdResource("user_domain_A", "cn=user_domain_a,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("monitor", "cn=monitor,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_C", "cn=user_domain_c,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("user_domain_D", "cn=user_domain_d,ou=groups,o=taskanatest"),
|
||||
|
||||
new AccessIdResource("admin", "cn=admin,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("manager_domain_B", "cn=manager_domain_b,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("manager_domain_C", "cn=manager_domain_c,ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("manager_domain_D", "cn=manager_domain_d,ou=groups,o=taskanatest"),
|
||||
|
||||
new AccessIdResource("teamlead_2", "cn=teamlead_2" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("teamlead_4", "cn=teamlead_4" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("team_3", "cn=team_3" + ",ou=groups,o=taskanatest"),
|
||||
new AccessIdResource("team_4", "cn=team_4" + ",ou=groups,o=taskanatest")));
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> findMatchingAccessId(String searchFor, int maxNumberOfReturnedAccessIds) {
|
||||
return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> findGroupsOfUser(String searchFor, int maxNumberOfReturnedAccessIds) {
|
||||
if (users == null) {
|
||||
addUsersToGroups();
|
||||
}
|
||||
return findAcessIdResource(searchFor, maxNumberOfReturnedAccessIds, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessIdResource> validateAccessId(String accessId) {
|
||||
return accessIds.stream()
|
||||
.filter(t -> (t.getAccessId().equalsIgnoreCase(accessId.toLowerCase())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<AccessIdResource> findAcessIdResource(String searchFor, int maxNumberOfReturnedAccessIds,
|
||||
boolean groupMember) {
|
||||
List<AccessIdResource> usersAndGroups = accessIds.stream()
|
||||
.filter(t -> (t.getName().toLowerCase().contains(searchFor.toLowerCase())
|
||||
|| t.getAccessId().toLowerCase().contains(searchFor.toLowerCase())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<AccessIdResource> usersAndGroupsAux = new ArrayList<>(usersAndGroups);
|
||||
if (groupMember) {
|
||||
usersAndGroupsAux.forEach(item -> {
|
||||
if (users.get(item) != null) {
|
||||
usersAndGroups.addAll(users.get(item));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
usersAndGroups.sort((AccessIdResource a, AccessIdResource b) -> {
|
||||
return a.getAccessId().compareToIgnoreCase(b.getAccessId());
|
||||
});
|
||||
|
||||
List<AccessIdResource> result = usersAndGroups.subList(0,
|
||||
Math.min(usersAndGroups.size(), maxNumberOfReturnedAccessIds));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addUsersToGroups() {
|
||||
List<AccessIdResource> groups = new ArrayList<>();
|
||||
users = new HashMap<>();
|
||||
|
||||
accessIds.forEach(item -> {
|
||||
if (!item.getAccessId().contains("ou=groups")) {
|
||||
users.put(item, new ArrayList<>());
|
||||
} else {
|
||||
groups.add(item);
|
||||
}
|
||||
});
|
||||
|
||||
int groupNumber = 0;
|
||||
List<AccessIdResource> group0 = new ArrayList<>(), group1 = new ArrayList<>(), group2 = new ArrayList<>(), group3 = new ArrayList<>();
|
||||
|
||||
for (AccessIdResource group : groups) {
|
||||
switch (groupNumber) {
|
||||
case 0:
|
||||
group0.add(group);
|
||||
break;
|
||||
case 1:
|
||||
group1.add(group);
|
||||
break;
|
||||
case 2:
|
||||
group2.add(group);
|
||||
break;
|
||||
case 3:
|
||||
group3.add(group);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
groupNumber = (groupNumber + 1) % 4;
|
||||
}
|
||||
|
||||
int countUser = 0;
|
||||
for (AccessIdResource item : accessIds) {
|
||||
if (!item.getAccessId().contains("ou=groups")) {
|
||||
switch (countUser) {
|
||||
case 0:
|
||||
users.put(item, group0);
|
||||
break;
|
||||
case 1:
|
||||
users.put(item, group1);
|
||||
break;
|
||||
case 2:
|
||||
users.put(item, group2);
|
||||
break;
|
||||
case 3:
|
||||
users.put(item, group3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
countUser = (countUser + 1) % 4;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -20,9 +20,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import pro.taskana.jobs.TransactionalJobsConfiguration;
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.ldap.LdapClient;
|
||||
import pro.taskana.sampledata.SampleDataGenerator;
|
||||
|
||||
/**
|
||||
|
@ -31,23 +29,15 @@ import pro.taskana.sampledata.SampleDataGenerator;
|
|||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@ComponentScan(basePackages = "pro.taskana")
|
||||
@Import({TransactionalJobsConfiguration.class, RestConfiguration.class, WebMvcConfig.class})
|
||||
@Import({RestConfiguration.class})
|
||||
public class ExampleDocumentationApp {
|
||||
|
||||
@Value("${taskana.schemaName:TASKANA}")
|
||||
private String schemaName;
|
||||
|
||||
@Value("${generateSampleData:true}")
|
||||
private boolean generateSampleData;
|
||||
|
||||
@Autowired
|
||||
private SampleDataGenerator sampleDataGenerator;
|
||||
|
||||
@Autowired
|
||||
private LdapClient ldapClient;
|
||||
|
||||
@Autowired private LdapCacheTestImpl ldapCacheTest;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExampleDocumentationApp.class, args);
|
||||
}
|
||||
|
@ -80,11 +70,7 @@ public class ExampleDocumentationApp {
|
|||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
if (!ldapClient.useLdap()) {
|
||||
AccessIdController.setLdapCache(ldapCacheTest);
|
||||
}
|
||||
if (generateSampleData) {
|
||||
sampleDataGenerator.generateSampleData(schemaName);
|
||||
}
|
||||
AccessIdController.setLdapCache(new LdapCacheTestImpl());
|
||||
sampleDataGenerator.generateSampleData(schemaName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package pro.taskana.rest;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -24,7 +22,6 @@ import ch.qos.logback.classic.spi.LoggingEvent;
|
|||
import ch.qos.logback.core.Appender;
|
||||
import pro.taskana.RestHelper;
|
||||
import pro.taskana.TaskanaSpringBootTest;
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +29,7 @@ import pro.taskana.rest.resource.ClassificationSummaryListResource;
|
|||
*/
|
||||
|
||||
@TaskanaSpringBootTest
|
||||
class GenenalExceptionHandlingTest {
|
||||
class GeneralExceptionHandlingTest {
|
||||
|
||||
@Mock
|
||||
private Appender<ILoggingEvent> mockAppender;
|
||||
|
@ -64,21 +61,6 @@ class GenenalExceptionHandlingTest {
|
|||
logger.detachAppender(mockAppender);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAccessIdValidationMinimunValueExceptionIsLogged() {
|
||||
try {
|
||||
|
||||
AccessIdController.setLdapCache(new LdapCacheTestImpl());
|
||||
template.exchange(
|
||||
restHelper.toUrl(Mapping.URL_ACCESSID) + "?search-for=al", HttpMethod.GET, restHelper.defaultRequest(),
|
||||
ParameterizedTypeReference.forType(List.class));
|
||||
} catch (Exception ex) {
|
||||
verify(mockAppender).doAppend(captorLoggingEvent.capture());
|
||||
assertTrue(
|
||||
captorLoggingEvent.getValue().getMessage().contains("is too short. Minimum searchFor length = "));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||
try {
|
|
@ -0,0 +1,84 @@
|
|||
package pro.taskana.rest.security;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.security.auth.Subject;
|
||||
import javax.security.auth.callback.Callback;
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
import javax.security.auth.callback.NameCallback;
|
||||
import javax.security.auth.callback.PasswordCallback;
|
||||
import javax.security.auth.spi.LoginModule;
|
||||
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||
import pro.taskana.rest.resource.AccessIdResource;
|
||||
import pro.taskana.security.GroupPrincipal;
|
||||
import pro.taskana.security.UserPrincipal;
|
||||
|
||||
/**
|
||||
* TODO.
|
||||
*/
|
||||
public class SampleLoginModule extends UsernamePasswordAuthenticationFilter implements LoginModule {
|
||||
|
||||
private NameCallback nameCallback;
|
||||
|
||||
private PasswordCallback passwordCallback;
|
||||
|
||||
private Subject subject;
|
||||
|
||||
@Override
|
||||
public boolean abort() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commit() {
|
||||
addUserPrincipalToSubject();
|
||||
addGroupSubjectsDerivedFromUsername();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addGroupSubjectsDerivedFromUsername() {
|
||||
LdapCacheTestImpl ldapCacheTest = new LdapCacheTestImpl();
|
||||
String username = nameCallback.getName().toLowerCase();
|
||||
List<AccessIdResource> groups = ldapCacheTest.findGroupsOfUser(username, Integer.MAX_VALUE);
|
||||
groups.forEach((AccessIdResource group) -> {
|
||||
if (group.getAccessId().contains("ou=groups")) {
|
||||
subject.getPrincipals().add(new GroupPrincipal(group.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addUserPrincipalToSubject() {
|
||||
subject.getPrincipals().add(new UserPrincipal(nameCallback.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
|
||||
Map<String, ?> options) {
|
||||
|
||||
this.subject = subject;
|
||||
|
||||
try {
|
||||
nameCallback = new NameCallback("prompt");
|
||||
passwordCallback = new PasswordCallback("prompt", false);
|
||||
|
||||
callbackHandler.handle(new Callback[] {nameCallback, passwordCallback});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() {
|
||||
return nameCallback.getName().equals(new String(passwordCallback.getPassword()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logout() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package pro.taskana.rest.security;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.security.authentication.jaas.AuthorityGranter;
|
||||
import org.springframework.security.authentication.jaas.JaasAuthenticationCallbackHandler;
|
||||
import org.springframework.security.authentication.jaas.JaasAuthenticationProvider;
|
||||
import org.springframework.security.authentication.jaas.JaasNameCallbackHandler;
|
||||
import org.springframework.security.authentication.jaas.JaasPasswordCallbackHandler;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.jaasapi.JaasApiIntegrationFilter;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Default basic configuration for taskana web example.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http.authorizeRequests()
|
||||
.and()
|
||||
.csrf()
|
||||
.disable()
|
||||
.httpBasic()
|
||||
.and()
|
||||
.authenticationProvider(jaasAuthProvider())
|
||||
.authorizeRequests()
|
||||
.and()
|
||||
.addFilter(new JaasApiIntegrationFilter())
|
||||
.authorizeRequests()
|
||||
.anyRequest()
|
||||
.fullyAuthenticated();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JaasAuthenticationProvider jaasAuthProvider() {
|
||||
JaasAuthenticationProvider authenticationProvider = new JaasAuthenticationProvider();
|
||||
authenticationProvider.setAuthorityGranters(new AuthorityGranter[] {p -> Collections.singleton(p.getName())});
|
||||
authenticationProvider.setCallbackHandlers(new JaasAuthenticationCallbackHandler[] {
|
||||
new JaasNameCallbackHandler(), new JaasPasswordCallbackHandler()});
|
||||
authenticationProvider.setLoginContextName("taskana");
|
||||
authenticationProvider.setLoginConfig(new ClassPathResource("pss_jaas.config"));
|
||||
return authenticationProvider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedOrigins("*");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<CorsFilter> corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.setAllowCredentials(true);
|
||||
config.addAllowedOrigin("*");
|
||||
config.addAllowedHeader("*");
|
||||
config.addAllowedMethod("*");
|
||||
config.addAllowedMethod("POST");
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
|
||||
bean.setOrder(0);
|
||||
return bean;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
taskana {pro.taskana.rest.security.SampleLoginModule required;};
|
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
|
|
@ -1,225 +0,0 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -1,143 +0,0 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
Loading…
Reference in New Issue