Java Code Examples for org.sonatype.nexus.common.node.NodeAccess

The following examples show how to use org.sonatype.nexus.common.node.NodeAccess. These examples are extracted from open source projects. 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
@Inject
public ReindexNpmRepositoryTaskDescriptor(final NodeAccess nodeAccess) {
  super(TYPE_ID,
      OrientReindexNpmRepositoryTask.class,
      "Repair - Reconcile npm /-/v1/search metadata",
      VISIBLE,
      EXPOSED,
      new RepositoryCombobox(
          REPOSITORY_NAME_FIELD_ID,
          "Repository",
          "Select the npm repository to reconcile",
          true
      ).includingAnyOfFacets(NpmSearchFacet.class).includeAnEntryForAllRepositories(),

      nodeAccess.isClustered() ? newMultinodeFormField().withInitialValue(true) : null
  );
}
 
Example 2
@Inject
public DatabaseFreezeServiceImpl(final Set<Provider<DatabaseInstance>> providers,
                                 final EventManager eventManager,
                                 final DatabaseFrozenStateManager databaseFrozenStateManager,
                                 final Provider<OServer> server,
                                 final NodeAccess nodeAccess,
                                 final SecurityHelper securityHelper,
                                 final List<Freezable> freezables)
{
  this.providers = checkNotNull(providers);
  this.eventManager = checkNotNull(eventManager);
  this.databaseFrozenStateManager = checkNotNull(databaseFrozenStateManager);
  checkNotNull(server);
  distributedServerManagerProvider = () -> server.get().getDistributedManager();
  this.nodeAccess = checkNotNull(nodeAccess);
  this.securityHelper = securityHelper;
  this.freezables = checkNotNull(freezables);
}
 
Example 3
Source Project: nexus-public   Source File: IndexSyncService.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Inject
public IndexSyncService(@Named(COMPONENT) final Provider<DatabaseInstance> componentDatabase,
                        final ComponentEntityAdapter componentEntityAdapter,
                        final AssetEntityAdapter assetEntityAdapter,
                        final ApplicationDirectories directories,
                        final NodeAccess nodeAccess,
                        final IndexRequestProcessor indexRequestProcessor,
                        final IndexRebuildManager indexRebuildManager)
{
  this.componentDatabase = checkNotNull(componentDatabase);
  this.componentEntityAdapter = checkNotNull(componentEntityAdapter);
  this.nodeAccess = checkNotNull(nodeAccess);
  this.indexRequestProcessor = checkNotNull(indexRequestProcessor);
  this.indexRebuildManager = checkNotNull(indexRebuildManager);

  this.entityLog = new EntityLog(componentDatabase, componentEntityAdapter, assetEntityAdapter);
  this.checkpointFile = new File(directories.getWorkDirectory("elasticsearch"), "nexus.lsn");
}
 
Example 4
@Inject
public RebuildIndexTaskDescriptor(final NodeAccess nodeAccess) {
  super(TYPE_ID,
      org.sonatype.nexus.repository.search.index.RebuildIndexTask.class,
      "Repair - Rebuild repository search",
      VISIBLE,
      EXPOSED,
      new RepositoryCombobox(
          REPOSITORY_NAME_FIELD_ID,
          "Repository",
          "Select the repository to rebuild index",
          true
      ).includingAnyOfFacets(SearchFacet.class).includeAnEntryForAllRepositories(),

      nodeAccess.isClustered() ? newMultinodeFormField().withInitialValue(true) : null
  );
}
 
Example 5
Source Project: nexus-public   Source File: AbstractSecurityTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected void customizeModules(List<Module> modules) {
  modules.add(new AbstractModule()
  {
    @Override
    protected void configure() {
      install(new WebSecurityModule(mock(ServletContext.class)));

      bind(SecurityConfigurationSource.class).annotatedWith(Names.named("default")).toInstance(
          new PreconfiguredSecurityConfigurationSource(initialSecurityConfiguration()));

      RealmConfiguration realmConfiguration = new TestRealmConfiguration();
      realmConfiguration.setRealmNames(Arrays.asList("MockRealmA", "MockRealmB"));
      bind(RealmConfiguration.class).annotatedWith(Names.named("initial")).toInstance(realmConfiguration);

      bind(ApplicationDirectories.class).toInstance(mock(ApplicationDirectories.class));
      bind(NodeAccess.class).toInstance(mock(NodeAccess.class));
      bind(AnonymousManager.class).toInstance(mock(AnonymousManager.class));
      bind(EventManager.class).toInstance(getEventManager());

      requestInjection(AbstractSecurityTest.this);
    }
  });
}
 
Example 6
Source Project: nexus-public   Source File: FileBlobStore.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Inject
public FileBlobStore(final BlobIdLocationResolver blobIdLocationResolver,
                     final FileOperations fileOperations,
                     final ApplicationDirectories applicationDirectories,
                     final FileBlobStoreMetricsStore metricsStore,
                     final NodeAccess nodeAccess,
                     final DryRunPrefix dryRunPrefix)
{
  super(blobIdLocationResolver, dryRunPrefix);
  this.fileOperations = checkNotNull(fileOperations);
  this.applicationDirectories = checkNotNull(applicationDirectories);
  this.metricsStore = checkNotNull(metricsStore);
  this.nodeAccess = checkNotNull(nodeAccess);
  this.supportsHardLinkCopy = true;
  this.supportsAtomicMove = true;
}
 
Example 7
Source Project: nexus-public   Source File: ScriptTaskDescriptor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Inject
public ScriptTaskDescriptor(final NodeAccess nodeAccess, @Named("${nexus.scripts.allowCreation:-false}") boolean allowCreation) {
  super(TYPE_ID,
      ScriptTask.class,
      messages.name(),
      VISIBLE,
      isExposed(allowCreation),
      new StringTextFormField(
          LANGUAGE,
          messages.languageLabel(),
          messages.languageHelpText(),
          FormField.MANDATORY
      ).withInitialValue(ScriptEngineManagerProvider.DEFAULT_LANGUAGE),
      new TextAreaFormField(
          SOURCE,
          messages.sourceLabel(),
          messages.sourceHelpText(),
          FormField.MANDATORY,
          null,
          !allowCreation
      ),
      nodeAccess.isClustered() ? newMultinodeFormField() : null);
}
 
Example 8
Source Project: nexus-public   Source File: QuartzSchedulerSPI.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("squid:S00107") //suppress constructor parameter count
@Inject
public QuartzSchedulerSPI(final EventManager eventManager,
                          final NodeAccess nodeAccess,
                          final Provider<JobStore> jobStoreProvider,
                          final Provider<Scheduler> schedulerProvider,
                          final LastShutdownTimeService lastShutdownTimeService,
                          final DatabaseStatusDelayedExecutor delayedExecutor,
                          @Named("${nexus.quartz.recoverInterruptedJobs:-true}") final boolean recoverInterruptedJobs)
{
  this.eventManager = checkNotNull(eventManager);
  this.nodeAccess = checkNotNull(nodeAccess);
  this.jobStoreProvider = checkNotNull(jobStoreProvider);
  this.schedulerProvider = checkNotNull(schedulerProvider);
  this.lastShutdownTimeService = checkNotNull(lastShutdownTimeService);
  this.recoverInterruptedJobs = recoverInterruptedJobs;
  this.delayedExecutor = checkNotNull(delayedExecutor);

  this.scheduleFactory = new QuartzScheduleFactory();
  this.triggerConverter = new QuartzTriggerConverter(this.scheduleFactory);

  // FIXME: sort out with refinement to lifecycle below
  this.active = true;
}
 
Example 9
Source Project: nexus-public   Source File: BlobStoreManagerImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Inject
public BlobStoreManagerImpl(final EventManager eventManager, //NOSONAR
                            final BlobStoreConfigurationStore store,
                            final Map<String, BlobStoreDescriptor> blobStoreDescriptors,
                            final Map<String, Provider<BlobStore>> blobStorePrototypes,
                            final FreezeService freezeService,
                            final Provider<RepositoryManager> repositoryManagerProvider,
                            final NodeAccess nodeAccess,
                            @Nullable @Named("${nexus.blobstore.provisionDefaults}") final Boolean provisionDefaults)
{
  this.eventManager = checkNotNull(eventManager);
  this.store = checkNotNull(store);
  this.blobStoreDescriptors = checkNotNull(blobStoreDescriptors);
  this.blobStorePrototypes = checkNotNull(blobStorePrototypes);
  this.freezeService = checkNotNull(freezeService);
  this.repositoryManagerProvider = checkNotNull(repositoryManagerProvider);

  if (provisionDefaults != null) {
    // explicit true/false setting, so honour that
    this.provisionDefaults = provisionDefaults::booleanValue;
  }
  else {
    // otherwise only create in non-clustered mode
    this.provisionDefaults = () -> !nodeAccess.isClustered();
  }
}
 
Example 10
@Inject
public GoogleCloudBlobStoreMetricsStore(final PeriodicJobService jobService,
                                        final NodeAccess nodeAccess,
                                        final BlobStoreQuotaService quotaService,
                                        @Named("${nexus.blobstore.quota.warnIntervalSeconds:-60}")
                                        final int quotaCheckInterval)
{
  super(nodeAccess, jobService, quotaService, quotaCheckInterval);
}
 
Example 11
@Inject
public P2RestoreBlobStrategy(final NodeAccess nodeAccess,
                             final RepositoryManager repositoryManager,
                             final BlobStoreManager blobStoreManager,
                             final DryRunPrefix dryRunPrefix)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
}
 
Example 12
@Inject
public HelmRestoreBlobStrategy(final NodeAccess nodeAccess,
                               final RepositoryManager repositoryManager,
                               final BlobStoreManager blobStoreManager,
                               final DryRunPrefix dryRunPrefix)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
}
 
Example 13
@Inject
public RRestoreBlobStrategy(final NodeAccess nodeAccess,
                            final RepositoryManager repositoryManager,
                            final BlobStoreManager blobStoreManager,
                            final DryRunPrefix dryRunPrefix)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
}
 
Example 14
@Inject
public AptRestoreBlobStrategy(final NodeAccess nodeAccess,
                              final RepositoryManager repositoryManager,
                              final BlobStoreManager blobStoreManager,
                              final DryRunPrefix dryRunPrefix)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
}
 
Example 15
@Inject
public S3BlobStoreMetricsStore(final PeriodicJobService jobService,
                               final NodeAccess nodeAccess,
                               final BlobStoreQuotaService quotaService,
                               @Named("${nexus.blobstore.quota.warnIntervalSeconds:-60}")
                               final int quotaCheckInterval)
{
  super(nodeAccess, jobService, quotaService, quotaCheckInterval);
}
 
Example 16
@Inject
public RawRestoreBlobStrategy(final NodeAccess nodeAccess,
                              final RepositoryManager repositoryManager,
                              final BlobStoreManager blobStoreManager,
                              final DryRunPrefix dryRunPrefix)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
}
 
Example 17
@Inject
public NpmRestoreBlobStrategy(final NodeAccess nodeAccess,
                              final RepositoryManager repositoryManager,
                              final BlobStoreManager blobStoreManager,
                              final DryRunPrefix dryRunPrefix,
                              final NpmRepairPackageRootComponent npmRepairPackageRootComponent)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
  this.npmRepairPackageRootComponent = checkNotNull(npmRepairPackageRootComponent);
}
 
Example 18
@Inject
public OrientPyPiRestoreBlobStrategy(final NodeAccess nodeAccess,
                                     final RepositoryManager repositoryManager,
                                     final BlobStoreManager blobStoreManager,
                                     final DryRunPrefix dryRunPrefix,
                                     final OrientPyPiRepairIndexComponent pyPiRepairIndexComponent,
                                     final PyPiRestoreBlobDataFactory pyPiRestoreBlobDataFactory)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
  this.pyPiRepairIndexComponent = pyPiRepairIndexComponent;
  this.pyPiRestoreBlobDataFactory = pyPiRestoreBlobDataFactory;
}
 
Example 19
Source Project: nexus-public   Source File: AuditRecorderImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public AuditRecorderImpl(final EventManager eventManager,
                         final NodeAccess nodeAccess,
                         final InitiatorProvider initiatorProvider)
{
  this.eventManager = eventManager;
  this.nodeAccess = nodeAccess;
  this.initiatorProvider = initiatorProvider;
}
 
Example 20
public BaseRestoreBlobStrategy(final NodeAccess nodeAccess,
                               final RepositoryManager repositoryManager,
                               final BlobStoreManager blobStoreManager,
                               final DryRunPrefix dryRunPrefix)
{
  this.nodeAccess = checkNotNull(nodeAccess);
  this.repositoryManager = checkNotNull(repositoryManager);
  this.blobStoreManager = checkNotNull(blobStoreManager);
  this.dryRunPrefix = checkNotNull(dryRunPrefix);
}
 
Example 21
@Inject
public MavenRestoreBlobStrategy(
    final MavenPathParser mavenPathParser,
    final NodeAccess nodeAccess,
    final RepositoryManager repositoryManager,
    final BlobStoreManager blobStoreManager,
    final DryRunPrefix dryRunPrefix)
{
  super(nodeAccess, repositoryManager, blobStoreManager, dryRunPrefix);
  this.mavenPathParser = checkNotNull(mavenPathParser);
}
 
Example 22
@Inject
public OrientStatusHealthCheckStore(
    @Named(DatabaseInstanceNames.COMPONENT) final Provider<DatabaseInstance> databaseInstance,
    final OrientStatusHealthCheckEntityAdapter entityAdapter,
    final NodeAccess nodeAccess)
{
  this.databaseInstance = checkNotNull(databaseInstance);
  this.entityAdapter = checkNotNull(entityAdapter);
  this.nodeAccess = checkNotNull(nodeAccess);
}
 
Example 23
Source Project: nexus-public   Source File: NodeProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public NodeProvider(final ApplicationDirectories directories,
                    final NodeAccess nodeAccess,
                    @Nullable @Named("${nexus.elasticsearch.plugins}") final String plugins,
                    @Nullable final List<PluginLocator> pluginLocators)
{
  this.directories = checkNotNull(directories);
  this.nodeAccess = checkNotNull(nodeAccess);
  this.plugins = plugins == null ? new ArrayList<>() : Splitter.on(",").splitToList(plugins);
  this.pluginLocators = pluginLocators == null ? Collections.emptyList() : pluginLocators;
}
 
Example 24
@Inject
public RuntimeCacheManagerProvider(final Map<String, Provider<CacheManager>> providers,
                                   @Nullable @Named("${nexus.cache.provider}") final String customName,
                                   final NodeAccess nodeAccess)
{
  this.providers = checkNotNull(providers);
  this.name = customName != null ? customName : (nodeAccess.isClustered() ? "hazelcast" : "ehcache");
  checkArgument(!"default".equals(name));
  log.info("Cache-provider: {}", name);
  checkState(providers.containsKey(name), "Missing cache-provider: %s", name);
}
 
Example 25
@Inject
public DefaultCacheBuilderProvider(final Map<String, Provider<CacheBuilder>> providers,
                                   @Nullable @Named("${nexus.cache.provider}") final String customName,
                                   final NodeAccess nodeAccess)
{
  this.providers = checkNotNull(providers);
  this.name = customName != null ? customName : (nodeAccess.isClustered() ? "hazelcast" : "ehcache");
  checkArgument(!"default".equals(name));
  checkState(providers.containsKey(name), "Missing cache-builder: %s", name);
}
 
Example 26
Source Project: nexus-public   Source File: IndexRebuildManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public IndexRebuildManager(final NodeAccess nodeAccess,
                           final TaskScheduler taskScheduler,
                           @Named("${nexus.elasticsearch.autoRebuild:-true}") final boolean autoRebuild)
{
  this.nodeAccess = checkNotNull(nodeAccess);
  this.taskScheduler = checkNotNull(taskScheduler);
  this.autoRebuild = autoRebuild;
}
 
Example 27
Source Project: nexus-public   Source File: PrefetchedAssetBlob.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public PrefetchedAssetBlob(final NodeAccess nodeAccess,
                           final BlobStore blobStore,
                           final Blob blob,
                           final String contentType,
                           final Map<HashAlgorithm, HashCode> hashes,
                           final boolean hashesVerified)
{
  super(nodeAccess, blobStore, store -> blob, contentType, hashes, hashesVerified);
  /*
   * Pre-fetched blobs are stored in the blob-store but when a duplicate is encountered it is not used meaning it needs
   * to be cleaned up. Because it hasn't been ingested the cleanup fails on BlobTx.commit, this method ingests the blob
   * to ensure that it is correctly deleted. We use this class so that we don't eagerly ingest ALL blobs.
   */
  getBlob();
}
 
Example 28
Source Project: nexus-public   Source File: StorageFacetImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public StorageFacetImpl(final NodeAccess nodeAccess,
                        final BlobStoreManager blobStoreManager,
                        @Named(ComponentDatabase.NAME) final Provider<DatabaseInstance> databaseInstanceProvider,
                        final BucketEntityAdapter bucketEntityAdapter,
                        final ComponentEntityAdapter componentEntityAdapter,
                        final AssetEntityAdapter assetEntityAdapter,
                        final ClientInfoProvider clientInfoProvider,
                        final ContentValidatorSelector contentValidatorSelector,
                        final MimeRulesSourceSelector mimeRulesSourceSelector,
                        final StorageFacetManager storageFacetManager,
                        final ComponentFactory componentFactory,
                        final ConstraintViolationFactory constraintViolationFactory)
{
  this.nodeAccess = checkNotNull(nodeAccess);
  this.blobStoreManager = checkNotNull(blobStoreManager);
  this.databaseInstanceProvider = checkNotNull(databaseInstanceProvider);

  this.bucketEntityAdapter = checkNotNull(bucketEntityAdapter);
  this.componentEntityAdapter = checkNotNull(componentEntityAdapter);
  this.assetEntityAdapter = checkNotNull(assetEntityAdapter);
  this.clientInfoProvider = checkNotNull(clientInfoProvider);
  this.contentValidatorSelector = checkNotNull(contentValidatorSelector);
  this.mimeRulesSourceSelector = checkNotNull(mimeRulesSourceSelector);
  this.storageFacetManager = checkNotNull(storageFacetManager);
  this.componentFactory = checkNotNull(componentFactory);
  this.constraintViolationFactory = checkNotNull(constraintViolationFactory);

  this.txSupplier = () -> openStorageTx(databaseInstanceProvider.get().acquire());
}
 
Example 29
@Inject
public RebuildAssetUploadMetadataTaskDescriptor(final NodeAccess nodeAccess,
                                                final RebuildAssetUploadMetadataConfiguration configuration) {
  super(
      TYPE_ID,
      RebuildAssetUploadMetadataTask.class,
      "Repair - Reconcile date metadata from blob store",
      configuration.isEnabled() ? VISIBLE : NOT_VISIBLE,
      configuration.isEnabled() ? EXPOSED : NOT_EXPOSED,
      nodeAccess.isClustered() ? newLimitNodeFormField() : null);
}
 
Example 30
Source Project: nexus-public   Source File: AssetBlob.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public AssetBlob(final NodeAccess nodeAccess,
                 final BlobStore blobStore,
                 final Function<BlobStore, Blob> blobFunction,
                 final String contentType,
                 final Map<HashAlgorithm, HashCode> hashes,
                 final boolean hashesVerified)
{
  this.nodeAccess = checkNotNull(nodeAccess);
  this.blobStore = checkNotNull(blobStore);
  this.blobFunction = checkNotNull(blobFunction);
  this.contentType = checkNotNull(contentType);
  this.hashes = checkNotNull(hashes);
  this.hashesVerified = hashesVerified;
}