tsgrp / OpenContent

TSG's Web Services for ECM Repositories
8 stars 4 forks source link

User Preferences: logs spammed if user preferences doesn't exist #69

Open mikeblum opened 9 years ago

mikeblum commented 9 years ago

A client noticed in their logs a bunch of traces regarding user preferences:

2015-09-13 21:59:39,330  ERROR [opencontent.rest.RESTService] [http-apr-8080-exec-4] Unable to find object with path: hpi/user/admin
com.tsgrp.opencontent.core.exception.OCObjectNotFoundException: Unable to find object with path: hpi/user/admin
        at com.tsgrp.opencontent.alfresco.util.AlfrescoEmbUtil.getNodeRefByPath(AlfrescoEmbUtil.java:678)
        at com.tsgrp.opencontent.alfresco.content.AlfrescoEmbContentImpl.getObjectByPath(AlfrescoEmbContentImpl.java:1154)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

Could we swallow this exception and just put in a logger.info saaying that a user preferences file doesn't exist?

gsteimer commented 9 years ago

I thought that with the new user prefs model auto-save code, this shouldn't really be an issue after a user is in the system for more than 1 minute.

Is that correct @aviking ?

aviking commented 9 years ago

@gsteimer That's how it was when it was first created but I think there have been updates since then that may have changed this. I'm not sure exactly what those were.

ghost commented 9 years ago

@gsteimer @aviking The user preferences no longer get saved every minute, they get saved on a throttle so that they get updated when needed, but don't get spammed (the solution ever minute tried to solve). However, this change did create this problem, because since the save does not automatically happen now. When the user logs in, this line is used and it won't exist until the user has done something to create userPreferences. I'm assuming this error also used to show when a new user first logged in, since it wouldn't have a user preferences folder (yet) in the old saving strategy either. I'm guessing a findOrCreateByPath method can be used to fix this. Or just throw an info statement that the folder doesn't exist, as Mike suggested.

This is an issue with how it is being fetched upon login. It uses this line : OpenContentObject oco = CoreContext.getContent().getObjectByPath(ticket, userPreferencesPath+name);

mikeblum commented 8 years ago

Seeing this now:

[2015-12-08 09:46:08,311|ERROR|RESTConfigService|saveUserPreference|228] Error creating JSON object with the request and grabbing name of user preferences: A JSONObject text must begin with '{' at character 0
org.json.JSONException: A JSONObject text must begin with '{' at character 0

we're spamming client logs right now.