org.apache.cxf.common.util.CollectionUtils Java Examples
The following examples show how to use
org.apache.cxf.common.util.CollectionUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractCodegenMojo.java From cxf with Apache License 2.0 | 6 votes |
private Artifact resolveArbitraryWsdl(Artifact artifact) { ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifact); request.setResolveRoot(true).setResolveTransitively(false); request.setServers(mavenSession.getRequest().getServers()); request.setMirrors(mavenSession.getRequest().getMirrors()); request.setProxies(mavenSession.getRequest().getProxies()); request.setLocalRepository(mavenSession.getLocalRepository()); request.setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories()); ArtifactResolutionResult result = repositorySystem.resolve(request); Artifact resolvedArtifact = result.getOriginatingArtifact(); if (resolvedArtifact == null && !CollectionUtils.isEmpty(result.getArtifacts())) { resolvedArtifact = result.getArtifacts().iterator().next(); } return resolvedArtifact; }
Example #2
Source File: HTTPUndertowTransportActivator.java From cxf with Apache License 2.0 | 6 votes |
public void start(BundleContext ctx) throws Exception { this.context = ctx; reg = context.registerService(ManagedServiceFactory.class.getName(), this, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, FACTORY_PID)); mbeanServerTracker = new ServiceTracker<>(ctx, MBeanServer.class, null); try { BlueprintNameSpaceHandlerFactory nsHandlerFactory = new BlueprintNameSpaceHandlerFactory() { @Override public Object createNamespaceHandler() { return new HTTPUndertowTransportNamespaceHandler(); } }; NamespaceHandlerRegisterer.register(context, nsHandlerFactory, "http://cxf.apache.org/transports/http-undertow/configuration"); } catch (NoClassDefFoundError e) { // Blueprint not available, ignore } }
Example #3
Source File: HTTPJettyTransportActivator.java From cxf with Apache License 2.0 | 6 votes |
public void start(BundleContext ctx) throws Exception { this.context = ctx; reg = context.registerService(ManagedServiceFactory.class, this, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, FACTORY_PID)); mbeanServerTracker = new ServiceTracker<>(ctx, MBeanServer.class, null); try { BlueprintNameSpaceHandlerFactory nsHandlerFactory = new BlueprintNameSpaceHandlerFactory() { @Override public Object createNamespaceHandler() { return new HTTPJettyTransportNamespaceHandler(); } }; NamespaceHandlerRegisterer.register(context, nsHandlerFactory, "http://cxf.apache.org/transports/http-jetty/configuration"); } catch (NoClassDefFoundError e) { // Blueprint not available, ignore } }
Example #4
Source File: RequiredDeserializer.java From peer-os with Apache License 2.0 | 6 votes |
private void checkCollection( Field field, T object ) throws IllegalAccessException { if ( CollectionUtils.isEmpty( ( Collection ) field.get( object ) ) ) { throw new JsonParseException( "Missing Json field: " + field.getName() ); } if ( field.get( object ) instanceof Collection<?> ) { Gson gson = RequiredDeserializer.createValidatingGson(); gson.fromJson( new Gson().toJson( field.get( object ) ), new TypeToken<Collection<?>>() { }.getType() ); } }
Example #5
Source File: WSIBPValidator.java From cxf with Apache License 2.0 | 5 votes |
public boolean checkR2205() { Collection<Binding> bindings = CastUtils.cast(def.getBindings().values()); for (Binding binding : bindings) { if (!SOAPBindingUtil.isSOAPBinding(binding)) { System.err.println("WSIBP Validator found <" + binding.getQName() + "> is NOT a SOAP binding"); continue; } if (binding.getPortType() == null) { //will error later continue; } for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext();) { Operation operation = (Operation)ite2.next(); Collection<Fault> faults = CastUtils.cast(operation.getFaults().values()); if (CollectionUtils.isEmpty(faults)) { continue; } for (Fault fault : faults) { Message message = fault.getMessage(); Collection<Part> parts = CastUtils.cast(message.getParts().values()); for (Part part : parts) { if (part.getElementName() == null) { addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message " + message.getQName() + ", part " + part.getName() + " must specify a 'element' attribute"); return false; } } } } } return true; }
Example #6
Source File: CXFActivator.java From cxf with Apache License 2.0 | 5 votes |
private <T> ServiceRegistration<T> registerManagedServiceFactory(BundleContext context, Class<T> serviceClass, T service, String servicePid) { return context.registerService(serviceClass, service, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, servicePid)); }
Example #7
Source File: OSGIBusListener.java From cxf with Apache License 2.0 | 5 votes |
private void registerBusAsService() { BundleContext context = bus.getExtension(BundleContext.class); if (context != null) { Map<String, Object> props = new HashMap<>(); props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, context.getBundle().getSymbolicName()); props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(context.getBundle())); props.put(CONTEXT_NAME_PROPERTY, bus.getId()); service = context.registerService(Bus.class.getName(), bus, CollectionUtils.toDictionary(props)); } }
Example #8
Source File: AbstractCodeGeneratorMojo.java From cxf with Apache License 2.0 | 5 votes |
private Artifact resolveRemoteWadlArtifact(Artifact artifact) throws MojoExecutionException { /** * First try to find the artifact in the reactor projects of the maven session. * So an artifact that is not yet built can be resolved */ List<MavenProject> rProjects = mavenSession.getProjects(); for (MavenProject rProject : rProjects) { if (artifact.getGroupId().equals(rProject.getGroupId()) && artifact.getArtifactId().equals(rProject.getArtifactId()) && artifact.getVersion().equals(rProject.getVersion())) { Set<Artifact> artifacts = rProject.getArtifacts(); for (Artifact pArtifact : artifacts) { if ("wadl".equals(pArtifact.getType())) { return pArtifact; } } } } ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifact); request.setResolveRoot(true).setResolveTransitively(false); request.setServers(mavenSession.getRequest().getServers()); request.setMirrors(mavenSession.getRequest().getMirrors()); request.setProxies(mavenSession.getRequest().getProxies()); request.setLocalRepository(mavenSession.getLocalRepository()); request.setRemoteRepositories(mavenSession.getRequest().getRemoteRepositories()); ArtifactResolutionResult result = repositorySystem.resolve(request); Artifact resolvedArtifact = result.getOriginatingArtifact(); if (resolvedArtifact == null && !CollectionUtils.isEmpty(result.getArtifacts())) { resolvedArtifact = result.getArtifacts().iterator().next(); } return resolvedArtifact; }
Example #9
Source File: HttpServiceTrackerCust.java From cxf with Apache License 2.0 | 5 votes |
@Override public HttpService addingService(ServiceReference<HttpService> reference) { HttpService httpService = context.getService(reference); Servlet servlet = new CXFNonSpringServlet(destinationRegistry, false); servletExporter = new ServletExporter(servlet, httpService); servletPublisherReg = context.registerService(ManagedService.class, servletExporter, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, CXF_CONFIG_PID)); return httpService; }
Example #10
Source File: UriBuilderImpl.java From cxf with Apache License 2.0 | 5 votes |
private void setUriParts(URI uri) { if (uri == null) { throw new IllegalArgumentException("uri is null"); } String theScheme = uri.getScheme(); if (theScheme != null) { scheme = theScheme; } String rawPath = uri.getRawPath(); if (!uri.isOpaque() && schemeSpecificPart == null && (theScheme != null || rawPath != null)) { port = uri.getPort(); host = uri.getHost(); if (rawPath != null) { setPathAndMatrix(rawPath); } String rawQuery = uri.getRawQuery(); if (rawQuery != null) { query = JAXRSUtils.getStructuredParams(rawQuery, "&", false, true); } userInfo = uri.getUserInfo(); schemeSpecificPart = null; } else { schemeSpecificPart = uri.getSchemeSpecificPart(); } if (scheme != null && host == null && port == -1 && userInfo == null && CollectionUtils.isEmpty(query) && uri.getSchemeSpecificPart() != null && !schemeSpecificPartMatchesUriPath(uri)) { schemeSpecificPart = uri.getSchemeSpecificPart(); } String theFragment = uri.getFragment(); if (theFragment != null) { fragment = theFragment; } }
Example #11
Source File: OSGiJaxwsEndpointManager.java From cxf with Apache License 2.0 | 5 votes |
private void createCXFBus() { BlueprintBus bp = new BlueprintBus(); bp.setBundleContext(bundleContext); bp.setBlueprintContainer(container); bp.setId("WS-Notification"); bp.initialize(); if (null != bundleContext) { Map<String, Object> props = new HashMap<>(); props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, bundleContext.getBundle().getSymbolicName()); props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(bundleContext.getBundle())); props.put(CONTEXT_NAME_PROPERTY, bp.getId()); bundleContext.registerService(Bus.class.getName(), bp, CollectionUtils.toDictionary(props)); } cxfBus = bp; }
Example #12
Source File: DistributedCacheManagerDecoratorTest.java From rice with Educational Community License v2.0 | 5 votes |
/** * Test that duplicate cache flushes are filtered by * DistributedCacheManagerDecorator.CacheMessageSendingTransactionSynchronization.exhaustQueue(...) * to just the unique set, and that duplicate cache entry flushes are filtered to just the unique set as well. */ @Test public void testDuplicateCacheRemovalCase3() { Queue<CacheTarget> targets = Queues.newLinkedBlockingQueue(); // duplicate caches, we expect these to be filtered to the unique set targets.add(CacheTarget.entireCache(ROLE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(ROLE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(DELEGATE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(DELEGATE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(PERMISSION_TYPE)); targets.add(CacheTarget.entireCache(PERMISSION_TYPE)); // duplicate cache entries, we expect these to be filtered down to the unique set. targets.add(CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key1")); targets.add(CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key1")); targets.add(CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key2")); targets.add(CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key2")); // the expected result is the unique set of caches, and the unique set of specified cache entries ArrayList<CacheTarget> correctResults = Lists.newArrayList( CacheTarget.entireCache(ROLE_TYPE_CACHE), CacheTarget.entireCache(DELEGATE_TYPE_CACHE), CacheTarget.entireCache(PERMISSION_TYPE), CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key1"), CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key2")); Collection<CacheTarget> results = new ArrayList<CacheTarget>(invokeExhaustQueue(targets)); assertTrue(CollectionUtils.diff(correctResults, results).isEmpty()); }
Example #13
Source File: DistributedCacheManagerDecoratorTest.java From rice with Educational Community License v2.0 | 5 votes |
/** * Test that duplicate cache flushes are filtered by * DistributedCacheManagerDecorator.CacheMessageSendingTransactionSynchronization.exhaustQueue(...) * to just the unique set, and that duplicate cache entry flushes are filtered to just the unique set as well. */ @Test public void testDuplicateCacheRemovalCase2() { Queue<CacheTarget> targets = Queues.newLinkedBlockingQueue(); // duplicate caches, we expect these to be filtered to the unique set targets.add(CacheTarget.entireCache(ROLE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(ROLE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(DELEGATE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(DELEGATE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(PERMISSION_TYPE)); targets.add(CacheTarget.entireCache(PERMISSION_TYPE)); // cache entries -- we expect no filtering, since (1) the caches these entries are in are not being // flushed in their entirety, and (2) the cache + key combinations are unique targets.add(CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key1")); targets.add(CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key2")); targets.add(CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key3")); targets.add(CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key4")); // the expected result is the unique set of caches, and each of the specified cache entries ArrayList<CacheTarget> correctResults = Lists.newArrayList( CacheTarget.entireCache(ROLE_TYPE_CACHE), CacheTarget.entireCache(DELEGATE_TYPE_CACHE), CacheTarget.entireCache(PERMISSION_TYPE), CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key1"), CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key2"), CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key3"), CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key4")); Collection<CacheTarget> results = new ArrayList<CacheTarget>(invokeExhaustQueue(targets)); assertTrue(CollectionUtils.diff(correctResults, results).isEmpty()); }
Example #14
Source File: DistributedCacheManagerDecoratorTest.java From rice with Educational Community License v2.0 | 5 votes |
/** * Test that duplicate cache flushes are filtered by * DistributedCacheManagerDecorator.CacheMessageSendingTransactionSynchronization.exhaustQueue(...) * to just the unique set, and that individual cache entry flushes are filtered if the containing caches are also * being flushed in their entirety. */ @Test public void testDuplicateCacheRemovalCase1() { // duplicate caches, we expect these to be filtered to the unique set Queue<CacheTarget> targets = Queues.newLinkedBlockingQueue(); targets.add(CacheTarget.entireCache(ROLE_RESPONSIBILITY_CACHE)); targets.add(CacheTarget.entireCache(ROLE_RESPONSIBILITY_CACHE)); targets.add(CacheTarget.entireCache(ROLE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(ROLE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(DELEGATE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(DELEGATE_TYPE_CACHE)); targets.add(CacheTarget.entireCache(ROLE_MEMBER_TYPE)); targets.add(CacheTarget.entireCache(ROLE_MEMBER_TYPE)); targets.add(CacheTarget.entireCache(PERMISSION_TYPE)); targets.add(CacheTarget.entireCache(PERMISSION_TYPE)); // specific cache entries by key. We expect these all to be filtered out because the entire caches // are being flushed based on the targets added above. targets.add(CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key1")); targets.add(CacheTarget.singleEntry(ROLE_MEMBER_TYPE, "key2")); targets.add(CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key3")); targets.add(CacheTarget.singleEntry(ROLE_RESPONSIBILITY_CACHE, "key4")); // the expected result is the unique set of caches from targets ArrayList<CacheTarget> correctResults = Lists.newArrayList( CacheTarget.entireCache(ROLE_RESPONSIBILITY_CACHE), CacheTarget.entireCache(ROLE_MEMBER_TYPE), CacheTarget.entireCache(ROLE_TYPE_CACHE), CacheTarget.entireCache(DELEGATE_TYPE_CACHE), CacheTarget.entireCache(PERMISSION_TYPE)); Collection<CacheTarget> results = new ArrayList<CacheTarget>(invokeExhaustQueue(targets)); assertTrue(CollectionUtils.diff(correctResults, results).isEmpty()); }
Example #15
Source File: GroupWizardBuilder.java From syncope with Apache License 2.0 | 5 votes |
@Override protected Serializable onApplyInternal(final AnyWrapper<GroupTO> modelObject) { GroupTO updated = modelObject instanceof GroupWrapper ? GroupWrapper.class.cast(modelObject).fillDynamicConditions() : modelObject.getInnerObject(); ProvisioningResult<GroupTO> result; if (updated.getKey() == null) { GroupCR req = new GroupCR(); EntityTOUtils.toAnyCR(updated, req); result = GroupRestClient.create(req); } else { GroupTO original = getOriginalItem().getInnerObject(); fixPlainAndVirAttrs(updated, original); // SYNCOPE-1170 boolean othersNotEqualsOrBlanks = !updated.getADynMembershipConds().equals(original.getADynMembershipConds()) || (StringUtils.isNotBlank(original.getUDynMembershipCond()) && StringUtils.isBlank(updated.getUDynMembershipCond())) || (StringUtils.isBlank(original.getUDynMembershipCond()) && StringUtils.isNotBlank(updated.getUDynMembershipCond())) || StringUtils.isAllBlank(original.getUDynMembershipCond(), updated.getUDynMembershipCond()) || !updated.getUDynMembershipCond().equals(original.getUDynMembershipCond()) || !CollectionUtils.diff(updated.getTypeExtensions(), original.getTypeExtensions()).isEmpty(); GroupUR groupUR = AnyOperations.diff(updated, original, false); // update just if it is changed if (groupUR.isEmpty() && !othersNotEqualsOrBlanks) { result = new ProvisioningResult<>(); result.setEntity(updated); } else { result = groupRestClient.update(original.getETagValue(), groupUR); } } return result; }
Example #16
Source File: HTTPTransportActivator.java From cxf with Apache License 2.0 | 4 votes |
private <T> ServiceRegistration<T> registerService(BundleContext context, Class<T> serviceInterface, T serviceObject, String servicePid) { return context.registerService(serviceInterface, serviceObject, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, servicePid)); }
Example #17
Source File: TrackerOperationDataService.java From peer-os with Apache License 2.0 | 4 votes |
public void setOperationViewState( String source, final UUID operationTrackId, boolean viewState ) throws SQLException { EntityManager em = emf.createEntityManager(); source = source.toUpperCase(); try { TrackerOperationEntity result; em.getTransaction().begin(); TypedQuery<TrackerOperationEntity> query = em.createNamedQuery( TrackerOperationEntity.QUERY_GET_OPERATION, TrackerOperationEntity.class ); query.setParameter( "source", source ); query.setParameter( "operationTrackId", operationTrackId.toString() ); List<TrackerOperationEntity> operations = query.getResultList(); if ( !CollectionUtils.isEmpty( operations ) ) { result = operations.get( 0 ); result.setViewState( viewState ); em.merge( result ); } em.getTransaction().commit(); } catch ( Exception e ) { LOGGER.error( "Error in getTrackerOperations.", e ); if ( em.getTransaction().isActive() ) { em.getTransaction().rollback(); } throw new SQLException( e ); } finally { em.close(); } }
Example #18
Source File: TrackerOperationDataService.java From peer-os with Apache License 2.0 | 4 votes |
public TrackerOperationView getTrackerUserOperation( String source, final UUID operationTrackId, long userId ) { TrackerOperationEntity result = null; source = source.toUpperCase(); EntityManager em = emf.createEntityManager(); try { em.getTransaction().begin(); TypedQuery<TrackerOperationEntity> query = em.createNamedQuery( TrackerOperationEntity.QUERY_GET_USER_OPERATION, TrackerOperationEntity.class ); query.setParameter( "source", source ); query.setParameter( "operationTrackId", operationTrackId.toString() ); query.setParameter( "userId", userId ); List<TrackerOperationEntity> operations = query.getResultList(); if ( !CollectionUtils.isEmpty( operations ) ) { result = operations.get( 0 ); } em.getTransaction().commit(); } catch ( Exception e ) { LOGGER.error( "Error .", e ); if ( em.getTransaction().isActive() ) { em.getTransaction().rollback(); } } finally { em.close(); } if ( result != null ) { return createTrackerOperation( result.getInfo() ); } else { return null; } }
Example #19
Source File: TrackerOperationDataService.java From peer-os with Apache License 2.0 | 4 votes |
public TrackerOperationView getTrackerOperation( String source, final UUID operationTrackId ) { TrackerOperationEntity result = null; source = source.toUpperCase(); EntityManager em = emf.createEntityManager(); try { em.getTransaction().begin(); TypedQuery<TrackerOperationEntity> query = em.createNamedQuery( TrackerOperationEntity.QUERY_GET_OPERATION, TrackerOperationEntity.class ); query.setParameter( "source", source ); query.setParameter( "operationTrackId", operationTrackId.toString() ); List<TrackerOperationEntity> operations = query.getResultList(); if ( !CollectionUtils.isEmpty( operations ) ) { result = operations.get( 0 ); } em.getTransaction().commit(); } catch ( Exception e ) { LOGGER.error( "Error .", e ); if ( em.getTransaction().isActive() ) { em.getTransaction().rollback(); } } finally { em.close(); } if ( result != null ) { return createTrackerOperation( result.getInfo() ); } else { return null; } }
Example #20
Source File: ResourceHostMetrics.java From peer-os with Apache License 2.0 | 4 votes |
@JsonIgnore public boolean isEmpty() { return CollectionUtils.isEmpty( resources ); }