Skip to content

Commit 6daccfe

Browse files
committed
fixed some unnecessary user creation
1 parent 855bbcd commit 6daccfe

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/main/java/de/unirostock/sems/cbarchive/web/Tools.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,18 @@ public static UserManager getUser (CookieManager cookies) throws IOException
116116

117117
Cookie userInfo = cookies.getCookie( Fields.COOKIE_USER );
118118

119-
UserManager user = new UserManager(pathCookie.getValue());
120-
if( userInfo != null && !userInfo.getValue().isEmpty() )
121-
user.setData( UserData.fromJson( userInfo.getValue() ) );
119+
UserManager user = null;
120+
if( WorkspaceManager.getInstance().hasWorkspace( pathCookie.getValue() ) ) {
121+
// workspace exists
122+
user = new UserManager(pathCookie.getValue());
123+
// parse vCard info
124+
if( userInfo != null && !userInfo.getValue().isEmpty() )
125+
user.setData( UserData.fromJson( userInfo.getValue() ) );
126+
}
122127

123128
storeUserCookies(cookies, user);
124129

125130
return user;
126-
127131
}
128132

129133
public static void storeUserCookies(CookieManager cookies, UserManager user) {

src/main/java/de/unirostock/sems/cbarchive/web/UserManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public UserManager( String workspaceId ) throws IOException {
7171
LOGGER.debug("Workspace with id ", workspaceId, " not found. Create new one with random id.");
7272
workspace = workspaceManager.createWorkspace();
7373
}
74+
else
75+
LOGGER.debug("Got it...");
7476

7577
// updates the last-seen time stamp
7678
workspace.updateLastseen();

src/main/java/de/unirostock/sems/cbarchive/web/rest/ShareApi.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ public class ShareApi extends RestHelper {
8686
@Produces( MediaType.TEXT_PLAIN )
8787
public Response setUserPath( @CookieParam(Fields.COOKIE_PATH) String oldUserPath, @PathParam("user_path") String userPath, @CookieParam(Fields.COOKIE_WORKSPACE_HISTORY) String historyCookie, @Context HttpServletRequest requestContext) {
8888

89+
// clean up user path
90+
userPath = userPath.trim();
8991
LOGGER.debug("Got share link to workspace ", userPath);
92+
9093
// user stuff
9194
UserManager user = null;
9295
try {

src/main/java/de/unirostock/sems/cbarchive/web/servlet/DownloadServlet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import de.unirostock.sems.cbarchive.web.Fields;
4141
import de.unirostock.sems.cbarchive.web.Tools;
4242
import de.unirostock.sems.cbarchive.web.UserManager;
43-
import de.unirostock.sems.cbarchive.web.WorkspaceManager;
4443
import de.unirostock.sems.cbarchive.web.dataholder.Archive;
4544
import de.unirostock.sems.cbarchive.web.exception.CombineArchiveWebCriticalException;
4645
import de.unirostock.sems.cbarchive.web.exception.CombineArchiveWebException;

0 commit comments

Comments
 (0)