Source:
<code>public void addContainer(AgentPrincipals agent, PID parentPid, Resource containerType) { ContentContainerObject child = null; FedoraTransaction tx = txManager.startTransaction(); try { if (Cdr.AdminUnit.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create admin units", parentPid, agent.getPrincipals(), Permission.createAdminUnit); child = repoObjFactory.createAdminUnit(null); } else if (Cdr.Collection.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create collections", parentPid, agent.getPrincipals(), Permission.createCollection); child = repoObjFactory.createCollectionObject(null); } else if (Cdr.Folder.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create folders", parentPid, agent.getPrincipals(), Permission.ingest); child = repoObjFactory.createFolderObject(null); } else if (Cdr.Work.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create works", parentPid, agent.getPrincipals(), Permission.ingest); child = repoObjFactory.createWorkObject(null); } ContentContainerObject parent = (ContentContainerObject) repoObjLoader.getRepositoryObject(parentPid); parent.addMember(child); child.getPremisLog() .buildEvent(Premis.Creation) .addImplementorAgent(agent.getUsernameUri()) .addEventDetail("Container added at destination " + parentPid) .write(); } catch (Exception e) { tx.cancel(e); } finally { tx.close(); } <START> Collection<PID> destinationPids = new ArrayList<>(); <END> destinationPids.add(parentPid); Collection<PID> addedContainers = new ArrayList<>(); addedContainers.add(child.getPid()); operationsMessageSender.sendAddOperation(agent.getUsername(), destinationPids, addedContainers, null, null); }</code><technical_language>For throwaway, immutable lists, prefer more succinct Arrays.asList(parentPid) syntax</technical_language>

Target:
public void addContainer(AgentPrincipals agent, PID parentPid, Resource containerType) { ContentContainerObject child = null; FedoraTransaction tx = txManager.startTransaction(); try { if (Cdr.AdminUnit.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create admin units", parentPid, agent.getPrincipals(), Permission.createAdminUnit); child = repoObjFactory.createAdminUnit(null); } else if (Cdr.Collection.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create collections", parentPid, agent.getPrincipals(), Permission.createCollection); child = repoObjFactory.createCollectionObject(null); } else if (Cdr.Folder.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create folders", parentPid, agent.getPrincipals(), Permission.ingest); child = repoObjFactory.createFolderObject(null); } else if (Cdr.Work.equals(containerType)) { aclService.assertHasAccess( "User does not have permissions to create works", parentPid, agent.getPrincipals(), Permission.ingest); child = repoObjFactory.createWorkObject(null); } ContentContainerObject parent = (ContentContainerObject) repoObjLoader.getRepositoryObject(parentPid); parent.addMember(child); child.getPremisLog() .buildEvent(Premis.Creation) .addImplementorAgent(agent.getUsernameUri()) .addEventDetail("Container added at destination " + parentPid) .write(); } catch (Exception e) { tx.cancel(e); } finally { tx.close(); } operationsMessageSender.sendAddOperation(agent.getUsername(), Arrays.asList(parentPid), Arrays.asList(child.getPid()), null, null); }