Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1649 #1653

Merged
merged 23 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5bddb96
Fully documented class to help better understand Shiro session implem…
zfi Feb 14, 2019
b2c08a3
Add comments; refactor logging statements.
zfi Feb 17, 2019
f75d9dd
Correct document name.
pjewald Feb 20, 2019
891739c
Refactor TextileIndexServlet to return the index.jsp page. Remove old
pjewald Feb 20, 2019
6b4b9d0
Minor changes to documentation and license date.
pjewald Feb 20, 2019
74c132b
Minor changes to documentation and license date. Refactor variable re…
pjewald Feb 20, 2019
3aab6b3
Add inline documentation. Expand SQL statements to improve readability.
pjewald Feb 20, 2019
a90999e
Add inline documentation. Insert copyright notice.
pjewald Feb 20, 2019
16f0742
Insert copyright notice. Minor code refactor to validate user list
pjewald Feb 20, 2019
2f691c4
Insert missing copyright notice. Deprecate method that uses the screen
pjewald Feb 20, 2019
ebeee33
Add inline documentation. Insert copyright notice.
pjewald Feb 20, 2019
88e6598
Add inline documentation. Insert copyright notice. Minor refactor to …
pjewald Feb 20, 2019
37ebec6
Update copyright notice.
pjewald Feb 20, 2019
d4a53d2
Insert copyright notice. Minor code refactoring to correct compiler w…
pjewald Feb 20, 2019
180d91c
Add inline documentation. Insert copyright notice. Add code to suppor…
pjewald Feb 20, 2019
d623f7d
Insert copyright notice. Add entry point logging.
pjewald Feb 20, 2019
8d155f3
Update copyright notice. Replace null return with a new thrown exception
pjewald Feb 20, 2019
969d1f2
Insert copyright notice. Add code to trap a null user record.
pjewald Feb 20, 2019
f0add68
Add lots of inline documentation. Update copyright notice. Updated se…
pjewald Feb 20, 2019
d7d2935
Increment build number for deployment to Demo
pjewald Feb 20, 2019
47816e7
Add inline documentation. Insert copyright notice.
pjewald Feb 20, 2019
4105aae
Add inline documentation.
pjewald Feb 20, 2019
37b2cc4
Re-enable code to update user screen name when a mismatch is detected.
pjewald Feb 20, 2019
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
35 changes: 31 additions & 4 deletions src/main/java/com/parallax/server/blocklyprop/SessionData.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (c) 2019 Parallax Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.parallax.server.blocklyprop;

import com.google.inject.servlet.SessionScoped;
Expand All @@ -13,15 +29,21 @@
* User session details.
*
* This class contains the fields used to manage the client's session with
* the application.
* the application. The @SessionScoped decorator will enforce a single
* instance per session.
*
* @author Michel
*/
@SessionScoped
public class SessionData implements Serializable {

// A cloud session user profile object
private User user;

// A cloud session user profile primary key ID
private Long idUser;

// A locale string for this user
private String locale;

/**
Expand Down Expand Up @@ -54,6 +76,11 @@ public void setLocale(String locale) {
this.locale = locale;
}

/**
* Override the default toString method to enumerate all fields
*
* @return string representation of SessionData fields
*/
@Override
public String toString() {
return "SessionData{" + "user=" + user + ", idUser=" + idUser + ", locale=" + locale + '}';
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/com/parallax/server/blocklyprop/TableOrder.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (c) 2019 Parallax Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.parallax.server.blocklyprop;

/**
* Enumberate possible sort orders for project listings
*
* @author Michel
*/
public enum TableOrder {

asc,
desc

}
27 changes: 22 additions & 5 deletions src/main/java/com/parallax/server/blocklyprop/TableSort.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (c) 2019 Parallax Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.parallax.server.blocklyprop;

import com.parallax.server.blocklyprop.db.generated.Tables;
import com.parallax.server.blocklyprop.db.generated.tables.records.ProjectRecord;
import org.jooq.TableField;

/**
* A list of the possible fields on which to sort project data
*
* @author Michel
*/
Expand All @@ -21,14 +38,14 @@ public enum TableSort {
user(Tables.PROJECT.ID_USER),
modified(Tables.PROJECT.MODIFIED);

// Map this enum to a Field in the JooQ ProjectRecord class
private final TableField<ProjectRecord, ?> field;

private TableSort(TableField<ProjectRecord, ?> field) {
TableSort(TableField<ProjectRecord, ?> field) {
this.field = field;
}

public TableField<ProjectRecord, ?> getField() {
return field;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Parallax Inc.
* Copyright (c) 2019 Parallax Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without
Expand Down Expand Up @@ -64,6 +64,7 @@ protected Injector getInjector() {

@Override
protected void configure() {

bind(Configuration.class).toInstance(configuration);

bind(SessionData.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.parallax.server.blocklyprop.db.generated.tables.records.UserRecord;

/**
* Convert user object to a Json string
*
* @author Michel
*/
Expand Down
47 changes: 40 additions & 7 deletions src/main/java/com/parallax/server/blocklyprop/db/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@ public interface UserDao {

@Deprecated
UserRecord create(Long idCloudSession);


/**
* Update the blockly user screen name
*
* @param idUser - is the long integer id for the blockly user record
* @param screenName - is ghe new screen name to store in the user record
*/
void updateScreenName(Long idUser, String screenName);

/**
*
* @param idCloudSession
* @param screenName
* @return
*/
UserRecord create(Long idCloudSession, String screenName);


/**
* Retrieve a BP user record
*
Expand All @@ -38,16 +53,34 @@ public interface UserDao {
*/
UserRecord getUser(Long idCloudSession, String screenName);


/**
*
* @return
*/
List<UserRecord> getAll();

/**
*
* @param idUser
* @param roles
*/
void setRoles(Long idUser, Set<Role> roles);

/**
*
* @param idUser
* @return
*/
List<Role> getRoles(Long idUser);

Long getUserIdForCloudSessionUserId(Long id);

@Deprecated
public void updateScreenname(Long idUser, String screenname);

/**
* Obtain the blocklyprop user ID from the supplied cloud session user id
*
* @param idCloudSession
* The user profile ID
*
* @return
* Returns a Long integer blocklyprop user ID if successful, otherwise returns zero
*/
Long getUserIdForCloudSessionUserId(Long idCloudSession);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (c) 2019 Parallax Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.parallax.server.blocklyprop.db.dao.impl;

import com.google.inject.Inject;
Expand Down Expand Up @@ -62,7 +78,8 @@ public void setConfiguration(Configuration configuration) {
*/
@Override
public void create(SessionRecord session) {
LOG.info("Create a session. Timeout set to: {}", session.getTimeout());

LOG.debug("Create a session. Timeout set to: {}", session.getTimeout());

// Log session details if the configuration file permits it
printSessionInfo("create", session);
Expand Down Expand Up @@ -98,7 +115,9 @@ public void create(SessionRecord session) {
*/
@Override
public SessionRecord readSession(String idSession) throws NullPointerException {
LOG.debug("Getting session details");

LOG.debug("Getting session {} details", idSession);

SessionRecord sessionRecord = null;

try {
Expand All @@ -112,9 +131,8 @@ public SessionRecord readSession(String idSession) throws NullPointerException {
catch (org.jooq.exception.DataAccessException sqex) {
LOG.error("Database exception {}", sqex.getMessage());
}
finally {
return sessionRecord;
}

return sessionRecord;
}

/**
Expand All @@ -124,6 +142,7 @@ public SessionRecord readSession(String idSession) throws NullPointerException {
*/
@Override
public void updateSession(SessionRecord session) throws NullPointerException {

LOG.debug("Update a session");

try {
Expand Down Expand Up @@ -158,8 +177,12 @@ public void updateSession(SessionRecord session) throws NullPointerException {
*/
@Override
public void deleteSession(String idSession) {

LOG.info("Deleting session {}", idSession);
create.deleteFrom(Tables.SESSION).where(Tables.SESSION.IDSESSION.eq(idSession)).execute();

create.deleteFrom(Tables.SESSION)
.where(Tables.SESSION.IDSESSION.eq(idSession))
.execute();
}

/**
Expand Down
Loading