From: <jsh...@rh...> - 2009-04-29 20:41:45
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [3878] rhq-2042 patch</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>3878</dd> <dt>Author</dt> <dd>jshaughn</dd> <dt>Date</dt> <dd>2009-04-29 15:41:40 -0500 (Wed, 29 Apr 2009)</dd> </dl> <h3>Log Message</h3> <pre>rhq-2042 patch</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqbranchesRHQ_1_2_0_CPmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthprefsSubjectPreferencesCachejava">rhq/branches/RHQ_1_2_0_CP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesCache.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqbranchesRHQ_1_2_0_CPmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthprefsSubjectPreferencesCachejava"></a> <div class="modfile"><h4>Modified: rhq/branches/RHQ_1_2_0_CP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesCache.java (3877 => 3878)</h4> <pre class="diff"> <span class="info">--- rhq/branches/RHQ_1_2_0_CP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesCache.java 2009-04-29 14:47:55 UTC (rev 3877) +++ rhq/branches/RHQ_1_2_0_CP/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/prefs/SubjectPreferencesCache.java 2009-04-29 20:41:40 UTC (rev 3878) </span><span class="lines">@@ -39,24 +39,39 @@ </span><span class="cx"> private void load(int subjectId) { if (!subjectPreferences.containsKey(subjectId)) { </span><span class="rem">- Subject subject = subjectManager.loadUserConfiguration(subjectId); - Configuration configuration = subject.getUserConfiguration(); - subjectPreferences.put(subjectId, configuration); </span><span class="add">+ try { + Subject subject = subjectManager.loadUserConfiguration(subjectId); + Configuration configuration = subject.getUserConfiguration(); + subjectPreferences.put(subjectId, configuration); + } catch (Throwable t) { + log.warn("Can not get preferences for subject[id=" + subjectId + "], subject does not exist yet"); + } </span><span class="cx"> } } public synchronized PropertySimple getUserProperty(int subjectId, String propertyName) { load(subjectId); </span><span class="rem">- PropertySimple prop = subjectPreferences.get(subjectId).getSimple(propertyName); </span><span class="add">+ Configuration config = subjectPreferences.get(subjectId); + if (config == null) { + return null; + } + + PropertySimple prop = config.getSimple(propertyName); </span><span class="cx"> if (prop == null) { return null; } </span><span class="add">+ </span><span class="cx"> return new PropertySimple(propertyName, prop.getStringValue()); } public synchronized void setUserProperty(int subjectId, String propertyName, String value) { load(subjectId); </span><span class="add">+ </span><span class="cx"> Configuration config = subjectPreferences.get(subjectId); </span><span class="add">+ if ( config == null ) { + return; + } + </span><span class="cx"> PropertySimple prop = config.getSimple(propertyName); if (prop == null) { </span><span class="lines">@@ -80,7 +95,13 @@ </span><span class="cx"> public synchronized void unsetUserProperty(int subjectId, String propertyName) { load(subjectId); </span><span class="rem">- Property property = subjectPreferences.get(subjectId).remove(propertyName); </span><span class="add">+ + Configuration config = subjectPreferences.get(subjectId); + if (config == null) { + return; + } + + Property property = config.remove(propertyName); </span><span class="cx"> // it's possible property was already removed, and thus this operation becomes a no-op to the backing store if (property != null && property.getId() != 0) { try { </span> </pre> </div> </div> </body> </html> |