Search in sources :

Example 1 with StringUtils.join

use of org.apache.commons.lang3.StringUtils.join in project cassandra by apache.

the class CommitLog method recoverSegmentsOnDisk.

/**
     * Perform recovery on commit logs located in the directory specified by the config file.
     *
     * @return the number of mutations replayed
     * @throws IOException
     */
public int recoverSegmentsOnDisk() throws IOException {
    FilenameFilter unmanagedFilesFilter = (dir, name) -> CommitLogDescriptor.isValid(name) && CommitLogSegment.shouldReplay(name);
    // archiving pass, which we should not treat as serious. 
    for (File file : new File(segmentManager.storageDirectory).listFiles(unmanagedFilesFilter)) {
        archiver.maybeArchive(file.getPath(), file.getName());
        archiver.maybeWaitForArchiving(file.getName());
    }
    assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore";
    archiver.maybeRestoreArchive();
    // List the files again as archiver may have added segments.
    File[] files = new File(segmentManager.storageDirectory).listFiles(unmanagedFilesFilter);
    int replayed = 0;
    if (files.length == 0) {
        logger.info("No commitlog files found; skipping replay");
    } else {
        Arrays.sort(files, new CommitLogSegmentFileComparator());
        logger.info("Replaying {}", StringUtils.join(files, ", "));
        replayed = recoverFiles(files);
        logger.info("Log replay complete, {} replayed mutations", replayed);
        for (File f : files) segmentManager.handleReplayedSegment(f);
    }
    return replayed;
}
Also used : DataOutputBufferFixed(org.apache.cassandra.io.util.DataOutputBufferFixed) java.util(java.util) BufferedDataOutputStreamPlus(org.apache.cassandra.io.util.BufferedDataOutputStreamPlus) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) TableId(org.apache.cassandra.schema.TableId) EncryptionContext(org.apache.cassandra.security.EncryptionContext) LoggerFactory(org.slf4j.LoggerFactory) Config(org.apache.cassandra.config.Config) org.apache.cassandra.db(org.apache.cassandra.db) ICompressor(org.apache.cassandra.io.compress.ICompressor) StringUtils(org.apache.commons.lang3.StringUtils) FBUtilities.updateChecksum(org.apache.cassandra.utils.FBUtilities.updateChecksum) ByteBuffer(java.nio.ByteBuffer) Allocation(org.apache.cassandra.db.commitlog.CommitLogSegment.Allocation) MBeanServer(javax.management.MBeanServer) ManagementFactory(java.lang.management.ManagementFactory) CommitLogMetrics(org.apache.cassandra.metrics.CommitLogMetrics) FBUtilities.updateChecksumInt(org.apache.cassandra.utils.FBUtilities.updateChecksumInt) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) JVMStabilityInspector(org.apache.cassandra.utils.JVMStabilityInspector) FSWriteError(org.apache.cassandra.io.FSWriteError) MessagingService(org.apache.cassandra.net.MessagingService) Logger(org.slf4j.Logger) FBUtilities(org.apache.cassandra.utils.FBUtilities) WriteTimeoutException(org.apache.cassandra.exceptions.WriteTimeoutException) StorageService(org.apache.cassandra.service.StorageService) ObjectName(javax.management.ObjectName) ENTRY_OVERHEAD_SIZE(org.apache.cassandra.db.commitlog.CommitLogSegment.ENTRY_OVERHEAD_SIZE) CompressionParams(org.apache.cassandra.schema.CompressionParams) java.io(java.io) ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) FileUtils(org.apache.cassandra.io.util.FileUtils) CRC32(java.util.zip.CRC32) VisibleForTesting(com.google.common.annotations.VisibleForTesting) CommitLogSegmentFileComparator(org.apache.cassandra.db.commitlog.CommitLogSegment.CommitLogSegmentFileComparator) CommitLogSegmentFileComparator(org.apache.cassandra.db.commitlog.CommitLogSegment.CommitLogSegmentFileComparator)

Example 2 with StringUtils.join

use of org.apache.commons.lang3.StringUtils.join in project nifi by apache.

the class FlowResource method activateControllerServices.

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-groups/{id}/controller-services")
@ApiOperation(value = "Enable or disable Controller Services in the specified Process Group.", response = ActivateControllerServicesEntity.class, authorizations = { @Authorization(value = "Read - /flow"), @Authorization(value = "Write - /{component-type}/{uuid} - For every service being enabled/disabled") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response activateControllerServices(@Context HttpServletRequest httpServletRequest, @ApiParam(value = "The process group id.", required = true) @PathParam("id") String id, @ApiParam(value = "The request to schedule or unschedule. If the comopnents in the request are not specified, all authorized components will be considered.", required = true) final ActivateControllerServicesEntity requestEntity) {
    // ensure the same id is being used
    if (!id.equals(requestEntity.getId())) {
        throw new IllegalArgumentException(String.format("The process group id (%s) in the request body does " + "not equal the process group id of the requested resource (%s).", requestEntity.getId(), id));
    }
    final ControllerServiceState state;
    if (requestEntity.getState() == null) {
        throw new IllegalArgumentException("The controller service state must be specified.");
    } else {
        try {
            state = ControllerServiceState.valueOf(requestEntity.getState());
        } catch (final IllegalArgumentException iae) {
            throw new IllegalArgumentException(String.format("The controller service state must be one of [%s].", StringUtils.join(EnumSet.of(ControllerServiceState.ENABLED, ControllerServiceState.DISABLED), ", ")));
        }
    }
    // ensure its a supported scheduled state
    if (ControllerServiceState.DISABLING.equals(state) || ControllerServiceState.ENABLING.equals(state)) {
        throw new IllegalArgumentException(String.format("The scheduled must be one of [%s].", StringUtils.join(EnumSet.of(ControllerServiceState.ENABLED, ControllerServiceState.DISABLED), ", ")));
    }
    // if the components are not specified, gather all components and their current revision
    if (requestEntity.getComponents() == null) {
        // get the current revisions for the components being updated
        final Set<Revision> revisions = serviceFacade.getRevisionsFromGroup(id, group -> {
            final Set<String> componentIds = new HashSet<>();
            final Predicate<ControllerServiceNode> filter;
            if (ControllerServiceState.ENABLED.equals(state)) {
                filter = service -> !service.isActive() && service.isValid();
            } else {
                filter = service -> service.isActive();
            }
            group.findAllControllerServices().stream().filter(filter).filter(service -> service.isAuthorized(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser())).forEach(service -> componentIds.add(service.getIdentifier()));
            return componentIds;
        });
        // build the component mapping
        final Map<String, RevisionDTO> componentsToSchedule = new HashMap<>();
        revisions.forEach(revision -> {
            final RevisionDTO dto = new RevisionDTO();
            dto.setClientId(revision.getClientId());
            dto.setVersion(revision.getVersion());
            componentsToSchedule.put(revision.getComponentId(), dto);
        });
        // set the components and their current revision
        requestEntity.setComponents(componentsToSchedule);
    }
    if (isReplicateRequest()) {
        return replicate(HttpMethod.PUT, requestEntity);
    }
    final Map<String, RevisionDTO> requestComponentsToSchedule = requestEntity.getComponents();
    final Map<String, Revision> requestComponentRevisions = requestComponentsToSchedule.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> getRevision(e.getValue(), e.getKey())));
    final Set<Revision> requestRevisions = new HashSet<>(requestComponentRevisions.values());
    return withWriteLock(serviceFacade, requestEntity, requestRevisions, lookup -> {
        // ensure access to the flow
        authorizeFlow();
        // ensure access to every component being scheduled
        requestComponentsToSchedule.keySet().forEach(componentId -> {
            final Authorizable authorizable = lookup.getControllerService(componentId).getAuthorizable();
            authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
        });
    }, () -> serviceFacade.verifyActivateControllerServices(id, state, requestComponentRevisions.keySet()), (revisions, scheduleComponentsEntity) -> {
        final ControllerServiceState serviceState = ControllerServiceState.valueOf(scheduleComponentsEntity.getState());
        final Map<String, RevisionDTO> componentsToSchedule = scheduleComponentsEntity.getComponents();
        final Map<String, Revision> componentRevisions = componentsToSchedule.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> getRevision(e.getValue(), e.getKey())));
        // update the controller services
        final ActivateControllerServicesEntity entity = serviceFacade.activateControllerServices(id, serviceState, componentRevisions);
        return generateOkResponse(entity).build();
    });
}
Also used : Bundle(org.apache.nifi.bundle.Bundle) DateTimeParameter(org.apache.nifi.web.api.request.DateTimeParameter) StatusHistoryEntity(org.apache.nifi.web.api.entity.StatusHistoryEntity) Produces(javax.ws.rs.Produces) BulletinBoardPatternParameter(org.apache.nifi.web.api.request.BulletinBoardPatternParameter) ApiParam(io.swagger.annotations.ApiParam) StringUtils(org.apache.commons.lang3.StringUtils) BucketsEntity(org.apache.nifi.web.api.entity.BucketsEntity) MediaType(javax.ws.rs.core.MediaType) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NiFiRegistryException(org.apache.nifi.registry.client.NiFiRegistryException) AboutDTO(org.apache.nifi.web.api.dto.AboutDTO) Map(java.util.Map) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) RegistriesEntity(org.apache.nifi.web.api.entity.RegistriesEntity) CurrentUserEntity(org.apache.nifi.web.api.entity.CurrentUserEntity) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) EnumSet(java.util.EnumSet) HistoryQueryDTO(org.apache.nifi.web.api.dto.action.HistoryQueryDTO) NarClassLoaders(org.apache.nifi.nar.NarClassLoaders) ControllerServicesEntity(org.apache.nifi.web.api.entity.ControllerServicesEntity) Set(java.util.Set) BulletinBoardDTO(org.apache.nifi.web.api.dto.BulletinBoardDTO) ScheduledState(org.apache.nifi.controller.ScheduledState) WebApplicationException(javax.ws.rs.WebApplicationException) ActionEntity(org.apache.nifi.web.api.entity.ActionEntity) ControllerBulletinsEntity(org.apache.nifi.web.api.entity.ControllerBulletinsEntity) RemoteProcessGroupStatusEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity) GET(javax.ws.rs.GET) ControllerServiceEntity(org.apache.nifi.web.api.entity.ControllerServiceEntity) TemplateEntity(org.apache.nifi.web.api.entity.TemplateEntity) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) BulletinBoardEntity(org.apache.nifi.web.api.entity.BulletinBoardEntity) HttpMethod(javax.ws.rs.HttpMethod) ArrayList(java.util.ArrayList) HttpServletRequest(javax.servlet.http.HttpServletRequest) ReportingTaskTypesEntity(org.apache.nifi.web.api.entity.ReportingTaskTypesEntity) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) NodeConnectionState(org.apache.nifi.cluster.coordination.node.NodeConnectionState) Api(io.swagger.annotations.Api) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) FlowConfigurationEntity(org.apache.nifi.web.api.entity.FlowConfigurationEntity) NiFiServiceFacade(org.apache.nifi.web.NiFiServiceFacade) RequestAction(org.apache.nifi.authorization.RequestAction) BannerEntity(org.apache.nifi.web.api.entity.BannerEntity) HistoryDTO(org.apache.nifi.web.api.dto.action.HistoryDTO) ClusteSummaryEntity(org.apache.nifi.web.api.entity.ClusteSummaryEntity) Authorizer(org.apache.nifi.authorization.Authorizer) NiFiProperties(org.apache.nifi.util.NiFiProperties) VersionedFlowSnapshotMetadataEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity) VersionedFlowSnapshotMetadataSetEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity) ProcessorStatusEntity(org.apache.nifi.web.api.entity.ProcessorStatusEntity) ApiResponse(io.swagger.annotations.ApiResponse) BucketEntity(org.apache.nifi.web.api.entity.BucketEntity) ScheduleComponentsEntity(org.apache.nifi.web.api.entity.ScheduleComponentsEntity) VersionedFlowEntity(org.apache.nifi.web.api.entity.VersionedFlowEntity) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) ProcessGroup(org.apache.nifi.groups.ProcessGroup) BulletinQueryDTO(org.apache.nifi.web.api.dto.BulletinQueryDTO) Date(java.util.Date) Path(javax.ws.rs.Path) ClusterSummaryDTO(org.apache.nifi.web.api.dto.ClusterSummaryDTO) ProcessGroupStatusEntity(org.apache.nifi.web.api.entity.ProcessGroupStatusEntity) ApiOperation(io.swagger.annotations.ApiOperation) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) ControllerStatusDTO(org.apache.nifi.web.api.dto.status.ControllerStatusDTO) ActivateControllerServicesEntity(org.apache.nifi.web.api.entity.ActivateControllerServicesEntity) ConnectionStatusEntity(org.apache.nifi.web.api.entity.ConnectionStatusEntity) ControllerStatusEntity(org.apache.nifi.web.api.entity.ControllerStatusEntity) DefaultValue(javax.ws.rs.DefaultValue) IntegerParameter(org.apache.nifi.web.api.request.IntegerParameter) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse) HistoryEntity(org.apache.nifi.web.api.entity.HistoryEntity) Context(javax.ws.rs.core.Context) Authorizable(org.apache.nifi.authorization.resource.Authorizable) ReportingTaskEntity(org.apache.nifi.web.api.entity.ReportingTaskEntity) Predicate(java.util.function.Predicate) NodeSearchResultDTO(org.apache.nifi.web.api.dto.search.NodeSearchResultDTO) ClusterSearchResultsEntity(org.apache.nifi.web.api.entity.ClusterSearchResultsEntity) LongParameter(org.apache.nifi.web.api.request.LongParameter) Collectors(java.util.stream.Collectors) List(java.util.List) Response(javax.ws.rs.core.Response) BannerDTO(org.apache.nifi.web.api.dto.BannerDTO) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) ControllerServiceState(org.apache.nifi.controller.service.ControllerServiceState) SearchResultsEntity(org.apache.nifi.web.api.entity.SearchResultsEntity) PathParam(javax.ws.rs.PathParam) Revision(org.apache.nifi.web.Revision) TemplatesEntity(org.apache.nifi.web.api.entity.TemplatesEntity) ClusterDTO(org.apache.nifi.web.api.dto.ClusterDTO) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) HashMap(java.util.HashMap) ApiResponses(io.swagger.annotations.ApiResponses) BundleDetails(org.apache.nifi.bundle.BundleDetails) HashSet(java.util.HashSet) ClusterCoordinator(org.apache.nifi.cluster.coordination.ClusterCoordinator) ControllerServiceTypesEntity(org.apache.nifi.web.api.entity.ControllerServiceTypesEntity) PrioritizerTypesEntity(org.apache.nifi.web.api.entity.PrioritizerTypesEntity) ProcessorTypesEntity(org.apache.nifi.web.api.entity.ProcessorTypesEntity) RegistryClientsEntity(org.apache.nifi.web.api.entity.RegistryClientsEntity) PortStatusEntity(org.apache.nifi.web.api.entity.PortStatusEntity) ComponentHistoryEntity(org.apache.nifi.web.api.entity.ComponentHistoryEntity) NiFiUserUtils(org.apache.nifi.authorization.user.NiFiUserUtils) SearchResultsDTO(org.apache.nifi.web.api.dto.search.SearchResultsDTO) AboutEntity(org.apache.nifi.web.api.entity.AboutEntity) RegistryEntity(org.apache.nifi.web.api.entity.RegistryEntity) NodeDTO(org.apache.nifi.web.api.dto.NodeDTO) PUT(javax.ws.rs.PUT) IllegalClusterResourceRequestException(org.apache.nifi.web.IllegalClusterResourceRequestException) Authorization(io.swagger.annotations.Authorization) VersionedFlowsEntity(org.apache.nifi.web.api.entity.VersionedFlowsEntity) ReportingTasksEntity(org.apache.nifi.web.api.entity.ReportingTasksEntity) ControllerServiceState(org.apache.nifi.controller.service.ControllerServiceState) HashMap(java.util.HashMap) ActivateControllerServicesEntity(org.apache.nifi.web.api.entity.ActivateControllerServicesEntity) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Revision(org.apache.nifi.web.Revision) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) Authorizable(org.apache.nifi.authorization.resource.Authorizable) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with StringUtils.join

use of org.apache.commons.lang3.StringUtils.join in project nifi by apache.

the class HostHeaderHandler method extractIPsFromNetworkInterfaces.

/**
 * Extracts the list of IP addresses from custom bound network interfaces. If both HTTPS and HTTP interfaces are
 * defined and HTTPS is enabled, only HTTPS interfaces will be returned. If none are defined, an empty list will be
 * returned.
 *
 * @param niFiProperties the NiFiProperties object
 * @return the list of IP addresses
 */
static List<String> extractIPsFromNetworkInterfaces(NiFiProperties niFiProperties) {
    Map<String, String> networkInterfaces = niFiProperties.isHTTPSConfigured() ? niFiProperties.getHttpsNetworkInterfaces() : niFiProperties.getHttpNetworkInterfaces();
    if (isNotDefined(networkInterfaces)) {
        // No custom interfaces defined
        return new ArrayList<>(0);
    } else {
        List<String> allIPAddresses = new ArrayList<>();
        for (Map.Entry<String, String> entry : networkInterfaces.entrySet()) {
            final String networkInterfaceName = entry.getValue();
            try {
                NetworkInterface ni = NetworkInterface.getByName(networkInterfaceName);
                List<String> ipAddresses = Collections.list(ni.getInetAddresses()).stream().map(inetAddress -> inetAddress.getHostAddress().toLowerCase()).collect(Collectors.toList());
                logger.debug("Resolved the following IP addresses for network interface {}: {}", new Object[] { networkInterfaceName, StringUtils.join(ipAddresses, ", ") });
                allIPAddresses.addAll(ipAddresses);
            } catch (SocketException e) {
                logger.warn("Cannot resolve network interface named " + networkInterfaceName);
            }
        }
        // Dedupe while maintaining order
        return uniqueList(allIPAddresses);
    }
}
Also used : Request(org.eclipse.jetty.server.Request) PrintWriter(java.io.PrintWriter) Logger(org.slf4j.Logger) ServletException(javax.servlet.ServletException) LoggerFactory(org.slf4j.LoggerFactory) HttpServletResponse(javax.servlet.http.HttpServletResponse) NetworkInterface(java.net.NetworkInterface) IOException(java.io.IOException) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) Objects(java.util.Objects) Strings(com.google.common.base.Strings) HttpServletRequest(javax.servlet.http.HttpServletRequest) SocketException(java.net.SocketException) List(java.util.List) NiFiProperties(org.apache.nifi.util.NiFiProperties) ScopedHandler(org.eclipse.jetty.server.handler.ScopedHandler) Map(java.util.Map) InetAddressUtils(org.apache.http.conn.util.InetAddressUtils) StringEscapeUtils(org.apache.commons.lang3.StringEscapeUtils) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) SocketException(java.net.SocketException) ArrayList(java.util.ArrayList) NetworkInterface(java.net.NetworkInterface) Map(java.util.Map)

Example 4 with StringUtils.join

use of org.apache.commons.lang3.StringUtils.join in project nifi by apache.

the class TlsHelperTest method testShouldIncludeSANFromCSR.

@Test
public void testShouldIncludeSANFromCSR() throws Exception {
    // Arrange
    final List<String> SAN_ENTRIES = Arrays.asList("127.0.0.1", "nifi.nifi.apache.org");
    final String SAN = StringUtils.join(SAN_ENTRIES, ",");
    final int SAN_COUNT = SAN_ENTRIES.size();
    final String DN = "CN=localhost";
    KeyPair keyPair = keyPairGenerator.generateKeyPair();
    logger.info("Generating CSR with DN: " + DN);
    // Act
    JcaPKCS10CertificationRequest csrWithSan = TlsHelper.generateCertificationRequest(DN, SAN, keyPair, TlsConfig.DEFAULT_SIGNING_ALGORITHM);
    logger.info("Created CSR with SAN: " + SAN);
    String testCsrPem = TlsHelper.pemEncodeJcaObject(csrWithSan);
    logger.info("Encoded CSR as PEM: " + testCsrPem);
    // Assert
    String subjectName = csrWithSan.getSubject().toString();
    logger.info("CSR Subject Name: " + subjectName);
    assert subjectName.equals(DN);
    List<String> extractedSans = extractSanFromCsr(csrWithSan);
    assert extractedSans.size() == SAN_COUNT + 1;
    List<String> formattedSans = SAN_ENTRIES.stream().map(s -> "DNS: " + s).collect(Collectors.toList());
    assert extractedSans.containsAll(formattedSans);
    // We check that the SANs also contain the CN
    assert extractedSans.contains("DNS: localhost");
}
Also used : X509Certificate(java.security.cert.X509Certificate) KeyPair(java.security.KeyPair) CertificateUtils(org.apache.nifi.security.util.CertificateUtils) Arrays(java.util.Arrays) Extension(org.bouncycastle.asn1.x509.Extension) Date(java.util.Date) TlsConfig(org.apache.nifi.toolkit.tls.configuration.TlsConfig) OperatorCreationException(org.bouncycastle.operator.OperatorCreationException) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Mockito.doThrow(org.mockito.Mockito.doThrow) GeneralSecurityException(java.security.GeneralSecurityException) Matchers.eq(org.mockito.Matchers.eq) After(org.junit.After) Assert.fail(org.junit.Assert.fail) KeyPairGenerator(java.security.KeyPairGenerator) JcaPKCS10CertificationRequest(org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest) PEMParser(org.bouncycastle.openssl.PEMParser) SignatureException(java.security.SignatureException) KeyStore(java.security.KeyStore) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) Provider(java.security.Provider) List(java.util.List) GeneralName(org.bouncycastle.asn1.x509.GeneralName) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) X509CertificateHolder(org.bouncycastle.cert.X509CertificateHolder) JcaPEMKeyConverter(org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter) AdditionalMatchers(org.mockito.AdditionalMatchers) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PKCSObjectIdentifiers(org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers) JcaX509CertificateConverter(org.bouncycastle.cert.jcajce.JcaX509CertificateConverter) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) Before(org.junit.Before) Logger(org.slf4j.Logger) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) PublicKey(java.security.PublicKey) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) CertificateException(java.security.cert.CertificateException) Field(java.lang.reflect.Field) InputStreamReader(java.io.InputStreamReader) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) KeyStoreSpi(java.security.KeyStoreSpi) Extensions(org.bouncycastle.asn1.x509.Extensions) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) TimeUnit(java.util.concurrent.TimeUnit) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) GeneralNames(org.bouncycastle.asn1.x509.GeneralNames) PEMKeyPair(org.bouncycastle.openssl.PEMKeyPair) FileReader(java.io.FileReader) Attribute(org.bouncycastle.asn1.pkcs.Attribute) NoSuchProviderException(java.security.NoSuchProviderException) Assert.assertEquals(org.junit.Assert.assertEquals) KeyPair(java.security.KeyPair) PEMKeyPair(org.bouncycastle.openssl.PEMKeyPair) JcaPKCS10CertificationRequest(org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest) Test(org.junit.Test)

Example 5 with StringUtils.join

use of org.apache.commons.lang3.StringUtils.join in project entando-core by entando.

the class RowContentListViewerConfigProcessor method buildConfiguration.

@SuppressWarnings("unchecked")
@Override
public Object buildConfiguration(WidgetConfigurationRequest widget) {
    ApsProperties properties = new ApsProperties();
    List<RowContentListConfigurationEntry> entryList = (List<RowContentListConfigurationEntry>) widget.getProcessInfo().get(WidgetConfigurationValidator.PROCESS_INFO_CONFIG);
    if (null != entryList && !entryList.isEmpty()) {
        StringBuffer sbuffer = new StringBuffer("[");
        List<String> configTokens = entryList.stream().map(i -> i.toCfg()).collect(Collectors.toList());
        sbuffer.append(StringUtils.join(configTokens, ","));
        sbuffer.append("]");
        properties.put("contents", sbuffer.toString());
    }
    return properties;
}
Also used : Properties(java.util.Properties) IOException(java.io.IOException) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties) WidgetConfigurationProcessor(org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationProcessor) RowContentListHelper(org.entando.entando.plugins.jacms.aps.system.services.content.widget.RowContentListHelper) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) List(java.util.List) Map(java.util.Map) WidgetConfigurationValidator(org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationValidator) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) JsonParseException(com.fasterxml.jackson.core.JsonParseException) List(java.util.List) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

StringUtils (org.apache.commons.lang3.StringUtils)34 List (java.util.List)30 Collectors (java.util.stream.Collectors)23 ArrayList (java.util.ArrayList)21 Map (java.util.Map)17 HashMap (java.util.HashMap)15 Set (java.util.Set)14 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 IOException (java.io.IOException)13 HashSet (java.util.HashSet)11 Arrays (java.util.Arrays)10 Collections (java.util.Collections)10 Date (java.util.Date)9 File (java.io.File)6 StopWatch (org.apache.commons.lang3.time.StopWatch)6 InputStream (java.io.InputStream)5 java.util (java.util)5 Pair (org.apache.commons.lang3.tuple.Pair)5 Path (java.nio.file.Path)4