Search in sources :

Example 71 with Collections

use of java.util.Collections in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method getProjectAssets.

@Override
public AssetQueryResult getProjectAssets(final ProjectAssetsQuery query) {
    checkNotNull("query", query);
    final boolean projectStillExists = ioService.exists(Paths.convert(query.getProject().getBranch().getPath()));
    if (!projectStillExists) {
        log.info("Asset lookup result: project [{}] does not exist.", projectIdentifierFrom(query));
        return AssetQueryResult.nonexistent();
    } else if (!indexOracle.isIndexed(query.getProject())) {
        log.info("Asset lookup result: project [{}] is not indexed.", projectIdentifierFrom(query));
        return AssetQueryResult.unindexed();
    }
    final HashSet<ValueIndexTerm> queryTerms = buildProjectAssetsQuery(query);
    final PageResponse<RefactoringPageRow> findRulesByProjectQuery = refactoringQueryService.query(new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, queryTerms, query.getStartIndex(), query.getAmount(), Boolean.TRUE));
    final List<FolderItem> assets = findRulesByProjectQuery.getPageRowList().stream().map(row -> {
        final Path path = (Path) row.getValue();
        return new FolderItem(path, path.getFileName(), FolderItemType.FILE, false, Paths.readLockedBy(path), Collections.<String>emptyList(), explorerServiceHelper.getRestrictedOperations(path));
    }).collect(Collectors.toList());
    log.info("Asset lookup result: project [{}] is indexed with {} index hits.", projectIdentifierFrom(query), assets.size());
    return AssetQueryResult.normal(assets.stream().map(asset -> {
        AssetInfo info = null;
        try {
            final Map<String, Object> attributes = ioService.readAttributes(Paths.convert((Path) asset.getItem()));
            final FileTime lastModifiedFileTime = (FileTime) getAttribute(LibraryService.LAST_MODIFIED_TIME, attributes).get();
            final FileTime createdFileTime = (FileTime) getAttribute(LibraryService.CREATED_TIME, attributes).get();
            final Date lastModifiedTime = new Date(lastModifiedFileTime.toMillis());
            final Date createdTime = new Date(createdFileTime.toMillis());
            info = new AssetInfo(asset, lastModifiedTime, createdTime);
        } catch (NoSuchFileException nfe) {
            log.debug("File '" + asset.getFileName() + "' in LibraryIndex but not VFS. Suspected deletion. Skipping.");
        }
        return Optional.ofNullable(info);
    }).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()));
}
Also used : FileTime(org.uberfire.java.nio.file.attribute.FileTime) Date(java.util.Date) ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) GAV(org.guvnor.common.services.project.model.GAV) LoggerFactory(org.slf4j.LoggerFactory) AuthorizationManager(org.uberfire.security.authz.AuthorizationManager) OrganizationalUnitService(org.guvnor.structure.organizationalunit.OrganizationalUnitService) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) Paths(org.uberfire.backend.server.util.Paths) POM(org.guvnor.common.services.project.model.POM) BranchPermissions(org.guvnor.structure.organizationalunit.config.BranchPermissions) RefactoringQueryService(org.kie.workbench.common.services.refactoring.service.RefactoringQueryService) LibraryValueFileNameIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileNameIndexTerm) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) ContributorType(org.uberfire.security.ContributorType) Service(org.jboss.errai.bus.server.annotations.Service) SessionInfo(org.uberfire.rpc.SessionInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) RepositoryAction(org.guvnor.structure.security.RepositoryAction) LibraryValueRepositoryRootIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm) UserManagerService(org.uberfire.ext.security.management.api.service.UserManagerService) Repository(org.guvnor.structure.repositories.Repository) SpaceConfigStorageRegistry(org.guvnor.structure.organizationalunit.config.SpaceConfigStorageRegistry) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) Collection(java.util.Collection) Set(java.util.Set) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm) Collectors(java.util.stream.Collectors) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) List(java.util.List) DeploymentMode(org.guvnor.common.services.project.service.DeploymentMode) OrganizationalUnitRepositoryInfo(org.kie.workbench.common.screens.library.api.OrganizationalUnitRepositoryInfo) LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ClusterService(org.uberfire.commons.cluster.ClusterService) PageResponse(org.uberfire.paging.PageResponse) AssetQueryResult(org.kie.workbench.common.screens.library.api.AssetQueryResult) AssetInfo(org.kie.workbench.common.screens.library.api.AssetInfo) PortablePreconditions.checkNotNull(org.kie.soup.commons.validation.PortablePreconditions.checkNotNull) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) ArchetypeService(org.kie.workbench.common.screens.archetype.mgmt.shared.services.ArchetypeService) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) Named(javax.inject.Named) Path(org.uberfire.backend.vfs.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) FolderItemType(org.kie.workbench.common.screens.explorer.model.FolderItemType) Logger(org.slf4j.Logger) FindAllLibraryAssetsQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindAllLibraryAssetsQuery) ExplorerServiceHelper(org.kie.workbench.common.screens.explorer.backend.server.ExplorerServiceHelper) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) ExamplesService(org.kie.workbench.common.screens.examples.service.ExamplesService) Contributor(org.uberfire.security.Contributor) NewWorkspaceProjectUtils(org.guvnor.common.services.project.utils.NewWorkspaceProjectUtils) User(org.jboss.errai.security.shared.api.identity.User) RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) OrganizationalUnitAction(org.guvnor.structure.security.OrganizationalUnitAction) UnauthorizedException(org.jboss.errai.security.shared.exception.UnauthorizedException) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) IOService(org.uberfire.io.IOService) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Collections(java.util.Collections) Branch(org.guvnor.structure.repositories.Branch) Path(org.uberfire.backend.vfs.Path) RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) Optional(java.util.Optional) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) FileTime(org.uberfire.java.nio.file.attribute.FileTime) AssetInfo(org.kie.workbench.common.screens.library.api.AssetInfo) Date(java.util.Date) FolderItem(org.kie.workbench.common.screens.explorer.model.FolderItem) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 72 with Collections

use of java.util.Collections in project kylo by Teradata.

the class SparkShellProxyController method fileMetadata.

@POST
@Path(FILE_METADATA)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("returns filemetadata based upon the list of file paths in the dataset.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the status of the file-metadata job.", response = TransformResponse.class), @ApiResponse(code = 400, message = "The requested data source does not exist.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "There was a problem processing the data.", response = RestResponseStatus.class) })
public Response fileMetadata(com.thinkbiganalytics.kylo.catalog.rest.model.DataSet dataSet) {
    TransformRequest request = new TransformRequest();
    DataSet decrypted = catalogModelTransform.decryptOptions(dataSet);
    request.setScript(FileMetadataScalaScriptGenerator.getScript(DataSetUtil.getPaths(decrypted).orElseGet(Collections::emptyList), DataSetUtil.mergeTemplates(decrypted).getOptions()));
    final SparkShellProcess process = getSparkShellProcess();
    return getModifiedTransformResponse(() -> Optional.of(restClient.transform(process, request)), new FileMetadataTransformResponseModifier(fileMetadataTrackerService));
}
Also used : SparkShellProcess(com.thinkbiganalytics.spark.shell.SparkShellProcess) DataSet(com.thinkbiganalytics.kylo.catalog.rest.model.DataSet) Collections(java.util.Collections) TransformRequest(com.thinkbiganalytics.spark.rest.model.TransformRequest) FileMetadataTransformResponseModifier(com.thinkbiganalytics.spark.rest.filemetadata.FileMetadataTransformResponseModifier) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 73 with Collections

use of java.util.Collections in project ignite by apache.

the class CacheAffinitySharedManager method processClientCacheStartRequests.

/**
 * @param crd Coordinator flag.
 * @param msg Change request.
 * @param topVer Current topology version.
 * @param discoCache Discovery data cache.
 * @return Map of started caches (cache ID to near enabled flag).
 */
@Nullable
private Map<Integer, Boolean> processClientCacheStartRequests(boolean crd, ClientCacheChangeDummyDiscoveryMessage msg, AffinityTopologyVersion topVer, DiscoCache discoCache) {
    Map<String, DynamicCacheChangeRequest> startReqs = msg.startRequests();
    List<DynamicCacheDescriptor> startDescs = clientCachesToStart(msg.requestId(), startReqs);
    if (startDescs == null || startDescs.isEmpty()) {
        cctx.cache().completeClientCacheChangeFuture(msg.requestId(), null);
        return null;
    }
    Map<Integer, GridDhtAssignmentFetchFuture> fetchFuts = U.newHashMap(startDescs.size());
    Map<Integer, Boolean> startedInfos = U.newHashMap(startDescs.size());
    List<StartCacheInfo> startCacheInfos = startDescs.stream().map(desc -> {
        DynamicCacheChangeRequest changeReq = startReqs.get(desc.cacheName());
        startedInfos.put(desc.cacheId(), changeReq.nearCacheConfiguration() != null);
        return new StartCacheInfo(desc.cacheConfiguration(), desc, changeReq.nearCacheConfiguration(), topVer, changeReq.disabledAfterStart(), true);
    }).collect(Collectors.toList());
    Set<String> startedCaches = startCacheInfos.stream().map(info -> info.getCacheDescriptor().cacheName()).collect(Collectors.toSet());
    try {
        cctx.cache().prepareStartCaches(startCacheInfos);
    } catch (IgniteCheckedException e) {
        cctx.cache().closeCaches(startedCaches, false);
        cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e);
        return null;
    }
    Set<CacheGroupDescriptor> groupDescs = startDescs.stream().map(DynamicCacheDescriptor::groupDescriptor).collect(Collectors.toSet());
    for (CacheGroupDescriptor grpDesc : groupDescs) {
        try {
            CacheGroupContext grp = cctx.cache().cacheGroup(grpDesc.groupId());
            assert grp != null : grpDesc.groupId();
            assert !grp.affinityNode() || grp.isLocal() : grp.cacheOrGroupName();
            // Skip for local caches.
            if (grp.isLocal())
                continue;
            CacheGroupHolder grpHolder = grpHolders.get(grp.groupId());
            assert !crd || (grpHolder != null && grpHolder.affinity().idealAssignmentRaw() != null);
            if (grpHolder == null)
                grpHolder = getOrCreateGroupHolder(topVer, grpDesc);
            // If current node is not client and current node have no aff holder.
            if (grpHolder.nonAffNode() && !cctx.localNode().isClient()) {
                GridDhtPartitionsExchangeFuture excFut = context().exchange().lastFinishedFuture();
                grp.topology().updateTopologyVersion(excFut, discoCache, -1, false);
                // Exchange free cache creation, just replacing client topology with dht.
                // Topology should be initialized before the use.
                grp.topology().beforeExchange(excFut, true, false);
                grpHolder = new CacheGroupAffNodeHolder(grp, grpHolder.affinity());
                grpHolders.put(grp.groupId(), grpHolder);
                GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId());
                if (clientTop != null) {
                    grp.topology().update(grpHolder.affinity().lastVersion(), clientTop.partitionMap(true), clientTop.fullUpdateCounters(), Collections.<Integer>emptySet(), null, null, null, clientTop.lostPartitions());
                    excFut.validate(grp);
                }
                assert grpHolder.affinity().lastVersion().equals(grp.affinity().lastVersion());
            } else if (!crd && !fetchFuts.containsKey(grp.groupId())) {
                boolean topVerLessOrNotInitialized = !grp.topology().initialized() || grp.topology().readyTopologyVersion().compareTo(topVer) < 0;
                if (grp.affinity().lastVersion().compareTo(topVer) < 0 || topVerLessOrNotInitialized) {
                    GridDhtAssignmentFetchFuture fetchFut = new GridDhtAssignmentFetchFuture(cctx, grp.groupId(), topVer, discoCache);
                    fetchFut.init(true);
                    fetchFuts.put(grp.groupId(), fetchFut);
                }
            }
        } catch (IgniteCheckedException e) {
            cctx.cache().closeCaches(startedCaches, false);
            cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e);
            return null;
        }
    }
    for (GridDhtAssignmentFetchFuture fetchFut : fetchFuts.values()) {
        try {
            CacheGroupContext grp = cctx.cache().cacheGroup(fetchFut.groupId());
            assert grp != null;
            GridDhtAffinityAssignmentResponse res = fetchAffinity(topVer, null, discoCache, grp.affinity(), fetchFut);
            GridDhtPartitionFullMap partMap;
            if (res != null) {
                partMap = res.partitionMap();
                assert partMap != null : res;
            } else
                partMap = new GridDhtPartitionFullMap(cctx.localNodeId(), cctx.localNode().order(), 1);
            GridDhtPartitionsExchangeFuture exchFut = context().exchange().lastFinishedFuture();
            grp.topology().updateTopologyVersion(exchFut, discoCache, -1, false);
            GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId());
            Set<Integer> lostParts = clientTop == null ? null : clientTop.lostPartitions();
            grp.topology().update(topVer, partMap, null, Collections.emptySet(), null, null, null, lostParts);
            if (clientTop == null)
                grp.topology().detectLostPartitions(topVer, exchFut);
            exchFut.validate(grp);
        } catch (IgniteCheckedException e) {
            cctx.cache().closeCaches(startedCaches, false);
            cctx.cache().completeClientCacheChangeFuture(msg.requestId(), e);
            return null;
        }
    }
    for (DynamicCacheDescriptor desc : startDescs) {
        if (desc.cacheConfiguration().getCacheMode() != LOCAL) {
            CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId());
            assert grp != null;
            grp.topology().onExchangeDone(null, grp.affinity().cachedAffinity(topVer), true);
        }
    }
    cctx.cache().initCacheProxies(topVer, null);
    startReqs.keySet().forEach(req -> cctx.cache().completeProxyInitialize(req));
    cctx.cache().completeClientCacheChangeFuture(msg.requestId(), null);
    return startedInfos;
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) Arrays(java.util.Arrays) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridPartitionStateMap(org.apache.ignite.internal.util.GridPartitionStateMap) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) GridLongList(org.apache.ignite.internal.util.GridLongList) AFFINITY_CALCULATION(org.apache.ignite.internal.processors.tracing.SpanType.AFFINITY_CALCULATION) Map(java.util.Map) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) CacheGroupAffinityMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CacheGroupAffinityMessage) GridDhtAssignmentFetchFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAssignmentFetchFuture) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) IgniteFuture(org.apache.ignite.lang.IgniteFuture) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) LOCAL(org.apache.ignite.cache.CacheMode.LOCAL) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) Event(org.apache.ignite.events.Event) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) IgniteInClosureX(org.apache.ignite.internal.util.lang.IgniteInClosureX) OWNING(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) NONE(org.apache.ignite.cache.CacheRebalanceMode.NONE) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) CU(org.apache.ignite.internal.util.typedef.internal.CU) Optional(java.util.Optional) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridDhtAffinityAssignmentResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse) Span(org.apache.ignite.internal.processors.tracing.Span) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) ClusterNode(org.apache.ignite.cluster.ClusterNode) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgniteClosure(org.apache.ignite.lang.IgniteClosure) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) CacheException(javax.cache.CacheException) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) Iterator(java.util.Iterator) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridDhtAssignmentFetchFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAssignmentFetchFuture) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) GridDhtAffinityAssignmentResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse) Nullable(org.jetbrains.annotations.Nullable)

Example 74 with Collections

use of java.util.Collections in project ddf by codice.

the class DumpCommand method executeWithSubject.

@Override
protected final Object executeWithSubject() throws Exception {
    if (signer == null) {
        signer = new DigitalSignature(security);
    }
    if (FilenameUtils.getExtension(dirPath).equals("") && !dirPath.endsWith(File.separator)) {
        dirPath += File.separator;
    }
    final File dumpDir = new File(dirPath);
    if (!dumpDir.exists()) {
        printErrorMessage("Directory [" + dirPath + "] must exist.");
        console.println("If the directory does indeed exist, try putting the path in quotes.");
        return null;
    }
    if (!dumpDir.isDirectory()) {
        printErrorMessage("Path [" + dirPath + "] must be a directory.");
        return null;
    }
    if (!SERIALIZED_OBJECT_ID.matches(transformerId)) {
        transformers = getTransformers();
        if (transformers == null) {
            console.println(transformerId + " is an invalid metacard transformer.");
            return null;
        }
    }
    if (StringUtils.isNotBlank(zipFileName) && new File(dirPath + zipFileName).exists()) {
        console.println("Cannot dump Catalog.  Zip file " + zipFileName + " already exists.");
        return null;
    }
    if (StringUtils.isNotBlank(zipFileName) && !zipFileName.endsWith(".zip")) {
        zipFileName = zipFileName + ".zip";
    }
    securityLogger.audit("Called catalog:dump command with path : {}", dirPath);
    CatalogFacade catalog = getCatalog();
    SortBy sort = new SortByImpl(Core.ID, SortOrder.ASCENDING);
    QueryImpl query = new QueryImpl(getFilter());
    query.setRequestsTotalResultsCount(true);
    query.setPageSize(pageSize);
    query.setSortBy(sort);
    final AtomicLong resultCount = new AtomicLong(0);
    long start = System.currentTimeMillis();
    BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(multithreaded);
    RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
    final ExecutorService executorService = new ThreadPoolExecutor(multithreaded, multithreaded, 0L, TimeUnit.MILLISECONDS, blockingQueue, StandardThreadFactoryBuilder.newThreadFactory("dumpCommandThread"), rejectedExecutionHandler);
    QueryRequest queryRequest = new QueryRequestImpl(query);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Hits for Search: {}", catalog.query(queryRequest).getHits());
    }
    if (StringUtils.isNotBlank(zipFileName)) {
        File outputFile = new File(dirPath + zipFileName);
        createZip(catalog, queryRequest, outputFile, resultCount);
        String alias = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(SystemBaseUrl.EXTERNAL_HOST));
        String password = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("javax.net.ssl.keyStorePassword"));
        try (InputStream inputStream = new FileInputStream(outputFile)) {
            byte[] signature = signer.createDigitalSignature(inputStream, alias, password);
            if (signature != null) {
                String epoch = Long.toString(Instant.now().getEpochSecond());
                String signatureFilepath = String.format("%sdump_%s.sig", dirPath, epoch);
                FileUtils.writeByteArrayToFile(new File(signatureFilepath), signature);
            }
        }
    } else {
        ResultIterable.resultIterable(catalog::query, queryRequest).stream().map(Collections::singletonList).map(result -> new SourceResponseImpl(queryRequest, result)).forEach(response -> handleResult(response, executorService, dumpDir, resultCount));
    }
    executorService.shutdown();
    boolean interrupted = false;
    try {
        while (!executorService.isTerminated()) {
            try {
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (InterruptedException e) {
                interrupted = true;
            }
        }
    } finally {
        if (interrupted) {
            Thread.currentThread().interrupt();
        }
    }
    long end = System.currentTimeMillis();
    String elapsedTime = timeFormatter.print(new Period(start, end).withMillis(0));
    console.printf(" %d file(s) dumped in %s\t%n", resultCount.get(), elapsedTime);
    LOGGER.debug("{} file(s) dumped in {}", resultCount.get(), elapsedTime);
    console.println();
    securityLogger.audit("Exported {} files to {}", resultCount.get(), dirPath);
    return null;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) BinaryContent(ddf.catalog.data.BinaryContent) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) Command(org.apache.karaf.shell.api.action.Command) MetacardTransformer(ddf.catalog.transform.MetacardTransformer) RejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler) Map(java.util.Map) SortByImpl(ddf.catalog.filter.impl.SortByImpl) URI(java.net.URI) ZipEntry(java.util.zip.ZipEntry) ServiceReference(org.osgi.framework.ServiceReference) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) StandardThreadFactoryBuilder(org.codice.ddf.platform.util.StandardThreadFactoryBuilder) ResourceRequestById(ddf.catalog.operation.impl.ResourceRequestById) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) BlockingQueue(java.util.concurrent.BlockingQueue) PrivilegedAction(java.security.PrivilegedAction) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) Serializable(java.io.Serializable) Objects(java.util.Objects) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Attribute(ddf.catalog.data.Attribute) PeriodFormatterBuilder(org.joda.time.format.PeriodFormatterBuilder) AccessController(java.security.AccessController) FilenameUtils(org.apache.commons.io.FilenameUtils) FileBackedOutputStream(com.google.common.io.FileBackedOutputStream) ResourceResponse(ddf.catalog.operation.ResourceResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ZipOutputStream(java.util.zip.ZipOutputStream) ResultIterable(ddf.catalog.util.impl.ResultIterable) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) HashMap(java.util.HashMap) PeriodFormatter(org.joda.time.format.PeriodFormatter) Resource(ddf.catalog.resource.Resource) ArrayList(java.util.ArrayList) Reference(org.apache.karaf.shell.api.action.lifecycle.Reference) SortBy(org.opengis.filter.sort.SortBy) ContentItem(ddf.catalog.content.data.ContentItem) Constants(ddf.catalog.Constants) Metacard(ddf.catalog.data.Metacard) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) ResourceRequest(ddf.catalog.operation.ResourceRequest) QueryRequest(ddf.catalog.operation.QueryRequest) ObjectOutputStream(java.io.ObjectOutputStream) Result(ddf.catalog.data.Result) SimpleEntry(java.util.AbstractMap.SimpleEntry) Core(ddf.catalog.data.types.Core) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) SortOrder(org.opengis.filter.sort.SortOrder) Period(org.joda.time.Period) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Logger(org.slf4j.Logger) SystemBaseUrl(org.codice.ddf.configuration.SystemBaseUrl) SecurityLogger(ddf.security.audit.SecurityLogger) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Argument(org.apache.karaf.shell.api.action.Argument) FileInputStream(java.io.FileInputStream) File(java.io.File) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) SourceResponse(ddf.catalog.operation.SourceResponse) Service(org.apache.karaf.shell.api.action.lifecycle.Service) CatalogFacade(org.codice.ddf.commands.catalog.facade.CatalogFacade) Option(org.apache.karaf.shell.api.action.Option) Collections(java.util.Collections) InputStream(java.io.InputStream) DigitalSignature(org.codice.ddf.commands.util.DigitalSignature) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) SortBy(org.opengis.filter.sort.SortBy) QueryImpl(ddf.catalog.operation.impl.QueryImpl) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CatalogFacade(org.codice.ddf.commands.catalog.facade.CatalogFacade) Collections(java.util.Collections) QueryRequest(ddf.catalog.operation.QueryRequest) RejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) DigitalSignature(org.codice.ddf.commands.util.DigitalSignature) Period(org.joda.time.Period) FileInputStream(java.io.FileInputStream) AtomicLong(java.util.concurrent.atomic.AtomicLong) SortByImpl(ddf.catalog.filter.impl.SortByImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) File(java.io.File)

Example 75 with Collections

use of java.util.Collections in project groovy by apache.

the class StaticTypeCheckingVisitor method inferReturnTypeGenerics.

/**
 * If a method call returns a parameterized type, then perform additional
 * inference on the return type, so that the type gets actual type arguments.
 * For example, the method {@code Arrays.asList(T...)} is parameterized with
 * {@code T}, which can be deduced type arguments or call arguments.
 *
 * @param method            the method node
 * @param arguments         the method call arguments
 * @param receiver          the object expression type
 * @param explicitTypeHints type arguments (optional), for example {@code Collections.<String>emptyList()}
 */
protected ClassNode inferReturnTypeGenerics(final ClassNode receiver, final MethodNode method, final Expression arguments, final GenericsType[] explicitTypeHints) {
    ClassNode returnType = method instanceof ConstructorNode ? method.getDeclaringClass() : method.getReturnType();
    if (!GenericsUtils.hasUnresolvedGenerics(returnType)) {
        // GROOVY-7538: replace "Type<?>" with "Type<? extends/super X>" for any "Type<T extends/super X>"
        if (getGenericsWithoutArray(returnType) != null)
            returnType = boundUnboundedWildcards(returnType);
        return returnType;
    }
    if (method instanceof ExtensionMethodNode) {
        ArgumentListExpression args = getExtensionArguments(receiver, method, arguments);
        MethodNode extension = ((ExtensionMethodNode) method).getExtensionMethodNode();
        return inferReturnTypeGenerics(receiver, extension, args, explicitTypeHints);
    }
    Map<GenericsTypeName, GenericsType> context = method.isStatic() || method instanceof ConstructorNode ? null : extractPlaceHoldersVisibleToDeclaration(receiver, method, arguments);
    GenericsType[] methodGenericTypes = method instanceof ConstructorNode ? method.getDeclaringClass().getGenericsTypes() : applyGenericsContext(context, method.getGenericsTypes());
    if (methodGenericTypes != null) {
        Map<GenericsTypeName, GenericsType> resolvedPlaceholders = new HashMap<>();
        for (GenericsType gt : methodGenericTypes) resolvedPlaceholders.put(new GenericsTypeName(gt.getName()), gt);
        applyGenericsConnections(extractGenericsConnectionsFromArguments(methodGenericTypes, Arrays.stream(method.getParameters()).map(param -> new Parameter(applyGenericsContext(context, param.getType()), param.getName())).toArray(Parameter[]::new), arguments, explicitTypeHints), resolvedPlaceholders);
        returnType = applyGenericsContext(resolvedPlaceholders, returnType);
    }
    if (context != null) {
        returnType = applyGenericsContext(context, returnType);
        if (receiver.getGenericsTypes() == null && receiver.redirect().getGenericsTypes() != null && GenericsUtils.hasUnresolvedGenerics(returnType)) {
            // GROOVY-10049: do not return "Stream<E>" for raw type "List#stream()"
            returnType = returnType.getPlainNodeReference();
        }
    }
    // 3) resolve bounds of type parameters from calling context
    returnType = applyGenericsContext(extractGenericsParameterMapOfThis(typeCheckingContext), returnType);
    return returnType;
}
Also used : BigInteger_TYPE(org.codehaus.groovy.ast.ClassHelper.BigInteger_TYPE) Enumeration(java.util.Enumeration) StaticTypeCheckingSupport.applyGenericsContext(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext) StaticTypeCheckingSupport.filterMethodsByVisibility(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.filterMethodsByVisibility) Character_TYPE(org.codehaus.groovy.ast.ClassHelper.Character_TYPE) LinkedHashSet_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.LinkedHashSet_TYPE) InvocationWriter(org.codehaus.groovy.classgen.asm.InvocationWriter) StaticTypeCheckingSupport.chooseBestMethod(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.chooseBestMethod) StaticTypeCheckingSupport.fullyResolve(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolve) Map(java.util.Map) GeneralUtils.propX(org.codehaus.groovy.ast.tools.GeneralUtils.propX) StaticTypeCheckingSupport.prettyPrintTypeName(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintTypeName) VOID_TYPE(org.codehaus.groovy.ast.ClassHelper.VOID_TYPE) PropertyNode(org.codehaus.groovy.ast.PropertyNode) COMPARE_TO(org.codehaus.groovy.syntax.Types.COMPARE_TO) UnaryMinusExpression(org.codehaus.groovy.ast.expr.UnaryMinusExpression) ClosureListExpression(org.codehaus.groovy.ast.expr.ClosureListExpression) PV_FIELDS_MUTATION(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_FIELDS_MUTATION) ClassHelper.isPrimitiveLong(org.codehaus.groovy.ast.ClassHelper.isPrimitiveLong) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) StaticTypeCheckingSupport.findDGMMethodsForClassNode(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsForClassNode) MethodReferenceExpression(org.codehaus.groovy.ast.expr.MethodReferenceExpression) TernaryExpression(org.codehaus.groovy.ast.expr.TernaryExpression) OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE) ClassHelper.byte_TYPE(org.codehaus.groovy.ast.ClassHelper.byte_TYPE) GeneralUtils.elvisX(org.codehaus.groovy.ast.tools.GeneralUtils.elvisX) STRING_TYPE(org.codehaus.groovy.ast.ClassHelper.STRING_TYPE) BeanUtils.decapitalize(org.apache.groovy.util.BeanUtils.decapitalize) ClassHelper.getWrapper(org.codehaus.groovy.ast.ClassHelper.getWrapper) COMPARE_NOT_IN(org.codehaus.groovy.syntax.Types.COMPARE_NOT_IN) StaticTypeCheckingSupport.isOperationInGroup(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isOperationInGroup) COMPARE_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_EQUAL) GeneralUtils.isOrImplements(org.codehaus.groovy.ast.tools.GeneralUtils.isOrImplements) ClassHelper.isPrimitiveDouble(org.codehaus.groovy.ast.ClassHelper.isPrimitiveDouble) PropertyExpression(org.codehaus.groovy.ast.expr.PropertyExpression) ClassHelper.isWrapperInteger(org.codehaus.groovy.ast.ClassHelper.isWrapperInteger) DIVIDE_EQUAL(org.codehaus.groovy.syntax.Types.DIVIDE_EQUAL) StaticTypeCheckingSupport.getOperationName(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getOperationName) IMPLICIT_RECEIVER(org.codehaus.groovy.transform.stc.StaticTypesMarker.IMPLICIT_RECEIVER) StaticTypeCheckingSupport.resolveClassNodeGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.resolveClassNodeGenerics) ClassHelper.isPrimitiveShort(org.codehaus.groovy.ast.ClassHelper.isPrimitiveShort) ClosureUtils.getParametersSafe(org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe) ClassHelper.isWrapperDouble(org.codehaus.groovy.ast.ClassHelper.isWrapperDouble) Matcher_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Matcher_TYPE) LinkedHashMap(java.util.LinkedHashMap) PrefixExpression(org.codehaus.groovy.ast.expr.PrefixExpression) SystemUtil(org.apache.groovy.util.SystemUtil) ExpressionStatement(org.codehaus.groovy.ast.stmt.ExpressionStatement) PostfixExpression(org.codehaus.groovy.ast.expr.PostfixExpression) Expression(org.codehaus.groovy.ast.expr.Expression) ClassHelper.short_TYPE(org.codehaus.groovy.ast.ClassHelper.short_TYPE) StaticTypeCheckingSupport.isPowerOperator(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isPowerOperator) Opcodes(org.objectweb.asm.Opcodes) UnaryPlusExpression(org.codehaus.groovy.ast.expr.UnaryPlusExpression) SourceUnit(org.codehaus.groovy.control.SourceUnit) ClassNode(org.codehaus.groovy.ast.ClassNode) ClassHelper.isStringType(org.codehaus.groovy.ast.ClassHelper.isStringType) ClassHelper.float_TYPE(org.codehaus.groovy.ast.ClassHelper.float_TYPE) ClassHelper.isPrimitiveInt(org.codehaus.groovy.ast.ClassHelper.isPrimitiveInt) GenericsType(org.codehaus.groovy.ast.GenericsType) ClassHelper.isPrimitiveBoolean(org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean) GeneralUtils.castX(org.codehaus.groovy.ast.tools.GeneralUtils.castX) ReturnStatement(org.codehaus.groovy.ast.stmt.ReturnStatement) AnnotationConstantExpression(org.codehaus.groovy.ast.expr.AnnotationConstantExpression) UNKNOWN_PARAMETER_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.UNKNOWN_PARAMETER_TYPE) AtomicLong(java.util.concurrent.atomic.AtomicLong) DYNAMIC_RESOLUTION(org.codehaus.groovy.transform.stc.StaticTypesMarker.DYNAMIC_RESOLUTION) BitwiseNegationExpression(org.codehaus.groovy.ast.expr.BitwiseNegationExpression) ClassHelper.isFunctionalInterface(org.codehaus.groovy.ast.ClassHelper.isFunctionalInterface) Float_TYPE(org.codehaus.groovy.ast.ClassHelper.Float_TYPE) CONSTRUCTED_LAMBDA_EXPRESSION(org.codehaus.groovy.transform.stc.StaticTypesMarker.CONSTRUCTED_LAMBDA_EXPRESSION) MapExpression(org.codehaus.groovy.ast.expr.MapExpression) ClassHelper.isGStringType(org.codehaus.groovy.ast.ClassHelper.isGStringType) GenericsTypeName(org.codehaus.groovy.ast.GenericsType.GenericsTypeName) AnnotatedNode(org.codehaus.groovy.ast.AnnotatedNode) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Long_TYPE(org.codehaus.groovy.ast.ClassHelper.Long_TYPE) StaticTypeCheckingSupport.extractGenericsParameterMapOfThis(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsParameterMapOfThis) StaticTypesTransformation(org.codehaus.groovy.transform.StaticTypesTransformation) GeneralUtils.getGetterName(org.codehaus.groovy.ast.tools.GeneralUtils.getGetterName) StaticTypeCheckingSupport.getCombinedBoundType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedBoundType) Number_TYPE(org.codehaus.groovy.ast.ClassHelper.Number_TYPE) MethodCall(org.codehaus.groovy.ast.expr.MethodCall) ClassHelper.isBigDecimalType(org.codehaus.groovy.ast.ClassHelper.isBigDecimalType) Collectors.toMap(java.util.stream.Collectors.toMap) StaticTypeCheckingSupport.evaluateExpression(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.evaluateExpression) INFERRED_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_TYPE) ForStatement(org.codehaus.groovy.ast.stmt.ForStatement) PV_FIELDS_ACCESS(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_FIELDS_ACCESS) StaticTypeCheckingSupport.findSetters(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findSetters) Collection(java.util.Collection) DefaultGroovyMethods(org.codehaus.groovy.runtime.DefaultGroovyMethods) Collectors(java.util.stream.Collectors) NotExpression(org.codehaus.groovy.ast.expr.NotExpression) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) Short_TYPE(org.codehaus.groovy.ast.ClassHelper.Short_TYPE) Objects(java.util.Objects) StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments) IfStatement(org.codehaus.groovy.ast.stmt.IfStatement) FieldExpression(org.codehaus.groovy.ast.expr.FieldExpression) StaticTypeCheckingSupport.isBitOperator(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBitOperator) ClosureUtils.hasImplicitParameter(org.codehaus.groovy.ast.tools.ClosureUtils.hasImplicitParameter) StaticTypeCheckingSupport.isWildcardLeftHandSide(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isWildcardLeftHandSide) BigDecimal_TYPE(org.codehaus.groovy.ast.ClassHelper.BigDecimal_TYPE) ClassHelper.isPrimitiveByte(org.codehaus.groovy.ast.ClassHelper.isPrimitiveByte) StaticTypeCheckingSupport.getCombinedGenericsType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedGenericsType) WideningCategories.isIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isIntCategory) DynamicVariable(org.codehaus.groovy.ast.DynamicVariable) Double_TYPE(org.codehaus.groovy.ast.ClassHelper.Double_TYPE) IntStream(java.util.stream.IntStream) StaticTypeCheckingSupport.isAssignableTo(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignableTo) ClosureSignatureHint(groovy.transform.stc.ClosureSignatureHint) AnnotationNode(org.codehaus.groovy.ast.AnnotationNode) StaticTypeCheckingSupport.isBeingCompiled(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBeingCompiled) StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics) DIVIDE(org.codehaus.groovy.syntax.Types.DIVIDE) Function(java.util.function.Function) ASSIGN(org.codehaus.groovy.syntax.Types.ASSIGN) HashSet(java.util.HashSet) ClassHelper.isNumberType(org.codehaus.groovy.ast.ClassHelper.isNumberType) BiPredicate(java.util.function.BiPredicate) ELVIS_EQUAL(org.codehaus.groovy.syntax.Types.ELVIS_EQUAL) NUMBER_OPS(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.NUMBER_OPS) Tuple2(groovy.lang.Tuple2) ClassHelper.boolean_TYPE(org.codehaus.groovy.ast.ClassHelper.boolean_TYPE) PV_METHODS_ACCESS(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_METHODS_ACCESS) ClassCodeVisitorSupport(org.codehaus.groovy.ast.ClassCodeVisitorSupport) StaticTypeCheckingSupport.checkPossibleLossOfPrecision(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkPossibleLossOfPrecision) GeneralUtils.varX(org.codehaus.groovy.ast.tools.GeneralUtils.varX) EmptyExpression(org.codehaus.groovy.ast.expr.EmptyExpression) LinkedList(java.util.LinkedList) StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics) ConstructorCallExpression(org.codehaus.groovy.ast.expr.ConstructorCallExpression) COMPARE_NOT_INSTANCEOF(org.codehaus.groovy.syntax.Types.COMPARE_NOT_INSTANCEOF) ClassHelper(org.codehaus.groovy.ast.ClassHelper) DECLARATION_INFERRED_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.DECLARATION_INFERRED_TYPE) SET_TYPE(org.codehaus.groovy.ast.ClassHelper.SET_TYPE) StaticTypeCheckingSupport.isArrayOp(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isArrayOp) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) ASTNode(org.codehaus.groovy.ast.ASTNode) TupleExpression(org.codehaus.groovy.ast.expr.TupleExpression) GeneralUtils.binX(org.codehaus.groovy.ast.tools.GeneralUtils.binX) TryCatchStatement(org.codehaus.groovy.ast.stmt.TryCatchStatement) GenericsUtils(org.codehaus.groovy.ast.tools.GenericsUtils) StringJoiner(java.util.StringJoiner) MethodPointerExpression(org.codehaus.groovy.ast.expr.MethodPointerExpression) StaticTypeCheckingSupport.allParametersAndArgumentsMatchWithDefaultParams(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.allParametersAndArgumentsMatchWithDefaultParams) ClassHelper.isWrapperCharacter(org.codehaus.groovy.ast.ClassHelper.isWrapperCharacter) ConstructorNode(org.codehaus.groovy.ast.ConstructorNode) MapEntryExpression(org.codehaus.groovy.ast.expr.MapEntryExpression) ClassHelper.isObjectType(org.codehaus.groovy.ast.ClassHelper.isObjectType) Arrays(java.util.Arrays) INFERRED_RETURN_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_RETURN_TYPE) StaticTypeCheckingSupport.checkCompatibleAssignmentTypes(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkCompatibleAssignmentTypes) Closure(groovy.lang.Closure) StaticTypeCheckingSupport.getGenericsWithoutArray(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getGenericsWithoutArray) WideningCategories.isFloatingCategory(org.codehaus.groovy.ast.tools.WideningCategories.isFloatingCategory) StaticTypeCheckingSupport.isTraitSelf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isTraitSelf) RANGE_TYPE(org.codehaus.groovy.ast.ClassHelper.RANGE_TYPE) ClosureParams(groovy.transform.stc.ClosureParams) CLOSURE_ARGUMENTS(org.codehaus.groovy.transform.stc.StaticTypesMarker.CLOSURE_ARGUMENTS) INTDIV_EQUAL(org.codehaus.groovy.syntax.Types.INTDIV_EQUAL) StaticTypeCheckingSupport.extractGenericsConnections(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsConnections) CaseStatement(org.codehaus.groovy.ast.stmt.CaseStatement) ClassHelper.isBigIntegerType(org.codehaus.groovy.ast.ClassHelper.isBigIntegerType) Traits(org.codehaus.groovy.transform.trait.Traits) ClassHelper.char_TYPE(org.codehaus.groovy.ast.ClassHelper.char_TYPE) MINUS_MINUS(org.codehaus.groovy.syntax.Types.MINUS_MINUS) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) EnumMap(java.util.EnumMap) LIST_TYPE(org.codehaus.groovy.ast.ClassHelper.LIST_TYPE) TypeCheckingMode(groovy.transform.TypeCheckingMode) BeanUtils.capitalize(org.apache.groovy.util.BeanUtils.capitalize) PATTERN_TYPE(org.codehaus.groovy.ast.ClassHelper.PATTERN_TYPE) NamedParams(groovy.transform.NamedParams) Set(java.util.Set) Token(org.codehaus.groovy.syntax.Token) ClassHelper.isPrimitiveVoid(org.codehaus.groovy.ast.ClassHelper.isPrimitiveVoid) ClassHelper.getUnwrapper(org.codehaus.groovy.ast.ClassHelper.getUnwrapper) GeneralUtils.callX(org.codehaus.groovy.ast.tools.GeneralUtils.callX) InvocationTargetException(java.lang.reflect.InvocationTargetException) WideningCategories.isFloat(org.codehaus.groovy.ast.tools.WideningCategories.isFloat) STREAM_TYPE(org.codehaus.groovy.ast.ClassHelper.STREAM_TYPE) CLASS_Type(org.codehaus.groovy.ast.ClassHelper.CLASS_Type) StaticTypeCheckingSupport.toMethodParametersString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.toMethodParametersString) ClassHelper.isWrapperByte(org.codehaus.groovy.ast.ClassHelper.isWrapperByte) COMPARE_NOT_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_NOT_EQUAL) StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf) ClassHelper.getNextSuperClass(org.codehaus.groovy.ast.ClassHelper.getNextSuperClass) ClassHelper.isWrapperFloat(org.codehaus.groovy.ast.ClassHelper.isWrapperFloat) ClassHelper.dynamicType(org.codehaus.groovy.ast.ClassHelper.dynamicType) ClassHelper.long_TYPE(org.codehaus.groovy.ast.ClassHelper.long_TYPE) LinkedHashMap_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.LinkedHashMap_TYPE) StaticTypeCheckingSupport.isBoolIntrinsicOp(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBoolIntrinsicOp) CastExpression(org.codehaus.groovy.ast.expr.CastExpression) StaticTypeCheckingSupport.boundUnboundedWildcards(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.boundUnboundedWildcards) ReturnAdder(org.codehaus.groovy.classgen.ReturnAdder) INTDIV(org.codehaus.groovy.syntax.Types.INTDIV) StaticMethodCallExpression(org.codehaus.groovy.ast.expr.StaticMethodCallExpression) LambdaExpression(org.codehaus.groovy.ast.expr.LambdaExpression) TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.TYPE) GeneralUtils.thisPropX(org.codehaus.groovy.ast.tools.GeneralUtils.thisPropX) StaticTypeCheckingSupport.missesGenericsTypes(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.missesGenericsTypes) MOD_EQUAL(org.codehaus.groovy.syntax.Types.MOD_EQUAL) WhileStatement(org.codehaus.groovy.ast.stmt.WhileStatement) ArrayList(java.util.ArrayList) ClosureUtils.getResolveStrategyName(org.codehaus.groovy.ast.tools.ClosureUtils.getResolveStrategyName) MethodNode(org.codehaus.groovy.ast.MethodNode) WideningCategories.isBigDecCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigDecCategory) ClassHelper.isPrimitiveFloat(org.codehaus.groovy.ast.ClassHelper.isPrimitiveFloat) KEYWORD_IN(org.codehaus.groovy.syntax.Types.KEYWORD_IN) LinkedHashSet(java.util.LinkedHashSet) Parameter(org.codehaus.groovy.ast.Parameter) MAP_TYPE(org.codehaus.groovy.ast.ClassHelper.MAP_TYPE) WideningCategories.isDoubleCategory(org.codehaus.groovy.ast.tools.WideningCategories.isDoubleCategory) EmptyStatement(org.codehaus.groovy.ast.stmt.EmptyStatement) ClassHelper.isClassType(org.codehaus.groovy.ast.ClassHelper.isClassType) ClassHelper.isPrimitiveType(org.codehaus.groovy.ast.ClassHelper.isPrimitiveType) ClassHelper.double_TYPE(org.codehaus.groovy.ast.ClassHelper.double_TYPE) ClassHelper.isPrimitiveChar(org.codehaus.groovy.ast.ClassHelper.isPrimitiveChar) WideningCategories.isLongCategory(org.codehaus.groovy.ast.tools.WideningCategories.isLongCategory) DIRECT_METHOD_CALL_TARGET(org.codehaus.groovy.transform.stc.StaticTypesMarker.DIRECT_METHOD_CALL_TARGET) WideningCategories.isNumberCategory(org.codehaus.groovy.ast.tools.WideningCategories.isNumberCategory) PLUS_PLUS(org.codehaus.groovy.syntax.Types.PLUS_PLUS) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) KEYWORD_INSTANCEOF(org.codehaus.groovy.syntax.Types.KEYWORD_INSTANCEOF) StaticTypeCheckingSupport.isAssignment(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignment) GeneralUtils.getSetterName(org.codehaus.groovy.ast.tools.GeneralUtils.getSetterName) DELEGATION_METADATA(org.codehaus.groovy.transform.stc.StaticTypesMarker.DELEGATION_METADATA) StaticTypeCheckingSupport.lastArgMatchesVarg(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.lastArgMatchesVarg) StaticTypeCheckingSupport.isGStringOrGStringStringLUB(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isGStringOrGStringStringLUB) ClassHelper.findSAM(org.codehaus.groovy.ast.ClassHelper.findSAM) RangeExpression(org.codehaus.groovy.ast.expr.RangeExpression) ResolveVisitor(org.codehaus.groovy.control.ResolveVisitor) Variable(org.codehaus.groovy.ast.Variable) ClassHelper.isSAMType(org.codehaus.groovy.ast.ClassHelper.isSAMType) FIND_REGEX(org.codehaus.groovy.syntax.Types.FIND_REGEX) StaticTypeCheckingSupport.prettyPrintType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintType) GeneralUtils(org.codehaus.groovy.ast.tools.GeneralUtils) WideningCategories.isDouble(org.codehaus.groovy.ast.tools.WideningCategories.isDouble) Integer_TYPE(org.codehaus.groovy.ast.ClassHelper.Integer_TYPE) DelegatesTo(groovy.lang.DelegatesTo) SpreadExpression(org.codehaus.groovy.ast.expr.SpreadExpression) SUPER_MOP_METHOD_REQUIRED(org.codehaus.groovy.transform.stc.StaticTypesMarker.SUPER_MOP_METHOD_REQUIRED) ClassHelper.isWrapperLong(org.codehaus.groovy.ast.ClassHelper.isWrapperLong) ArrayExpression(org.codehaus.groovy.ast.expr.ArrayExpression) GROOVY_OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.GROOVY_OBJECT_TYPE) GeneralUtils.args(org.codehaus.groovy.ast.tools.GeneralUtils.args) CatchStatement(org.codehaus.groovy.ast.stmt.CatchStatement) GroovyBugError(org.codehaus.groovy.GroovyBugError) READONLY_PROPERTY(org.codehaus.groovy.transform.stc.StaticTypesMarker.READONLY_PROPERTY) List(java.util.List) TypeChecked(groovy.transform.TypeChecked) BinaryExpression(org.codehaus.groovy.ast.expr.BinaryExpression) BlockStatement(org.codehaus.groovy.ast.stmt.BlockStatement) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) Statement(org.codehaus.groovy.ast.stmt.Statement) ClassHelper.isWrapperShort(org.codehaus.groovy.ast.ClassHelper.isWrapperShort) GeneralUtils.constX(org.codehaus.groovy.ast.tools.GeneralUtils.constX) ClassHelper.int_TYPE(org.codehaus.groovy.ast.ClassHelper.int_TYPE) CodeVisitorSupport(org.codehaus.groovy.ast.CodeVisitorSupport) ElvisOperatorExpression(org.codehaus.groovy.ast.expr.ElvisOperatorExpression) Collection_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Collection_TYPE) StaticTypeCheckingSupport.findTargetVariable(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findTargetVariable) WideningCategories.lowestUpperBound(org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound) HashMap(java.util.HashMap) ClassHelper.isDynamicTyped(org.codehaus.groovy.ast.ClassHelper.isDynamicTyped) TokenUtil(org.codehaus.groovy.syntax.TokenUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) StaticTypeCheckingSupport.isVargs(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isVargs) CompilationUnit(org.codehaus.groovy.control.CompilationUnit) CLOSURE_TYPE(org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE) WideningCategories.isBigIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigIntCategory) MethodCallExpression(org.codehaus.groovy.ast.expr.MethodCallExpression) StaticTypeCheckingSupport.isCompareToBoolean(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isCompareToBoolean) StaticTypeCheckingSupport.isParameterizedWithString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isParameterizedWithString) Byte_TYPE(org.codehaus.groovy.ast.ClassHelper.Byte_TYPE) ErrorCollector(org.codehaus.groovy.control.ErrorCollector) Iterator(java.util.Iterator) IntRange(groovy.lang.IntRange) ClosureSignatureConflictResolver(groovy.transform.stc.ClosureSignatureConflictResolver) GenericsUtils.makeClassSafe0(org.codehaus.groovy.ast.tools.GenericsUtils.makeClassSafe0) StaticTypeCheckingSupport.isUsingGenericsOrIsArrayUsingGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isUsingGenericsOrIsArrayUsingGenerics) DeclarationExpression(org.codehaus.groovy.ast.expr.DeclarationExpression) StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType) StaticTypeCheckingSupport.isParameterizedWithGStringOrGStringString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isParameterizedWithGStringOrGStringString) NamedParam(groovy.transform.NamedParam) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) StaticTypeCheckingSupport.applyGenericsConnections(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsConnections) StaticTypeCheckingSupport.fullyResolveType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolveType) SwitchStatement(org.codehaus.groovy.ast.stmt.SwitchStatement) StaticTypeCheckingSupport.isShiftOperation(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isShiftOperation) FieldNode(org.codehaus.groovy.ast.FieldNode) AttributeExpression(org.codehaus.groovy.ast.expr.AttributeExpression) WideningCategories(org.codehaus.groovy.ast.tools.WideningCategories) AUTOCLOSEABLE_TYPE(org.codehaus.groovy.ast.ClassHelper.AUTOCLOSEABLE_TYPE) EQUAL(org.codehaus.groovy.syntax.Types.EQUAL) MOD(org.codehaus.groovy.syntax.Types.MOD) Collections(java.util.Collections) Iterator_TYPE(org.codehaus.groovy.ast.ClassHelper.Iterator_TYPE) ArrayList_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.ArrayList_TYPE) StaticTypeCheckingSupport.findDGMMethodsForClassNode(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsForClassNode) ClassNode(org.codehaus.groovy.ast.ClassNode) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) MethodNode(org.codehaus.groovy.ast.MethodNode) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ConstructorNode(org.codehaus.groovy.ast.ConstructorNode) GenericsType(org.codehaus.groovy.ast.GenericsType) StaticTypeCheckingSupport.getCombinedGenericsType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedGenericsType) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) GenericsTypeName(org.codehaus.groovy.ast.GenericsType.GenericsTypeName) ClosureUtils.hasImplicitParameter(org.codehaus.groovy.ast.tools.ClosureUtils.hasImplicitParameter) Parameter(org.codehaus.groovy.ast.Parameter)

Aggregations

Collections (java.util.Collections)113 List (java.util.List)59 ArrayList (java.util.ArrayList)41 Test (org.junit.Test)39 Map (java.util.Map)37 Collectors (java.util.stream.Collectors)34 Arrays (java.util.Arrays)28 HashMap (java.util.HashMap)26 Set (java.util.Set)25 HashSet (java.util.HashSet)23 IOException (java.io.IOException)19 Collection (java.util.Collection)19 Optional (java.util.Optional)19 TimeUnit (java.util.concurrent.TimeUnit)16 URI (java.net.URI)13 Assert (org.junit.Assert)13 Function (java.util.function.Function)12 Stream (java.util.stream.Stream)12 Before (org.junit.Before)12 Logger (org.slf4j.Logger)12