Example usage for java.util ConcurrentModificationException ConcurrentModificationException

List of usage examples for java.util ConcurrentModificationException ConcurrentModificationException

Introduction

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

Prototype

public ConcurrentModificationException(String message, Throwable cause) 

Source Link

Document

Constructs a new exception with the specified detail message and cause.

Usage

From source file:se.nrm.bio.mediaserver.rs.MediaResourceForm.java

/**
 * @TODO JUnit gives java.util.ConcurrentModificationException - must use
 * iterator and it.remove(); to handle this.
 *
 * @param updatedMediaText/*ww w  .j ava 2s .  c om*/
 * @param media
 * @return
 */
protected Media updateMediatext(final MediaText updatedMediaText, final Media media) {
    final String locale = updatedMediaText.getLang();

    // ie:temp
    final Set<MediaText> mediatextList = media.getTexts();

    String comment = "";
    try {
        Iterator<MediaText> it = mediatextList.iterator();
        while (it.hasNext()) {
            MediaText mediaText = it.next();
            comment = mediaText.getComment().trim();
            if (mediaText.getLang().equals(locale)) {
                bean.delete(mediaText);
                it.remove();
            }
        }
        if (!comment.isEmpty()) {
            if (comment.equals(updatedMediaText.getComment().trim())) {
                updatedMediaText.setComment(comment);
            }
        }
        media.addMediaText(updatedMediaText);
    } catch (ConcurrentModificationException ex) {
        logger.info(ex);
        throw new ConcurrentModificationException("probz with MEDIA_TEXT", ex);
    }

    return media;
}

From source file:se.nrm.bio.mediaserver.rs.NewMediaResourceForm.java

protected Media updateMediatext(final MediaText updatedMediaText, final Media media) {
    final String locale = updatedMediaText.getLang();

    // ie:temp/*from w w  w. j a  v a2s.c  o  m*/
    final Set<MediaText> currentMediatextList = media.getTexts();

    String comment = "";
    try {
        Iterator<MediaText> it = currentMediatextList.iterator();
        while (it.hasNext()) {
            MediaText mediaText = it.next();
            //                comment = mediaText.getComment().trim();
            if (mediaText.getLang().equals(locale)) {
                bean.delete(mediaText);
                it.remove();
            }
        }
        //            if (!comment.isEmpty()) {
        //                if (comment.equals(updatedMediaText.getComment().trim())) {
        //                    updatedMediaText.setComment(comment);
        //                }
        //            }
        media.addMediaText(updatedMediaText);
    } catch (ConcurrentModificationException ex) {
        logger.info(ex);
        throw new ConcurrentModificationException("probz with MEDIA_TEXT", ex);
    }

    return media;
}

From source file:se.nrm.mediaserver.resteasy.MediaResourceForm.java

/**
 * @TODO JUnit gives java.util.ConcurrentModificationException - must use
 * iterator and it.remove(); to handle this.
 *
 * @param updatedMediaText//  w ww . ja  va  2 s .  c o m
 * @param media
 * @return
 */
protected Media updateMediatext(final MediaText updatedMediaText, final Media media) {
    final String locale = updatedMediaText.getLang();
    final Set<MediaText> mediatextList = media.getTexts();

    String comment = "";
    try {
        Iterator<MediaText> it = mediatextList.iterator();
        while (it.hasNext()) {
            MediaText mediaText = it.next();
            comment = mediaText.getComment().trim();
            if (mediaText.getLang().equals(locale)) {
                bean.delete(mediaText);
                it.remove();
            }
        }
        if (!comment.isEmpty()) {
            if (comment.equals(updatedMediaText.getComment().trim())) {
                updatedMediaText.setComment(comment);
            }
        }
        media.addMediaText(updatedMediaText);
    } catch (ConcurrentModificationException ex) {
        logger.info(ex);
        throw new ConcurrentModificationException("probz with MEDIA_TEXT", ex);
    }

    return media;
}