private void checkValidatorCount() throws ValidatorException {
if (LOG.isDebugEnabled()) {
LOG.debug("Checking validator count...");
}
Integer instanceCreated = (Integer) INSTANCE_COUNTER.get(
getClass().getName());
if (LOG.isDebugEnabled()) {
LOG.debug("Method validate() invoked " + validateInvoked + " times.");
LOG.debug("Validator created " + instanceCreated.intValue() + " times.");
}
if (instanceCreated.intValue() != 1) {
throw new ValidatorException(instanceCreated.toString()
+ " validator instances were created, "
+ "expected 1 validator instance per portlet definition.",
null);
}
}
java类javax.portlet.ValidatorException的实例源码
PreferencesValidatorImpl.java 文件源码
项目:portals-pluto
阅读 23
收藏 0
点赞 0
评论 0
PortletPreferencesImpl.java 文件源码
项目:portals-pluto
阅读 23
收藏 0
点赞 0
评论 0
/**
* Stores the portlet preferences to a persistent storage. If a preferences
* validator is defined for this portlet, this method firstly validates the
* portlet preferences.
* <p>
* This method is invoked internally, thus it does not check the portlet
* request method ID (METHOD_RENDER or METHOD_ACTION).
* </p>
* @throws ValidatorException if the portlet preferences are not valid.
* @throws IOException if an error occurs with the persistence mechanism.
*/
protected final void internalStore() throws IOException, ValidatorException {
// Validate the preferences before storing, if a validator is defined.
// If the preferences cannot pass the validation,
// an ValidatorException will be thrown out.
PortletDefinition portletD = window.getPortletDefinition();
PreferencesValidator validator = preferencesService.getPreferencesValidator(portletD);
if (validator != null)
{
validator.validate(this);
}
// Store the portlet preferences.
try {
preferencesService.store(window, request, preferences);
} catch (PortletContainerException ex) {
LOG.error("Error storing preferences.", ex);
throw new IOException("Error storing perferences: " + ex.getMessage());
}
}
SpeechUtil.java 文件源码
项目:liferay-voice-command
阅读 16
收藏 0
点赞 0
评论 0
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;
}
FlashlightSearchServiceImpl.java 文件源码
项目:flashlight-search
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
ConfigurationStorageV1.java 文件源码
项目:flashlight-search
阅读 21
收藏 0
点赞 0
评论 0
@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();
}
ConfigurationStorageV1.java 文件源码
项目:flashlight-search
阅读 32
收藏 0
点赞 0
评论 0
@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();
}
JuZExoInviteFriendFrontendApplication.java 文件源码
项目:invite-friend
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
AbstractMangedBean.java 文件源码
项目:org.portletbeans
阅读 25
收藏 0
点赞 0
评论 0
/**
* Stores the values of this bean into the preferences and stays in the current portlet mode.
*/
public void store() {
try {
final PortletPreferences portletPreferences = getPortletPreferences();
store(portletPreferences);
portletPreferences.store();
} catch (final ReadOnlyException | ValidatorException | IOException e) {
log.error("Could not store portlet preferences", e);
}
}
ConfiguracaoPage.java 文件源码
项目:edemocracia
阅读 21
收藏 0
点赞 0
评论 0
private void initForm() {
form = new Form<Void>("form") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit() {
PortletPreferences prefs = UIUtils.getPortletPreferences();
HtmlStripper htmlStripper = new HtmlStripper();
try {
prefs.setValue("titulo", tituloProjetoLei.getModelObject());
prefs.setValue("tituloDescricao", tituloDescricaoProjeto.getModelObject());
prefs.setValue("descricaoProjeto", htmlStripper.strip(descricaoProjeto.getModelObject()));
prefs.setValue("habilitaPlugins", habilitaPlugins.getModelObject().toString());
prefs.setValue("habilitaSugestoes", habilitaSugestoes.getModelObject().toString());
info("Alterações realizadas com sucesso!");
getRequestCycle().setRequestTarget(new RedirectRequestTarget(viewUrl));
} catch (ReadOnlyException e) {
error("Erro ao gravar alterações");
return;
}
try {
prefs.store();
} catch (ValidatorException e) {
error("Erro ao gravar alterações");
} catch (IOException e) {
error("Erro ao gravar alterações");
}
}
};
add(form);
}
V2EnvironmentTests_PortletPreferences_Validator.java 文件源码
项目:portals-pluto
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void validate(PortletPreferences preferences) throws ValidatorException {
EnvironmentTests_PortletPreferences_ApiAction.tr32_success = true;
EnvironmentTests_PortletPreferences_ApiEvent_event.tr32_success = true;
EnvironmentTests_PortletPreferences_ApiResource.tr32_success = true;
if (preferences.getValue("tr33", "true").equals("false")) {
ArrayList<String> al = new ArrayList<String>();
al.add("tr33");
al.add("tr34");
throw new ValidatorException("ValidatorException for tr33 and tr34", al);
}
}
MeinungsbildRepository.java 文件源码
项目:politaktiv-aktuelles-meinungsbild-portlet
阅读 20
收藏 0
点赞 0
评论 0
public void saveMaximumRatings(SetOfOpinion tmpSetOfOpinionWithOnlyMaxValues, ActionRequest actionRequest) throws ReadOnlyException, ValidatorException, IOException {
javax.portlet.PortletPreferences prefs = actionRequest.getPreferences();
if(tmpSetOfOpinionWithOnlyMaxValues.validateMaxValues()){
prefs.setValue("maximumRatingPerUser", Integer.toString(tmpSetOfOpinionWithOnlyMaxValues.getNumberOfMaximumScoresByUser()));
prefs.setValue("maximumOfRatingPerSubtopic", Integer.toString(tmpSetOfOpinionWithOnlyMaxValues.getNumberOfMaximumScoreBySubtopic()));
prefs.store();
} else {
SessionErrors.add(actionRequest, "maximumsInputNotValid");
}
}
FlashlightSearchServiceImpl.java 文件源码
项目:flashlight-search
阅读 18
收藏 0
点赞 0
评论 0
@Override
public FlashlightSearchConfiguration readConfiguration(PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
return this.storageEngine.readConfiguration(preferences);
}
FlashlightSearchServiceImpl.java 文件源码
项目:flashlight-search
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void saveGlobalSettings(String adtUuid, boolean doSearchOnStartup, String doSearchOnStartupKeywords, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
this.storageEngine.saveGlobalSettings(adtUuid, doSearchOnStartup, doSearchOnStartupKeywords, preferences);
}
FlashlightSearchServiceImpl.java 文件源码
项目:flashlight-search
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void saveConfigurationTab(FlashlightSearchConfigurationTab configurationTab, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
this.storageEngine.saveConfigurationTab(configurationTab, preferences);
}
FlashlightSearchServiceImpl.java 文件源码
项目:flashlight-search
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void saveSearchFacetConfig(FlashlightSearchConfigurationTab configurationTab, SearchFacet searchFacet, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
this.storageEngine.saveSearchFacetConfig(configurationTab, searchFacet, preferences);
}
FlashlightSearchServiceImpl.java 文件源码
项目:flashlight-search
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void deleteConfigurationTab(String tabId, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
this.storageEngine.deleteConfigurationTab(tabId, preferences);
}
ConfigurationStorageV1.java 文件源码
项目:flashlight-search
阅读 18
收藏 0
点赞 0
评论 0
@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();
}
MockPortletPreferences.java 文件源码
项目:spring4-understanding
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void store() throws IOException, ValidatorException {
if (this.preferencesValidator != null) {
this.preferencesValidator.validate(this);
}
}
MockPortletPreferences.java 文件源码
项目:spring4-understanding
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void store() throws IOException, ValidatorException {
if (this.preferencesValidator != null) {
this.preferencesValidator.validate(this);
}
}
SetupPages.java 文件源码
项目:liferay-db-setup-core
阅读 25
收藏 0
点赞 0
评论 0
private static void setupLiferayPage(final Layout layout, final Page page, final String defaultLayout,
final String defaultLayoutContainedInThemeWithId, final long groupId,
final boolean isPrivate, final long company, final long userId,
final String pageTemplateName) throws SystemException, PortalException {
if (page.getTheme() != null) {
setPageTheme(layout, page);
}
if (page.getLayout() != null) {
setLayoutTemplate(layout, page, userId);
}
setPageTarget(page, layout);
List<Pageportlet> portlets = page.getPageportlet();
if (portlets != null && !portlets.isEmpty()) {
for (Pageportlet portlet : portlets) {
try {
addPortletIntoPage(page, layout, portlet, company, groupId);
} catch (ValidatorException | IOException e) {
LOG.error(e);
}
}
}
List<Page> subPages = page.getPage();
if (subPages != null && !subPages.isEmpty()) {
if (pageTemplateName != null && !pageTemplateName.equals("")) {
LOG.error("Page template " + pageTemplateName + " may not have any sub-pages! "
+ "Will ignore them!");
} else {
addPages(subPages, defaultLayout, defaultLayoutContainedInThemeWithId, groupId, isPrivate,
layout.getLayoutId(), company, userId);
}
}
if (page.getCustomFieldSetting() != null && !page.getCustomFieldSetting().isEmpty()) {
setCustomFields(userId, groupId, company, page, layout);
}
SetupPermissions.updatePermission("Page " + page.getFriendlyURL(), groupId, company,
layout.getPlid(), Layout.class, page.getRolePermissions(),
getDefaultPermissions(isPrivate));
}
SimpleRSSPreferencesValidator.java 文件源码
项目:sakai
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void validate(PortletPreferences prefs) throws ValidatorException {
//get prefs as strings
String max_items = prefs.getValue("max_items", Integer.toString(Constants.MAX_ITEMS));
String feed_url = prefs.getValue(PREF_FEED_URL, null);
//check readonly
boolean feedUrlIsLocked = prefs.isReadOnly(PREF_FEED_URL);
/**
* max_items
*/
IntegerValidator integerValidator = IntegerValidator.getInstance();
Integer maxItems = integerValidator.validate(max_items);
//check it's a number
if(maxItems == null) {
throw new ValidatorException("Invalid value, must be a number", Collections.singleton("max_items"));
}
//check greater than or equal to a minimum of 1
if(!integerValidator.minValue(maxItems, Constants.MIN_ITEMS)) {
throw new ValidatorException("Invalid number, must be greater than 0", Collections.singleton("max_items"));
}
/**
* feed_url
*/
//only validate if it's not readonly
if(!feedUrlIsLocked) {
String[] schemes = {"http","https"};
DetailedUrlValidator urlValidator = new DetailedUrlValidator(schemes);
//check not null
if(StringUtils.isBlank(feed_url)){
throw new ValidatorException("You must specify a URL for the RSS feed", Collections.singleton(PREF_FEED_URL));
}
//check valid scheme
if(!urlValidator.isValidScheme(feed_url)){
throw new ValidatorException("Invalid feed scheme. Must be one of: " + Arrays.toString(schemes), Collections.singleton(PREF_FEED_URL));
}
//check valid URL
if(!urlValidator.isValid(feed_url)){
throw new ValidatorException("Invalid feed URL", Collections.singleton(PREF_FEED_URL));
}
}
/**
* portlet_title not validated here as it is reasonable to allow blank entry. We deal with this later
*/
}
TestPreferences.java 文件源码
项目:org.portletbeans
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void store() throws IOException, ValidatorException {
// Nothing to do
}
MockPortletPreferences.java 文件源码
项目:class-guard
阅读 22
收藏 0
点赞 0
评论 0
public void store() throws IOException, ValidatorException {
if (this.preferencesValidator != null) {
this.preferencesValidator.validate(this);
}
}
MockPortletPreferences.java 文件源码
项目:class-guard
阅读 23
收藏 0
点赞 0
评论 0
public void store() throws IOException, ValidatorException {
if (this.preferencesValidator != null) {
this.preferencesValidator.validate(this);
}
}
PreferencesValidatorImpl.java 文件源码
项目:portals-pluto
阅读 115
收藏 0
点赞 0
评论 0
public void validate(PortletPreferences preferences)
throws ValidatorException {
validateInvoked++;
String value = preferences.getValue(CHECK_VALIDATOR_COUNT, null);
if (value != null && value.equalsIgnoreCase("true")) {
checkValidatorCount();
}
//
// TODO: Determine why we use this - I seem to remember it's a
// spec requirement, and fix it so that we don't have issues
// anymore. When enabled, all preferences fail in testsuite.
//
final String[] DEFAULT_VALUES = new String[] { "no values" };
Collection<String> failedNames = new ArrayList<String>();
for (Enumeration<String> en = preferences.getNames();
en.hasMoreElements(); ) {
String name = (String) en.nextElement();
String[] values = preferences.getValues(name, DEFAULT_VALUES);
if (values != null) { // null values are allowed
for (int i = 0; i < values.length; i++) {
if (values[i] != null) { // null values are allowed
// Validate that the preferences do not
// start or end with white spaces.
if (!values[i].equals(values[i].trim())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Validation failed: "
+ "value has white spaces: "
+ "name=" + name
+ "; value=|" + values[i] + "|");
}
failedNames.add(name);
}
}
}
}
}
if (!failedNames.isEmpty()) {
throw new ValidatorException(
"One or more preferences do not pass the validation.",
failedNames);
}
}
ExceptionTests_ValidatorException_ApiRender.java 文件源码
项目:portals-pluto
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
throws PortletException, IOException {
long tid = Thread.currentThread().getId();
portletReq.setAttribute(THREADID_ATTR, tid);
PrintWriter writer = portletResp.getWriter();
JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();
// Create result objects for the tests
/* TestCase: V2ExceptionTests_ValidatorException_ApiRender_constructor2 */
/* Details: "For ValidatorException(java.lang.String, */
/* java.util.Collection<java.lang.String>), the failedKeys */
/* parameter may be null" */
TestResult tr0 =
tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_CONSTRUCTOR2);
ValidatorException ve = new ValidatorException("TestException", null);
if (ve.getMessage().equals("TestException")) {
tr0.setTcSuccess(true);
}
tr0.writeTo(writer);
/* TestCase: V2ExceptionTests_ValidatorException_ApiRender_constructor4 */
/* Details: "For ValidatorException(java.lang.String, */
/* java.lang.Throwable, */
/* java.util.Collection<java.lang.String>), the failedKeys */
/* parameter may be null" */
TestResult tr1 =
tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_CONSTRUCTOR4);
Throwable tw = new Throwable("TestThrow");
ValidatorException ve1 = new ValidatorException("TestException1", tw, null);
if (ve1.getMessage().equals("TestException1")) {
tr1.setTcSuccess(true);
}
tr1.writeTo(writer);
/* TestCase: V2ExceptionTests_ValidatorException_ApiRender_constructor6 */
/* Details: "For ValidatorException(java.lang.Throwable, */
/* java.util.Collection<java.lang.String>), the failedKeys */
/* parameter may be null" */
TestResult tr2 =
tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_CONSTRUCTOR6);
Throwable tw1 = new Throwable("TestThrow1");
ValidatorException ve2 = new ValidatorException(tw1, null);
if (ve2.getMessage().contains("TestThrow1")) {
tr2.setTcSuccess(true);
}
tr2.writeTo(writer);
/* TestCase: V2ExceptionTests_ValidatorException_ApiRender_getFailedKeys1 */
/* Details: "Method getFailedKeys(): Returns a */
/* java.util.Enumeration<java.lang.String> object containing */
/* the preference keys that failed validation" */
TestResult tr3 =
tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_GETFAILEDKEYS1);
tr3.setTcSuccess(true);
tr3.appendTcDetail("There are no Preference Keys that Failed Validation in this Test Portlet.");
tr3.writeTo(writer);
/* TestCase: V2ExceptionTests_ValidatorException_ApiRender_getFailedKeys2 */
/* Details: "Method getFailedKeys(): Returns an empty enmueration if */
/* no failed keys are available" */
TestResult tr4 =
tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_GETFAILEDKEYS2);
Enumeration<?> eu = ve1.getFailedKeys();
List<?> li = Collections.list(eu);
if (li.isEmpty()) {
tr4.setTcSuccess(true);
}
tr4.writeTo(writer);
}
TestAnnotatedPrefs2.java 文件源码
项目:portals-pluto
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void validate(PortletPreferences arg0) throws ValidatorException {
}
TestAnnotatedPrefs1.java 文件源码
项目:portals-pluto
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void validate(PortletPreferences arg0) throws ValidatorException {
}
SimpleRSSPreferencesValidator.java 文件源码
项目:sakai
阅读 17
收藏 0
点赞 0
评论 0
@Override
public void validate(PortletPreferences prefs) throws ValidatorException {
//get prefs as strings
String max_items = prefs.getValue("max_items", Integer.toString(Constants.MAX_ITEMS));
String feed_url = prefs.getValue(PREF_FEED_URL, null);
//check readonly
boolean feedUrlIsLocked = prefs.isReadOnly(PREF_FEED_URL);
/**
* max_items
*/
IntegerValidator integerValidator = IntegerValidator.getInstance();
Integer maxItems = integerValidator.validate(max_items);
//check it's a number
if(maxItems == null) {
throw new ValidatorException("Invalid value, must be a number", Collections.singleton("max_items"));
}
//check greater than or equal to a minimum of 1
if(!integerValidator.minValue(maxItems, Constants.MIN_ITEMS)) {
throw new ValidatorException("Invalid number, must be greater than 0", Collections.singleton("max_items"));
}
/**
* feed_url
*/
//only validate if it's not readonly
if(!feedUrlIsLocked) {
String[] schemes = {"http","https"};
DetailedUrlValidator urlValidator = new DetailedUrlValidator(schemes);
//check not null
if(StringUtils.isBlank(feed_url)){
throw new ValidatorException("You must specify a URL for the RSS feed", Collections.singleton(PREF_FEED_URL));
}
//check valid scheme
if(!urlValidator.isValidScheme(feed_url)){
throw new ValidatorException("Invalid feed scheme. Must be one of: " + Arrays.toString(schemes), Collections.singleton(PREF_FEED_URL));
}
//check valid URL
if(!urlValidator.isValid(feed_url)){
throw new ValidatorException("Invalid feed URL", Collections.singleton(PREF_FEED_URL));
}
}
/**
* portlet_title not validated here as it is reasonable to allow blank entry. We deal with this later
*/
}
SpeechUtil.java 文件源码
项目:liferay-voice-command
阅读 19
收藏 0
点赞 0
评论 0
public static void deleteVoiceCommand(ActionRequest request)
throws PortalException, SystemException, ReadOnlyException, ValidatorException, IOException {
String commandKey = ParamUtil.get(request, SpeechConstants.VOICE_COMMAND, StringPool.BLANK);
deleteVoiceCommand(request, commandKey);
}