001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2010 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.tools.dsreplication; 018 019import java.util.Date; 020import java.util.List; 021 022import org.opends.server.backends.task.FailedDependencyAction; 023import org.opends.server.config.ConfigConstants; 024import org.opends.server.protocols.ldap.LDAPAttribute; 025import org.opends.server.tools.tasks.TaskScheduleInformation; 026import org.opends.server.tools.tasks.TaskScheduleUserData; 027import org.opends.server.types.RawAttribute; 028 029/** 030 * This is a simple adaptor to create a task schedule information object 031 * using the data provided by the user. It is used to be able to share some 032 * code with the {@link org.opends.server.tools.tasks.TaskTool} class. 033 */ 034public class PurgeHistoricalScheduleInformation 035implements TaskScheduleInformation 036{ 037 private final PurgeHistoricalUserData uData; 038 private TaskScheduleUserData taskSchedule; 039 040 /** 041 * Default constructor. 042 * @param uData the data provided by the user to do the purge historical. 043 */ 044 public PurgeHistoricalScheduleInformation( 045 PurgeHistoricalUserData uData) 046 { 047 this.uData = uData; 048 this.taskSchedule = uData.getTaskSchedule(); 049 if (taskSchedule == null) 050 { 051 taskSchedule = new TaskScheduleUserData(); 052 } 053 } 054 055 @Override 056 public void addTaskAttributes(List<RawAttribute> attributes) 057 { 058 attributes.add(new LDAPAttribute( 059 ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN, uData.getBaseDNs())); 060 attributes.add(new LDAPAttribute( 061 ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION, 062 Long.toString(uData.getMaximumDuration()))); 063 } 064 065 @Override 066 public List<String> getDependencyIds() 067 { 068 return taskSchedule.getDependencyIds(); 069 } 070 071 @Override 072 public FailedDependencyAction getFailedDependencyAction() 073 { 074 return taskSchedule.getFailedDependencyAction(); 075 } 076 077 @Override 078 public List<String> getNotifyUponCompletionEmailAddresses() 079 { 080 return taskSchedule.getNotifyUponCompletionEmailAddresses(); 081 } 082 083 @Override 084 public List<String> getNotifyUponErrorEmailAddresses() 085 { 086 return taskSchedule.getNotifyUponErrorEmailAddresses(); 087 } 088 089 @Override 090 public String getRecurringDateTime() 091 { 092 return taskSchedule.getRecurringDateTime(); 093 } 094 095 @Override 096 public Date getStartDateTime() 097 { 098 return taskSchedule.getStartDate(); 099 } 100 101 @Override 102 public Class<?> getTaskClass() 103 { 104 return org.opends.server.tasks.PurgeConflictsHistoricalTask.class; 105 } 106 107 @Override 108 public String getTaskId() 109 { 110 return null; 111 } 112 113 @Override 114 public String getTaskObjectclass() 115 { 116 return "ds-task-purge-conflicts-historical"; 117 } 118}