Example usage for java.util TimeZone getAvailableIDs

List of usage examples for java.util TimeZone getAvailableIDs

Introduction

In this page you can find the example usage for java.util TimeZone getAvailableIDs.

Prototype

public static synchronized String[] getAvailableIDs() 

Source Link

Document

Gets all the available IDs supported.

Usage

From source file:org.iwethey.forums.web.user.EditUserController.java

private List getAllowedTimeZones() {
    if (this.allowedTimeZones != null) {
        return this.allowedTimeZones;
    }//from   w  w  w  . j a va2  s.  c  o m

    this.allowedTimeZones = new ArrayList();

    String[] zones = TimeZone.getAvailableIDs();

    for (int i = 0; i < zones.length; i++) {
        String zone = zones[i];
        if (zone.startsWith("Etc/") || zone.startsWith("SystemV/") || zone.indexOf("/") < 0) {
            continue;
        }
        this.allowedTimeZones.add(new SelectEntry(zone, zone, false));
    }

    return this.allowedTimeZones;
}

From source file:com.seajas.search.attender.wsdl.Profile.java

/**
 * {@inheritDoc}//from  www . j av a  2 s . c  o  m
 */
@Override
public List<ProfileError> createProfile(final String email, final String emailLanguage, final String timeZone,
        final String notificationType, final Integer day, final Integer hour, final Integer minute,
        final Integer interval, final Integer maximum, final String query, final String searchParameterFormat,
        final String searchParameterLanguage, final String searchParameterAuthor,
        final String searchParameterType, final String searchParameterGeo,
        final List<Integer> taxonomyIdentifiers) {
    List<ProfileError> errors = new ArrayList<ProfileError>();

    // Validate the given input

    if (StringUtils.isEmpty(query))
        errors.add(new ProfileError("query", "profiles.error.query.empty"));

    String unescapedQuery = StringEscapeUtils.unescapeXml(StringEscapeUtils.unescapeXml(query));

    // Validate the subscriber(s)

    String[] emails = email.trim().split(",");

    for (String subscriberEmail : emails)
        if (StringUtils.isEmpty(subscriberEmail.trim())
                || !EmailValidator.getInstance().isValid(subscriberEmail.trim()))
            errors.add(new ProfileError("email", "profiles.error.subscriber.emails.invalid"));

    if (StringUtils.isEmpty(emailLanguage))
        errors.add(new ProfileError("emailLanguage", "profiles.error.subscriber.email.languages.invalid"));
    else if (!attenderService.getAvailableSearchLanguages().contains(emailLanguage))
        errors.add(new ProfileError("emailLanguage", "profiles.error.subscriber.email.languages.invalid"));

    if (StringUtils.isEmpty(timeZone))
        errors.add(new ProfileError("timeZone", "profiles.error.subscriber.timezones.invalid"));
    else if (!Arrays.asList(TimeZone.getAvailableIDs()).contains(timeZone)
            && !timeZone.matches("^GMT[+\\-][0-9]{2}:[0-9]{2}$"))
        errors.add(new ProfileError("timeZone", "profiles.error.subscriber.timezones.invalid"));

    if (StringUtils.isEmpty(notificationType))
        errors.add(new ProfileError("notificationType", "profiles.error.subscriber.types.invalid"));
    else
        try {
            NotificationType.valueOf(notificationType);
        } catch (IllegalArgumentException e) {
            errors.add(new ProfileError("notificationType", "profiles.error.subscriber.types.invalid"));
        }

    if (day == null)
        errors.add(new ProfileError("day", "profiles.error.subscriber.days.invalid"));
    else if (day < 0 || day > 6)
        errors.add(new ProfileError("day", "profiles.error.subscriber.days.invalid"));

    if (hour == null)
        errors.add(new ProfileError("subscriberHours", "profiles.error.subscriber.hours.invalid"));
    else if (hour < 0 || hour > 23)
        errors.add(new ProfileError("subscriberHours", "profiles.error.subscriber.hours.invalid"));

    if (minute == null)
        errors.add(new ProfileError("minute", "profiles.error.subscriber.minutes.invalid"));
    else if (minute < 0 || minute > 59)
        errors.add(new ProfileError("minute", "profiles.error.subscriber.minutes.invalid"));

    // Validate the search parameters

    if (!StringUtils.isEmpty(searchParameterFormat))
        try {
            MediaType.parseMediaTypes(searchParameterFormat.replaceAll(" ", ","));
        } catch (IllegalArgumentException e) {
            errors.add(new ProfileError("searchParameterFormat",
                    "profiles.error.search.parameter.format.invalid"));
        }
    else if (!StringUtils.isEmpty(searchParameterLanguage)) {
        if (!attenderService.getAvailableSearchLanguages().contains(searchParameterLanguage))
            errors.add(new ProfileError("searchParameterLanguage",
                    "profiles.error.search.parameter.language.invalid"));
    }

    // Validate the taxonomy identifiers

    for (Integer taxonomyIdentifier : taxonomyIdentifiers)
        if (taxonomyIdentifier == null)
            errors.add(new ProfileError("taxonomyIdentifiers", "profiles.error.taxonomy.identifiers.empty"));

    // Add it up if there aren't any errors

    if (errors.size() == 0) {
        List<ProfileSubscriber> subscribers = new ArrayList<ProfileSubscriber>(emails.length);

        for (String subscriberEmail : emails)
            subscribers.add(new ProfileSubscriber(subscriberEmail.trim(), emailLanguage, false, null, timeZone,
                    NotificationType.valueOf(notificationType), day, hour, minute, interval, maximum, null));

        Map<String, String> searchParameters = new HashMap<String, String>();

        if (!StringUtils.isEmpty(searchParameterFormat))
            searchParameters.put("dcterms_format", searchParameterFormat);
        if (!StringUtils.isEmpty(searchParameterLanguage))
            searchParameters.put("dcterms_language", searchParameterLanguage);
        if (!StringUtils.isEmpty(searchParameterAuthor))
            searchParameters.put("dcterms_author", searchParameterAuthor);
        if (!StringUtils.isEmpty(searchParameterType))
            searchParameters.put("dcterms_type", searchParameterType);
        if (!StringUtils.isEmpty(searchParameterGeo))
            searchParameters.put("geo_total", searchParameterGeo);

        attenderService.addProfile(unescapedQuery, true, subscribers, searchParameters, taxonomyIdentifiers);
    }

    return errors;
}

From source file:org.dpadgett.timer.WorldClockFragment.java

private void newClockDialog(final int position) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getString(R.string.world_clock_select_timezone));
    final Map<String, String> timezoneNameToId = new HashMap<String, String>();
    final Set<Integer> timezones = new TreeSet<Integer>();
    final Map<Integer, List<String>> offsetToName = new HashMap<Integer, List<String>>();
    final long currentTime = System.currentTimeMillis();

    for (final String timezone : TimeZone.getAvailableIDs()) {
        final TimeZone tz = TimeZone.getTimeZone(timezone);
        final boolean isDaylight = tz.useDaylightTime();
        final String timezoneName = tz.getDisplayName(isDaylight, TimeZone.LONG, Locale.getDefault());
        if (timezoneNameToId.containsKey(timezoneName)) {
            continue;
        }//from  w w  w  .  j a  va  2  s. c om
        final int millisOffset = tz.getOffset(currentTime);
        timezones.add(millisOffset);
        if (!offsetToName.containsKey(millisOffset)) {
            offsetToName.put(millisOffset, new ArrayList<String>());
        }
        offsetToName.get(millisOffset).add(timezoneName);
        timezoneNameToId.put(timezoneName, timezone);
    }
    for (final List<String> names : offsetToName.values()) {
        Collections.sort(names);
    }
    if (position > -1) {
        builder.setPositiveButton(context.getString(R.string.world_clock_button_remove),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        clockList.remove(position);
                        clocksListAdapter.notifyDataSetChanged();

                        final SharedPreferences.Editor prefs = context
                                .getSharedPreferences("WorldClocks", Context.MODE_PRIVATE).edit();
                        prefs.putInt("numClocks", clockList.size());
                        int idx;
                        for (idx = position; idx < clockList.size(); idx++) {
                            prefs.putString("clock" + idx, clockList.get(idx));
                        }
                        prefs.remove("clock" + idx);
                        prefs.commit();
                    }
                });
    }
    final LinearLayout tzView = (LinearLayout) LayoutInflater.from(context)
            .inflate(R.layout.timezone_picker_dialog, (ViewGroup) finder.findViewById(R.id.layout_root));

    final List<String> initialItems = new ArrayList<String>();
    initialItems.add(context.getString(R.string.world_clock_timezone_gmt));
    initialItems.add(context.getString(R.string.world_clock_timezone_utc));
    final ArrayAdapter<String> adapter = ArrayAdapter.newArrayAdapter(context,
            R.layout.timezone_dialog_list_item, initialItems);
    final ListView timezoneList = (ListView) tzView.findViewById(R.id.timezoneList);
    timezoneList.setAdapter(adapter);

    final TextView sliderView = (TextView) tzView.findViewById(R.id.timezoneLabel);

    final SeekBar timezoneSeeker = (SeekBar) tzView.findViewById(R.id.timezoneSeeker);
    final List<Integer> timezonesList = new ArrayList<Integer>(timezones);
    timezoneSeeker.setMax(timezonesList.size() - 1);
    if (position > -1) {
        final int offset = TimeZone.getTimeZone(clockList.get(position)).getOffset(currentTime);
        timezoneSeeker.setProgress(timezonesList.indexOf(offset));
    } else {
        timezoneSeeker.setProgress(timezonesList.indexOf(0));
    }
    timezoneSeeker.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        // initialize the timezoneSeeker
        {
            onProgressChanged(timezoneSeeker, timezoneSeeker.getProgress(), false);
        }

        @Override
        public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
            adapter.clear();
            adapter.addAll(offsetToName.get(timezonesList.get(progress)));
            final int millisOffset = timezonesList.get(progress);
            String offset = String.format("%02d:%02d", Math.abs(millisOffset / 1000 / 60 / 60),
                    Math.abs(millisOffset / 1000 / 60) % 60);
            if (millisOffset / 1000 / 60 / 60 < 0) {
                offset = "-" + offset;
            } else {
                offset = "+" + offset;
            }
            sliderView.setText(context.getString(R.string.world_clock_timezone_label) + offset);
        }

        @Override
        public void onStartTrackingTouch(final SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(final SeekBar seekBar) {
        }
    });
    builder.setView(tzView);
    final AlertDialog alert = builder.create();

    timezoneList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int selectedPosition,
                final long id) {
            final String timezoneName = adapter.getItem(selectedPosition);
            final String timezone = timezoneNameToId.get(timezoneName);
            addNewClock(timezone, position);
            alert.dismiss();
        }
    });

    alert.show();
}

From source file:org.lamsfoundation.lams.admin.web.action.TimezoneManagementAction.java

/**
 * Shows page where admin can choose server timezone.
 * /*from ww  w . j  ava  2  s . com*/
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward serverTimezoneManagement(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());

    ArrayList<TimezoneDTO> timezoneDtos = new ArrayList<TimezoneDTO>();
    for (String availableTimezoneId : TimeZone.getAvailableIDs()) {
        TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
        TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, false);
        timezoneDtos.add(timezoneDto);
    }

    request.setAttribute("timezoneDtos", timezoneDtos);
    request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());

    return mapping.findForward(FORWARD_SERVER_TIMEZONE_MANAGEMENT);
}

From source file:org.jini.commands.utils.TimeInZone.java

private ArrayList<String> searchTimeZone(String search) {
    ArrayList<String> res = new ArrayList<String>();
    if (this.jcError == false) {
        String[] timeZones = TimeZone.getAvailableIDs();
        for (int x = 0; x < timeZones.length; x++) {
            if (timeZones[x].toLowerCase().contains(search.toLowerCase())) {
                res.add(timeZones[x]);/*  w  w  w .j  a v  a  2 s.co m*/
            }
        }
    }

    return res;
}

From source file:at.bitfire.davdroid.ui.CreateCalendarActivity.java

@Override
public void onLoadFinished(Loader<AccountInfo> loader, AccountInfo info) {
    Spinner spinner = (Spinner) findViewById(R.id.time_zone);
    String[] timeZones = TimeZone.getAvailableIDs();
    spinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, timeZones));
    // select system time zone
    String defaultTimeZone = TimeZone.getDefault().getID();
    for (int i = 0; i < timeZones.length; i++)
        if (timeZones[i].equals(defaultTimeZone)) {
            spinner.setSelection(i);/*from   w  w w . jav  a2  s.  c o m*/
            break;
        }

    if (info != null) {
        spinner = (Spinner) findViewById(R.id.home_sets);
        spinner.setAdapter(
                new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, info.homeSets));
    }
}

From source file:org.pentaho.platform.web.http.api.resources.SystemResource.java

/**
 * Returns a list of TimeZones ensuring that the server (default) timezone is at the top of the list (0th element)
 * /* w  ww . j  a  v  a  2s . c o  m*/
 * @return a list of TimeZones ensuring that the server (default) timezone is at the top of the list (0th element)
 */
@GET
@Path("/timezones")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
@Facet(name = "Unsupported")
public TimeZoneWrapper getTimeZones() {
    Map<String, String> timeZones = new HashMap<String, String>();
    for (String tzId : TimeZone.getAvailableIDs()) {
        if (!tzId.toLowerCase().contains("gmt")) {
            int offset = TimeZone.getTimeZone(tzId).getOffset(System.currentTimeMillis());
            String text = String.format("%s%02d%02d", offset >= 0 ? "+" : "", offset / 3600000,
                    (offset / 60000) % 60);
            timeZones.put(tzId,
                    TimeZone.getTimeZone(tzId).getDisplayName(true, TimeZone.LONG) + " (UTC" + text + ")");
        }
    }
    return new TimeZoneWrapper(timeZones, TimeZone.getDefault().getID());
}

From source file:com.microsoft.exchange.DateHelpTest.java

@Test
public void getXMLGregorianCalendarsForTimeZones() throws DatatypeConfigurationException {
    List<String> availableIDs = Arrays.asList(TimeZone.getAvailableIDs());
    for (String timeZoneID : availableIDs) {
        TimeZone currTimeZone = TimeZone.getTimeZone(timeZoneID);
        XMLGregorianCalendar currXmlCalendar = DateHelp.getXMLGregorianCalendarNow(currTimeZone);
        boolean match = xmlGregorianCalendareMatchesTimeZone(currXmlCalendar, currTimeZone);
        if (!match)
            log.info(currTimeZone.getID() + " " + (match ? "PASSED" : "FAILED"));
    }/*w  w  w.  j a  v a  2  s. c  o  m*/
}

From source file:it.jugpadova.controllers.JuggerEditController.java

@ModelAttribute("timezones")
protected List<TimeZoneBean> getTimezones(HttpServletRequest req) throws Exception {
    RequestContext rc = (RequestContext) req.getAttribute("requestContext");
    List<TimeZoneBean> timezones = new ArrayList();
    Date now = new Date();
    String[] tzIds = TimeZone.getAvailableIDs();
    for (Object otzId : tzIds) {
        String tzId = (String) otzId;
        TimeZone fdtz = TimeZone.getTimeZone(tzId);
        timezones.add(new TimeZoneBean(fdtz.getID(), fdtz.getID()));
    }/*from w  ww. ja va2  s.co  m*/

    Collections.sort(timezones);
    return timezones;
}

From source file:com.seajas.search.attender.validator.ProfileValidator.java

/**
 * Validate the given command object./* ww w . j  a v a  2  s . co  m*/
 * 
 * @param command
 * @param errors
 */
@Override
public void validate(final Object command, final Errors errors) {
    ProfileCommand profile = (ProfileCommand) command;

    if (profile.getAction().equals("add") || profile.getAction().equals("edit")) {
        if (StringUtils.isEmpty(profile.getQuery()))
            errors.rejectValue("query", "profiles.error.query.empty");

        // Validate the subscribers

        int numberOfSubscribers = profile.getSubscriberEmails().size();

        if (numberOfSubscribers == 0)
            errors.rejectValue("subscriberEmails", "profiles.error.subscriber.emails.empty");
        else if (profile.getSubscriberEmailLanguages().size() != numberOfSubscribers)
            errors.rejectValue("subscriberEmailLanguages", "profiles.error.subscriber.email.languages.empty");
        else if (profile.getSubscriberTimeZones().size() != numberOfSubscribers)
            errors.rejectValue("subscriberTimeZones", "profiles.error.subscriber.timezones.empty");
        else if (profile.getSubscriberTypes().size() != numberOfSubscribers)
            errors.rejectValue("subscriberTypes", "profiles.error.subscriber.types.empty");
        else if (profile.getSubscriberDays().size() != numberOfSubscribers)
            errors.rejectValue("subscriberDays", "profiles.error.subscriber.days.empty");
        else if (profile.getSubscriberHours().size() != numberOfSubscribers)
            errors.rejectValue("subscriberHours", "profiles.error.subscriber.hours.empty");
        else if (profile.getSubscriberMinutes().size() != numberOfSubscribers)
            errors.rejectValue("subscriberMinutes", "profiles.error.subscriber.minutes.empty");
        else if (profile.getSubscriberIntervals().size() != numberOfSubscribers)
            errors.rejectValue("subscriberIntervals", "profiles.error.subscriber.intervals.empty");
        else if (profile.getSubscriberMaximums().size() != numberOfSubscribers)
            errors.rejectValue("subscriberMaximums", "profiles.error.subscriber.maximums.empty");
        else {
            List<String> emails = new Vector<String>(), types = new Vector<String>();

            for (int i = 0; i < profile.getSubscriberEmails().size(); i++) {
                // Validate the e-mail

                String subscriberEmail = profile.getSubscriberEmails().get(i);

                // Skip if empty

                if (StringUtils.isEmpty(subscriberEmail))
                    continue;

                if (!EmailValidator.getInstance().isValid(subscriberEmail)) {
                    errors.rejectValue("subscriberEmails", "profiles.error.subscriber.emails.invalid");

                    break;
                }

                String subscriberEmailLanguage = profile.getSubscriberEmailLanguages().get(i);

                if (StringUtils.isEmpty(subscriberEmailLanguage)) {
                    errors.rejectValue("subscriberEmailLanguages",
                            "profiles.error.subscriber.email.languages.invalid");

                    break;
                } else if (!attenderService.getAvailableSearchLanguages().contains(subscriberEmailLanguage)) {
                    errors.rejectValue("subscriberEmailLanguages",
                            "profiles.error.subscriber.email.languages.invalid");

                    break;
                }

                String subscriberTimeZone = profile.getSubscriberTimeZones().get(i);

                if (StringUtils.isEmpty(subscriberTimeZone)) {
                    errors.rejectValue("subscriberTimeZones", "profiles.error.subscriber.timezones.invalid");

                    break;
                } else if (!Arrays.asList(TimeZone.getAvailableIDs()).contains(subscriberTimeZone)
                        && !subscriberTimeZone.matches("^GMT[+\\-][0-9]{2}:[0-9]{2}$")) {
                    errors.rejectValue("subscriberTimeZones", "profiles.error.subscriber.timezones.invalid");

                    break;
                }

                String subscriberType = profile.getSubscriberTypes().get(i);

                if (StringUtils.isEmpty(subscriberType)) {
                    errors.rejectValue("subscriberTypes", "profiles.error.subscriber.types.invalid");

                    break;
                }

                try {
                    NotificationType.valueOf(subscriberType);
                } catch (IllegalArgumentException e) {
                    errors.rejectValue("subscriberTypes", "profiles.error.subscriber.types.invalid");

                    break;
                }

                String subscriberDay = profile.getSubscriberDays().get(i);

                if (StringUtils.isEmpty(subscriberDay)) {
                    errors.rejectValue("subscriberDays", "profiles.error.subscriber.days.invalid");

                    break;
                }

                try {
                    Integer dayNumber = Integer.parseInt(subscriberDay);

                    if (dayNumber < 0 || dayNumber > 6) {
                        errors.rejectValue("subscriberDays", "profiles.error.subscriber.days.invalid");

                        break;
                    }
                } catch (NumberFormatException e) {
                    errors.rejectValue("subscriberDays", "profiles.error.subscriber.days.invalid");

                    break;
                }

                String subscriberHour = profile.getSubscriberHours().get(i);

                if (StringUtils.isEmpty(subscriberHour)) {
                    errors.rejectValue("subscriberHours", "profiles.error.subscriber.hours.invalid");

                    break;
                }

                try {
                    Integer hourNumber = Integer.parseInt(subscriberHour);

                    if (hourNumber < 0 || hourNumber > 23) {
                        errors.rejectValue("subscriberHours", "profiles.error.subscriber.hours.invalid");

                        break;
                    }
                } catch (NumberFormatException e) {
                    errors.rejectValue("subscriberHours", "profiles.error.subscriber.hours.invalid");

                    break;
                }

                String subscriberMinute = profile.getSubscriberMinutes().get(i);

                if (StringUtils.isEmpty(subscriberMinute)) {
                    errors.rejectValue("subscriberMinutes", "profiles.error.subscriber.minutes.invalid");

                    break;
                }

                try {
                    Integer minuteNumber = Integer.parseInt(subscriberMinute);

                    if (minuteNumber < 0 || minuteNumber > 59) {
                        errors.rejectValue("subscriberMinutes", "profiles.error.subscriber.minutes.invalid");

                        break;
                    }
                } catch (NumberFormatException e) {
                    errors.rejectValue("subscriberMinutes", "profiles.error.subscriber.minutes.invalid");

                    break;
                }

                String subscriberInterval = profile.getSubscriberIntervals().get(i);

                if (StringUtils.isEmpty(subscriberInterval)) {
                    errors.rejectValue("subscriberIntervals", "profiles.error.subscriber.intervals.invalid");

                    break;
                }

                try {
                    Integer intervalNumber = Integer.parseInt(subscriberInterval);

                    // XXX: An arbitrary, but not outrageously high number

                    if (intervalNumber < -1 || intervalNumber > 60000) {
                        errors.rejectValue("subscriberIntervals",
                                "profiles.error.subscriber.intervals.invalid");

                        break;
                    }
                } catch (NumberFormatException e) {
                    errors.rejectValue("subscriberIntervals", "profiles.error.subscriber.intervals.invalid");

                    break;
                }

                String subscriberMaximum = profile.getSubscriberMaximums().get(i);

                if (StringUtils.isEmpty(subscriberMaximum)) {
                    errors.rejectValue("subscriberMaximums", "profiles.error.subscriber.maximums.invalid");

                    break;
                }

                try {
                    Integer maximumNumber = Integer.parseInt(subscriberMaximum);

                    // XXX: An arbitrary, but not outrageously high number

                    if (maximumNumber < -1 || maximumNumber > 60000) {
                        errors.rejectValue("subscriberMaximums", "profiles.error.subscriber.maximums.invalid");

                        break;
                    }
                } catch (NumberFormatException e) {
                    errors.rejectValue("subscriberMaximums", "profiles.error.subscriber.maximums.invalid");

                    break;
                }

                if (subscriberMaximum.equals("-1") && !subscriberInterval.equals("-1"))
                    errors.rejectValue("subscriberMaximums", "profiles.error.subscriber.maximums.invalid");
                if (subscriberInterval.equals("-1") && !subscriberMaximum.equals("-1"))
                    errors.rejectValue("subscriberIntervals", "profiles.error.subscriber.intervals.invalid");

                emails.add(subscriberEmail);
                types.add(subscriberType);
            }

            if (emails.size() == 0)
                errors.rejectValue("subscriberEmails", "profiles.error.subscriber.emails.empty");
            else {
                // Now check for duplicates

                for (int i = 0; i < emails.size(); i++) {
                    int occurs = 0;

                    for (int j = 0; j < emails.size(); j++) {
                        String duplicateEmail = emails.get(j), duplicateType = types.get(j);

                        if (duplicateEmail.equals(emails.get(i)) && duplicateType.equals(types.get(i)))
                            occurs++;
                    }

                    if (occurs > 1) {
                        errors.rejectValue("subscriberEmails", "profiles.error.subscriber.emails.duplicate");

                        break;
                    }
                }
            }
        }

        // Validate the search parameters

        if (!StringUtils.isEmpty(profile.getSearchParameterFormat()))
            try {
                MediaType.parseMediaTypes(profile.getSearchParameterFormat().replaceAll(" ", ","));
            } catch (IllegalArgumentException e) {
                errors.rejectValue("searchParameterFormat", "profiles.error.search.parameter.format.invalid");
            }
        else if (!StringUtils.isEmpty(profile.getSearchParameterLanguage())) {
            if (!attenderService.getAvailableSearchLanguages().contains(profile.getSearchParameterLanguage()))
                errors.rejectValue("searchParameterLanguage",
                        "profiles.error.search.parameter.language.invalid");
        }

        // Validate the taxonomy identifiers

        for (String taxonomyIdentifier : profile.getTaxonomyIdentifiers())
            try {
                if (StringUtils.isEmpty(taxonomyIdentifier))
                    errors.rejectValue("taxonomyIdentifiers", "profiles.error.taxonomy.identifiers.empty");

                Integer.parseInt(taxonomyIdentifier);
            } catch (NumberFormatException e) {
                errors.rejectValue("taxonomyIdentifiers", "profiles.error.taxonomy.identifiers.invalid");

                break;
            }
    }
}