当前位置: 首页>>代码示例>>Java>>正文


Java ReadOnlyException类代码示例

本文整理汇总了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");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:25,代码来源:IMSBLTIPortlet.java

示例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);
}
 
开发者ID:liefke,项目名称:org.portletbeans,代码行数:17,代码来源:JournalArticlePreferenceHandler.java

示例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;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:22,代码来源:PreferenceCommonTest.java

示例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;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:23,代码来源:PreferenceCommonTest.java

示例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;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:23,代码来源:PreferenceCommonTest.java

示例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);
    }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:17,代码来源:PortletPreferencesImpl.java

示例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);
    }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:23,代码来源:PortletPreferencesImpl.java

示例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;
}
 
开发者ID:rivetlogic,项目名称:liferay-voice-command,代码行数:24,代码来源:SpeechUtil.java

示例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);
        }
    }
}
 
开发者ID:brandt,项目名称:GridSphere,代码行数:34,代码来源:PortletPreferencesImpl.java

示例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);
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:29,代码来源:FlashlightSearchServiceImpl.java

示例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();
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:11,代码来源:ConfigurationStorageV1.java

示例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();
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:8,代码来源:ConfigurationStorageV1.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:MockPortletPreferences.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:MockPortletPreferences.java

示例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);
}
 
开发者ID:exo-addons,项目名称:invite-friend,代码行数:8,代码来源:JuZExoInviteFriendFrontendApplication.java


注:本文中的javax.portlet.ReadOnlyException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。