Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
serjihsklovski committed Jun 26, 2017
2 parents d9ab6ca + c336609 commit 3660326
Show file tree
Hide file tree
Showing 41 changed files with 1,845 additions and 128 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.teapot</groupId>
<artifactId>teapot-backend</artifactId>
<version>1.0.3</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.teapot.backend.model.meta.TeapotAction;
import org.teapot.backend.model.meta.TeapotProperty;
import org.teapot.backend.model.User;
import org.teapot.backend.model.UserAuthority;
import org.teapot.backend.model.meta.TeapotResource;
import org.teapot.backend.repository.TeapotActionRepository;
import org.teapot.backend.repository.TeapotPropertyRepository;
import org.teapot.backend.repository.TeapotResourceRepository;
import org.teapot.backend.repository.UserRepository;
import org.teapot.backend.model.organization.Member;
import org.teapot.backend.model.organization.MemberStatus;
import org.teapot.backend.model.organization.Organization;
import org.teapot.backend.model.user.User;
import org.teapot.backend.model.user.UserAuthority;
import org.teapot.backend.repository.meta.TeapotActionRepository;
import org.teapot.backend.repository.meta.TeapotPropertyRepository;
import org.teapot.backend.repository.meta.TeapotResourceRepository;
import org.teapot.backend.repository.organization.MemberRepository;
import org.teapot.backend.repository.organization.OrganizationRepository;
import org.teapot.backend.repository.user.UserRepository;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;


Expand All @@ -43,6 +47,12 @@ public class DevelopmentProfileConfig {
@Autowired
private PasswordEncoder passwordEncoder;

@Autowired
private OrganizationRepository organizationRepository;

@Autowired
private MemberRepository memberRepository;

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
Expand Down Expand Up @@ -70,6 +80,8 @@ public CommandLineRunner loadData() {
addProperties();
addResources();
addActions();
addOrganizations();
addMembers();
};
}

Expand All @@ -82,7 +94,7 @@ private void registerAdmin() {
admin.setActivated(true);
admin.setFirstName("Cake");
admin.setLastName("Lover");
admin.setRegistrationDate(LocalDateTime.now());
admin.setRegistrationDate(LocalDate.now());
admin.setBirthday(LocalDate.now());
admin.setDescription("i manage everything");
admin.setAuthority(UserAuthority.ADMIN);
Expand All @@ -99,7 +111,7 @@ private void registerDaleCooper() {
user.setActivated(true);
user.setFirstName("Dale");
user.setLastName("Cooper");
user.setRegistrationDate(LocalDateTime.now());
user.setRegistrationDate(LocalDate.now());
user.setBirthday(LocalDate.now());
user.setDescription("a special FBI agent");
user.setAuthority(UserAuthority.USER);
Expand All @@ -116,7 +128,7 @@ private void registerLoraPalmer() {
user.setActivated(true);
user.setFirstName("Lora");
user.setLastName("Palmer");
user.setRegistrationDate(LocalDateTime.now());
user.setRegistrationDate(LocalDate.now());
user.setBirthday(LocalDate.now());
user.setDescription("a dead girl");
user.setAuthority(UserAuthority.USER);
Expand All @@ -133,7 +145,7 @@ private void registerSherlockHolmes() {
user.setActivated(true);
user.setFirstName("Sherlock");
user.setLastName("Holmes");
user.setRegistrationDate(LocalDateTime.now());
user.setRegistrationDate(LocalDate.now());
user.setBirthday(LocalDate.now());
user.setDescription("private detective");
user.setAuthority(UserAuthority.USER);
Expand All @@ -150,7 +162,7 @@ private void registerDoctorWatson() {
user.setActivated(true);
user.setFirstName("John");
user.setLastName("Watson");
user.setRegistrationDate(LocalDateTime.now());
user.setRegistrationDate(LocalDate.now());
user.setBirthday(LocalDate.now());
user.setDescription("Sherlock Holmes' mate");
user.setAuthority(UserAuthority.USER);
Expand All @@ -166,7 +178,7 @@ private void addProperties() {
property1.setValue("1");

property2.setName("site-uri");
property2.setValue("localhost:8080");
property2.setValue("http://localhost:8080");

propertyRepository.save(property1);
propertyRepository.save(property2);
Expand Down Expand Up @@ -196,4 +208,46 @@ private void addActions() {

actionRepository.save(Arrays.asList(action1, action2));
}

private void addOrganizations() {
Organization teapot = new Organization();
teapot.setName("teapot");
teapot.setCreationDate(LocalDate.now());
organizationRepository.save(teapot);

Organization someOrganization = new Organization();
someOrganization.setName("someOrganization");
someOrganization.setCreationDate(LocalDate.now());
organizationRepository.save(someOrganization);
}

private void addMembers() {
Member member1 = new Member();
member1.setAdmissionDate(LocalDate.now());
member1.setOrganization(organizationRepository.findByName("teapot"));
member1.setUser(userRepository.findByUsername("dr_watson"));
member1.setStatus(MemberStatus.CREATOR);
memberRepository.save(member1);

Member member2 = new Member();
member2.setAdmissionDate(LocalDate.now());
member2.setOrganization(organizationRepository.findByName("teapot"));
member2.setUser(userRepository.findByUsername("lora_palmer"));
member2.setStatus(MemberStatus.WORKER);
memberRepository.save(member2);

Member member3 = new Member();
member3.setAdmissionDate(LocalDate.now());
member3.setOrganization(organizationRepository.findByName("someOrganization"));
member3.setUser(userRepository.findByUsername("dale_cooper"));
member3.setStatus(MemberStatus.CREATOR);
memberRepository.save(member3);

Member member4 = new Member();
member4.setAdmissionDate(LocalDate.now());
member4.setOrganization(organizationRepository.findByName("someOrganization"));
member4.setUser(userRepository.findByUsername("sherlock_holmes"));
member4.setStatus(MemberStatus.OWNER);
memberRepository.save(member4);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
Expand All @@ -14,7 +13,6 @@

@Configuration
@EnableAuthorizationServer
@Profile("security")
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {

@Autowired
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
Expand All @@ -12,7 +11,6 @@

@Configuration
@EnableResourceServer
@Profile("security")
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER - 1)
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
Expand All @@ -15,11 +14,10 @@
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Profile("security")
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityProfileWebSecurityConfig extends WebSecurityConfigurerAdapter {
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

public SecurityProfileWebSecurityConfig() {
public WebSecurityConfig() {
super(true);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.teapot.backend.controller;
package org.teapot.backend.controller.meta;

import com.google.common.primitives.Longs;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -7,13 +7,13 @@
import org.teapot.backend.controller.exception.BadRequestException;
import org.teapot.backend.controller.exception.ConflictException;
import org.teapot.backend.controller.exception.ResourceNotFoundException;
import org.teapot.backend.model.User;
import org.teapot.backend.model.VerificationToken;
import org.teapot.backend.model.user.User;
import org.teapot.backend.model.user.VerificationToken;
import org.teapot.backend.model.meta.TeapotAction;
import org.teapot.backend.repository.TeapotActionRepository;
import org.teapot.backend.repository.TeapotResourceRepository;
import org.teapot.backend.repository.UserRepository;
import org.teapot.backend.repository.VerificationTokenRepository;
import org.teapot.backend.repository.meta.TeapotActionRepository;
import org.teapot.backend.repository.meta.TeapotResourceRepository;
import org.teapot.backend.repository.user.UserRepository;
import org.teapot.backend.repository.user.VerificationTokenRepository;
import org.teapot.backend.util.VerificationMailSender;

import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.teapot.backend.controller;
package org.teapot.backend.controller.meta;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
Expand All @@ -7,7 +7,7 @@
import org.teapot.backend.controller.exception.BadRequestException;
import org.teapot.backend.controller.exception.ResourceNotFoundException;
import org.teapot.backend.model.meta.TeapotProperty;
import org.teapot.backend.repository.TeapotPropertyRepository;
import org.teapot.backend.repository.meta.TeapotPropertyRepository;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.teapot.backend.controller;
package org.teapot.backend.controller.meta;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
Expand All @@ -7,7 +7,7 @@
import org.teapot.backend.controller.exception.BadRequestException;
import org.teapot.backend.controller.exception.ResourceNotFoundException;
import org.teapot.backend.model.meta.TeapotResource;
import org.teapot.backend.repository.TeapotResourceRepository;
import org.teapot.backend.repository.meta.TeapotResourceRepository;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
Expand Down
Loading

0 comments on commit 3660326

Please sign in to comment.