Search in sources :

Example 6 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class JavaRefactoringRename method createLinkedRenameRefactoringApplyDto.

@NotNull
private LinkedRenameRefactoringApply createLinkedRenameRefactoringApplyDto(String newName, String sessionId) {
    LinkedRenameRefactoringApply dto = dtoFactory.createDto(LinkedRenameRefactoringApply.class);
    dto.setNewName(newName);
    dto.setSessionId(sessionId);
    return dto;
}
Also used : LinkedRenameRefactoringApply(org.eclipse.che.ide.ext.java.shared.dto.refactoring.LinkedRenameRefactoringApply) NotNull(javax.validation.constraints.NotNull)

Example 7 with NotNull

use of javax.validation.constraints.NotNull in project cassandra-mesos-deprecated by mesosphere.

the class PersistedCassandraFrameworkConfigurationTest method createInitializedState.

@NotNull
private State createInitializedState(@NotNull final String varName, @NotNull final String resourceName) throws IOException {
    final State state = new InMemoryState();
    final Variable var = await(state.fetch(varName));
    final Variable mut = var.mutate(readConfigurationFile(resourceName));
    await(state.store(mut));
    return state;
}
Also used : Variable(org.apache.mesos.state.Variable) InMemoryState(org.apache.mesos.state.InMemoryState) State(org.apache.mesos.state.State) InMemoryState(org.apache.mesos.state.InMemoryState) NotNull(javax.validation.constraints.NotNull)

Example 8 with NotNull

use of javax.validation.constraints.NotNull in project graylog2-server by Graylog2.

the class Indices method getIndexNamesAndAliases.

@NotNull
public Map<String, Set<String>> getIndexNamesAndAliases(String indexPattern) {
    // only request indices matching the name or pattern in `indexPattern` and only get the alias names for each index,
    // not the settings or mappings
    final GetIndexRequestBuilder getIndexRequestBuilder = c.admin().indices().prepareGetIndex();
    getIndexRequestBuilder.addFeatures(GetIndexRequest.Feature.ALIASES);
    getIndexRequestBuilder.setIndices(indexPattern);
    final GetIndexResponse getIndexResponse = c.admin().indices().getIndex(getIndexRequestBuilder.request()).actionGet();
    final String[] indices = getIndexResponse.indices();
    final ImmutableOpenMap<String, List<AliasMetaData>> aliases = getIndexResponse.aliases();
    final Map<String, Set<String>> indexAliases = Maps.newHashMap();
    for (String index : indices) {
        final List<AliasMetaData> aliasMetaData = aliases.get(index);
        if (aliasMetaData == null) {
            indexAliases.put(index, Collections.emptySet());
        } else {
            indexAliases.put(index, aliasMetaData.stream().map(AliasMetaData::alias).collect(toSet()));
        }
    }
    return indexAliases;
}
Also used : AliasMetaData(org.elasticsearch.cluster.metadata.AliasMetaData) IndexSet(org.graylog2.indexer.IndexSet) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) GetIndexResponse(org.elasticsearch.action.admin.indices.get.GetIndexResponse) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) GetIndexRequestBuilder(org.elasticsearch.action.admin.indices.get.GetIndexRequestBuilder) NotNull(javax.validation.constraints.NotNull)

Example 9 with NotNull

use of javax.validation.constraints.NotNull in project ddf by codice.

the class MetacardsMigratable method export.

/**
     * Exports all the metacards currently stored in the catalog framework.
     * <p>
     * {@inheritDoc}
     */
@Override
@NotNull
public MigrationMetadata export(@NotNull Path exportPath) throws MigrationException {
    config.setExportPath(exportPath.resolve(this.getId()));
    fileWriter.createExportDirectory(config.getExportPath());
    Collection<MigrationWarning> warnings = new ArrayList<>();
    Map<String, Serializable> props = createMapWithNativeQueryMode();
    Filter dumpFilter = filterBuilder.attribute(Metacard.ANY_TEXT).is().like().text("*");
    QueryImpl exportQuery = new QueryImpl(dumpFilter);
    exportQuery.setPageSize(config.getExportQueryPageSize());
    exportQuery.setRequestsTotalResultsCount(false);
    QueryRequest exportQueryRequest = new QueryRequestImpl(exportQuery, props);
    try {
        executeQueryLoop(exportQuery, exportQueryRequest);
    } catch (Exception e) {
        LOGGER.info("Internal error occurred when exporting catalog: {}", e);
        throw new ExportMigrationException(DEFAULT_FAILURE_MESSAGE);
    } finally {
        cleanup();
    }
    return new MigrationMetadata(warnings);
}
Also used : MigrationWarning(org.codice.ddf.migration.MigrationWarning) Serializable(java.io.Serializable) ExportMigrationException(org.codice.ddf.migration.ExportMigrationException) QueryRequest(ddf.catalog.operation.QueryRequest) ArrayList(java.util.ArrayList) MigrationMetadata(org.codice.ddf.migration.MigrationMetadata) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) MigrationException(org.codice.ddf.migration.MigrationException) ExportMigrationException(org.codice.ddf.migration.ExportMigrationException) FederationException(ddf.catalog.federation.FederationException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) NotNull(javax.validation.constraints.NotNull)

Example 10 with NotNull

use of javax.validation.constraints.NotNull in project ddf by codice.

the class MigratableUtil method copyFileFromSystemPropertyValue.

/**
     * Copies a file, whose path is taken from a {@link System} property value, to a destination
     * directory. The file to copy must be a relative path under {@code ddf.home}, and its path
     * must not contain any symbolic link, otherwise the file will not be copied and a
     * {@link MigrationWarning} will be returned.
     *
     * @param systemProperty  name of the {@link System} property that contains the path to the
     *                        source file
     * @param exportDirectory root directory where the file will be copied. If the file'
     *                        relative path included any directories, those will be re-created
     *                        under this directory.
     * @param warnings        any warnings generated during this operation (e.g., source file outside
     *                        of {@code ddf.home}) will be added to this collection
     */
public void copyFileFromSystemPropertyValue(@NotNull String systemProperty, @NotNull Path exportDirectory, @NotNull Collection<MigrationWarning> warnings) throws MigrationException {
    String source = System.getProperty(systemProperty);
    notEmpty(source, String.format("Source path property [%s] is invalid: [%s]", systemProperty, source));
    Path sourcePath = Paths.get(source);
    copy(sourcePath, exportDirectory, warnings, () -> isSourceMigratable(sourcePath, (reason) -> new PathMigrationWarning(systemProperty, sourcePath, reason), warnings));
}
Also used : Path(java.nio.file.Path) StringUtils(org.apache.commons.lang.StringUtils) Validate.notEmpty(org.apache.commons.lang.Validate.notEmpty) Properties(java.util.Properties) Logger(org.slf4j.Logger) Files(java.nio.file.Files) MigrationWarning(org.codice.ddf.migration.MigrationWarning) ExportMigrationException(org.codice.ddf.migration.ExportMigrationException) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) FileInputStream(java.io.FileInputStream) NotNull(javax.validation.constraints.NotNull) Function(java.util.function.Function) Validate.notNull(org.apache.commons.lang.Validate.notNull) BooleanSupplier(java.util.function.BooleanSupplier) Paths(java.nio.file.Paths) Path(java.nio.file.Path) MigrationException(org.codice.ddf.migration.MigrationException) InputStream(java.io.InputStream)

Aggregations

NotNull (javax.validation.constraints.NotNull)16 ArrayList (java.util.ArrayList)3 ExportMigrationException (org.codice.ddf.migration.ExportMigrationException)3 MigrationException (org.codice.ddf.migration.MigrationException)3 MigrationWarning (org.codice.ddf.migration.MigrationWarning)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2 Collection (java.util.Collection)2 Properties (java.util.Properties)2 BooleanSupplier (java.util.function.BooleanSupplier)2 Function (java.util.function.Function)2 FileUtils (org.apache.commons.io.FileUtils)2 StringUtils (org.apache.commons.lang.StringUtils)2 Validate.notEmpty (org.apache.commons.lang.Validate.notEmpty)2 Validate.notNull (org.apache.commons.lang.Validate.notNull)2 RecipeWidget (org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.entry.RecipeWidget)2