Example usage for java.util ArrayList contains

List of usage examples for java.util ArrayList contains

Introduction

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

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:de.kp.ames.web.function.role.RoleDQM.java

/**
 * Retrieve all registered roles in the context 
 * of a certain affiliation, i.e. attached roles
 * are marked 'checked' and others not//from   w w w  .  j  a  va2  s. c  o m
 * 
 * @param user
 * @param community
 * @return
 * @throws Exception
 */
public JSONArray getRoles(String user, String community) throws Exception {

    /*
     * Retrieve all roles actually registered
     */
    VocabDQM vocab = new VocabDQM(jaxrHandle);
    JSONArray jConcepts = vocab.getConceptsByParent(ClassificationConstants.FNC_ID_Role);

    /*
     * Retrieve affiliation that refers to affiliate & community
     */
    String sqlString = JaxrSQL.getSQLAssociations_AffiliatedWith(user, community);
    List<AssociationImpl> affiliations = getAssociationsByQuery(sqlString);

    if (affiliations.size() == 0)
        return jConcepts;

    /* 
     * There must only be one association available
     */
    AssociationImpl affiliation = affiliations.get(0);

    /*
     * Retrieve concept types for the selected affiliation
     */
    ArrayList<String> conceptTypes = new ArrayList<String>();

    Collection<?> clases = affiliation.getClassifications();
    Iterator<?> iterator = clases.iterator();

    while (iterator.hasNext()) {

        ClassificationImpl clas = (ClassificationImpl) iterator.next();
        conceptTypes.add(clas.getConcept().getKey().getId());

    }

    if (conceptTypes.size() == 0)
        return jConcepts;

    /*
     * Mark concepts (above) as checked, if they also
     * refer to concept types attached to an affiliation
     */

    for (int i = 0; i < jConcepts.length(); i++) {

        JSONObject jConcept = jConcepts.getJSONObject(i);

        String conceptType = jConcept.getString(RIM_ID);

        jConcept.put(JsonConstants.J_CHECK, false);
        if (conceptTypes.contains(conceptType))
            jConcept.put(JsonConstants.J_CHECK, true);

    }

    return jConcepts;

}

From source file:ca.uhn.fhir.jpa.term.BaseHapiTerminologySvc.java

private int validateConceptForStorage(TermConcept theConcept, TermCodeSystemVersion theCodeSystem,
        ArrayList<String> theConceptsStack, IdentityHashMap<TermConcept, Object> theAllConcepts) {
    ValidateUtil.isTrueOrThrowInvalidRequest(theConcept.getCodeSystem() != null, "CodesystemValue is null");
    ValidateUtil.isTrueOrThrowInvalidRequest(theConcept.getCodeSystem() == theCodeSystem,
            "CodeSystems are not equal");
    ValidateUtil.isNotBlankOrThrowInvalidRequest(theConcept.getCode(),
            "Codesystem contains a code with no code value");

    if (theConceptsStack.contains(theConcept.getCode())) {
        throw new InvalidRequestException(
                "CodeSystem contains circular reference around code " + theConcept.getCode());
    }//from  w w w.j a v a  2 s. c om
    theConceptsStack.add(theConcept.getCode());

    int retVal = 0;
    if (theAllConcepts.put(theConcept, theAllConcepts) == null) {
        if (theAllConcepts.size() % 1000 == 0) {
            ourLog.info("Have validated {} concepts", theAllConcepts.size());
        }
        retVal = 1;
    }

    for (TermConceptParentChildLink next : theConcept.getChildren()) {
        next.setCodeSystem(theCodeSystem);
        retVal += validateConceptForStorage(next.getChild(), theCodeSystem, theConceptsStack, theAllConcepts);
    }

    theConceptsStack.remove(theConceptsStack.size() - 1);

    return retVal;
}

From source file:gsn.webservice.standard.GSNWebServiceSkeleton.java

private void updateSelectionKey(HashMap<String, ArrayList<String>> source, String key,
        ArrayList<String> values) {
    if (source == null || key == null || values == null)
        return;//from   w  ww.ja v  a2s  .  co m
    ArrayList<String> sv = source.get(key);
    if (sv == null) {
        source.put(key, values);
    } else {
        for (String value : values) {
            if (!sv.contains(value))
                sv.add(value);
        }
    }
}

From source file:com.ikon.module.jcr.JcrAuthModule.java

/**
 * Grant user// ww w .j ava 2s.c o  m
 */
private void grantUser(Node node, String user, String property)
        throws ValueFormatException, PathNotFoundException, javax.jcr.RepositoryException {
    Value[] actualUsers = node.getProperty(property).getValues();
    ArrayList<String> newUsers = new ArrayList<String>();

    for (int i = 0; i < actualUsers.length; i++) {
        newUsers.add(actualUsers[i].getString());
    }

    // If the user isn't already granted add him
    if (!newUsers.contains(user)) {
        newUsers.add(user);
    }

    try {
        node.setProperty(property, (String[]) newUsers.toArray(new String[newUsers.size()]));
        node.save();
    } catch (javax.jcr.lock.LockException e) {
        log.warn("grantUser -> LockException : {}", node.getPath());
        JCRUtils.discardsPendingChanges(node);
    } catch (javax.jcr.AccessDeniedException e) {
        log.warn("grantUser -> AccessDeniedException : {}", node.getPath());
        JCRUtils.discardsPendingChanges(node);
    }
}

From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_node.java

@Override
public ArrayList<String> getAttributesColumnsHeaders() {
    ArrayList<String> attColumnsHeaders = new ArrayList<>();
    for (Node node : getVisibleElementsInTable())
        for (Map.Entry<String, String> entry : node.getAttributes().entrySet())
            if (attColumnsHeaders.contains(entry.getKey()) == false)
                attColumnsHeaders.add(entry.getKey());
    return attColumnsHeaders;
}

From source file:pplabmed.controller.userController.java

@RequestMapping(value = "updUsuarioC.htm", method = RequestMethod.POST)
public ModelAndView updateUser(@RequestParam("Nombre") String nombre, @RequestParam("Area") int area,
        @RequestParam("Estado") String estado, @RequestParam("WebApp") boolean web,
        @RequestParam("MobileApp") boolean mobile, @RequestParam("asignados") String asignados,
        @RequestParam("originales") String originales, @RequestParam("id") int id) throws Exception {

    ModelAndView mv = new ModelAndView("cargatempPermisos");
    UsuarioDAO usuario = new UsuarioDAO();
    boolean estadoU = true;

    if (estado.equals("Inactivo"))
        estadoU = false;//ww w.  j ava2  s . c om

    String num = usuario.EditarUsuario(nombre, area, estadoU, web, mobile, id, 0, "");
    ArrayList<Integer> IdAsignados = new ArrayList<Integer>();
    ArrayList<Integer> IdOriginales = new ArrayList<Integer>();

    String nuevos = "";
    String quitar = "";

    String[] separacion;
    //Crear ArrayList con alumnos seleccionados (Nuevos y viejos)
    if (!asignados.equals("")) {
        separacion = asignados.split("_xk12x_");
        for (int i = 0; i < separacion.length; i++) {
            IdAsignados.add(Integer.parseInt(separacion[i]));
        }
    }

    if (!originales.equals("")) {
        separacion = originales.split("_xk12x_");
        for (int i = 0; i < separacion.length; i++) {
            IdOriginales.add(Integer.parseInt(separacion[i]));
        }
    }

    for (int i = 0; i < IdOriginales.size(); i++) {
        if (!IdAsignados.contains(IdOriginales.get(i))) {
            if (quitar.equals("")) {
                quitar = IdOriginales.get(i).toString();
            } else {
                quitar = quitar + "_xk12x_" + IdOriginales.get(i).toString();
            }
        }
    }
    for (int i = 0; i < IdAsignados.size(); i++) {
        if (!IdOriginales.contains(IdAsignados.get(i))) {
            if (nuevos.equals("")) {
                nuevos = IdAsignados.get(i).toString();
            } else {
                nuevos = nuevos + "_xk12x_" + IdAsignados.get(i).toString();
            }
        }
    }

    UsuarioPorPerfilDAO usxp = new UsuarioPorPerfilDAO();
    usxp.UpdUsuarioPorPerfil(nuevos, quitar, Integer.valueOf(num), 0, "");

    mv.addObject("resp", "No");
    return mv;
}

From source file:com.eurelis.opencms.workflows.functions.EmailNotificationFunction.java

/**
 * Add a new Value in the map _resourcePerReviewer
 * //ww w.j av a2s  .c  o m
 * @param emailAddress
 *            the email address of the reviewer
 * @param listOfFiles
 *            the list of files associated
 */
private void addResourcesInMap(String emailAddress, List<String> listOfFiles) {
    // get the list of associated file if the email address is already in
    // the map
    if (_resourcesPerReviewer.containsKey(emailAddress)) {
        List<String> registeredPath = _resourcesPerReviewer.get(emailAddress);

        /*
         * Copy the content of the list of files and check value to avoid double
         */
        Iterator<String> listOfFilesIterator = listOfFiles.iterator();
        while (listOfFilesIterator.hasNext()) {
            String filePath = listOfFilesIterator.next();
            if (!registeredPath.contains(filePath)) {
                registeredPath.add(filePath);
            }
        }
    } else {
        /*
         * Copy the list of files
         */
        ArrayList<String> newList = new ArrayList<String>();
        Iterator<String> listOfFilesIterator = listOfFiles.iterator();
        while (listOfFilesIterator.hasNext()) {
            String filePath = listOfFilesIterator.next();
            if (!newList.contains(filePath)) {
                newList.add(filePath);
            }

            // create a new entry in the map
            _resourcesPerReviewer.put(emailAddress, newList);
        }
    }
}

From source file:com.hygenics.parser.SpecifiedDump.java

/**
 * Runs the Dump//from  w w  w.ja va2  s  .  c o  m
 */
public void run() {

    if (archive) {
        if (tables.keySet().size() > 0) {

            Archiver zip = new Archiver();
            String basefile = tables.keySet().iterator().next().split("\\|")[1];

            if (basefile.trim().length() > 0) {
                zip.setBasedirectory(basefile);
                zip.setZipDirectory(basefile + "archive.zip");
                zip.setAvoidanceString(".zip|archive");
                zip.setDelFiles(true);
                zip.run();
            }
        }
    }

    int dumped = 0;
    ForkJoinPool fjp = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
    boolean checkedTables = (this.tablesMustHave == null);
    for (String tf : tables.keySet()) {
        String[] split = tf.split("\\|");
        log.info("Dumping for " + split[0]);
        String schema = null;
        try {
            schema = split[0].split("\\.")[0];

            if (!checkedTables) {
                ArrayList<String> mustHaveTemp = (ArrayList<String>) this.tablesMustHave.clone();
                ArrayList<String> existingTables = this.template.getJsonData(
                        "SELECT table_name FROM information_schema.tables WHERE table_schema ILIKE '%" + schema
                                + "%'");
                for (String tdict : existingTables) {
                    String table = JsonObject.readFrom(tdict).get("table_name").asString();
                    if (mustHaveTemp.contains(table)) {
                        mustHaveTemp.remove(table);

                        // get count
                        if (this.template.getCount(schema + "." + table) == 0) {
                            try {
                                throw new MissingData(
                                        "Data Missing from Required Table: " + schema + "." + table);
                            } catch (MissingData e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }

                if (mustHaveTemp.size() > 0) {
                    log.error("Drop Schema " + schema + "  is missing the following tables:\n");
                    for (String table : mustHaveTemp) {
                        log.error(table + "\n");
                    }

                    try {
                        throw new TableMissingException();
                    } catch (TableMissingException e) {
                        e.printStackTrace();
                        System.exit(-1);
                    }
                }

            }

        } catch (IndexOutOfBoundsException e) {
            try {
                throw new SQLMalformedException("FATAL ERROR: Table name " + split[0] + " malformed");
            } catch (SQLMalformedException e2) {
                e2.printStackTrace();
                System.exit(-1);
            }
        }

        log.info("Checking  table: " + split[0] + "&& schema: " + schema);
        if (template.checkTable(split[0], schema)) {
            if (template.getCount(schema + "." + split[0].replace(schema + ".", "")) > 0) {
                Set<String> keys = tables.get(tf).keySet();
                String sql;
                String select = "SELECT ";
                String distinct = null;
                String attrs = null;
                String where = null;
                String group = null;
                String order = null;

                /**
                 * SET THE ATTRIBUTES WHICH CAN BE SPECIFIED WITH
                 * distinct-for concacting distinct part of query not0-for
                 * specifiying that the length must be greater than 0 in the
                 * WHERE clause group-for grouping the attribute not
                 * null-for specifying that the attr cannot be null
                 * orderby-for specifying our one order attr
                 */
                for (String k : keys) {
                    if (k.toLowerCase().contains("distinct")) {
                        distinct = (distinct == null)
                                ? "distinct on(" + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                : distinct + "," + tables.get(tf).get(k).replaceAll("\\sas.*", "");
                    }

                    if (k.toLowerCase().contains("group")) {
                        group = (group == null) ? "GROUP BY " + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                : group + "," + tables.get(tf).get(k).replaceAll("\\sas.*", "");
                    }

                    if (k.toLowerCase().contains("not0")) {
                        if (k.contains("not0OR")) {
                            where = (where == null)
                                    ? "WHERE length(" + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + ") >0 "
                                    : where + "OR length(" + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + ")";
                        } else {
                            where = (where == null)
                                    ? "WHERE length(" + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + ") >0 "
                                    : where + "AND length(" + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + ")";
                        }
                    }

                    if (k.toLowerCase().contains("notnull")) {
                        if (k.toLowerCase().contains("notnullor")) {
                            where = (where == null)
                                    ? "WHERE " + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + " IS NOT NULL"
                                    : where + " OR " + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + " IS NOT NULL";
                        } else {
                            where = (where == null)
                                    ? "WHERE " + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + " IS NOT NULL"
                                    : where + " AND " + tables.get(tf).get(k).replaceAll("\\sas.*", "")
                                            + " IS NOT NULL";
                        }
                    }

                    if (k.toLowerCase().contains("order")) {
                        if (k.toLowerCase().contains("orderdesc")) {
                            order = (order == null)
                                    ? "ORDER BY " + tables.get(tf).get(k).replaceAll("\\sas.*", "") + " ASC"
                                    : order;
                        } else {
                            order = (order == null)
                                    ? "ORDER BY " + tables.get(tf).get(k).replaceAll("\\sas.*", "") + " DESC"
                                    : order;
                        }
                    }

                    String field = tables.get(tf).get(k);
                    if (k.toLowerCase().contains("attr")) {
                        if (unicoderemove == true) {
                            field = "trim(replace(regexp_replace(" + field
                                    + ",'[^\\u0020-\\u007e,\\(\\);\\-\\[\\]]+',' '),'" + this.delimiter + "','"
                                    + this.replacedel + "')) as " + field;
                        } else {
                            field = "trim(replace(" + field + ",'" + this.delimiter + "','" + this.replacedel
                                    + "'))";
                        }

                        attrs = (attrs == null) ? field : attrs + "," + field;
                    }
                }

                select = (distinct == null) ? select : select.trim() + " " + distinct.trim() + ")";
                select += " " + attrs.trim();
                select += " FROM " + split[0].trim();
                select = (where == null) ? select : select.trim() + " " + where.trim();
                select = (group == null) ? select : select.trim() + " " + group.trim();
                select = (order == null) ? select : select.trim() + " " + order.trim();

                if (extracondition != null) {
                    select += (select.contains(" WHERE ") == true) ? " AND" + extracondition
                            : " WHERE " + extracondition;
                }

                select = select.trim();

                log.info("Dump Select Command: " + select);

                sql = "COPY  (" + select + ") TO STDOUT WITH DELIMITER '" + delimiter.trim()
                        + "' NULL as '' CSV HEADER";
                fjp.execute(new ToFile(sql, split[1].trim()));

                select = "SELECT ";
                distinct = null;
                attrs = null;
                where = null;
                group = null;
                order = null;
                dumped += 1;
            } else {
                try {
                    throw new NoDataException("No Data found in " + split[0]);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else {
            try {
                throw new SQLMalformedException("WARNING: Table " + split[0] + " is missing");
            } catch (SQLMalformedException e) {
                e.printStackTrace();
            }
        }
    }

    try {
        fjp.awaitTermination(60000, TimeUnit.MILLISECONDS);
        fjp.shutdown();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (dumped == 0) {
        log.error("No Date found in any tables");
        System.exit(-1);
    }

}

From source file:com.sec.ose.osi.report.standard.data.BillOfMaterialsRowGenerator.java

private ArrayList<BillOfMaterialsRow> getBillOfMaterialsRows(String projectName, ArrayList<BOMEnt> boms,
        ArrayList<IdentifiedFilesRow> IdentifiedFilesRowList, boolean isAllFileListUp,
        ArrayList<String> filePathListUpComponent) {

    ArrayList<BillOfMaterialsRow> BillOfMaterialsRowList = new ArrayList<BillOfMaterialsRow>();

    HashMap<String, ArrayList<IdentifiedFilesRow>> fileEntMap = toComponentFileEntHashMap(
            IdentifiedFilesRowList);// ww w .j  a  v a 2  s.  c o m

    ArrayList<String> keyListForDup = new ArrayList<String>();
    for (int i = 0; i < boms.size(); i++) {
        BOMEnt curBOM = boms.get(i);

        // 0. gen key (component name + license name)
        String componentName = curBOM.getComponentName().trim();
        log.debug(projectName + "'s BoM info " + " (" + i + "/" + boms.size() + ") : " + componentName);
        if (componentName.equals(projectName))
            continue;

        String componentLicense = curBOM.getLicense().trim();
        String key = componentName + "#" + componentLicense;
        if (keyListForDup.contains(key))
            continue;
        else
            keyListForDup.add(key);

        // 1. extract component info
        String componentVersion = curBOM.getComponentVersion();
        String componentComment = curBOM.getComment();

        String matchedFiles = "";
        Integer matchedFileCounts = 0;
        StringBuffer componentCommentBuf = new StringBuffer("");
        StringBuffer fileCommentBuf = new StringBuffer("");

        if ((componentComment != null) && (componentComment.length() != 0)
                && (componentComment.equals("null") == false)
                && (componentComment.equals("null\nnull") == false) && (componentComment
                        .equals("null<" + componentName + " - " + componentVersion + ">\nnull") == false)) {
            componentCommentBuf.append("[Compoment Comment]\n" + componentComment + "\n\n");
        }

        log.debug("- Component Comment: " + componentCommentBuf.toString());

        BillOfMaterialsRow sheetRow = null;

        //    2. extract file info - component
        log.debug("- get FileInfo start");
        if (fileEntMap.containsKey(key) == true) {
            ArrayList<IdentifiedFilesRow> fileEntList = fileEntMap.get(key);
            log.debug("- File # : " + fileEntList.size());
            ArrayList<String> categorySet = getCategorySet(fileEntList);

            if (categorySet == null)
                continue;

            // 3. Top folder
            for (String topFolder : categorySet) {

                ArrayList<IdentifiedFilesRow> fileEntListForRow = getFileEntListForRow(topFolder, fileEntList);
                if (fileEntListForRow != null) {
                    // matchedFileCount
                    matchedFileCounts = fileEntListForRow.size();

                    // comments
                    fileCommentBuf.setLength(0);
                    for (IdentifiedFilesRow curFileEnt : fileEntListForRow) {
                        curFileEnt.setLicense(componentLicense);
                        String fileComment = curFileEnt.getComment();
                        if ((fileComment != null) && (fileComment.length() != 0)) {
                            fileCommentBuf
                                    .append("## " + curFileEnt.getFullPath() + "\n" + fileComment + "\n\n");

                        }
                    }

                    // fileList
                    if (isAllFileListUp == true || (filePathListUpComponent != null
                            && filePathListUpComponent.contains(componentName))) {
                        matchedFiles = getFullPaths(fileEntListForRow);
                    } else {
                        matchedFiles = getFileCountForFolders(fileEntListForRow);
                    }
                }

                sheetRow = new BillOfMaterialsRow(topFolder, matchedFiles, matchedFileCounts, componentName,
                        componentLicense, componentCommentBuf.toString() + fileCommentBuf.toString());

                BillOfMaterialsRowList.add(sheetRow);
            }
            log.debug("- getFileInfo end");
        } else {
            log.debug("- getFileInfo ent - no file info");

            sheetRow = new BillOfMaterialsRow("", matchedFiles, matchedFileCounts, componentName,
                    componentLicense, componentCommentBuf.toString());

            BillOfMaterialsRowList.add(sheetRow);
        }
    } // end of for

    log.debug("IdentifiedRowSize: " + BillOfMaterialsRowList.size());
    if (BillOfMaterialsRowList.size() == 0) {
        BillOfMaterialsRow xSheetRow = new BillOfMaterialsRow("",
                "No component is identified for this project.", 0, "", "", "");

        BillOfMaterialsRowList.add(xSheetRow);
    }

    return BillOfMaterialsRowList;
}

From source file:com.surevine.alfresco.repo.action.AssignRandomValidSecurityGroupsAction.java

@Override
protected void executeImpl(final Action action, final NodeRef nodeRef) {
    try {//from   w ww. j  a va  2 s.c  om

        //First things first, set a modifier for this item.  We try to round-robin all the users
        //This is intended to be run against an item without any security groups assigned.  If run against
        //an item that already has security groups assigned, it will not consider that the selected user may
        //not be able to access the item, and will throw an AccessDenied exception accordingly

        Iterator<NodeRef> peopleNodes = _personService.getAllPeople().iterator();
        int skipCount = 0;
        while (peopleNodes.hasNext()) {
            NodeRef personNode = peopleNodes.next();
            if (!(skipCount++ < _userIndexOffset)) {
                String userName = _nodeService.getProperty(personNode, ContentModel.PROP_USERNAME).toString();
                if (LOG.isInfoEnabled()) {
                    LOG.info("Setting modifier of " + nodeRef + " to " + userName);
                }
                AuthenticationUtil.runAs(new ModifyItemWork(nodeRef), userName);
                if (!peopleNodes.hasNext()) {
                    _userIndexOffset = 0;
                } else {
                    _userIndexOffset++;
                }
                break;
            }
        }
        ;

        // First, get the list of everyone to have modified this item - we
        // need to make sure all
        // these users could have seen the security marking we will
        // generate, to ensure
        // consistency (actually, we could be more specific than this if we
        // needed to as what we
        // actually need to ensure is that a user who can see Version X can
        // see all versions <X)

        Object o = _nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIER);
        if (o == null) {
            o = _nodeService.getProperty(nodeRef, ContentModel.PROP_CREATOR);
        }
        final String owner = o.toString();

        Collection<String> modifiers = new HashSet<String>(1);
        try {
            Iterator<Version> allVersions = _versionService.getVersionHistory(nodeRef).getAllVersions()
                    .iterator();
            while (allVersions.hasNext()) {
                Version v = allVersions.next();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Adding " + v.getFrozenModifier() + " to the list of modifiers for " + nodeRef);
                }
                modifiers.add(v.getFrozenModifier());
            }
        } catch (NullPointerException e) {
            // This means that the item isn't versionable, in which case use
            // the current modifier
            modifiers.add(owner);
        }
        Iterator<String> modifierUserNames;

        // For each security Group, work out the groups to assign
        for (int i = 0; i < _constraintNames.length; i++) {
            modifierUserNames = modifiers.iterator();

            Set<String> potentialGroups = null;

            while (modifierUserNames.hasNext()) {
                String userName = modifierUserNames.next();
                if (potentialGroups == null) {
                    potentialGroups = new HashSet<String>(AuthenticationUtil
                            .runAs(new GetGivenUserSecurityMarkingsWork(_constraintNames[i]), userName));
                } else {
                    potentialGroups.retainAll(AuthenticationUtil
                            .runAs(new GetGivenUserSecurityMarkingsWork(_constraintNames[i]), userName));
                }
            }

            Iterator<String> potentialGroupsIt = potentialGroups.iterator();
            ArrayList<String> groupsToAdd = new ArrayList<String>(2);
            while (potentialGroupsIt.hasNext()) {
                String potentialGroup = potentialGroupsIt.next();
                if (LOG.isDebugEnabled()) {
                    LOG.debug(potentialGroup + " is a potential group for " + nodeRef);
                }
                if (_randomiser.nextFloat() < _chanceToApplyGivenSecurityGroup) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("Adding " + potentialGroup + " to " + nodeRef);
                    }
                    groupsToAdd.add(potentialGroup);
                }
            }
            if (groupsToAdd.contains("ATOMAL2") && !groupsToAdd.contains("ATOMAL1")) {
                groupsToAdd.add("ATOMAL1");
            }
            QName propertyQName = getQNameFromConstraintName(_constraintNames[i]);

            if (groupsToAdd.size() > 0) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Making modification as " + owner);
                }
                //Parts of the renditioned aspects, which require us to have privs to previews etc, require this to be run as the last modifier of the document
                AuthenticationUtil.runAs(new ModifySecurityMarkingWork(nodeRef, propertyQName, groupsToAdd),
                        owner);
            }

        }

        //OK, now we've set the security groups - we are now going to munge the modifier of the item
        /*
         * 
         * This bit seems to:
         *    A) Break whichever site you run it against
         *    B) Not consider whether the selected user could actually access the node they are trying to update
         * 
        */

    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}