rsanchez
2014-11-14 1371dd17f28f3342d02383df8f80e152c0cdd995
#2021 fix - Added MySQL support and bugfixing on angular and url's
9 files modified
changed files
securis/etc/context/securis.xml patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/LicenseTypeMetadata.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/db/PackMetadata.java patch | view | blame | history
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java patch | view | blame | history
securis/src/main/resources/META-INF/persistence.xml patch | view | blame | history
securis/src/main/resources/db/schema.sql patch | view | blame | history
securis/src/main/webapp/header.html patch | view | blame | history
securis/src/main/webapp/js/catalogs.js patch | view | blame | history
securis/etc/context/securis.xml
....@@ -40,9 +40,13 @@
4040 <property name="hibernate.c3p0.acquireRetryAttempts" value="1" />
4141 <property name="hibernate.c3p0.acquireRetryDelay" value="250" />
4242 -->
43
- <Resource name="jdbc/SeCurisDS" auth="Container" type="javax.sql.DataSource"
43
+ <Resource name="jdbc/SeCurisDSOld" auth="Container" type="javax.sql.DataSource"
4444 maxActive="100" maxIdle="3" maxWait="5000"
4545 username="curis" password="cur151T 53curi5" driverClassName="org.h2.Driver"
4646 url="jdbc:h2:~/.SeCuris/db/securis"/>
47
+ <Resource name="jdbc/SeCurisDS" auth="Container" type="javax.sql.DataSource"
48
+ maxActive="100" maxIdle="3" maxWait="5000"
49
+ username="curis" password="securis" driverClassName="com.mysql.jdbc.Driver"
50
+ url="jdbc:mysql://localhost:3306/securis?autoReconnect=true"/>
4751
4852 </Context>
securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
....@@ -40,6 +40,7 @@
4040 private Application application;
4141
4242 @Id
43
+ @Column(name = "\"key\"")
4344 private String key;
4445
4546 private String value;
....@@ -47,6 +48,7 @@
4748 private boolean mandatory;
4849
4950 @Column(name = "creation_timestamp")
51
+ @JsonProperty("creation_timestamp")
5052 private Date creationTimestamp;
5153
5254 public String getKey() {
securis/src/main/java/net/curisit/securis/db/LicenseTypeMetadata.java
....@@ -2,6 +2,7 @@
22
33 import java.io.Serializable;
44
5
+import javax.persistence.Column;
56 import javax.persistence.Entity;
67 import javax.persistence.Id;
78 import javax.persistence.JoinColumn;
....@@ -38,6 +39,7 @@
3839 private LicenseType licenseType;
3940
4041 @Id
42
+ @Column(name = "\"key\"")
4143 private String key;
4244
4345 private String value;
securis/src/main/java/net/curisit/securis/db/PackMetadata.java
....@@ -2,6 +2,7 @@
22
33 import java.io.Serializable;
44
5
+import javax.persistence.Column;
56 import javax.persistence.Entity;
67 import javax.persistence.Id;
78 import javax.persistence.JoinColumn;
....@@ -38,6 +39,7 @@
3839 private Pack pack;
3940
4041 @Id
42
+ @Column(name = "\"key\"")
4143 private String key;
4244
4345 private String value;
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java
....@@ -127,6 +127,7 @@
127127 em.persist(md);
128128 }
129129 }
130
+ LOG.info("Creating application with date: " + app.getCreationTimestamp());
130131
131132 return Response.ok(app).build();
132133 }
....@@ -153,13 +154,14 @@
153154 currentapp.setName(app.getName());
154155 currentapp.setDescription(app.getDescription());
155156 em.persist(currentapp);
156
-
157
- Set<ApplicationMetadata> newMD = app.getApplicationMetadata();
157
+
158
+ Set<ApplicationMetadata> newMD = app.getApplicationMetadata();
158159 for (ApplicationMetadata currentMd : currentapp.getApplicationMetadata()) {
159
- if (newMD == null || !newMD.contains(currentMd));
160
- em.remove(currentMd);
160
+ if (newMD == null || !newMD.contains(currentMd))
161
+ ;
162
+ em.remove(currentMd);
161163 }
162
-
164
+
163165 if (newMD != null) {
164166 for (ApplicationMetadata md : newMD) {
165167 md.setApplication(app);
securis/src/main/resources/META-INF/persistence.xml
....@@ -5,17 +5,17 @@
55 <persistence-unit name="localdb" transaction-type="RESOURCE_LOCAL">
66 <description>SeCuris LocalDB</description>
77 <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
8
-
9
- <jta-data-source>java:comp/env/jdbc/SeCurisDS</jta-data-source>
10
-
11
-<!-- <class>net.curisit.securis.db.UserSettingsUnits</class> -->
8
+
9
+<!-- <jta-data-source>java:comp/env/jdbc/SeCurisDS</jta-data-source>
10
+ -->
11
+ <!-- <class>net.curisit.securis.db.UserSettingsUnits</class> -->
1212
1313 <properties>
14
- <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
15
- <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/SeCurisDS"/>
14
+ <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
15
+ <property name="hibernate.connection.datasource" value="java:comp/env/jdbc/SeCurisDS" />
1616
17
- <property name="hibernate.show_sql" value="false" />
17
+ <property name="hibernate.show_sql" value="true" />
1818 </properties>
19
-
19
+
2020 </persistence-unit>
2121 </persistence>
securis/src/main/resources/db/schema.sql
....@@ -1,9 +1,10 @@
1
+
12 drop table IF EXISTS settings;
23 CREATE TABLE IF NOT EXISTS settings (
3
- key VARCHAR(100) NOT NULL ,
4
+ `key` VARCHAR(100) NOT NULL ,
45 value VARCHAR(2000) NULL ,
5
- timestamp DATETIME NOT NULL DEFAULT now() ,
6
- PRIMARY KEY (key) );
6
+ creation_timestamp DATETIME NOT NULL default now(),
7
+ PRIMARY KEY (``key``) );
78
89 drop table IF EXISTS user;
910 CREATE TABLE IF NOT EXISTS user (
....@@ -15,7 +16,7 @@
1516 last_login DATETIME NULL ,
1617 lang VARCHAR(10) NULL ,
1718 email VARCHAR(150) NULL ,
18
- creation_timestamp DATETIME NULL ,
19
+ creation_timestamp DATETIME NOT NULL default now(),
1920 modification_timestamp DATETIME NULL ,
2021 PRIMARY KEY (username));
2122
....@@ -25,17 +26,17 @@
2526 name VARCHAR(45) NOT NULL ,
2627 license_filename VARCHAR(100) NOT NULL ,
2728 description VARCHAR(500) NULL ,
28
- creation_timestamp DATETIME NULL ,
29
+ creation_timestamp DATETIME NOT NULL default now(),
2930 PRIMARY KEY (id));
3031
3132 drop table IF EXISTS application_metadata;
3233 CREATE TABLE IF NOT EXISTS application_metadata (
3334 application_id INT NOT NULL ,
34
- key VARCHAR(100) NOT NULL ,
35
+ `key` VARCHAR(100) NOT NULL ,
3536 value VARCHAR(200) NULL ,
3637 mandatory BOOLEAN NOT NULL default true,
37
- creation_timestamp DATETIME NOT NULL ,
38
- PRIMARY KEY (application_id, key));
38
+ creation_timestamp DATETIME NOT NULL default now(),
39
+ PRIMARY KEY (application_id, `key`));
3940
4041
4142 drop table IF EXISTS license_type;
....@@ -45,16 +46,16 @@
4546 name VARCHAR(45) NOT NULL ,
4647 description VARCHAR(100) NULL ,
4748 application_id INT NULL ,
48
- creation_timestamp DATETIME NULL ,
49
+ creation_timestamp DATETIME NOT NULL default now(),
4950 PRIMARY KEY (id));
5051
5152 drop table IF EXISTS licensetype_metadata;
5253 CREATE TABLE IF NOT EXISTS licensetype_metadata (
5354 license_type_id INT NOT NULL ,
54
- key VARCHAR(100) NOT NULL ,
55
+ `key` VARCHAR(100) NOT NULL ,
5556 value VARCHAR(200) NULL ,
5657 mandatory BOOLEAN NOT NULL default true,
57
- PRIMARY KEY (license_type_id, key));
58
+ PRIMARY KEY (license_type_id, `key`));
5859
5960 drop table IF EXISTS organization;
6061 CREATE TABLE IF NOT EXISTS organization (
....@@ -63,7 +64,7 @@
6364 name VARCHAR(45) NOT NULL ,
6465 description VARCHAR(100) NULL ,
6566 org_parent_id INT NULL ,
66
- creation_timestamp DATETIME NULL ,
67
+ creation_timestamp DATETIME NOT NULL default now(),
6768 PRIMARY KEY (id));
6869
6970 drop table IF EXISTS user_organization;
....@@ -77,8 +78,8 @@
7778 id INT NOT NULL auto_increment,
7879 code VARCHAR(50) NOT NULL ,
7980 num_licenses INT NOT NULL ,
80
- init_valid_date DATE NOT NULL default today(),
81
- end_valid_date DATE NOT NULL default today(),
81
+ init_valid_date DATE NOT NULL,
82
+ end_valid_date DATE NOT NULL,
8283 status VARCHAR(2) NOT NULL default 'CR',
8384 comments VARCHAR(1024) NULL ,
8485 license_type_id INT NOT NULL,
....@@ -86,17 +87,17 @@
8687 license_preactivation BOOLEAN NOT NULL DEFAULT true,
8788 default_valid_period INT NOT NULL DEFAULT 60,
8889 created_by varchar(45) NULL ,
89
- creation_timestamp DATETIME NOT NULL ,
90
+ creation_timestamp DATETIME NOT NULL default now(),
9091 PRIMARY KEY (id));
9192
9293 drop table IF EXISTS pack_metadata;
9394 CREATE TABLE IF NOT EXISTS pack_metadata (
9495 pack_id INT NOT NULL ,
95
- key VARCHAR(100) NOT NULL ,
96
+ `key` VARCHAR(100) NOT NULL ,
9697 value VARCHAR(200) NULL ,
9798 readonly BOOlEAN NOT NULL default false,
9899 mandatory BOOLEAN NOT NULL default true,
99
- PRIMARY KEY (pack_id, key));
100
+ PRIMARY KEY (pack_id, `key`));
100101
101102
102103 drop table IF EXISTS license;
....@@ -110,24 +111,22 @@
110111 full_name VARCHAR(150) NULL,
111112 email VARCHAR(100) NOT NULL,
112113 comments VARCHAR(1024) NULL ,
113
- creation_timestamp DATETIME NOT NULL ,
114
+ creation_timestamp DATETIME NOT NULL default now(),
114115 modification_timestamp DATETIME NULL ,
115116 last_access_timestamp DATETIME NULL ,
116117 expiration_date DATETIME NULL ,
117118 cancelled_by varchar(45) NULL ,
118119 created_by varchar(45) NULL ,
119120 status VARCHAR(2) NOT NULL default 'CR',
120
- PRIMARY KEY (id));
121
-
122
-create index if not exists lic_hash_req_idx on license(request_data_hash);
123
-create index if not exists lic_pack_idx on license(pack_id);
121
+ PRIMARY KEY (id),
122
+ index(request_data_hash, pack_id));
124123
125124 drop table IF EXISTS license_history;
126125 CREATE TABLE IF NOT EXISTS license_history (
127126 id INT NOT NULL auto_increment,
128127 license_id INT NOT NULL,
129128 username VARCHAR(45) NOT NULL,
130
- timestamp DATETIME NOT NULL ,
129
+ creation_timestamp DATETIME NOT NULL default now(),
131130 action VARCHAR(40) ,
132131 comments VARCHAR(512) ,
133132 PRIMARY KEY (id));
securis/src/main/webapp/header.html
....@@ -4,8 +4,8 @@
44 <div class="navbar-header">
55 <ul class="nav navbar-nav navbar-left">
66 <li i18n style="color: white; padding-top: 15px;">SeCuris</li>
7
- <li><a i18n href="/licenses">Licenses</a></li>
8
- <li><a i18n href="/admin">Admin</a></li>
7
+ <li><a i18n href="licenses">Licenses</a></li>
8
+ <li><a i18n href="admin">Admin</a></li>
99 </ul>
1010 </div>
1111 <div class="navbar-collapse collapse">
securis/src/main/webapp/js/catalogs.js
....@@ -21,7 +21,7 @@
2121 'application/:appId', {
2222 appId : '@id'
2323 }),
24
- user : $resource('/user/:userId', {
24
+ user : $resource('user/:userId', {
2525 userId : '@username'
2626 }),
2727 organization : $resource(