本文整理汇总了Java中javax.portlet.ReadOnlyException类的典型用法代码示例。如果您正苦于以下问题:Java ReadOnlyException类的具体用法?Java ReadOnlyException怎么用?Java ReadOnlyException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReadOnlyException类属于javax.portlet包,在下文中一共展示了ReadOnlyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processActionReset
import javax.portlet.ReadOnlyException; //导入依赖的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: store
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Override
public void store(final PortletPreferences preferences, final String key, final JournalArticle article)
throws ReadOnlyException {
String articleResourceUuid = null;
String articleId = null;
if (article != null) {
try {
articleResourceUuid = article.getArticleResourceUuid();
articleId = article.getArticleId();
} catch (final PortalException | SystemException e) {
log.error("Could not load article resource id for article {}", article.getArticleId(), e);
}
}
preferences.setValue(key + RESOURCE_UUID_SUFFIX, articleResourceUuid);
preferences.setValue(key + ARTICLE_ID_SUFFIX, articleId);
}
示例3: checkSetPreferenceSingleValue
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
protected TestResult checkSetPreferenceSingleValue(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure a single preference value can be set.");
result.setSpecPLT("14.1");
PortletPreferences preferences = request.getPreferences();
try {
preferences.setValue("TEST", "TEST_VALUE");
} catch (ReadOnlyException ex) {
TestUtils.failOnException("Unable to set preference value.", ex, result);
return result;
}
String value = preferences.getValue("TEST", DEF_VALUE);
if (value != null && value.equals("TEST_VALUE")) {
result.setReturnCode(TestResult.PASSED);
} else {
TestUtils.failOnAssertion("preference value", value, "TEST_VALUE", result);
}
return result;
}
示例4: checkSetPreferenceNull
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
protected TestResult checkSetPreferenceNull(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure a preference value can be set to null.");
result.setSpecPLT("14.1");
PortletPreferences preferences = request.getPreferences();
try {
preferences.setValue("TEST", null);
} catch (ReadOnlyException ex) {
TestUtils.failOnException("Unable to set preference value.", ex, result);
return result;
}
String value = preferences.getValue("TEST", DEF_VALUE);
// see PLUTO-609: behavioral change!
if (null == value) {
result.setReturnCode(TestResult.PASSED);
} else {
TestUtils.failOnAssertion("preference value", value, null, result);
}
return result;
}
示例5: checkSetPreferencesReturnsFirst
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
protected TestResult checkSetPreferencesReturnsFirst(PortletRequest request) {
TestResult result = new TestResult();
result.setDescription("Ensure the first value set to a given "
+ "preference is returned first by PortletPreferences.getValue().");
result.setSpecPLT("14.1");
PortletPreferences preferences = request.getPreferences();
try {
preferences.setValues("TEST", new String[] { "FIRST", "SECOND" });
} catch (ReadOnlyException ex) {
TestUtils.failOnException("Unable to set preference values.", ex, result);
return result;
}
String value = preferences.getValue("TEST", DEF_VALUE);
if (value != null && value.equals("FIRST")) {
result.setReturnCode(TestResult.PASSED);
} else {
TestUtils.failOnAssertion("preference value", value, "FIRST", result);
}
return result;
}
示例6: setValues
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
public void setValues(String key, String... values) throws ReadOnlyException {
if (isReadOnly(key)) {
throw new ReadOnlyException(EXCEPTIONS.getString(
"error.preference.readonly", key));
}
if (values == null) {
values = new String[0];
}
PortletPreference pref = preferences.get(key);
if (pref != null) {
pref.setValues(values);
} else {
pref = new PortletPreferenceImpl(key, values);
preferences.put(key, pref);
}
}
示例7: reset
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
public void reset(String key) throws ReadOnlyException {
// Read-only preferences cannot be reset.
if (isReadOnly(key)) {
throw new ReadOnlyException(EXCEPTIONS.getString(
"error.preference.readonly", key));
}
// Try to reset preference to the default values.
PortletPreference p = defaultPreferences.get(key);
if (p != null) {
if (LOG.isTraceEnabled()) {
LOG.trace("Resetting preference for key: " + key);
}
preferences.put(key,p.clone());
}
// Remove preference if default values are not defined (PLT.14.1).
else {
if (LOG.isTraceEnabled()) {
LOG.trace("Resetting preference to null for key: " + key);
}
preferences.remove(key);
}
}
示例8: deleteVoiceCommand
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
public static PortletPreferences deleteVoiceCommand(ActionRequest request, String voiceCommand)
throws PortalException, SystemException, ReadOnlyException, ValidatorException, IOException {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long plid = themeDisplay.getLayout().getPlid();
long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
long companyId = themeDisplay.getCompanyId();
PortletPreferences preference = request.getPreferences();
Map<String, String[]> preferencesMap = new HashMap<String, String[]>(preference.getMap());
preferencesMap.remove(voiceCommand);
PortletPreferencesLocalServiceUtil.deletePortletPreferences(ownerId, ownerType, plid, SpeechConstants.PORTLET_NAMESPACE);
preference = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, plid,
SpeechConstants.PORTLET_NAMESPACE);
for (Map.Entry<String, String[]> entry : preferencesMap.entrySet()) {
preference.setValue(entry.getKey(), entry.getValue()[0]);
}
preference.store();
return preference;
}
示例9: reset
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
/**
* Resets or removes the value associated with the specified key.
* <p/>
* If this implementation supports stored defaults, and there is such
* a default for the specified preference, the given key will be
* reset to the stored default.
* <p/>
* If there is no default available the key will be removed.
*
* @param key to reset
* @throws java.lang.IllegalArgumentException
* if key is <code>null</code>.
* @throws javax.portlet.ReadOnlyException
* if this preference cannot be modified for this request
*/
public void reset(String key) throws ReadOnlyException {
if (key == null) throw new IllegalArgumentException("key is NULL");
PersistencePreferenceAttribute ppa = (PersistencePreferenceAttribute) attributes.get(key);
if (ppa != null) {
if (ppa.isReadOnly()) throw new ReadOnlyException("PortletPreference is read-only!");
Preference defaultPref = (Preference) defaultPrefsMap.get(key);
if (defaultPref != null) {
Value[] defvals = defaultPref.getValue();
String[] vals = new String[defvals.length];
for (int i = 0; i < defvals.length; i++) {
vals[i] = defvals[i].getContent();
}
ppa.setAValues(vals);
} else {
attributes.remove(key);
}
}
}
示例10: search
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Override
public SearchResultsContainer search(PortletRequest request, PortletResponse response, String tabId, int pageOffset, boolean isLoadMore) throws ReadOnlyException, ValidatorException, IOException, SearchException {
FlashlightSearchConfiguration config = this.readConfiguration(request.getPreferences());
Map<String, FlashlightSearchConfigurationTab> tabs = config.getTabs();
FacetedSearcher searcher = this.facetedSearcherManager.createFacetedSearcher();
LinkedHashMap<FlashlightSearchConfigurationTab, SearchPage> resultMap = new LinkedHashMap<>(tabs.size());
for(FlashlightSearchConfigurationTab tab : tabs.values()) {
int pageSize;
int loadMoreSize;
if(tab.getId().equals(tabId)) {
pageSize = tab.getFullPageSize();
} else {
pageSize = tab.getPageSize();
}
if(isLoadMore) {
loadMoreSize = tab.getLoadMorePageSize();
} else {
loadMoreSize = 0;
}
resultMap.put(tab, this.search(request, response, config, tab, searcher, pageOffset, pageSize, loadMoreSize));
}
return new SearchResultsContainer(resultMap);
}
示例11: saveGlobalSettings
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Override
public void saveGlobalSettings(String adtUuid, boolean doSearchOnStartup, String doSearchOnStartupKeywords, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
if(Validator.isNull(doSearchOnStartupKeywords)) {
doSearchOnStartupKeywords = FlashlightSearchService.CONFIGURATION_DEFAULT_SEARCH_KEYWORDS;
}
preferences.setValue(CONF_KEY_ADT_UUID, adtUuid);
preferences.setValue(CONF_KEY_DO_SEARCH_ON_STARTUP, Boolean.toString(doSearchOnStartup));
preferences.setValue(CONF_KEY_DO_SEARCH_ON_STARTUP_KEYWORDS, doSearchOnStartupKeywords);
preferences.store();
}
示例12: saveSearchFacetConfig
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Override
public void saveSearchFacetConfig(FlashlightSearchConfigurationTab configurationTab, SearchFacet searchFacet, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
String tabId = configurationTab.getId();
String facetConfigKey = format(CONF_KEY_FORMAT_SEARCH_FACET, tabId, searchFacet.getClass().getName());
preferences.setValue(facetConfigKey, searchFacet.getData().toJSONString());
preferences.store();
}
示例13: setValues
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Override
public void setValues(String key, String[] values) throws ReadOnlyException {
Assert.notNull(key, "Key must not be null");
if (isReadOnly(key)) {
throw new ReadOnlyException("Preference '" + key + "' is read-only");
}
this.preferences.put(key, values);
}
示例14: reset
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Override
public void reset(String key) throws ReadOnlyException {
Assert.notNull(key, "Key must not be null");
if (isReadOnly(key)) {
throw new ReadOnlyException("Preference '" + key + "' is read-only");
}
this.preferences.remove(key);
}
示例15: saveSettings
import javax.portlet.ReadOnlyException; //导入依赖的package包/类
@Action
public Response saveSettings(String enableStoreData,String invitationUrl) throws ReadOnlyException, IOException, ValidatorException {
portletPreferences.setValue(ENABLE_STORE_DATA,enableStoreData);
portletPreferences.setValue(INVITATION_URL,invitationUrl);
portletPreferences.store();
return JuZExoInviteFriendFrontendApplication_.index().with(JuzuPortlet.PORTLET_MODE, PortletMode.VIEW);
}