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