List of usage examples for java.util Collections EMPTY_SET
Set EMPTY_SET
To view the source code for java.util Collections EMPTY_SET.
Click Source Link
From source file:web.MockServletContext.java
@Override public Enumeration getServletNames() { return Collections.enumeration(Collections.EMPTY_SET); }
From source file:com.phoenixst.plexus.AbstractGraph.java
/** * This implementation delegates to {@link #nodes() nodes()}, * except for when the specified <code>nodePredicate</code> is * either {@link FalsePredicate#INSTANCE} or an instance of * {@link EqualPredicate}. These two cases are optimized. *///from w w w .ja va 2 s .c om public Collection nodes(Predicate nodePredicate) { if (nodePredicate == null || nodePredicate == TruePredicate.INSTANCE) { return nodes(); } else if (nodePredicate == FalsePredicate.INSTANCE) { return Collections.EMPTY_SET; } else if (nodePredicate instanceof EqualPredicate) { Object testNode = ((EqualPredicate) nodePredicate).getTestObject(); if (!containsNode(testNode)) { return Collections.EMPTY_SET; } return new SingletonNodeCollection(this, testNode); } else { return new FilteredCollection(nodes(), nodePredicate); } }
From source file:org.syncope.core.persistence.beans.ExternalResource.java
public Set<ConnConfProperty> getConfiguration() { Set<ConnConfProperty> result = Collections.EMPTY_SET; Set<ConnConfProperty> deserializedSet; if (StringUtils.isNotBlank(xmlConfiguration)) { deserializedSet = XMLSerializer.<HashSet<ConnConfProperty>>deserialize(xmlConfiguration); if (deserializedSet != null) { result = deserializedSet;// w w w . j av a2 s . c om } } return result; }
From source file:com.espertech.esper.regression.client.TestDeployOrder.java
private Module getModule(String name, String... uses) { Set<String> usesSet = new HashSet<String>(); usesSet.addAll(Arrays.asList(uses)); return new Module(name, null, usesSet, Collections.EMPTY_SET, Collections.EMPTY_LIST, null); }
From source file:org.talend.updates.runtime.model.P2ExtraFeature.java
public Set<IInstallableUnit> getInstalledIUs(String p2IuId2, IProgressMonitor progress) throws ProvisionException { SubMonitor subMonitor = SubMonitor.convert(progress, 2); subMonitor.setTaskName(Messages.getString("ExtraFeature.checking.is.installed", getName())); //$NON-NLS-1$ Bundle bundle = FrameworkUtil.getBundle(org.eclipse.equinox.p2.query.QueryUtil.class);// not using this context // caus junit fails BundleContext context = bundle.getBundleContext(); ServiceReference sr = context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME); if (sr == null) { throw new ProvisionException(Messages.getString("ExtraFeature.p2.agent.service.not.found"));//$NON-NLS-1$ }//w w w.jav a 2 s. c om IProvisioningAgentProvider agentProvider = (IProvisioningAgentProvider) context.getService(sr); if (agentProvider == null) { throw new ProvisionException(Messages.getString("ExtraFeature.p2.agent.provider.not.found")); //$NON-NLS-1$ } IProvisioningAgent agent = null; try { IQuery<IInstallableUnit> iuQuery = QueryUtil.createIUQuery(p2IuId2); boolean interrupted = false; IProfile profile = null; // there seems to be a bug because if the agent is created too quickly then the profile is empty. // so we loop until we get a proper profile final String p2ProfileId = getP2ProfileId(); do { try { Thread.sleep(50); } catch (InterruptedException e) { interrupted = true; } if (agent != null) { agent.stop(); } agent = agentProvider.createAgent(getP2AgentUri()); IProfileRegistry profRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); profile = profRegistry.getProfile(p2ProfileId); } while (profile != null && profile.getTimestamp() == 0 && !interrupted && !subMonitor.isCanceled()); if (profile == null || subMonitor.isCanceled()) { throw new ProvisionException("Could not find the p2 profile named " + p2ProfileId); //$NON-NLS-1$ } subMonitor.worked(1); IQueryResult<IInstallableUnit> iuQueryResult = profile.available(iuQuery, subMonitor.newChild(1)); if (subMonitor.isCanceled()) { return Collections.EMPTY_SET; } return iuQueryResult.toSet(); } finally { if (agent != null) { agent.stop(); } } }
From source file:org.apache.accumulo.test.AuditMessageTest.java
@Test(timeout = 60 * 1000) @SuppressWarnings("unchecked") public void testTableOperationsAudits() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException, InterruptedException { conn.securityOperations().createLocalUser(AUDIT_USER_1, new PasswordToken(PASSWORD)); conn.securityOperations().grantSystemPermission(AUDIT_USER_1, SystemPermission.SYSTEM); conn.securityOperations().grantSystemPermission(AUDIT_USER_1, SystemPermission.CREATE_TABLE); // Connect as Audit User and do a bunch of stuff. // Testing activity begins here auditConnector = accumulo.getConnector(AUDIT_USER_1, PASSWORD); auditConnector.tableOperations().create(OLD_TEST_TABLE_NAME); auditConnector.tableOperations().rename(OLD_TEST_TABLE_NAME, NEW_TEST_TABLE_NAME); auditConnector.tableOperations().clone(NEW_TEST_TABLE_NAME, OLD_TEST_TABLE_NAME, true, Collections.EMPTY_MAP, Collections.EMPTY_SET); auditConnector.tableOperations().delete(OLD_TEST_TABLE_NAME); auditConnector.tableOperations().offline(NEW_TEST_TABLE_NAME); auditConnector.tableOperations().delete(NEW_TEST_TABLE_NAME); // Testing activity ends here ArrayList<String> auditMessages = getAuditMessages("testTableOperationsAudits"); assertEquals(1,/*from ww w . jav a 2 s. com*/ findAuditMessage(auditMessages, "action: createTable; targetTable: " + OLD_TEST_TABLE_NAME).size()); assertEquals(1, findAuditMessage(auditMessages, "action: renameTable; targetTable: " + OLD_TEST_TABLE_NAME).size()); assertEquals(1, findAuditMessage(auditMessages, "action: cloneTable; targetTable: " + NEW_TEST_TABLE_NAME).size()); assertEquals(1, findAuditMessage(auditMessages, "action: deleteTable; targetTable: " + OLD_TEST_TABLE_NAME).size()); assertEquals(1, findAuditMessage(auditMessages, "action: offlineTable; targetTable: " + NEW_TEST_TABLE_NAME) .size()); assertEquals(1, findAuditMessage(auditMessages, "action: deleteTable; targetTable: " + NEW_TEST_TABLE_NAME).size()); }
From source file:org.ireland.jnetty.dispatch.filter.FilterConfigImpl.java
public Collection<String> getUrlPatternMappings() { Set<String> patterns = _filterManager.getUrlPatternMappings(_filterName); if (patterns == null) return Collections.EMPTY_SET; return Collections.unmodifiableSet(patterns); }
From source file:pl.asie.modalyze.mcp.MCPDataManager.java
private void loadMappings(String version) throws IOException { File mappingClient = new File(MCP_DIR, version + "-client.map"); File mappingServer = new File(MCP_DIR, version + "-server.map"); if (mappingClient.exists() && mappingServer.exists()) { MAPPINGS.put(version + "-client", new HashSet<>(FileUtils.readLines(mappingClient, "UTF-8"))); MAPPINGS.put(version + "-server", new HashSet<>(FileUtils.readLines(mappingServer, "UTF-8"))); } else {//from w ww . j a v a 2 s .c o m File mcpFile = new File(MCP_DIR, MCP_VERSION_MAP.get(version).mcpFile); if (mcpFile.exists()) { ZipFile zipFile = new ZipFile(mcpFile); ZipEntry joinedSrgEntry = zipFile.getEntry("conf/joined.srg"); if (joinedSrgEntry != null) { loadJoinedSrgMapping(version, zipFile, joinedSrgEntry); } else { ZipEntry clientSrgEntry = zipFile.getEntry("conf/client.srg"); ZipEntry serverSrgEntry = zipFile.getEntry("conf/server.srg"); if (clientSrgEntry != null && serverSrgEntry != null) { loadSrgMapping(version + "-client", zipFile, clientSrgEntry); loadSrgMapping(version + "-server", zipFile, serverSrgEntry); } else { ZipEntry csvFields = zipFile.getEntry("conf/fields.csv"); ZipEntry csvMethods = zipFile.getEntry("conf/methods.csv"); if (csvFields != null && csvMethods != null) { loadCsvMapping(version, zipFile, csvFields, csvMethods); } else { System.err.println("MCP file for Minecraft " + version + " (" + mcpFile.toString() + ") stored in an unknown format!"); MAPPINGS.put(version + "-client", Collections.EMPTY_SET); MAPPINGS.put(version + "-server", Collections.EMPTY_SET); } } } if (MAPPINGS.get(version + "-client") != null) { FileUtils.writeLines(mappingClient, MAPPINGS.get(version + "-client")); } if (MAPPINGS.get(version + "-server") != null) { FileUtils.writeLines(mappingServer, MAPPINGS.get(version + "-server")); } } else { System.err .println("MCP file for Minecraft " + version + " (" + mcpFile.toString() + ") not found!"); MAPPINGS.put(version + "-client", Collections.EMPTY_SET); MAPPINGS.put(version + "-server", Collections.EMPTY_SET); } } }
From source file:org.kie.workbench.common.screens.projecteditor.backend.server.PomEditorServiceImplTest.java
@Test public void testSaveNonClashingGAVFilteredChangeToGAV() { final Set<ModuleRepositories.ModuleRepository> moduleRepositoriesMetadata = new HashSet<ModuleRepositories.ModuleRepository>() { {/*from w w w . j av a 2s. c om*/ add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL))); } }; final ModuleRepositories moduleRepositories = new ModuleRepositories(moduleRepositoriesMetadata); when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories); final ArgumentCaptor<MavenRepositoryMetadata> resolvedRepositoriesCaptor = ArgumentCaptor .forClass(MavenRepositoryMetadata.class); when(repositoryResolver.getRepositoriesResolvingArtifact(eq(pomXml), resolvedRepositoriesCaptor.capture())) .thenReturn(Collections.EMPTY_SET); when(pom.getGav()).thenReturn(new GAV("groupId", "artifactId", "0.0.2")); service.save(pomPath, pomXml, metaData, comment, DeploymentMode.VALIDATED); verify(moduleService, times(1)).resolveModule(pomPath); verify(moduleRepositoriesService, times(1)).load(moduleRepositoriesPath); verify(repositoryResolver, times(1)).getRepositoriesResolvingArtifact(eq(pomXml), any(MavenRepositoryMetadata.class)); final List<MavenRepositoryMetadata> resolvedRepositories = resolvedRepositoriesCaptor.getAllValues(); assertNotNull(resolvedRepositories); assertEquals(1, resolvedRepositories.size()); final MavenRepositoryMetadata repositoryMetadata = resolvedRepositories.get(0); assertEquals("local-id", repositoryMetadata.getId()); assertEquals("local-url", repositoryMetadata.getUrl()); assertEquals(MavenRepositorySource.LOCAL, repositoryMetadata.getSource()); verify(ioService, times(1)).startBatch(any(FileSystem.class)); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), eq(pomXml), eq(attributes), any(CommentedOption.class)); verify(ioService, times(1)).endBatch(); }
From source file:org.webcurator.core.targets.TargetManagerImpl.java
public void save(Target aTarget, List<GroupMemberDTO> parents) { boolean newSchedulesAddedByNonOwner = false; boolean wasHarvestNowSelected = aTarget.isHarvestNow(); // If dirty and the current state is approved, we need to change the // state back to nominated. if (aTarget.isDirty() && aTarget.getOriginalState() == Target.STATE_APPROVED && !authMgr.hasPrivilege(aTarget, Privilege.APPROVE_TARGET)) { log.debug("Target state changed to nominated due to changes"); aTarget.changeState(Target.STATE_NOMINATED); }/* w w w . j a v a 2s . c om*/ // Track a change into the approved state. if ((aTarget.getOriginalState() == Target.STATE_PENDING || aTarget.getOriginalState() == Target.STATE_REINSTATED || aTarget.getOriginalState() == Target.STATE_NOMINATED) && aTarget.getState() == Target.STATE_APPROVED) { aTarget.setSelectionDate(new Date()); } int numActiveTIsPrevious = targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()); // Deal with removed schedules for (Schedule schedule : aTarget.getRemovedSchedules()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } // Deal with new schedules List<Schedule> newSchedules = new LinkedList<Schedule>(); for (Schedule schedule : aTarget.getSchedules()) { if (schedule.isNew()) { // Record the schedule for auditing after save. newSchedules.add(schedule); // Flag that this schedule is going to be processed (only used when Target saved in Annotations tab) schedule.setSavedInThisSession(true); // Send a notification if the schedule owner is not the same as // the owner of the target. if (!schedule.getOwningUser().equals(aTarget.getOwningUser())) { newSchedulesAddedByNonOwner = true; } } else { // If this schedule is not new and has already been saved via adding an annotation then it is in a buggy state. if (schedule.isSavedInThisSession()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } } } if (aTarget.getState() == Target.STATE_COMPLETED && newSchedules.size() != 0) { aTarget.changeState(Target.STATE_APPROVED); } // Load the original target so we can do auditing afterwards. AbstractTargetDTO originalTarget = null; if (!aTarget.isNew()) { originalTarget = targetDao.loadAbstractTargetDTO(aTarget.getOid()); // targetDao.evict(originalTarget); } /* ---------------------------------------------------------------- */ /* Deal with the scheduling state changes */ /* ---------------------------------------------------------------- */ // Get the original parents Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET; if (!aTarget.isNew()) { origParents = targetDao.getAncestorDTOs(aTarget.getOid()); } // Save the target. log.debug("Saving Target"); int originalState = aTarget.getOriginalState(); targetDao.save(aTarget, parents); /* ---------------------------------------------------------------- */ /* Save the annotations */ /* ---------------------------------------------------------------- */ // Update the OIDs for the target. for (Annotation anno : aTarget.getAnnotations()) { anno.setObjectOid(aTarget.getOid()); } // Save the annotations annotationDAO.saveAnnotations(aTarget.getAnnotations()); annotationDAO.deleteAnnotations(aTarget.getDeletedAnnotations()); aTarget = targetDao.reloadTarget(aTarget.getOid()); log.debug("End of Save Target"); /* ---------------------------------------------------------------- */ /* Perform post-save auditing */ /* ---------------------------------------------------------------- */ if (originalState != aTarget.getState()) { String newState = messageSource.getMessage("target.state_" + aTarget.getState(), null, Locale.getDefault()); auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_STATE_CHANGE, "Target " + aTarget.getName() + " has changed into state '" + newState + "'"); } for (Schedule schedule : newSchedules) { auditor.audit(Schedule.class.getName(), schedule.getOid(), Auditor.ACTION_NEW_SCHEDULE, "New Schedule Created on Target " + aTarget.getName()); } if (originalTarget != null) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_UPDATE_TARGET, "Target " + aTarget.getName() + " has been updated"); if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_OWNER, "Target " + aTarget.getName() + " has been given to " + aTarget.getOwningUser().getNiceName()); } if (originalTarget.getProfileOid() != null && aTarget.getProfile() != null && !originalTarget.getProfileOid().equals(aTarget.getProfile().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_PROFILE, "Target " + aTarget.getName() + " is now using profile " + aTarget.getProfile().getName()); } } /* ---------------------------------------------------------------- */ /* Check state changes and task/notification creation */ /* ---------------------------------------------------------------- */ if (originalState != aTarget.getState()) { if (aTarget.getState() == Target.STATE_NOMINATED) { intrayManager.generateTask(Privilege.APPROVE_TARGET, MessageType.TASK_APPROVE_TARGET, aTarget); } if (aTarget.getState() == Target.STATE_APPROVED || aTarget.getState() == Target.STATE_REJECTED) { intrayManager.deleteTask(aTarget.getOid(), aTarget.getResourceType(), MessageType.TASK_APPROVE_TARGET); } if (aTarget.getState() == Target.STATE_APPROVED && aTarget.isRunOnApproval()) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); ti.setScheduledTime(new Date()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } } //Deal with harvest now if (aTarget.getState() == Target.STATE_APPROVED && wasHarvestNowSelected) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); ti.setScheduledTime(cal.getTime()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } if (originalTarget != null) { if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { // carry out notification of the target delegation intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.DELEGATE_TARGET, aTarget); // If ownership was transferred by someone other than the original owner, let the original // owner know. Long remoteUserObjectOid = AuthUtil.getRemoteUserObject().getOid(); if (originalTarget.getOwnerOid() != remoteUserObjectOid) { intrayManager.generateNotification(originalTarget.getOwnerOid(), MessageType.CATEGORY_MISC, MessageType.TRANSFER_TARGET, aTarget); } } } // Stay in a schedulable state. Process all schedules if (aTarget.isSchedulable()) { log.debug("Staying in Schedulable State - scheduling new schedules"); for (Schedule schedule : aTarget.getSchedules()) { // targetInstances.addAll(createTargetInstances(aTarget, schedule, false)); processSchedule(schedule); } } else { // Change to an unschedulable state - all scheduled target instances // must be removed. unschedule(aTarget); } // if this target record is in original state 'approved' and the state // is not changing and the target has no active TIs remaining (scheduled, // queued, running, paused, stopping) and updates to the schedules have // caused the removal of all scheduled TIs for this target then set the // status of the target to 'complete'. if (numActiveTIsPrevious > 0 && targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()) == 0 && aTarget.getOriginalState() == Target.STATE_APPROVED && aTarget.getState() == Target.STATE_APPROVED) { aTarget.changeState(Target.STATE_COMPLETED); } // Send notification if someone other than the owner has added // a schedule to this target. if (newSchedulesAddedByNonOwner) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.TARGET_SCHEDULE_ADDED, aTarget); } // We may need update the state of some of our parents. updateTargetGroupStatus(aTarget); // We also need to handle the updating of any groups that we used to // belong to. if (parents != null) { for (GroupMemberDTO dto : parents) { if (dto.getSaveState() == SAVE_STATE.DELETED) { updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid())); } } } // Propagate the group events. if (parents != null) { for (GroupMemberDTO dto : parents) { switch (dto.getSaveState()) { case NEW: TargetGroup grp = targetDao.loadGroup(dto.getParentOid()); GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, grp, aTarget); gep.runEventChain(); break; case DELETED: TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid()); MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, aTarget); mrep.runEventChain(); break; } } } // Send emails if necessary if (sendGroupUpdateNotifications && AuthUtil.getRemoteUserObject() != null) { String userName = AuthUtil.getRemoteUserObject().getNiceName(); // Get the new set of parents. Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(aTarget.getOid()); // Determine the added parents and removed parents. Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents); addedParents.removeAll(origParents); Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents); removedParents.removeAll(newParents); HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents); generateChangeMessageNotifications(aTarget, userName, changes); } }