public static ScheduledTask<YumRepository> createTaskFor(final NexusScheduler nexusScheduler, final GroupRepository groupRepository) { final MergeMetadataTask task = nexusScheduler.createTaskInstance( MergeMetadataTask.class ); task.setGroupRepository(groupRepository); return nexusScheduler.submit(MergeMetadataTask.ID, task); }
private static Set<ScheduledTask<?>> getTasks(final NexusScheduler nexusScheduler, final String taskType) { Set<ScheduledTask<?>> tasks = new HashSet<ScheduledTask<?>>(); Map<String, List<ScheduledTask<?>>> taskMap = nexusScheduler.getAllTasks(); for (List<ScheduledTask<?>> taskList : taskMap.values()) { for (ScheduledTask<?> task : taskList) { if (taskType == null || task.getType().equals(taskType)) { tasks.add(task); } } } return tasks; }
private GenerateMetadataTask createTask() { final GenerateMetadataTask task = nexusScheduler.createTaskInstance(GenerateMetadataTask.class); if (task == null) { throw new IllegalStateException( "Could not create a task fo type " + GenerateMetadataTask.class.getName() ); } return task; }
private ScheduledTask<YumRepository> submitTask(GenerateMetadataTask task) { try { return nexusScheduler.submit(ID, task); } catch (TaskAlreadyScheduledException e) { return mergeAddedFiles(e.getOriginal(), task); } }
/** * Cancel the execution of an existing scheduled task. * * @param scheduledServiceId The scheduled task to cancel. */ @Override @DELETE @ResourceMethodSignature(pathParams = {@PathParam(ScheduledServicePlexusResource.SCHEDULED_SERVICE_ID_KEY)}) public void delete(Context context, Request request, Response response) throws ResourceException { try { getNexusScheduler().getTaskById(getScheduledServiceId(request)).cancelOnly(); response.setStatus(Status.SUCCESS_NO_CONTENT); } catch (NoSuchTaskException e) { response.setStatus(Status.CLIENT_ERROR_NOT_FOUND, "Scheduled service not found!"); } }
getNexusScheduler().schedule(getModelName(serviceResource), nexusTask, schedule); getNexusScheduler().schedule(getModelName(serviceResource), nexusTask, new ManualRunSchedule()); getNexusScheduler().updateSchedule(task);
ScheduledTask<?> task = getNexusScheduler().getTaskById(getScheduledServiceId(request)); TaskState state = task.getTaskState(); if (TaskState.RUNNING.equals(state) || TaskState.CANCELLING.equals(state) getNexusScheduler().updateSchedule(task);
/** * Expire the cache of the selected domain (repository or group). This includes expiring the cache of items in a proxy repository * so the remote will be rechecked on next access, along with clearning the Not Found Cache. */ @Override @DELETE @ResourceMethodSignature( pathParams = { @PathParam( AbstractRestorePlexusResource.DOMAIN ), @PathParam( AbstractRestorePlexusResource.TARGET_ID ) } ) public void delete( Context context, Request request, Response response ) throws ResourceException { ExpireCacheTask task = getNexusScheduler().createTaskInstance( ExpireCacheTask.class ); task.setRepositoryId( getRepositoryId( request ) ); task.setRepositoryGroupId( getRepositoryGroupId( request ) ); task.setResourceStorePath( getResourceStorePath( request ) ); handleDelete( task, request ); }
public void handleDelete(NexusTask<?> task, Request request) throws ResourceException { try { // check reposes if (getRepositoryGroupId(request) != null) { getRepositoryRegistry().getRepositoryWithFacet(getRepositoryGroupId(request), GroupRepository.class); } else if (getRepositoryId(request) != null) { try { getRepositoryRegistry().getRepository(getRepositoryId(request)); } catch (NoSuchRepositoryException e) { getRepositoryRegistry().getRepositoryWithFacet(getRepositoryId(request), ShadowRepository.class); } } getNexusScheduler().submit("Internal", task); throw new ResourceException(Status.SUCCESS_NO_CONTENT); } catch (RejectedExecutionException e) { throw new ResourceException(Status.CLIENT_ERROR_CONFLICT, e.getMessage()); } catch (NoSuchRepositoryException e) { throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage()); } }
/** * Delete an existing scheduled task. * * @param scheduledServiceId The scheduled task to access. */ @Override @DELETE @ResourceMethodSignature(pathParams = {@PathParam(ScheduledServicePlexusResource.SCHEDULED_SERVICE_ID_KEY)}) public void delete(Context context, Request request, Response response) throws ResourceException { try { getNexusScheduler().getTaskById(getScheduledServiceId(request)).cancel(); response.setStatus(Status.SUCCESS_NO_CONTENT); } catch (NoSuchTaskException e) { response.setStatus(Status.CLIENT_ERROR_NOT_FOUND, "Scheduled service not found!"); } }
getNexusScheduler().schedule( getModelName( serviceResource ), nexusTask, schedule ); getNexusScheduler().schedule( getModelName( serviceResource ), nexusTask, new ManualRunSchedule() ); getNexusScheduler().updateSchedule( task );
ScheduledTask<?> task = getNexusScheduler().getTaskById( getScheduledServiceId( request ) ); TaskState state = task.getTaskState(); if ( TaskState.RUNNING.equals( state ) || TaskState.CANCELLING.equals( state ) getNexusScheduler().updateSchedule( task );
private void reindexRepo(Repository repository, boolean full, String taskName) { AbstractNexusRepositoriesPathAwareTask<Object> rt; if (full) { rt = nexusScheduler.createTaskInstance(RepairIndexTask.class); } else { rt = nexusScheduler.createTaskInstance(UpdateIndexTask.class); } rt.setRepositoryId(repository.getId()); nexusScheduler.submit(taskName, rt); }
/** * Expire the cache of the selected domain (repository or group). This includes expiring the cache of items in a * proxy repository * so the remote will be rechecked on next access, along with clearning the Not Found Cache. */ @Override @DELETE @ResourceMethodSignature(pathParams = { @PathParam(AbstractRestorePlexusResource.DOMAIN), @PathParam(AbstractRestorePlexusResource.TARGET_ID) }) public void delete(Context context, Request request, Response response) throws ResourceException { ExpireCacheTask task = getNexusScheduler().createTaskInstance(ExpireCacheTask.class); String repositoryId = getRepositoryId(request); if (repositoryId == null) { repositoryId = getRepositoryGroupId(request); } task.setRepositoryId(repositoryId); task.setResourceStorePath(getResourceStorePath(request)); handleDelete(task, request); }
public void handleDelete(NexusTask<?> task, Request request) throws ResourceException { try { // check reposes if (getRepositoryGroupId(request) != null) { getRepositoryRegistry().getRepositoryWithFacet(getRepositoryGroupId(request), GroupRepository.class); } else if (getRepositoryId(request) != null) { try { getRepositoryRegistry().getRepository(getRepositoryId(request)); } catch (NoSuchRepositoryException e) { getRepositoryRegistry().getRepositoryWithFacet(getRepositoryId(request), ShadowRepository.class); } } getNexusScheduler().submit("Internal", task); throw new ResourceException(Status.SUCCESS_NO_CONTENT); } catch (RejectedExecutionException e) { throw new ResourceException(Status.CLIENT_ERROR_CONFLICT, e.getMessage()); } catch (NoSuchRepositoryException e) { throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e.getMessage()); } }
static ScheduledTask<?> getTaskByName(final NexusScheduler nexusScheduler, final String name) { if (name == null) { return null; } final Map<String, List<ScheduledTask<?>>> taskMap = nexusScheduler.getAllTasks(); for (List<ScheduledTask<?>> taskList : taskMap.values()) { for (ScheduledTask<?> task : taskList) { if (task.getName().equals(name)) { return task; } } } return null; }
/** * Cancel the execution of an existing scheduled task. * * @param scheduledServiceId The scheduled task to cancel. */ @Override @DELETE @ResourceMethodSignature( pathParams = { @PathParam( ScheduledServicePlexusResource.SCHEDULED_SERVICE_ID_KEY ) } ) public void delete( Context context, Request request, Response response ) throws ResourceException { try { getNexusScheduler().getTaskById( getScheduledServiceId( request ) ).cancelOnly(); response.setStatus( Status.SUCCESS_NO_CONTENT ); } catch ( NoSuchTaskException e ) { response.setStatus( Status.CLIENT_ERROR_NOT_FOUND, "Scheduled service not found!" ); } }
/** * Empty the wastebasket. */ @Override @DELETE @ResourceMethodSignature( ) public void delete( Context context, Request request, Response response ) throws ResourceException { EmptyTrashTask task = nexusScheduler.createTaskInstance( EmptyTrashTask.class ); nexusScheduler.submit( "Internal", task ); response.setStatus( Status.SUCCESS_NO_CONTENT ); }
@Override public void delete(Context context, Request request, Response response) throws ResourceException { AbstractNexusRepositoriesPathAwareTask<Object> task; if (getIsFullReindex()) { task = getNexusScheduler().createTaskInstance(RepairIndexTask.class); } else { task = getNexusScheduler().createTaskInstance(UpdateIndexTask.class); } String repositoryId = getRepositoryId(request); if (repositoryId == null) { repositoryId = getRepositoryGroupId(request); } task.setRepositoryId(repositoryId); task.setResourceStorePath(getResourceStorePath(request)); handleDelete(task, request); }
getNexusScheduler().submit( "Internal", task );