Skip to content

Commit

Permalink
Merge branch 'releases/release-0.7.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
valesu committed Oct 3, 2017
2 parents 9092e45 + cb17e37 commit b802ab9
Show file tree
Hide file tree
Showing 101 changed files with 3,007 additions and 347 deletions.
12 changes: 5 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
image: riha-test-env

variables:
DEPLOYMENT_DIR: "/opt/riha/$CI_PROJECT_NAME"
ARTIFACT_NAME: "$CI_PROJECT_NAME.jar"
DEPLOYMENT_DIR: "/opt/tomcat/webapps"
ARTIFACT_NAME: "ROOT.war"

stages:
- test
Expand All @@ -25,7 +25,7 @@ build:
- ./build.sh
artifacts:
paths:
- backend/target/*.jar
- backend/target/*.war
tags:
- riha

Expand All @@ -36,12 +36,10 @@ deploy_development:
- chmod 700 id_rsa
- mkdir $HOME/.ssh
- echo "$SSH_HOST_KEY" > $HOME/.ssh/known_hosts
- scp -i id_rsa backend/target/*.jar deployer@$SSH_HOST:$DEPLOYMENT_DIR/$ARTIFACT_NAME
- ssh -i id_rsa deployer@$SSH_HOST "/bin/chmod ug+x $DEPLOYMENT_DIR/$ARTIFACT_NAME"
- ssh -i id_rsa deployer@$SSH_HOST "/sbin/service $CI_PROJECT_NAME restart"
- scp -i id_rsa backend/target/*.war deployer@$SSH_HOST:$DEPLOYMENT_DIR/$ARTIFACT_NAME
environment:
name: development
url: http://$SSH_HOST:$PORT/
url: http://$SSH_HOST:$PORT/$CI_PROJECT_NAME
when: manual
tags:
- riha
12 changes: 8 additions & 4 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<name>Backend</name>
<description>backend</description>

<packaging>war</packaging>

<parent>
<groupId>ee.ria.riha</groupId>
<artifactId>browser</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -72,6 +74,11 @@
<artifactId>storage-client</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -88,9 +95,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>com.github.kongchen</groupId>
Expand Down
9 changes: 8 additions & 1 deletion backend/src/main/java/ee/ria/riha/BrowserApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class BrowserApplication {
public class BrowserApplication extends SpringBootServletInitializer {

public static void main(String[] args) {
SpringApplication.run(BrowserApplication.class, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(BrowserApplication.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@ToString
public class EstEIDPrincipal implements Principal {

private static final String PREFIX = "EE";
private String serialNumber;
private String givenName;
private String surname;
Expand All @@ -22,7 +23,7 @@ public EstEIDPrincipal(String serialNumber) {

@Override
public String getName() {
return serialNumber;
return PREFIX + serialNumber;
}

public String getSerialNumber() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class RihaLdapUserDetailsContextMapper extends LdapUserDetailsMapper {
private static final String COMMON_NAME_ATTRIBUTE = "cn";
private static final String DISPLAY_NAME_ATTRIBUTE = "displayname";
private static final String ROLE_PREFIX = "ROLE_";
private static final String DEFAULT_RIHA_USER_ROLE = "ROLE_RIHA_USER";
private static final String DEFAULT_RIHA_USER_ROLE = ROLE_PREFIX + "RIHA_USER";

private LdapTemplate ldapTemplate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private Set<GrantedAuthority> getEffectiveAuthorities() {
combinedAuthorities.addAll(organizationAuthorities.get(this.activeOrganization));
}

return combinedAuthorities.isEmpty() ? null : ImmutableSet.copyOf(combinedAuthorities);
return ImmutableSet.copyOf(combinedAuthorities);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import org.springframework.util.Assert;

import java.util.Collection;
import java.util.StringJoiner;

import static org.springframework.util.StringUtils.hasText;

/**
* RIHA user details including additional information like personal code and name.
Expand Down Expand Up @@ -61,6 +64,19 @@ public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getFullName() {
StringJoiner stringJoiner = new StringJoiner(" ");
if (hasText(firstName)) {
stringJoiner.add(firstName);
}

if (hasText(lastName)) {
stringJoiner.add(lastName);
}

return stringJoiner.toString();
}

public Multimap<RihaOrganization, GrantedAuthority> getOrganizationAuthorities() {
return organizationAuthorities;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ee.ria.riha.domain.RihaStorageInfoSystemRepository;
import ee.ria.riha.service.JsonValidationService;
import ee.ria.riha.storage.client.StorageClient;
import ee.ria.riha.storage.domain.CommentRepository;
import ee.ria.riha.storage.domain.MainResourceRepository;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -35,6 +36,11 @@ public InfoSystemRepository infoSystemRepository(MainResourceRepository mainReso
return new RihaStorageInfoSystemRepository(mainResourceRepository);
}

@Bean
public CommentRepository commentRepository(ApplicationProperties applicationProperties) {
return new CommentRepository(getStorageClient(applicationProperties));
}

@Bean
public JsonValidationService jsonValidationService(ApplicationProperties applicationProperties) throws IOException {
return new JsonValidationService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class ApplicationProperties {

public static final String API_V1_PREFIX = "/api/v1";

private final RemoteApi remoteApi = new RemoteApi();
private final StorageClientProperties storageClient = new StorageClientProperties();
private final AuthenticationProperties authentication = new AuthenticationProperties();
private final ValidationProperties validation = new ValidationProperties();
Expand All @@ -28,12 +27,6 @@ public static class StorageClientProperties {
private String baseUrl;
}

@Getter
@Setter
public static class RemoteApi {
private String approverUrl;
}

@Getter
@Setter
public static class AuthenticationProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ee.ria.riha.storage.util.PagedResponse;

import java.util.List;
import java.util.UUID;

/**
* Interface for repositories that persist InfoSystem entities.
Expand All @@ -18,6 +19,8 @@ public interface InfoSystemRepository {

InfoSystem load(String shortName);

InfoSystem load(UUID uuid);

void update(String shortName, InfoSystem infoSystem);

void remove(String shortName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ee.ria.riha.storage.util.*;

import java.util.List;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -60,6 +61,18 @@ public InfoSystem load(String shortName) {
return infoSystems.get(0);
}

@Override
public InfoSystem load(UUID uuid) {
FilterRequest filter = new FilterRequest("uuid,=," + uuid.toString(), null, null);
List<InfoSystem> infoSystems = find(filter);

if (infoSystems.isEmpty()) {
throw new ObjectNotFoundException("Could not resolve info system by uuid " + uuid.toString());
}

return infoSystems.get(0);
}

@Override
public void update(String shortName, InfoSystem infoSystem) {
throw new RuntimeException(NOT_IMPLEMENTED);
Expand Down
42 changes: 42 additions & 0 deletions backend/src/main/java/ee/ria/riha/domain/model/Issue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ee.ria.riha.domain.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.UUID;

import static ee.ria.riha.domain.model.IssueEntityType.ISSUE;

/**
* Issue entity model
*
* @author Valentin Suhnjov
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
public class Issue implements IssueEntity {

private Long id;
private UUID infoSystemUuid;
private Date dateCreated;
private String title;
private String comment;
private String authorName;
private String authorPersonalCode;
private String organizationName;
private String organizationCode;
private IssueStatus status;

public Issue() {
}

@Override
public IssueEntityType getEntityType() {
return ISSUE;
}
}
39 changes: 39 additions & 0 deletions backend/src/main/java/ee/ria/riha/domain/model/IssueComment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package ee.ria.riha.domain.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

import static ee.ria.riha.domain.model.IssueEntityType.ISSUE_COMMENT;

/**
* Issue comment entity model
*
* @author Valentin Suhnjov
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
public class IssueComment implements IssueEntity {

private Long id;
private Long issueId;
private String comment;
private Date dateCreated;
private String authorName;
private String authorPersonalCode;
private String organizationName;
private String organizationCode;

public IssueComment() {
}

@Override
public IssueEntityType getEntityType() {
return ISSUE_COMMENT;
}
}
10 changes: 10 additions & 0 deletions backend/src/main/java/ee/ria/riha/domain/model/IssueEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ee.ria.riha.domain.model;

/**
* @author Valentin Suhnjov
*/
public interface IssueEntity {

IssueEntityType getEntityType();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ee.ria.riha.domain.model;

/**
* @author Valentin Suhnjov
*/
public enum IssueEntityType {
/**
* Issue entity discriminator
*/
ISSUE,

/**
* Issue comment entity discriminator
*/
ISSUE_COMMENT,

/**
* Issue event entity discriminator
*/
ISSUE_EVENT;
}
Loading

0 comments on commit b802ab9

Please sign in to comment.