1
14
15 package com.liferay.portlet.rss;
16
17 import com.liferay.portal.kernel.util.Validator;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import javax.portlet.PortletPreferences;
23 import javax.portlet.PreferencesValidator;
24 import javax.portlet.ValidatorException;
25
26
31 public class RSSPreferencesValidator implements PreferencesValidator {
32
33 public void validate(PortletPreferences preferences)
34 throws ValidatorException {
35
36 List<String> badURLs = new ArrayList<String>();
37
38 String[] urls = preferences.getValues("urls", new String[0]);
39
40 for (String url : urls) {
41 if (!Validator.isUrl(url)) {
42 badURLs.add(url);
43 }
44 }
45
46 if (badURLs.size() > 0) {
47 throw new ValidatorException("Failed to retrieve URLs", badURLs);
48 }
49 }
50
51 }