me.prettyprint.cassandra.service.template.ColumnFamilyResult Java Examples

The following examples show how to use me.prettyprint.cassandra.service.template.ColumnFamilyResult. 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: CassandraMetadataRepository.java    From archiva with Apache License 2.0 6 votes vote down vote up
protected Map<String, String> getChecksums( String artifactMetadataKey )
{
    Map<String, String> checksums = new HashMap<>();

    QueryResult<OrderedRows<String, String, String>> result =
            HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) //
                    .setColumnFamily( cassandraArchivaManager.getChecksumFamilyName() ) //
                    .setColumnNames( ARTIFACT_METADATA_MODEL_KEY, REPOSITORY_NAME.toString(),
                            CHECKSUM_ALG.toString(), CHECKSUM_VALUE.toString() ) //
                    .setRowCount( Integer.MAX_VALUE ) //
                    .addEqualsExpression(ARTIFACT_METADATA_MODEL_KEY, artifactMetadataKey) //
                    .execute();
    for ( Row<String, String, String> row : result.get() )
    {
        ColumnFamilyResult<String, String> columnFamilyResult =
                this.checksumTemplate.queryColumns( row.getKey() );

        checksums.put(columnFamilyResult.getString(CHECKSUM_ALG.toString()),
                columnFamilyResult.getString(CHECKSUM_VALUE.toString()));
    }

    return checksums;
}
 
Example #2
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 6 votes vote down vote up
protected List<License> getLicenses( String projectVersionMetadataKey )
{
    List<License> licenses = new ArrayList<>();

    QueryResult<OrderedRows<String, String, String>> result =
        HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) //
            .setColumnFamily( cassandraArchivaManager.getLicenseFamilyName() ) //
            .setColumnNames( "projectVersionMetadataModel.key" ) //
            .setRowCount( Integer.MAX_VALUE ) //
            .addEqualsExpression( "projectVersionMetadataModel.key", projectVersionMetadataKey ) //
            .execute();

    for ( Row<String, String, String> row : result.get() )
    {
        ColumnFamilyResult<String, String> columnFamilyResult = this.licenseTemplate.queryColumns( row.getKey() );

        licenses.add(
            new License( columnFamilyResult.getString( NAME.toString() ), columnFamilyResult.getString( URL.toString() ) ) );
    }

    return licenses;
}
 
Example #3
Source File: CassandraActorSystemEventListenerRepository.java    From elasticactors with Apache License 2.0 6 votes vote down vote up
@Override
public List<ActorSystemEventListener> mapRow(final ColumnFamilyResult<Composite, String> results) {
    List<ActorSystemEventListener> resultList = new ArrayList<>(1024);

    if(results.hasResults()) {
        Collection<String> actorIds = results.getColumnNames();
        for (String actorId : actorIds) {
            try {
                resultList.add(ActorSystemEventListenerDeserializer.get().deserialize(results.getByteArray(actorId)));
            } catch(IOException e)  {
                logger.error("IOException while deserializing ActorSystemEventListener",e);
            }
        }
    }
    return resultList;
}
 
Example #4
Source File: CassandraScheduledMessageRepository.java    From elasticactors with Apache License 2.0 6 votes vote down vote up
@Override
public List<ScheduledMessage> mapRow(final ColumnFamilyResult<Composite, Composite> results) {
    List<ScheduledMessage> resultList = new LinkedList<>();

    if(results.hasResults()) {
        Collection<Composite> scheduledMessages = results.getColumnNames();
        for (Composite columnName : scheduledMessages) {
            try {
                resultList.add(scheduledMessageDeserializer.deserialize(results.getByteArray(columnName)));
            } catch(IOException e)  {
                logger.error("Error while deserializing Scheduled Message", e);
            }
        }
    }
    return resultList;
}
 
Example #5
Source File: CassandraUserStoreManager.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Authenticates a user given the user name and password against the user
 * store.
 */
@Override
public boolean doAuthenticate(String userName, Object credential) throws UserStoreException {

    String password = (String) credential;
    boolean isAuthed = false;
    if (!checkUserNameValid(userName)) {
        log.error("Invalid Username");
        return false;
    }

    if (!checkUserPasswordValid(credential)) {
        log.error("Invalid password");
        return false;
    }

    if (UserCoreUtil.isRegistryAnnonymousUser(userName)) {
        log.error("Anonnymous user trying to login");
        return false;
    }

    Composite key = new Composite();
    key.addComponent(userName, stringSerializer);
    key.addComponent(tenantIdString, stringSerializer);

    ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
            keyspace, CFConstants.UM_USER, CompositeSerializer.get(), StringSerializer.get());

    ColumnFamilyResult<Composite, String> result = userCFTemplate.queryColumns(key);
    String saltVallue = result.getString(CFConstants.UM_SALT_VALUE);
    String storedPassword = result.getString(CFConstants.UM_SECRET);

    if (TRUE.equalsIgnoreCase(realmConfig.getUserStoreProperty(JDBCRealmConstants.STORE_SALTED_PASSWORDS))) {
        password = Util.preparePassword(password, saltVallue);
        if ((storedPassword != null) && (storedPassword.equals(password))) {
            isAuthed = true;
        }
    }
    return isAuthed;
}
 
Example #6
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 5 votes vote down vote up
protected List<MailingList> getMailingLists( String projectVersionMetadataKey )
{
    List<MailingList> mailingLists = new ArrayList<>();

    QueryResult<OrderedRows<String, String, String>> result =
        HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) //
            .setColumnFamily( cassandraArchivaManager.getMailingListFamilyName() ) //
            .setColumnNames( NAME.toString() ) //
            .setRowCount( Integer.MAX_VALUE ) //
            .addEqualsExpression( "projectVersionMetadataModel.key", projectVersionMetadataKey ) //
            .execute();
    for ( Row<String, String, String> row : result.get() )
    {
        ColumnFamilyResult<String, String> columnFamilyResult =
            this.mailingListTemplate.queryColumns( row.getKey() );

        MailingList mailingList = new MailingList();
        mailingList.setName( columnFamilyResult.getString( NAME.toString() ) );
        mailingList.setMainArchiveUrl( columnFamilyResult.getString( "mainArchiveUrl" ) );
        mailingList.setPostAddress( columnFamilyResult.getString( "postAddress" ) );
        mailingList.setSubscribeAddress( columnFamilyResult.getString( "subscribeAddress" ) );
        mailingList.setUnsubscribeAddress( columnFamilyResult.getString( "unsubscribeAddress" ) );

        List<String> otherArchives = new ArrayList<>();

        for ( String columnName : columnFamilyResult.getColumnNames() )
        {
            if ( StringUtils.startsWith( columnName, "otherArchive." ) )
            {
                otherArchives.add( columnFamilyResult.getString( columnName ) );
            }
        }

        mailingList.setOtherArchives( otherArchives );
        mailingLists.add( mailingList );
    }

    return mailingLists;
}
 
Example #7
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 5 votes vote down vote up
protected List<Dependency> getDependencies( String projectVersionMetadataKey )
{
    List<Dependency> dependencies = new ArrayList<>();

    QueryResult<OrderedRows<String, String, String>> result =
        HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) //
            .setColumnFamily( cassandraArchivaManager.getDependencyFamilyName() ) //
            .setColumnNames( "projectVersionMetadataModel.key" ) //
            .setRowCount( Integer.MAX_VALUE ) //
            .addEqualsExpression( "projectVersionMetadataModel.key", projectVersionMetadataKey ) //
            .execute();

    for ( Row<String, String, String> row : result.get() )
    {
        ColumnFamilyResult<String, String> columnFamilyResult =
            this.dependencyTemplate.queryColumns( row.getKey() );

        Dependency dependency = new Dependency();
        dependency.setClassifier( columnFamilyResult.getString( "classifier" ) );

        dependency.setOptional( Boolean.parseBoolean( columnFamilyResult.getString( "optional" ) ) );

        dependency.setScope( columnFamilyResult.getString( "scope" ) );

        dependency.setSystemPath( columnFamilyResult.getString( "systemPath" ) );

        dependency.setType( columnFamilyResult.getString( "type" ) );

        dependency.setArtifactId( columnFamilyResult.getString( ARTIFACT_ID.toString() ) );

        dependency.setNamespace( columnFamilyResult.getString( GROUP_ID.toString() ) );

        dependency.setVersion( columnFamilyResult.getString( VERSION.toString() ) );

        dependencies.add( dependency );
    }

    return dependencies;
}
 
Example #8
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Override
public List<ProjectVersionReference> getProjectReferences( RepositorySession session, String repoId, String namespace, String projectId,
                                                           String projectVersion )
    throws MetadataResolutionException
{
    QueryResult<OrderedRows<String, String, String>> result = HFactory //
        .createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getDependencyFamilyName() ) //
        .setColumnNames( "projectVersionMetadataModel.key" ) //
        .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) //
        .addEqualsExpression( GROUP_ID.toString(), namespace ) //
        .addEqualsExpression( ARTIFACT_ID.toString(), projectId ) //
        .addEqualsExpression( VERSION.toString(), projectVersion ) //
        .execute();

    List<String> dependenciesIds = new ArrayList<>( result.get().getCount() );

    for ( Row<String, String, String> row : result.get().getList() )
    {
        dependenciesIds.add( getStringValue( row.getColumnSlice(), "projectVersionMetadataModel.key" ) );
    }

    List<ProjectVersionReference> references = new ArrayList<>( result.get().getCount() );

    for ( String key : dependenciesIds )
    {
        ColumnFamilyResult<String, String> columnFamilyResult =
            this.projectVersionMetadataTemplate.queryColumns( key );
        references.add( new ProjectVersionReference( ProjectVersionReference.ReferenceType.DEPENDENCY, //
                                                     columnFamilyResult.getString( PROJECT_ID.toString() ), //
                                                     columnFamilyResult.getString( NAMESPACE_ID.toString() ), //
                                                     columnFamilyResult.getString( PROJECT_VERSION.toString() ) ) );
    }

    return references;
}