Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xTrello</groupId>
<groupId>com.trello</groupId>
<artifactId>Trello</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Trello Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
<project.encoding>UTF-8</project.encoding>
Expand Down Expand Up @@ -70,6 +68,22 @@
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.trello.ApplicationLauncher</mainClass>
</configuration>
</plugin>
</plugins>
<finalName>Trello</finalName>
</build>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/trello/ApplicationLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

@SpringBootApplication
public class ApplicationLauncher {
public static void main(String[] args){
String password ="123";
String encrytedPassword=encrytePassword(password);
System.out.println("Encryted Password "+encrytedPassword);
public static void main(String[] args) {
String password = "123";
String encrytedPassword = encrytePassword(password);
System.out.println("Encrypted Password " + encrytedPassword);
SpringApplication.run(ApplicationLauncher.class, args);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,5 @@ protected void configure(HttpSecurity config) throws Exception{
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/").permitAll();

}




}
58 changes: 26 additions & 32 deletions src/main/java/com/trello/controller/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,69 +34,63 @@ public String getCurrentUsername() {
}

@RequestMapping(method = RequestMethod.GET)
public String mainPage(Model model){
String username=getCurrentUsername();
if (username=="anonymousUser"){
model.addAttribute("check","anonim");
model.addAttribute("message","hello");
}else{
model.addAttribute("check","userloginned");
model.addAttribute("message","hello "+username);
}

public String mainPage(Model model) {
String username = getCurrentUsername();
if ("anonymousUser".equalsIgnoreCase(username)) {
model.addAttribute("check", "anonim");
model.addAttribute("message", "hello");
} else {
model.addAttribute("check", "userloginned");
model.addAttribute("message", "hello " + username);
}

model.addAttribute("board", boardService.getAll());
return "main";

}

@RequestMapping(value="/board")
public String boardPage(Model model,Principal principal)
{
User loginedUser = (User) ((Authentication)principal).getPrincipal();
@RequestMapping(value = "/board")
public String boardPage(Model model, Principal principal) {
User loginedUser = (User) ((Authentication) principal).getPrincipal();
//TODO create board with creator_id
model.addAttribute("board",new Board());
model.addAttribute("board", new Board());
return "board";
}


@RequestMapping(value="/board/view")
public String boardcontentPage(Model model,@RequestParam int id)
{
@RequestMapping(value = "/board/view")
public String boardcontentPage(Model model, @RequestParam Long id) {
model.addAttribute("board", boardService.findOne(id));
return "boardcontent";
}

@RequestMapping(value = "/board/submit",method = RequestMethod.POST)
public String submitBoard(@ModelAttribute Board board){
@RequestMapping(value = "/board/submit", method = RequestMethod.POST)
public String submitBoard(@ModelAttribute Board board) {
boardService.save(board);
return "redirect:/";
}


@RequestMapping(value = "/reg")
public String reg(Model model){
public String reg(Model model) {
model.addAttribute("user", new AppUser());
return "reg";
}

@RequestMapping(value = "/reg/submit",method = RequestMethod.POST)
public String submitUser(Model model,@ModelAttribute AppUser user){
String encrytedPassword=encrytePassword(user.getEncrytedPassword());
@RequestMapping(value = "/reg/submit", method = RequestMethod.POST)
public String submitUser(Model model, @ModelAttribute AppUser user) {
String encrytedPassword = encrytePassword(user.getEncrytedPassword());
user.setEncrytedPassword(encrytedPassword);
short enable=1;
short enable = 1;
user.setEnabled(enable);
appUserService.save(user);
model.addAttribute("check","anonim");
model.addAttribute("message","Registration succesful");
model.addAttribute("check", "anonim");
model.addAttribute("message", "Registration successful");
return "main";
}


@RequestMapping(value="/login")
public String loginPage(){
@RequestMapping(value = "/login")
public String loginPage() {
return "login";
}


}
2 changes: 1 addition & 1 deletion src/main/java/com/trello/dao/BoardRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import org.springframework.stereotype.Repository;

@Repository
public interface BoardRepository extends CrudRepository<Board, Integer>{
public interface BoardRepository extends CrudRepository<Board, Long>{
}
2 changes: 1 addition & 1 deletion src/main/java/com/trello/dao/UserRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends CrudRepository<AppUser, Integer> {
public interface UserRepository extends CrudRepository<AppUser, Long> {
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.trello.dao;


import com.trello.model.User_role;
import com.trello.model.UserRole;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface User_roleRepository extends CrudRepository<User_role, Long> {
public interface UserRoleRepository extends CrudRepository<UserRole, Long> {
}
7 changes: 3 additions & 4 deletions src/main/java/com/trello/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@

public class UserMapper implements RowMapper<AppUser> {

public static final String BASE_SQL//
="Select u.User_Id, u.User_Name, u.Encryted_Password From App_User u ";
public static final String BASE_SQL = "Select u.User_Id, u.User_Name, u.Encrypted_Password From App_User u ";

@Override
public AppUser mapRow(ResultSet rs, int rowNum) throws SQLException{
Long userId = rs.getLong("User_Id");
String userName = rs.getString("User_Name");
String encrytedPassword = rs.getString("Encryted_Password");
String encryptedPassword = rs.getString("Encrypted_Password");

return new AppUser(userId, userName, encrytedPassword);
return new AppUser(userId, userName, encryptedPassword);
}

}
25 changes: 13 additions & 12 deletions src/main/java/com/trello/model/AppUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
import javax.persistence.*;

@Entity
@Table(name = "app_user")
@Table(name = "App_User")
public class AppUser {

@Id
@GeneratedValue
@Column(name = "User_Id")
private Long userId;
@Column
@Column(name = "User_Name")
private String userName;
@Column
private String encrytedPassword;
@Column
private short enabled;
@Column(name = "Encrypted_Password")
private String encryptedPassword;
@Column(name = "Enabled")
private Short enabled;

public AppUser() {

Expand All @@ -23,7 +24,7 @@ public AppUser() {
public AppUser(Long userId, String userName, String encrytedPassword) {
this.userId = userId;
this.userName = userName;
this.encrytedPassword = encrytedPassword;
this.encryptedPassword = encrytedPassword;
}

public Long getUserId() {
Expand All @@ -43,23 +44,23 @@ public void setUserName(String userName) {
}

public String getEncrytedPassword() {
return encrytedPassword;
return encryptedPassword;
}

public void setEncrytedPassword(String encrytedPassword) {
this.encrytedPassword = encrytedPassword;
this.encryptedPassword = encrytedPassword;
}

public short getEnabled() {
public Short getEnabled() {
return enabled;
}

public void setEnabled(short enabled) {
public void setEnabled(Short enabled) {
this.enabled = enabled;
}

@Override
public String toString() {
return this.userName + "/" + this.encrytedPassword;
return this.userName + "/" + this.encryptedPassword;
}
}
32 changes: 16 additions & 16 deletions src/main/java/com/trello/model/Board.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package com.trello.model;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "board")
public class Board implements Serializable, Comparable<Board>{
@Table(name = "Board")
public class Board implements Comparable<Board> {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column
@Column(name = "Id")
private Long id;
@Column(name = "Name")
private String name;
@Column
private int creator_id;
@Column
private long creatorTimestamp;
@Column(name = "Creator_Id")
private Long creatorId;
@Column(name = "Creator_Timestamp")
private Long creatorTimestamp;

public Board() {
this.creatorTimestamp=System.currentTimeMillis();
this.creatorTimestamp = System.currentTimeMillis();
}

@Override
public int compareTo(Board that){
public int compareTo(Board that) {
return Long.compare(this.creatorTimestamp, that.creatorTimestamp);
}

public long getId() {
public Long getId() {
return id;
}

Expand All @@ -38,11 +38,11 @@ public void setName(String name) {
this.name = name;
}

public long getCreator_id() {
return creator_id;
public Long getCreatorId() {
return creatorId;
}

public void setCreator_id(int creator_id) {
this.creator_id = creator_id;
public void setCreatorId(Long creatorId) {
this.creatorId = creatorId;
}
}
42 changes: 42 additions & 0 deletions src/main/java/com/trello/model/UserRole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.trello.model;


import javax.persistence.*;

@Entity
@Table(name = "User_Role")
public class UserRole {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="Id")
private Long id;
@Column(name="User_Id")
private Long userId;
@Column(name="Role_Id")
private Long roleId;

public UserRole() {
}

public UserRole(long userId, long roleId) {
this.userId = userId;
this.roleId = roleId;
}

public long getUserId() {
return this.userId;
}

public void setUserId(long userId) {
this.userId = userId;
}

public long getRoleId() {
return this.roleId;
}

public void setRoleId(long roleId) {
this.roleId = roleId;
}
}
Loading