Skip to content

Commit 558fd1b

Browse files
authored
Merge pull request #1587 from parallaxinc/1.0
Release v1.0
2 parents 66c7f37 + ea99fa5 commit 558fd1b

File tree

26 files changed

+369
-247
lines changed

26 files changed

+369
-247
lines changed

pom.xml

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -253,31 +253,23 @@
253253
</dependency>
254254

255255
<!-- Dependencies for logging -->
256-
<!-- sl4fj is a facade for various logging frameworks -->
257256
<dependency>
258257
<groupId>org.slf4j</groupId>
259258
<artifactId>slf4j-api</artifactId>
260-
<version>1.7.21</version>
259+
<version>1.7.25</version>
261260
</dependency>
262261

263262
<dependency>
264263
<groupId>ch.qos.logback</groupId>
265264
<artifactId>logback-classic</artifactId>
266265
<version>1.1.8</version>
267266
</dependency>
267+
268268
<dependency>
269269
<groupId>ch.qos.logback</groupId>
270270
<artifactId>logback-core</artifactId>
271271
<version>1.1.8</version>
272272
</dependency>
273-
274-
<!--
275-
<dependency>
276-
<groupId>org.slf4j</groupId>
277-
<artifactId>slf4j-log4j12</artifactId>
278-
<version>1.7.21</version>
279-
</dependency>
280-
-->
281273
<!-- END Logging Dependencies -->
282274

283275
<!-- Dependencies for Guice -->
@@ -309,12 +301,6 @@
309301
<version>${jooq-version}</version>
310302
</dependency>
311303

312-
<!--<dependency>
313-
<groupId>org.jooq</groupId>
314-
<artifactId>jooq-meta</artifactId>
315-
<version>${jooq-version}</version>
316-
</dependency>-->
317-
318304
<dependency>
319305
<groupId>com.adamlewis</groupId>
320306
<artifactId>guice-persist-jooq</artifactId>
@@ -327,7 +313,6 @@
327313
<artifactId>joda-time</artifactId>
328314
<version>2.9.9</version>
329315
</dependency>
330-
331316
<!-- END JOOQ Dependencies -->
332317

333318
<!-- Dependencies for Shiro -->
@@ -497,13 +482,6 @@
497482
<version>3.1.2</version>
498483
</dependency>
499484

500-
<!--
501-
<dependency>
502-
<groupId>io.dropwizard.metrics</groupId>
503-
<artifactId>metrics-log4j</artifactId>
504-
<version>${metrics-version}</version>
505-
</dependency>
506-
-->
507485
<dependency>
508486
<groupId>io.dropwizard.metrics</groupId>
509487
<artifactId>metrics-servlet</artifactId>
@@ -557,23 +535,8 @@
557535
<dependency>
558536
<groupId>junit</groupId>
559537
<artifactId>junit</artifactId>
560-
<version>4.11</version>
538+
<version>4.12</version>
561539
<scope>test</scope>
562540
</dependency>
563-
564-
<!-- https://mvnrepository.com/artifact/org.netbeans.api/org-netbeans-modules-nbjunit -->
565-
<!-- <dependency>
566-
<groupId>org.netbeans.api</groupId>
567-
<artifactId>org-netbeans-modules-nbjunit</artifactId>
568-
<version>RELEASE801</version>
569-
</dependency>
570-
-->
571-
<!-- https://mvnrepository.com/artifact/org.netbeans.api/org-netbeans-modules-jellytools-platform -->
572-
<!-- <dependency>
573-
<groupId>org.netbeans.api</groupId>
574-
<artifactId>org-netbeans-modules-jellytools-platform</artifactId>
575-
<version>RELEASE801</version>
576-
</dependency>
577-
-->
578541
</dependencies>
579542
</project>

src/main/java/com/parallax/server/blocklyprop/config/SetupConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public void contextDestroyed(ServletContextEvent servletContextEvent) {
108108

109109
// This manually deregisters JDBC driver, which prevents Tomcat 7 from
110110
// complaining about memory leaks into this class
111+
112+
/*
111113
while (drivers.hasMoreElements()) {
112114
Driver driver = drivers.nextElement();
113115
try {
@@ -126,6 +128,7 @@ public void contextDestroyed(ServletContextEvent servletContextEvent) {
126128
if (loggerContext != null) {
127129
loggerContext.stop();
128130
}
131+
*/
129132
}
130133

131134
}

src/main/java/com/parallax/server/blocklyprop/converter/ProjectConverter.java

Lines changed: 86 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
*/
66
package com.parallax.server.blocklyprop.converter;
77

8-
import com.google.gson.JsonObject;
9-
import com.google.inject.Inject;
108
import com.parallax.server.blocklyprop.db.dao.ProjectDao;
119
import com.parallax.server.blocklyprop.db.generated.tables.pojos.Project;
1210
import com.parallax.server.blocklyprop.db.generated.tables.records.ProjectRecord;
1311
import com.parallax.server.blocklyprop.db.generated.tables.records.ProjectSharingRecord;
1412
import com.parallax.server.blocklyprop.security.BlocklyPropSecurityUtils;
15-
// import com.parallax.server.blocklyprop.services.ProjectService;
1613
import com.parallax.server.blocklyprop.services.ProjectSharingService;
1714
import com.parallax.server.blocklyprop.services.UserService;
1815
import com.parallax.server.blocklyprop.utils.DateConversion;
16+
17+
import com.google.gson.JsonObject;
18+
import com.google.inject.Inject;
1919
import java.util.List;
2020
import org.slf4j.Logger;
2121
import org.slf4j.LoggerFactory;
@@ -36,7 +36,6 @@ public class ProjectConverter {
3636

3737
private ProjectDao projectDao;
3838
private UserService userService;
39-
// private ProjectService projectService;
4039
private ProjectSharingService projectSharingService;
4140

4241
// Internal flag to enable/disable parent project details
@@ -53,12 +52,6 @@ public void setUserService(UserService userService) {
5352
this.userService = userService;
5453
}
5554

56-
/*
57-
@Inject
58-
public void setProjectService(ProjectService projectService) {
59-
this.projectService = projectService;
60-
}
61-
*/
6255
@Inject
6356
public void setProjectSharingService(ProjectSharingService projectSharingService) {
6457
this.projectSharingService = projectSharingService;
@@ -72,6 +65,8 @@ public void setProjectSharingService(ProjectSharingService projectSharingService
7265
* @return
7366
*/
7467
public JsonObject toListJson(ProjectRecord project) {
68+
LOG.debug("Converting a ProjectRecord to a Json object");
69+
7570
JsonObject result = new JsonObject();
7671

7772
if (project != null) {
@@ -105,6 +100,9 @@ public JsonObject toListJson(ProjectRecord project) {
105100
return result;
106101
}
107102

103+
// TODO: Refactor code to eliminate the parent project details. We don't use it
104+
105+
108106
// Overrride method to provide option to turn off parent project details
109107
public JsonObject toJson(ProjectRecord project, Boolean includeParentDetails) {
110108
includeParentProjectDetails = includeParentDetails;
@@ -125,72 +123,107 @@ public JsonObject toJson(Project project, Boolean includeParentDetails) {
125123
* @return
126124
*/
127125
public JsonObject toJson(ProjectRecord project) {
126+
LOG.debug("Converting a ProjectRecord object to JSON");
127+
128+
JsonObject result = null;
128129

129130
if (project == null) {
130131
LOG.error("Recieved a null project. Unable to convert it to JSON");
131132
return null;
132133
}
133134

134-
JsonObject result = new JsonObject();
135-
136-
LOG.info("Converting a ProjectRecord object to JSON");
135+
try {
136+
result = new JsonObject();
137137

138-
result.addProperty("id", project.getId());
139-
result.addProperty("name", project.getName());
140-
result.addProperty("description", project.getDescription());
141-
result.addProperty("description-html", project.getDescriptionHtml());
142-
result.addProperty("type", project.getType().name());
143-
result.addProperty("board", project.getBoard());
144-
result.addProperty("private", project.getPrivate());
145-
result.addProperty("shared", project.getShared());
146-
result.addProperty("created", DateConversion.toDateTimeString(project.getCreated().getTime()));
147-
result.addProperty("modified", DateConversion.toDateTimeString(project.getModified().getTime()));
138+
result.addProperty("id", project.getId());
139+
result.addProperty("name", project.getName());
140+
result.addProperty("description", project.getDescription());
141+
result.addProperty("description-html", project.getDescriptionHtml());
142+
result.addProperty("type", project.getType().name());
143+
result.addProperty("board", project.getBoard());
144+
result.addProperty("private", project.getPrivate());
145+
result.addProperty("shared", project.getShared());
146+
result.addProperty("created", DateConversion.toDateTimeString(project.getCreated().getTime()));
147+
result.addProperty("modified", DateConversion.toDateTimeString(project.getModified().getTime()));
148148

149-
LOG.debug("Evaluating project owner");
150-
// Does current user own this project?
151-
boolean isYours = project.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
152-
result.addProperty("yours", isYours);
153-
154-
result.addProperty("user", userService.getUserScreenName(project.getIdUser()));
149+
LOG.debug("Evaluating project owner");
150+
151+
// Does current user own this project?
152+
boolean isYours = project.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
155153

156-
// Obtain a project share key if it is available
157-
if (isYours) {
154+
LOG.debug("isYours = {}", isYours);
155+
156+
result.addProperty("yours", isYours);
157+
result.addProperty("user", userService.getUserScreenName(project.getIdUser()));
158158

159-
LOG.debug("Retrieving the project sharing record for project {}",project.getId());
159+
LOG.debug("Checking isYours State");
160+
161+
// Obtain a project share key if it is available
162+
if (isYours) {
163+
164+
LOG.debug("Retrieving the project sharing record for project {}",project.getId());
160165

161-
List<ProjectSharingRecord> projectSharingRecords =
162-
projectSharingService.getSharingInfo(project.getId());
166+
List<ProjectSharingRecord> projectSharingRecords =
167+
projectSharingService.getSharingInfo(project.getId());
163168

164-
LOG.debug("Checking results from project sharing request");
169+
LOG.debug("Checking results from project sharing request");
165170

166-
if (projectSharingRecords != null && !projectSharingRecords.isEmpty()) {
167-
result.addProperty("share-key", projectSharingRecords.get(0).getSharekey());
171+
if (projectSharingRecords == null) {
172+
LOG.debug("The project sharing record is null.");
173+
return result;
174+
}
175+
176+
if (projectSharingRecords.isEmpty()) {
177+
LOG.debug("The project sharing record is empty");
178+
return result;
179+
}
180+
181+
LOG.debug("Project shared key is {}", projectSharingRecords.get(0).getSharekey());
182+
183+
if (projectSharingRecords != null && !projectSharingRecords.isEmpty()) {
184+
LOG.debug("Adding shared key to the results");
185+
result.addProperty("share-key", projectSharingRecords.get(0).getSharekey());
186+
}
168187
}
169-
}
170188

171-
if (includeParentProjectDetails) {
172-
// Look for parent project - WHY????
173-
if (project.getBasedOn() != null) {
174-
JsonObject basedOn = new JsonObject();
175-
ProjectRecord basedOnProject = projectDao.getProject(project.getBasedOn());
176-
if (basedOnProject != null) {
177-
basedOn.addProperty("id", basedOnProject.getId());
178-
basedOn.addProperty("name", basedOnProject.getName());
179-
boolean basedOnProjectisYours = basedOnProject.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
180-
basedOn.addProperty("yours", basedOnProjectisYours);
181-
if (!isYours) {
182-
basedOn.addProperty("user", userService.getUserScreenName(basedOnProject.getIdUser()));
189+
LOG.debug("Include parent project details is {}", includeParentProjectDetails);
190+
191+
if (includeParentProjectDetails) {
192+
// Look for parent project - WHY????
193+
if (project.getBasedOn() != null) {
194+
JsonObject basedOn = new JsonObject();
195+
ProjectRecord basedOnProject = projectDao.getProject(project.getBasedOn());
196+
197+
if (basedOnProject != null) {
198+
basedOn.addProperty("id", basedOnProject.getId());
199+
basedOn.addProperty("name", basedOnProject.getName());
200+
boolean basedOnProjectisYours = basedOnProject.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
201+
basedOn.addProperty("yours", basedOnProjectisYours);
202+
203+
if (!isYours) {
204+
basedOn.addProperty("user", userService.getUserScreenName(basedOnProject.getIdUser()));
205+
}
206+
207+
result.add("basedOn", basedOn);
183208
}
184-
result.add("basedOn", basedOn);
185209
}
186210
}
187-
}
188211

212+
LOG.debug("Returning result: {}", result);
213+
214+
return result;
215+
}
216+
217+
catch (Exception ex) {
218+
LOG.error("Json Conversion failed with message: {}", ex.getMessage());
219+
}
220+
189221
return result;
222+
190223
}
191224

192225

193-
public JsonObject toJson(Project project) {
226+
private JsonObject toJson(Project project) {
194227
JsonObject result = new JsonObject();
195228
result.addProperty("id", project.getId());
196229
result.addProperty("name", project.getName());

src/main/java/com/parallax/server/blocklyprop/db/dao/impl/ProjectDaoImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
*/
66
package com.parallax.server.blocklyprop.db.dao.impl;
77

8-
import com.google.inject.Inject;
9-
import com.google.inject.Singleton;
108
import com.parallax.server.blocklyprop.TableOrder;
119
import com.parallax.server.blocklyprop.TableSort;
1210
import com.parallax.server.blocklyprop.db.dao.ProjectDao;
1311
import com.parallax.server.blocklyprop.db.enums.ProjectType;
1412
import com.parallax.server.blocklyprop.db.generated.Tables;
1513
import com.parallax.server.blocklyprop.db.generated.tables.records.ProjectRecord;
1614
import com.parallax.server.blocklyprop.security.BlocklyPropSecurityUtils;
15+
16+
import com.google.inject.Inject;
17+
import com.google.inject.Singleton;
1718
import java.util.GregorianCalendar;
1819
import java.util.List;
1920
import org.apache.shiro.authz.UnauthorizedException;

src/main/java/com/parallax/server/blocklyprop/rest/RestProfile.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.google.inject.Inject;
1515
import com.parallax.client.cloudsession.CloudSessionLocalUserService;
1616
import com.parallax.client.cloudsession.CloudSessionUserService;
17+
import com.parallax.client.cloudsession.exceptions.EmailNotConfirmedException;
1718
import com.parallax.client.cloudsession.exceptions.PasswordComplexityException;
1819
import com.parallax.client.cloudsession.exceptions.PasswordVerifyException;
1920
import com.parallax.client.cloudsession.exceptions.ScreennameUsedException;
@@ -132,6 +133,10 @@ public Response savePassword(
132133
result.addProperty("message", "could-not-change");
133134
return Response.ok(result.toString()).build();
134135
}
136+
} catch (EmailNotConfirmedException enc) {
137+
result.addProperty("success", false);
138+
result.addProperty("message", "email is not confirmed");
139+
return Response.ok(result.toString()).build();
135140
} catch (UnknownUserIdException uuie) {
136141
result.addProperty("success", false);
137142
result.addProperty("message", "unknown-user");

0 commit comments

Comments
 (0)