diff --git a/security_ejem1/pom.xml b/security_ejem1/pom.xml
index 4f06a39..02e7b65 100644
--- a/security_ejem1/pom.xml
+++ b/security_ejem1/pom.xml
@@ -30,11 +30,6 @@
mysql
mysql-connector-java
-
-
- com.h2database
- h2
-
org.springframework.boot
spring-boot-starter-security
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/book/Book.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/book/Book.java
deleted file mode 100644
index dff6604..0000000
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/book/Book.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package es.urjc.code.daw.library.book;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-
-@Entity
-public class Book {
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private long id = -1;
- private String title;
-
- @Column(length = 50000)
- private String description;
-
- public Book() {}
-
- public Book(String nombre, String description) {
- super();
- this.title = nombre;
- this.description = description;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- return "Book [id=" + id + ", title=" + title + ", description=" + description + "]";
- }
-
-}
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/book/BookController.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/book/BookController.java
deleted file mode 100644
index a9eced0..0000000
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/book/BookController.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package es.urjc.code.daw.library.book;
-
-import java.util.Collection;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-
-import es.urjc.code.daw.library.user.UserComponent;
-
-@RestController
-@RequestMapping("/books")
-public class BookController {
-
- private static final Logger log = LoggerFactory.getLogger(BookController.class);
-
- @Autowired
- private BookRepository repository;
-
- @Autowired
- private UserComponent user;
-
- @RequestMapping(value = "/", method = RequestMethod.GET)
- public Collection getBooks() {
- return repository.findAll();
- }
-
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public ResponseEntity getAnuncio(@PathVariable long id) {
-
- log.info("Get book {}", id);
-
- Book anuncio = repository.findOne(id);
- if (anuncio != null) {
- return new ResponseEntity<>(anuncio, HttpStatus.OK);
- } else {
- return new ResponseEntity<>(HttpStatus.NOT_FOUND);
- }
- }
-
- @RequestMapping(value = "/", method = RequestMethod.POST)
- @ResponseStatus(HttpStatus.CREATED)
- public Book nuevoAnuncio(@RequestBody Book anuncio) {
-
- repository.save(anuncio);
-
- return anuncio;
- }
-
- @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
- public ResponseEntity actulizaAnuncio(@PathVariable long id, @RequestBody Book updatedBook) {
-
- if(user.getLoggedUser().getName().equals("xx")){
- return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
- }
-
- Book anuncio = repository.findOne(id);
- if (anuncio != null) {
-
- updatedBook.setId(id);
- repository.save(updatedBook);
-
- return new ResponseEntity<>(updatedBook, HttpStatus.OK);
- } else {
- return new ResponseEntity<>(HttpStatus.NOT_FOUND);
- }
- }
-
- @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
- public ResponseEntity borraAnuncio(@PathVariable long id) {
-
- if (repository.exists(id)) {
- repository.delete(id);
- return new ResponseEntity<>(null, HttpStatus.OK);
- } else {
- return new ResponseEntity<>(HttpStatus.NOT_FOUND);
- }
- }
-
-}
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/book/BookRepository.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/book/BookRepository.java
deleted file mode 100644
index 35fb36c..0000000
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/book/BookRepository.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package es.urjc.code.daw.library.book;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface BookRepository extends JpaRepository {
-
-}
\ No newline at end of file
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchController.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchController.java
index bc89a45..403ec22 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchController.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchController.java
@@ -25,16 +25,16 @@ public class MatchController {
private MatchRepository repository;
@RequestMapping(value = "/", method = RequestMethod.GET)
- public List getMatches() {
+ public List getMatches() {
return repository.findAll();
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public ResponseEntity getMatch(@PathVariable long id) {
+ public ResponseEntity getMatch(@PathVariable long id) {
log.info("Get player {}", id);
- Match match = repository.findOne(id);
+ MatchX match = repository.findOne(id);
if (match != null) {
return new ResponseEntity<>(match, HttpStatus.OK);
} else {
@@ -44,16 +44,16 @@ public ResponseEntity getMatch(@PathVariable long id) {
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
- public Match newMatch(@RequestBody Match match) {
+ public MatchX newMatch(@RequestBody MatchX match) {
repository.save(match);
return match;
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
- public ResponseEntity updateMatch(@PathVariable long id, @RequestBody Match updatedMatch) {
+ public ResponseEntity updateMatch(@PathVariable long id, @RequestBody MatchX updatedMatch) {
- Match match = repository.findOne(id);
+ MatchX match = repository.findOne(id);
if (match != null) {
updatedMatch.setId(id);
@@ -66,7 +66,7 @@ public ResponseEntity updateMatch(@PathVariable long id, @RequestBody Mat
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
- public ResponseEntity deleteMatch(@PathVariable long id) {
+ public ResponseEntity deleteMatch(@PathVariable long id) {
if (repository.exists(id)) {
repository.delete(id);
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchRepository.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchRepository.java
index 1cf16a5..9de774c 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchRepository.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchRepository.java
@@ -2,6 +2,6 @@
import org.springframework.data.jpa.repository.JpaRepository;
-public interface MatchRepository extends JpaRepository {
+public interface MatchRepository extends JpaRepository {
}
\ No newline at end of file
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/match/Match.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchX.java
similarity index 82%
rename from security_ejem1/src/main/java/es/urjc/code/daw/library/match/Match.java
rename to security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchX.java
index 36103e7..887e249 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/match/Match.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/match/MatchX.java
@@ -13,7 +13,7 @@
import es.urjc.code.daw.library.team.Team;
@Entity
-public class Match {
+public class MatchX {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -21,31 +21,30 @@ public class Match {
private String date;
- @OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
+ @OneToOne
//@OneToOne(cascade=CascadeType.ALL)
private Schedule schedule;
- @OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
+ @OneToOne
//@OneToOne(cascade=CascadeType.ALL)
private Team local;
- @OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
+ @OneToOne
//@OneToOne(cascade=CascadeType.ALL)
private Team visitor;
private int resultLocal;
private int resultVisitor;
- public Match() {
+ public MatchX() {
//super();
}
- public Match(long id, String date, Schedule schedule, Team local, Team visitor, int resultLocal,
+ public MatchX(String date, Schedule schedule, Team local, Team visitor, int resultLocal,
int resultVisitor) {
super();
- this.id = id;
this.date = date;
this.schedule = schedule;
this.local = local;
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/news/News.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/news/News.java
index e45477d..85069bc 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/news/News.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/news/News.java
@@ -20,7 +20,7 @@ public class News {
private String subtitle;
private String author;
- @Column(length = 50000)
+ @Column(length = 20000)
private String description;
private String imgnews;
@@ -87,6 +87,17 @@ public void setImgnews(String imgnews) {
this.imgnews = imgnews;
}
+
+
+ public User getUser() {
+ return user;
+ }
+
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
@Override
public String toString() {
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/player/Player.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/player/Player.java
index 393f4ef..680f82e 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/player/Player.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/player/Player.java
@@ -27,7 +27,7 @@ public interface TeamAtt {}
@JsonView(BasicAtt.class)
private String name;
@JsonView(BasicAtt.class)
- @Column(length = 50000)
+ @Column(length = 20000)
private String biography;
//@ManyToOne(cascade=CascadeType.ALL)
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/team/DatabaseInitializer.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/team/DatabaseInitializer.java
index d5ac2b3..6fca185 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/team/DatabaseInitializer.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/team/DatabaseInitializer.java
@@ -7,6 +7,8 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Controller;
+import es.urjc.code.daw.library.match.MatchX;
+import es.urjc.code.daw.library.match.MatchRepository;
import es.urjc.code.daw.library.news.News;
import es.urjc.code.daw.library.news.NewsRepository;
import es.urjc.code.daw.library.player.Player;
@@ -37,6 +39,9 @@ public class DatabaseInitializer implements CommandLineRunner {
@Autowired
private ScheduleRepository scheduleRepository;
+ @Autowired
+ private MatchRepository matchRepository;
+
@Autowired
private PrincipalRepository principalRepository;
@@ -70,8 +75,10 @@ public void run(String... args) throws Exception {
playerRepository.save(p2);
// Sample Schedules
+ Schedule sche = new Schedule();
+ scheduleRepository.save(sche);
- scheduleRepository.save(new Schedule());
+ MatchX match = new MatchX("23", sche, madrid, valencia, 1, 0);
@@ -90,17 +97,20 @@ public void run(String... args) throws Exception {
// Sample users
-
- userRepository.save(new User("user", "pass", "ROLE_USER"));
+
+ User usuario = new User("user", "pass", "ROLE_USER");
+ userRepository.save(usuario);
userRepository.save(new User("admin", "pass", "ROLE_USER", "ROLE_ADMIN"));
//Sample News
- newsRepository.save(new News("Paul Pogba signs for Real Madrid",
+ News newes = new News("Paul Pogba signs for Real Madrid",
"Juventus announces that accepts the offer from Real Madrid for Paul Pogba. Juventus receives 80 million dollars in exchange for the player",
"Álvaro Parras Gomez",
"The french player Paul Pogba has signed a 5-year contract with Real Madrid. Juventus gets 80 million in exchange for the player. The player said in a Spanish television: 'I will live a dream I had since childhood'. Paul Labile Pogba (born 15 March 1993) is a French professional footballer who plays for France National Team. He operates primarily as a central midfielder and is comfortable at playing both in attack and defence. In Italy, he gained the nicknames Il Polpo Paul ('Paul the Octopus') for his long legs that look like tentacles during tackling or running and 'Pogboom' for his explosive style and energy on the pitch. He received the Golden Boy award for 2013, given to the best under-21 player in Europe, followed by the Bravo Award in 2014, awarded to the best under-23 player who has participated in European competitions.",
- "app/img/Players/PogbaNewsReal.jpeg"));
+ "app/img/Players/PogbaNewsReal.jpeg");
+ newes.setUser(usuario);
+ newsRepository.save(newes);
principalRepository.save(new Principal(1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1));
diff --git a/security_ejem1/src/main/java/es/urjc/code/daw/library/team/Team.java b/security_ejem1/src/main/java/es/urjc/code/daw/library/team/Team.java
index e8396fa..e7de832 100644
--- a/security_ejem1/src/main/java/es/urjc/code/daw/library/team/Team.java
+++ b/security_ejem1/src/main/java/es/urjc/code/daw/library/team/Team.java
@@ -41,11 +41,11 @@ public interface PlayersAtt {}
public String coach;
@JsonView(BasicAtt.class)
- @Column(length = 50000)
+ @Column(length = 10000)
public String description;
@JsonView(BasicAtt.class)
- @Column(length = 50000)
+ @Column(length = 10000)
public String history;
@JsonView(BasicAtt.class)
diff --git a/security_ejem1/src/main/resources/application.properties b/security_ejem1/src/main/resources/application.properties
index 57dff05..22f495d 100644
--- a/security_ejem1/src/main/resources/application.properties
+++ b/security_ejem1/src/main/resources/application.properties
@@ -1,8 +1,9 @@
-spring.datasource.url=jdbc:mysql://localhost/majorleaguefootball
+spring.datasource.url=jdbc:mysql://localhost/majorleague
spring.datasource.username=root
-spring.datasource.password=amuntRealMadrid
+spring.datasource.password=pass
spring.datasource.driverClassName=com.mysql.jdbc.Driver
-spring.jpa.hibernate.ddl-auto: update
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.show-sql=true
server.port=8443
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=tomcat
diff --git a/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.properties b/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.properties
index 93ad8c3..106f7ea 100644
--- a/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.properties
+++ b/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
-#Mon Jun 27 14:09:05 CEST 2016
+#Tue Jun 28 16:06:52 CEST 2016
version=0.1.0
groupId=es.sidelab
m2e.projectName=Probamos
diff --git a/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.xml b/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.xml
index 4f06a39..02e7b65 100644
--- a/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.xml
+++ b/security_ejem1/target/classes/META-INF/maven/es.sidelab/Probamos/pom.xml
@@ -30,11 +30,6 @@
mysql
mysql-connector-java
-
-
- com.h2database
- h2
-
org.springframework.boot
spring-boot-starter-security
diff --git a/security_ejem1/target/classes/es/urjc/code/daw/library/book/Book.class b/security_ejem1/target/classes/es/urjc/code/daw/library/book/Book.class
deleted file mode 100644
index 05257d6..0000000
Binary files a/security_ejem1/target/classes/es/urjc/code/daw/library/book/Book.class and /dev/null differ
diff --git a/security_ejem1/target/classes/es/urjc/code/daw/library/book/BookController.class b/security_ejem1/target/classes/es/urjc/code/daw/library/book/BookController.class
deleted file mode 100644
index 3b72b0c..0000000
Binary files a/security_ejem1/target/classes/es/urjc/code/daw/library/book/BookController.class and /dev/null differ
diff --git a/security_ejem1/target/classes/es/urjc/code/daw/library/book/BookRepository.class b/security_ejem1/target/classes/es/urjc/code/daw/library/book/BookRepository.class
deleted file mode 100644
index 71ebf7d..0000000
Binary files a/security_ejem1/target/classes/es/urjc/code/daw/library/book/BookRepository.class and /dev/null differ