本文整理匯總了Java中javax.portlet.PortletPreferences.reset方法的典型用法代碼示例。如果您正苦於以下問題:Java PortletPreferences.reset方法的具體用法?Java PortletPreferences.reset怎麽用?Java PortletPreferences.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.portlet.PortletPreferences
的用法示例。
在下文中一共展示了PortletPreferences.reset方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processActionReset
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
public void processActionReset(String action,ActionRequest request, ActionResponse response)
throws PortletException, IOException {
// TODO: Check Role
log.debug("Removing preferences....");
clearSession(request);
PortletSession pSession = request.getPortletSession(true);
PortletPreferences prefs = request.getPreferences();
try {
prefs.reset("sakai.descriptor");
for (String element : fieldList) {
prefs.reset("imsti."+element);
prefs.reset("sakai:imsti."+element);
}
log.debug("Preference removed");
} catch (ReadOnlyException e) {
setErrorMessage(request, rb.getString("error.modify.prefs")) ;
return;
}
prefs.store();
// Go back to the main edit page
pSession.setAttribute("sakai.view", "edit");
}
示例2: updateBuddyListStrategy
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
* Updates buddy list strategy preferences
*
* @param preferences PortletPreferences
* @param properties Properties
* @throws Exception
*/
private void updateBuddyListStrategy(PortletPreferences preferences, Properties properties) throws Exception {
// Reset previous preferences
preferences.reset(PortletPropertiesKeys.BUDDY_LIST_STRATEGY);
// Set the value in portlet preferences
preferences.setValue(
PortletPropertiesKeys.BUDDY_LIST_STRATEGY,
properties.getBuddyListStrategy().getDescription()
);
// Persist
preferences.store();
// Save in environment
setupBuddyListStrategy(preferences);
}
示例3: store
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public void store(final PortletPreferences preferences, final String key, final E value) throws ReadOnlyException {
if (value == null) {
preferences.setValue(key, null);
} else {
preferences.reset(key);
PreferenceFieldRegistry.store(preferences, key + '.', value);
}
}
示例4: updateBuddyListSocialRelations
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
* Updates buddy list social relations preferences
*
* @param preferences PortletPreferences
* @param properties Properties
* @throws Exception
*/
private void updateBuddyListSocialRelations(PortletPreferences preferences, Properties properties) throws Exception {
// Social relations needs to be mapped to the string alternatives so they can
// be moved to the preferences
Environment.BuddyListSocialRelation[] relations = properties.getBuddyListSocialRelations();
String[] relationStrings = new String[relations.length];
for (int i = 0; i < relationStrings.length; i++) {
relationStrings[i] = String.valueOf(relations[i].getCode());
}
// Reset previous preferences
preferences.reset(PortletPropertiesKeys.BUDDY_LIST_ALLOWED_SOCIAL_RELATION_TYPES);
// Set the value in portlet preferences
preferences.setValues(
PortletPropertiesKeys.BUDDY_LIST_ALLOWED_SOCIAL_RELATION_TYPES,
relationStrings
);
// Persist
preferences.store();
// Save in environment
setupBuddyListSocialRelations(preferences);
}
示例5: deleteConfigurationTab
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public void deleteConfigurationTab(String tabId, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
// First, delete any reference to this tab
List<String> tabIds = Arrays.asList(preferences.getValues(CONF_KEY_TABS, EMPTY_ARRAY))
.stream()
.filter(tab -> !tab.equals(tabId))
.collect(Collectors.toList());
preferences.setValues(CONF_KEY_TABS, tabIds.toArray(new String[tabIds.size()]));
// Then, flush out any singular value
String assetTypeKey = format(CONF_KEY_FORMAT_ASSET_TYPE, tabId);
String journalArticleViewTemplateKey = format(CONF_KEY_FORMAT_JOURNAL_ARTICLE_VIEW_TEMPLATE, tabId);
String orderKey = format(CONF_KEY_FORMAT_ORDER, tabId);
String pageSizeKey = format(CONF_KEY_FORMAT_PAGE_SIZE, tabId);
String fullPageSizeKey = format(CONF_KEY_FORMAT_FULL_PAGE_SIZE, tabId);
String loadMoreSizeKey = format(CONF_KEY_FORMAT_LOAD_MORE_PAGE_SIZE, tabId);
String sortByKey = format(CONF_KEY_FORMAT_SORT_BY, tabId);
String sortReverseKey = format(CONF_KEY_FORMAT_SORT_REVERSE, tabId);
preferences.reset(orderKey);
preferences.reset(assetTypeKey);
preferences.reset(journalArticleViewTemplateKey);
preferences.reset(pageSizeKey);
preferences.reset(fullPageSizeKey);
preferences.reset(loadMoreSizeKey);
preferences.reset(sortByKey);
preferences.reset(sortReverseKey);
// Finally, flush out composed values
Enumeration<String> prefKeys = preferences.getNames();
Pattern journalArticleTemplatesKeyPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_JOURNAL_ARTICLE_TEMPLATES, tabId));
Pattern dlFileEntryTemplatesKeyPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_DL_FILE_ENTRY_TYPE_TEMPLATES, tabId));
Pattern titleKeyPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_TITLE, tabId));
Pattern searchFacetPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_SEARCH_FACET, tabId));
while(prefKeys.hasMoreElements()) {
String key = prefKeys.nextElement();
boolean journalArticleTemplatesMatches = journalArticleTemplatesKeyPattern.matcher(key).matches();
boolean dlFileEntryTemplatesMatches = dlFileEntryTemplatesKeyPattern.matcher(key).matches();
boolean titleMatches = titleKeyPattern.matcher(key).matches();
boolean searchFacetMatches = searchFacetPattern.matcher(key).matches();
if(journalArticleTemplatesMatches || dlFileEntryTemplatesMatches || titleMatches || searchFacetMatches) {
preferences.reset(key);
}
}
preferences.store();
}
示例6: checkResetPreferenceToDefault
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
protected TestResult checkResetPreferenceToDefault(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure preferences are properly reset.");
result.setSpecPLT("14.1");
PortletPreferences preferences = request.getPreferences();
boolean setOccured = false;
boolean resetOccured = false;
try {
// Set new value to overwrite the default value.
preferences.setValue(PREF_NAME, NEW_VALUE);
String value = preferences.getValue(PREF_NAME, DEF_VALUE);
if (NEW_VALUE.equals(value)) {
setOccured = true;
}
// Reset the preference so that default value is restored.
preferences.reset(PREF_NAME);
value = preferences.getValue(PREF_NAME, DEF_VALUE);
if (PREF_VALUE.equals(value)) {
resetOccured = true;
}
} catch (ReadOnlyException ex) {
TestUtils.failOnException("Unable to set preference value.", ex, result);
return result;
}
// Everything is OK.
if (setOccured && resetOccured) {
result.setReturnCode(TestResult.PASSED);
}
// Error occurred when setting or storing preferences.
else if (!setOccured) {
result.setReturnCode(TestResult.WARNING);
result.setResultMessage("A function upon which the reset test "
+ "depends failed to execute as expected. "
+ "Check the other test results in this test suite.");
}
// Error occurred when resetting preference.
else {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage("Preferences value was not successfully reset after store");
}
return result;
}
示例7: checkResetPreferenceWithoutDefault
import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
protected TestResult checkResetPreferenceWithoutDefault(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure preferences are properly reset (removed) "
+ "when the default value is not defined.");
result.setSpecPLT("14.1");
PortletPreferences preferences = request.getPreferences();
boolean setOccured = false;
boolean resetOccured = false;
try {
// Set preference value to overwrite the original (null).
preferences.setValue(BOGUS_KEY, NEW_VALUE);
String value = preferences.getValue(BOGUS_KEY, DEF_VALUE);
if (NEW_VALUE.equals(value)) {
setOccured = true;
}
// Reset preference value to null.
preferences.reset(BOGUS_KEY);
value = preferences.getValue(BOGUS_KEY, DEF_VALUE);
if (DEF_VALUE.equals(value)) {
resetOccured = true;
}
} catch (ReadOnlyException ex) {
TestUtils.failOnException("Unable to set preference value.", ex, result);
return result;
}
// Everything is OK.
if (setOccured && resetOccured) {
result.setReturnCode(TestResult.PASSED);
}
// Error occurred when setting or storing preferences.
else if (!setOccured) {
result.setReturnCode(TestResult.WARNING);
result.setResultMessage("A function upon which the reset test "
+ "depends failed to execute as expected. "
+ "Check the other test results in this test suite.");
}
// Error occurred when resetting preference value.
else {
result.setReturnCode(TestResult.FAILED);
result.setResultMessage("Preferences value was not successfully "
+ "reset after store.");
}
return result;
}