me.prettyprint.hector.api.beans.OrderedRows Java Examples
The following examples show how to use
me.prettyprint.hector.api.beans.OrderedRows.
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 |
@Override public List<String> getProjects( RepositorySession session, final String repoId, final String namespace ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) // .setColumnNames( PROJECT_ID.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) // .execute(); final Set<String> projects = new HashSet<>( result.get( ).getCount( ) ); for ( Row<String, String, String> row : result.get() ) { projects.add( getStringValue( row.getColumnSlice(), PROJECT_ID.toString() ) ); } return new ArrayList<>( projects ); }
Example #2
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public List<String> getArtifactVersions( RepositorySession session, final String repoId, final String namespace, final String projectId, final String projectVersion ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataFamilyName() ) // .setColumnNames( VERSION.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) // .addEqualsExpression( PROJECT_ID.toString(), projectId ) // .addEqualsExpression( PROJECT_VERSION.toString(), projectVersion ) // .execute(); final Set<String> versions = new HashSet<>(); for ( Row<String, String, String> row : result.get() ) { versions.add( getStringValue( row.getColumnSlice(), VERSION.toString() ) ); } return new ArrayList<>( versions ); }
Example #3
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
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 #4
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public List<String> getMetadataFacets( RepositorySession session, final String repositoryId, final String facetId ) throws MetadataRepositoryException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) // .setColumnNames( NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( FACET_ID.toString(), facetId ) // .execute(); final List<String> facets = new ArrayList<>(); for ( Row<String, String, String> row : result.get() ) { facets.add( getStringValue( row.getColumnSlice(), NAME.toString() ) ); } return facets; }
Example #5
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
protected void removeMailingList( String projectVersionMetadataKey ) { 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(); if ( result.get().getCount() < 1 ) { return; } for ( Row<String, String, String> row : result.get() ) { this.mailingListTemplate.deleteRow( row.getKey() ); } }
Example #6
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
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 #7
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
protected void removeChecksums( String artifactMetadataKey ) { QueryResult<OrderedRows<String, String, String>> result = HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getChecksumFamilyName() ) // .setColumnNames( CHECKSUM_ALG.toString() ) // .setRowCount( Integer.MAX_VALUE ) // .addEqualsExpression(ARTIFACT_METADATA_MODEL_KEY, artifactMetadataKey ) // .execute(); if ( result.get().getCount() < 1 ) { return; } for ( Row<String, String, String> row : result.get() ) { this.checksumTemplate.deleteRow( row.getKey() ); } }
Example #8
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public void removeMetadataFacets( RepositorySession session, final String repositoryId, final String facetId ) throws MetadataRepositoryException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) // .setColumnNames( KEY.toString(), VALUE.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( FACET_ID.toString(), facetId ) // .execute(); for ( Row<String, String, String> row : result.get() ) { this.metadataFacetTemplate.deleteRow( row.getKey() ); } }
Example #9
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public void removeMetadataFacet( RepositorySession session, final String repositoryId, final String facetId, final String name ) throws MetadataRepositoryException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) // .setColumnNames( KEY.toString(), VALUE.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( FACET_ID.toString(), facetId ) // .addEqualsExpression( NAME.toString(), name ) // .execute(); for ( Row<String, String, String> row : result.get() ) { this.metadataFacetTemplate.deleteRow( row.getKey() ); } }
Example #10
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
protected List<String> getNamespaces( final String repoId ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .execute(); List<String> namespaces = new ArrayList<>( result.get().getCount() ); for ( Row<String, String, String> row : result.get() ) { namespaces.add( getStringValue( row.getColumnSlice(), NAME.toString() ) ); } return namespaces; }
Example #11
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public List<String> getRootNamespaces( RepositorySession session, final String repoId ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .execute(); Set<String> namespaces = new HashSet<>( result.get( ).getCount( ) ); for ( Row<String, String, String> row : result.get() ) { namespaces.add( StringUtils.substringBefore( getStringValue( row.getColumnSlice(), NAME.toString() ), "." ) ); } return new ArrayList<>( namespaces ); }
Example #12
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
protected Namespace getNamespace( String repositoryId, String namespaceId ) { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( REPOSITORY_NAME.toString(), NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( NAME.toString(), namespaceId ) // .execute(); if ( result.get().getCount() > 0 ) { ColumnSlice<String, String> columnSlice = result.get().getList().get( 0 ).getColumnSlice(); return new Namespace( getStringValue( columnSlice, NAME.toString() ), // new Repository( getStringValue( columnSlice, REPOSITORY_NAME.toString() ) ) ); } return null; }
Example #13
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public void removeFacetFromArtifact( RepositorySession session, final String repositoryId, final String namespace, final String project, final String version, final MetadataFacet metadataFacet ) throws MetadataRepositoryException { RangeSlicesQuery<String, String, String> query = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) // .setColumnNames( NAMESPACE_ID.toString() ); // query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) // .addEqualsExpression( PROJECT.toString(), project ) // .addEqualsExpression( VERSION.toString(), version ); QueryResult<OrderedRows<String, String, String>> result = query.execute(); for ( Row<String, String, String> row : result.get() ) { this.artifactMetadataTemplate.deleteRow( row.getKey() ); } }
Example #14
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 6 votes |
@Override public Stream<ArtifactMetadata> getArtifactStream( final RepositorySession session, final String repositoryId, final QueryParameter queryParameter ) throws MetadataResolutionException { RangeSlicesQuery<String, String, String> query = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName( ) ) // .setColumnNames( ArtifactMetadataModel.COLUMNS ); // query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ); QueryResult<OrderedRows<String, String, String>> result = query.execute(); try { return StreamSupport.stream( createResultSpliterator( result, ( Row<String, String, String> row, ArtifactMetadata last ) -> mapArtifactMetadataStringColumnSlice( row.getKey( ), row.getColumnSlice( ) ) ), false ) .skip( queryParameter.getOffset( ) ).limit( queryParameter.getLimit( ) ); } catch ( MetadataRepositoryException e ) { throw new MetadataResolutionException( e.getMessage( ), e ); } }
Example #15
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public List<ArtifactMetadata> getArtifactsByDateRange( RepositorySession session, final String repositoryId, final ZonedDateTime startTime, final ZonedDateTime endTime, QueryParameter queryParameter ) throws MetadataRepositoryException { LongSerializer ls = LongSerializer.get(); RangeSlicesQuery<String, String, Long> query = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ls ) // .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) // .setColumnNames( ArtifactMetadataModel.COLUMNS ); // if ( startTime != null ) { query = query.addGteExpression( WHEN_GATHERED.toString(), startTime.toInstant().toEpochMilli() ); } if ( endTime != null ) { query = query.addLteExpression( WHEN_GATHERED.toString(), endTime.toInstant().toEpochMilli() ); } QueryResult<OrderedRows<String, String, Long>> result = query.execute(); List<ArtifactMetadata> artifactMetadatas = new ArrayList<>( result.get().getCount() ); Iterator<Row<String, String, Long>> keyIter = result.get().iterator(); if (keyIter.hasNext()) { String key = keyIter.next().getKey(); for (Row<String, String, Long> row : result.get()) { ColumnSlice<String, Long> columnSlice = row.getColumnSlice(); String repositoryName = getAsStringValue(columnSlice, REPOSITORY_NAME.toString()); if (StringUtils.equals(repositoryName, repositoryId)) { artifactMetadatas.add(mapArtifactMetadataLongColumnSlice(key, columnSlice)); } } } return artifactMetadatas; }
Example #16
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
protected void removeDependencies( String projectVersionMetadataKey ) { QueryResult<OrderedRows<String, String, String>> result = HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getDependencyFamilyName() ) // .setColumnNames( GROUP_ID.toString() ) // .setRowCount( Integer.MAX_VALUE ) // .addEqualsExpression( "projectVersionMetadataModel.key", projectVersionMetadataKey ) // .execute(); for ( Row<String, String, String> row : result.get() ) { this.dependencyTemplate.deleteRow( row.getKey() ); } }
Example #17
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public List<ArtifactMetadata> getArtifactsByProjectVersionAttribute( RepositorySession session, String key, String value, String repositoryId ) throws MetadataRepositoryException { QueryResult<OrderedRows<String, String, String>> result = HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataFamilyName() ) // .setColumnNames( PROJECT_ID.toString(), REPOSITORY_NAME.toString(), NAMESPACE_ID.toString(), PROJECT_VERSION.toString() ) // .addEqualsExpression( key, value ) // .execute(); int count = result.get().getCount(); if ( count < 1 ) { return Collections.emptyList(); } List<ArtifactMetadata> artifacts = new LinkedList<>( ); for ( Row<String, String, String> row : result.get() ) { // TODO doing multiple queries, there should be a way to get all the artifactMetadatas for any number of // projects try { artifacts.addAll( getArtifacts( session, getStringValue( row.getColumnSlice(), REPOSITORY_NAME ), getStringValue( row.getColumnSlice(), NAMESPACE_ID ), getStringValue( row.getColumnSlice(), PROJECT_ID ), getStringValue( row.getColumnSlice(), PROJECT_VERSION ) ) ); } catch ( MetadataResolutionException e ) { // never raised throw new IllegalStateException( e ); } } return artifacts; }
Example #18
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public <T extends MetadataFacet> T getMetadataFacet( RepositorySession session, final String repositoryId, final Class<T> facetClazz, final String name ) throws MetadataRepositoryException { final MetadataFacetFactory<T> metadataFacetFactory = getFacetFactory( facetClazz ); if (metadataFacetFactory==null) { return null; } final String facetId = metadataFacetFactory.getFacetId( ); QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) // .setColumnNames( KEY.toString(), VALUE.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( FACET_ID.toString(), facetId ) // .addEqualsExpression( NAME.toString(), name ) // .execute(); T metadataFacet = metadataFacetFactory.createMetadataFacet( repositoryId, name ); int size = result.get().getCount(); if ( size < 1 ) { return null; } Map<String, String> map = new HashMap<>( size ); for ( Row<String, String, String> row : result.get() ) { ColumnSlice<String, String> columnSlice = row.getColumnSlice(); map.put( getStringValue( columnSlice, KEY.toString() ), getStringValue( columnSlice, VALUE.toString() ) ); } metadataFacet.fromProperties( map ); return metadataFacet; }
Example #19
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@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; }
Example #20
Source File: CassandraDB.java From cassandra-river with Apache License 2.0 | 5 votes |
public CassandraCFData getCFData(String columnFamily, String start, int limit) { int columnLimit = 100; CassandraCFData data = new CassandraCFData(); String lastEnd = null; Map<String, Map<String, String>> cfData = new HashMap<String, Map<String, String>>(); RangeSlicesQuery<String, String, String> query = HFactory.createRangeSlicesQuery(keyspace, STR, STR, STR); query.setColumnFamily(columnFamily); query.setKeys(start, ""); query.setRange("", "", false, columnLimit); query.setRowCount(limit); OrderedRows<String, String, String> rows = query.execute().get(); if (rows.getCount() != 1) { lastEnd = rows.peekLast().getKey(); data.start = lastEnd; } else { data.start = null; return data; } for(Row<String,String,String> row : rows.getList()){ Map<String, String> columnMap = new HashMap<String, String>(); ColumnSlice<String, String> columnData = row.getColumnSlice(); for (HColumn<String, String> column : columnData.getColumns()){ columnMap.put(column.getName(), column.getValue()); } cfData.put(row.getKey(), columnMap); } data.rowColumnMap = cfData; return data; }
Example #21
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
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 #22
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
protected void removeLicenses( String projectVersionMetadataKey ) { QueryResult<OrderedRows<String, String, String>> result = HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getLicenseFamilyName() ) // .setColumnNames( NAME.toString() ) // .setRowCount( Integer.MAX_VALUE ) // .addEqualsExpression( "projectVersionMetadataModel.key", projectVersionMetadataKey ) // .execute(); for ( Row<String, String, String> row : result.get() ) { this.licenseTemplate.deleteRow( row.getKey() ); } }
Example #23
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
/** * if the repository doesn't exist it will be created * * @param repositoryId * @return */ public Repository getOrCreateRepository( String repositoryId ) throws MetadataRepositoryException { String cf = cassandraArchivaManager.getRepositoryFamilyName(); QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get() ) // .setColumnFamily( cf ) // .setColumnNames( REPOSITORY_NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .execute(); if ( result.get().getCount() < 1 ) { // we need to create the repository Repository repository = new Repository( repositoryId ); try { MutationResult mutationResult = HFactory.createMutator( keyspace, StringSerializer.get() ) // .addInsertion( repositoryId, cf, CassandraUtils.column( REPOSITORY_NAME.toString(), repository.getName() ) ) // .execute(); logger.debug( "time to insert repository: {}", mutationResult.getExecutionTimeMicro() ); return repository; } catch ( HInvalidRequestException e ) { logger.error( e.getMessage(), e ); throw new MetadataRepositoryException( e.getMessage(), e ); } } return new Repository( result.get().getList().get( 0 ).getColumnSlice().getColumnByName( REPOSITORY_NAME.toString() ).getValue() ); }
Example #24
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
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 #25
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public ProjectMetadata getProject( RepositorySession session, final String repoId, final String namespace, final String id ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) // .setColumnNames( PROJECT_ID.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) // .addEqualsExpression( PROJECT_ID.toString(), id ) // .execute(); int count = result.get().getCount(); if ( count < 1 ) { return null; } ProjectMetadata projectMetadata = new ProjectMetadata(); projectMetadata.setId( id ); projectMetadata.setNamespace( namespace ); logger.debug( "getProject repoId: {}, namespace: {}, projectId: {} -> {}", repoId, namespace, id, projectMetadata ); return projectMetadata; }
Example #26
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public List<String> getProjectVersions( RepositorySession session, final String repoId, final String namespace, final String projectId ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataFamilyName() ) // .setColumnNames( PROJECT_VERSION.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) // .addEqualsExpression( PROJECT_ID.toString(), projectId ) // .execute(); int count = result.get().getCount(); if ( count < 1 ) { return Collections.emptyList(); } Set<String> versions = new HashSet<>( count ); for ( Row<String, String, String> orderedRows : result.get() ) { versions.add( getStringValue( orderedRows.getColumnSlice(), PROJECT_VERSION.toString() ) ); } return new ArrayList<>( versions ); }
Example #27
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public void updateProject( RepositorySession session, String repositoryId, ProjectMetadata projectMetadata ) throws MetadataRepositoryException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) // .setColumnNames( PROJECT_ID.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .addEqualsExpression( NAMESPACE_ID.toString(), projectMetadata.getNamespace() ) // .addEqualsExpression( PROJECT_ID.toString(), projectMetadata.getId() ) // .execute(); // project exists ? if yes return nothing to update here if ( result.get( ).getCount( ) <= 0 ) { Namespace namespace = updateOrAddNamespace( repositoryId, projectMetadata.getNamespace() ); String key = new Project.KeyBuilder().withProjectId( projectMetadata.getId() ).withNamespace( namespace ).build(); String cf = cassandraArchivaManager.getProjectFamilyName(); projectTemplate.createMutator() // values .addInsertion( key, cf, CassandraUtils.column( PROJECT_ID.toString(), projectMetadata.getId() ) ) // .addInsertion( key, cf, CassandraUtils.column( REPOSITORY_NAME.toString(), repositoryId ) ) // .addInsertion( key, cf, CassandraUtils.column( NAMESPACE_ID.toString(), projectMetadata.getNamespace() ) )// .execute(); } }
Example #28
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
protected Repository getRepository( String repositoryId ) throws MetadataRepositoryException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get() ) // .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) // .setColumnNames( REPOSITORY_NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId ) // .execute(); return ( result.get().getCount() > 0 ) ? new Repository( repositoryId ) : null; }
Example #29
Source File: CassandraMetadataRepository.java From archiva with Apache License 2.0 | 5 votes |
@Override public List<String> getChildNamespaces( RepositorySession session, final String repoId, final String namespaceId ) throws MetadataResolutionException { QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) // .setColumnNames( NAME.toString() ) // .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) // .execute(); List<String> namespaces = new ArrayList<>( result.get().getCount() ); for ( Row<String, String, String> row : result.get() ) { String currentNamespace = getStringValue( row.getColumnSlice(), NAME.toString() ); if ( StringUtils.startsWith( currentNamespace, namespaceId ) // && ( StringUtils.length( currentNamespace ) > StringUtils.length( namespaceId ) ) ) { // store after namespaceId '.' but before next '.' // call org namespace org.apache.maven.shared -> stored apache String calledNamespace = StringUtils.endsWith( namespaceId, "." ) ? namespaceId : namespaceId + "."; String storedNamespace = StringUtils.substringAfter( currentNamespace, calledNamespace ); storedNamespace = StringUtils.substringBefore( storedNamespace, "." ); namespaces.add( storedNamespace ); } } return namespaces; }
Example #30
Source File: CassandraUserStoreManager.java From carbon-identity with Apache License 2.0 | 4 votes |
/** * Lists the users in the user store. */ @Override protected String[] doListUsers(String filter, int maxItemLimit) throws UserStoreException { List<String> users = new ArrayList<String>(); int arrayLength = 0; if (maxItemLimit == 0) { return new String[0]; } int givenMax = UserCoreConstants.MAX_USER_ROLE_LIST; try { givenMax = Integer.parseInt(realmConfig .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST)); } catch (Exception e) { givenMax = UserCoreConstants.MAX_USER_ROLE_LIST; if (log.isDebugEnabled()) { log.debug("Realm configuration maximum not set : Using User Core Constant value instead!", e); } } if (maxItemLimit < 0 || maxItemLimit > givenMax) { maxItemLimit = givenMax; } RangeSlicesQuery<String, String, String> rangeSliceQuery = HFactory.createRangeSlicesQuery(keyspace, stringSerializer, stringSerializer, stringSerializer); rangeSliceQuery.setColumnFamily(CFConstants.UM_USER); rangeSliceQuery.setRange(filter, null, false, Integer.MAX_VALUE); rangeSliceQuery.addEqualsExpression(CFConstants.UM_TENANT_ID, tenantIdString); // TODO - Need to check how to use the filter for range rangeSliceQuery.setKeys("", ""); rangeSliceQuery.setRowCount(maxItemLimit); QueryResult<OrderedRows<String, String, String>> result = rangeSliceQuery.execute(); if (result != null) { OrderedRows<String, String, String> rows = result.get(); if (rows.getCount() <= 0) { // reformatted to avoid nesting too many blocks return users.toArray(new String[arrayLength]); } arrayLength = rows.getCount(); Iterator<Row<String, String, String>> rowsIterator = rows.iterator(); while (rowsIterator.hasNext()) { Row<String, String, String> row = rowsIterator.next(); if (row.getColumnSlice().getColumnByName(CFConstants.UM_USER_ID).getValue() != null) { String name = row.getColumnSlice().getColumnByName(CFConstants.UM_USER_NAME).getValue(); // append the domain if exist name = UserCoreUtil.addDomainToName(name, domain); users.add(name); } } } return users.toArray(new String[arrayLength]); }