Skip to content

Commit 75f21b9

Browse files
committed
Merge branch '1.2' of github.com:parallaxinc/BlocklyProp into local 1.2 branch.
2 parents b556c6b + dbce968 commit 75f21b9

File tree

3 files changed

+49
-27
lines changed

3 files changed

+49
-27
lines changed

src/main/java/com/parallax/server/blocklyprop/servlets/PublicProfileServlet.java

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
/*
2-
* To change this license header, choose License Headers in Project Properties.
3-
* To change this template file, choose Tools | Templates
4-
* and open the template in the editor.
2+
* Copyright (c) 2019 Parallax Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5+
* and associated documentation files (the “Software”), to deal in the Software without
6+
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
7+
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
8+
* Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in all copies or
11+
* substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
520
*/
21+
622
package com.parallax.server.blocklyprop.servlets;
723

824
import com.google.common.base.Strings;
@@ -12,7 +28,6 @@
1228
import com.parallax.client.cloudsession.exceptions.EmailNotConfirmedException;
1329
import com.parallax.client.cloudsession.exceptions.ServerException;
1430
import com.parallax.client.cloudsession.exceptions.UnknownUserIdException;
15-
import com.parallax.client.cloudsession.exceptions.EmailNotConfirmedException;
1631
import com.parallax.server.blocklyprop.db.generated.tables.pojos.User;
1732
import com.parallax.server.blocklyprop.services.UserService;
1833
import com.parallax.server.blocklyprop.services.impl.SecurityServiceImpl;
@@ -50,7 +65,9 @@ public void setConfiguration(Configuration configuration) {
5065
}
5166

5267
@Override
53-
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
68+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
69+
ServletException, IOException {
70+
5471
String idUserString = req.getParameter("id-user");
5572
Long idUser = null;
5673

@@ -61,14 +78,14 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
6178
if (SecurityUtils.getSubject().isAuthenticated()) {
6279
idUser = SecurityServiceImpl.getSessionData().getIdUser();
6380
} else {
64-
LOG.info("Getting current user while not authenticated");
81+
LOG.warn("Getting current user while not authenticated");
6582
resp.sendError(404);
6683
}
6784
} else {
6885
idUser = Long.parseLong(idUserString);
6986
}
7087
} catch (NumberFormatException nfe) {
71-
LOG.info("id-user is not a valid number: {}", idUserString);
88+
LOG.warn("id-user is not a valid number: {}", idUserString);
7289
resp.sendError(500);
7390
}
7491
try {
@@ -77,27 +94,39 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
7794
if (user == null) {
7895
LOG.info("Get public profile for user {} (Does not exist!)", idUser);
7996
resp.sendError(404);
80-
return;
8197
}
8298

83-
LOG.info("Get public profile for user {}: Cloud-session user: {}", idUser, user.getIdcloudsession());
84-
8599
com.parallax.client.cloudsession.objects.User cloudSessionUser =
86100
cloudSessionUserService.getUser(user.getIdcloudsession());
87101

102+
// It is possible to receive an empty, non-null object
103+
if (cloudSessionUser == null) {
104+
LOG.warn("User object is null");
105+
resp.sendError(404, "User profile is unavailable");
106+
}
107+
if (cloudSessionUser.getScreenname() == null ) {
108+
LOG.warn("Unable to decode result from Cloud Session call");
109+
resp.sendError(404, "User object is empty");
110+
}
111+
88112
req.setAttribute("screenname", cloudSessionUser.getScreenname());
89113
req.getRequestDispatcher("/WEB-INF/servlet/public-profile.jsp").forward(req, resp);
90-
} catch (EmailNotConfirmedException ex) {
91-
LOG.info("User not known in cloud-session");
114+
}
115+
catch (EmailNotConfirmedException ex) {
116+
LOG.info("User email is unconfirmed cloud-session");
92117
resp.sendError(404);
93-
} catch (UnknownUserIdException ex) {
118+
}
119+
catch (UnknownUserIdException ex) {
94120
LOG.info("User not known in cloud-session");
95121
resp.sendError(404);
96-
} catch (ServerException ex) {
122+
}
123+
catch (NullPointerException ex) {
124+
LOG.warn("Unexpected Null Pointer Exception encountered. Message is: {}", ex.getMessage());
125+
resp.sendError(404, "NPE error. User not found");
126+
}
127+
catch (ServerException ex) {
97128
LOG.error("Communication problem with Cloud-session", ex);
98129
resp.sendError(500);
99130
}
100-
101131
}
102-
103132
}

src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ footer.clientdownloadlink = BlocklyProp-client
2828
# Application version numbers.
2929
application.major = 1
3030
application.minor = 1
31-
application.build = 456
31+
application.build = 457
3232

3333
html.content_missing = Content missing
3434

src/main/webapp/editor/blocklyc.jsp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,8 @@
122122
<span class="keyed-lang-string" data-key="editor_client_not-available"></span>
123123
</a>
124124
</span>
125-
<span id="client-available" class="bp-client-available hidden">
126-
<span class="keyed-lang-string" data-key="editor_client_available"></span>
127-
</span>
128-
<span id="client-available-short" class="hidden">
129-
<span class="keyed-lang-string" data-key="editor_client_available_short"></span>
130-
</span>
131-
<span id="client-available-long" class="hidden">
132-
<span class="keyed-lang-string" data-key="editor_client_available"></span>
133-
</span>
125+
<span id="client-available" class="bp-client-available keyed-lang-string hidden" data-key="editor_client_available"></span>
126+
<span id="client-available-short" class="bp-client-available keyed-lang-string hidden" data-key="editor_client_available_short"></span>
134127
</div>
135128
<div style="display:inline; padding-left: 10px; line-height: 30px;" class="auth-false" data-displayas="inline">
136129
<span style="font-size:13px;"><span class="keyed-lang-string" data-key="editor_demonstration_mode_info"></span></span>
@@ -159,7 +152,7 @@
159152
<select class="dropdown port-dropdown auth-true" data-displayas="inline-block" title="Ports" data-placement="left" id="comPort"></select>
160153
<a class="btn-view-code" id="btn-view-propc" style="display:inline-block;" href="#" onclick="tabClick('tab_propc')"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" style="vertical-align: middle;"><path d="M0.5,7 C4,1.5 10,1.5 13.5,7 C10,12.5 4,12.5 0.5,7 M0.5,7 C4,3.5 10,3.5 13.5,7" style="stroke:#000;stroke-width:1.5;fill:none;"/><circle cx="7" cy="6.5" r="2.75" style="stroke:#000;stroke-width:1.5;fill:none;"></circle><circle cx="7" cy="6.5" r=".5" style="stroke:#000;stroke-width:1.5;fill:#000;"></circle></svg> <span class="keyed-lang-string" data-key="menu_code"></span></a>
161154
<a class="btn-view-blocks" id="btn-view-blocks" style="display:none;" href="#" onclick="tabClick('tab_blocks')"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" style="vertical-align: middle;"><path d="M0.5,7 C4,1.5 10,1.5 13.5,7 C10,12.5 4,12.5 0.5,7 M0.5,7 C4,3.5 10,3.5 13.5,7" style="stroke:#fff;stroke-width:1.5;fill:none;"/><circle cx="7" cy="6.5" r="2.75" style="stroke:#fff;stroke-width:1.5;fill:none;"></circle><circle cx="7" cy="6.5" r=".5" style="stroke:#fff;stroke-width:1.5;fill:#fff;"></circle></svg> <span class="keyed-lang-string" data-key="menu_blocks"></span></a>
162-
<a href="#" class="btn btn-sm btn-primary" id="btn-view-xml" onclick="tabClick('tab_xml')" style="display: none;"><span class="keyed-lang-string" data-key="editor_view_xml"></span></a>
155+
<a href="#" class="btn-view-blocks" id="btn-view-xml" onclick="tabClick('tab_xml')" style="display: none;"><span class="keyed-lang-string" data-key="editor_view_xml"></span></a>
163156
<div style="display:inline-block;" class="auth-true" data-displayas="inline-block"><a href="#" class="demo-function" id="save-project"><span class="keyed-lang-string" data-key="editor_save"></span></a></div>
164157
<span class="dropdown"><button class="btn btn-sm btn-default dropdown-toggle" id="options-menu" type="button" data-toggle="dropdown">&#9776; <span class="caret"></span></button>
165158
<ul class="dropdown-menu pull-right btn-sm">

0 commit comments

Comments
 (0)