Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.ScheduledServiceWeeklyResource


      }
      else if (SCHEDULE_TYPE_DAILY.equals(schedule)) {
        return new ScheduledServiceDailyResource();
      }
      else if (SCHEDULE_TYPE_WEEKLY.equals(schedule)) {
        return new ScheduledServiceWeeklyResource();
      }
      else if (SCHEDULE_TYPE_MONTHLY.equals(schedule)) {
        return new ScheduledServiceMonthlyResource();
      }
      else if (SCHEDULE_TYPE_ADVANCED.equals(schedule)) {
View Full Code Here


  private static ScheduledServiceWeeklyResource scheduledTask;

  @Override
  public ScheduledServiceWeeklyResource getTaskScheduled() {
    if (scheduledTask == null) {
      scheduledTask = new ScheduledServiceWeeklyResource();
      scheduledTask.setEnabled(true);
      scheduledTask.setId(null);
      scheduledTask.setName("taskWeekly");
      scheduledTask.setSchedule("weekly");
      // A future date
View Full Code Here

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setRecurringTime(formatTime(taskSchedule.getStartDate()));
    }
    else if (WeeklySchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceWeeklyResource();

      WeeklySchedule taskSchedule = (WeeklySchedule) task.getSchedule();
      ScheduledServiceWeeklyResource res = (ScheduledServiceWeeklyResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setRecurringTime(formatTime(taskSchedule.getStartDate()));
      res.setRecurringDay(formatRecurringDayOfWeek(taskSchedule.getDaysToRun()));
    }
    else if (MonthlySchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceMonthlyResource();

      MonthlySchedule taskSchedule = (MonthlySchedule) task.getSchedule();
      ScheduledServiceMonthlyResource res = (ScheduledServiceMonthlyResource) resource;

      res.setStartDate(formatDate(taskSchedule.getStartDate()));
      res.setRecurringTime(formatTime(taskSchedule.getStartDate()));
      res.setRecurringDay(formatRecurringDayOfMonth(taskSchedule.getDaysToRun()));
    }
    else if (CronSchedule.class.isAssignableFrom(task.getSchedule().getClass())) {
      resource = new ScheduledServiceAdvancedResource();

      CronSchedule taskSchedule = (CronSchedule) task.getSchedule();
      ScheduledServiceAdvancedResource res = (ScheduledServiceAdvancedResource) resource;

      res.setCronCommand(taskSchedule.getCronString());
    }

    if (resource != null) {
      resource.setId(task.getId());
      resource.setEnabled(task.isEnabled());
View Full Code Here

    this.validateXmlHasNoPackageNames(resourceResponse);
  }

  @Test
  public void testScheduledServiceWeeklyResource() {
    ScheduledServiceWeeklyResource resource = new ScheduledServiceWeeklyResource();
    resource.setId("Id");
    resource.setSchedule("weekly");
    resource.setTypeId("TypeId");
    resource.setAlertEmail("foo@bar.org");
    resource.setName("Name");
    resource.setEnabled(true);
    resource.setRecurringTime("recurringTime");
    resource.addRecurringDay("recurringDay1");
    resource.addRecurringDay("recurringDay2");

    ScheduledServicePropertyResource prop1 = new ScheduledServicePropertyResource();
    prop1.setKey("id1");
    prop1.setValue("value1");
    resource.addProperty(prop1);

    ScheduledServicePropertyResource prop2 = new ScheduledServicePropertyResource();
    prop2.setKey("id2");
    prop2.setValue("value2");
    resource.addProperty(prop2);

    ScheduledServiceResourceResponse resourceResponse = new ScheduledServiceResourceResponse();
    resourceResponse.setData(resource);

    this.marshalUnmarchalThenCompare(resourceResponse);
View Full Code Here

    this.marshalUnmarchalThenCompare(resourceResponse);
    this.validateXmlHasNoPackageNames(resourceResponse);
  }

  public void onHold() {
    ScheduledServiceWeeklyResource scheduledTask = new ScheduledServiceWeeklyResource();
    scheduledTask.setSchedule("weekly");
    scheduledTask.setEnabled(true);
    scheduledTask.setId(null);
    scheduledTask.setName("taskOnce");
    // A future date
    Date startDate = DateUtils.addDays(new Date(), 10);
    startDate = DateUtils.round(startDate, Calendar.DAY_OF_MONTH);
    scheduledTask.setStartDate(String.valueOf(startDate.getTime()));
    scheduledTask.setRecurringTime("03:30");

    // scheduledTask.setRecurringDay( Arrays.asList( new String[] { "monday", "wednesday", "friday" } ) );
    scheduledTask.addRecurringDay("monday");
    scheduledTask.addRecurringDay("wednesday");
    scheduledTask.addRecurringDay("friday");

    scheduledTask.setTypeId("org.sonatype.nexus.tasks.RepairIndexTask");
    scheduledTask.setAlertEmail("foo@bar.org");

    ScheduledServicePropertyResource prop = new ScheduledServicePropertyResource();
    prop.setKey("repositoryId");
    prop.setValue("all_repo");
    scheduledTask.addProperty(prop);

    ScheduledServiceResourceResponse resourceResponse = new ScheduledServiceResourceResponse();
    resourceResponse.setData(scheduledTask);

    // System.out.println( "xml:\n"+ this.xstreamXML.toXML( resourceResponse ) );
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.ScheduledServiceWeeklyResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.