~ubuntu-branches/ubuntu/wily/389-ds-console/wily-proposed

« back to all changes in this revision

Viewing changes to src/com/netscape/admin/dirserv/task/Backup.java

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-03-15 19:58:37 UTC
  • Revision ID: package-import@ubuntu.com-20120315195837-296zyft51thld8q7
Tags: upstream-1.2.6
ImportĀ upstreamĀ versionĀ 1.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** BEGIN COPYRIGHT BLOCK
 
2
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 
3
 * Copyright (C) 2005 Red Hat, Inc.
 
4
 * All rights reserved.
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation version 2 of the License.
 
9
 * 
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 * 
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 * END COPYRIGHT BLOCK **/
 
19
 
 
20
package com.netscape.admin.dirserv.task;
 
21
 
 
22
import java.util.Hashtable;
 
23
import javax.swing.JFrame;
 
24
import com.netscape.management.client.IPage;
 
25
import com.netscape.management.client.console.ConsoleInfo;
 
26
import com.netscape.admin.dirserv.panel.BackupPanel;
 
27
import com.netscape.admin.dirserv.panel.SimpleDialog;
 
28
import com.netscape.admin.dirserv.DSUtil;
 
29
import com.netscape.admin.dirserv.IDSModel;
 
30
import com.netscape.admin.dirserv.ExportImportProgressDialog;
 
31
import com.netscape.management.client.util.Debug;
 
32
import com.netscape.management.client.TaskObject;
 
33
import com.netscape.management.client.util.ModalDialogUtil;
 
34
import com.netscape.admin.dirserv.panel.SimpleDialog;
 
35
import netscape.ldap.*;
 
36
 
 
37
/**
 
38
 *      Netscape Admin Server 4.0 task for backing up the directory server.
 
39
 *
 
40
 * @author  jvergara
 
41
 * @version %I%, %G%
 
42
 * @date                28/03/2000
 
43
 * @see     com.netscape.admin.dirserv.DSAdmin
 
44
 * @see     com.netscape.admin.dirserv.task.CGITask
 
45
 */
 
46
public class Backup extends TaskObject {
 
47
        /**
 
48
         *      Constructor for the Start Directory Task
 
49
         */
 
50
        public Backup() {
 
51
                super();
 
52
                setName(DSUtil._resource.getString("dirtask","Backup"));
 
53
                setDescription(DSUtil._resource.getString(
 
54
                        "dirtask","backup-description"));
 
55
        }
 
56
        
 
57
        /**
 
58
         * Send an http request to the server and then popup a dialog if the
 
59
         * operation is successful.
 
60
         *
 
61
         * @param viewInstance The calling page
 
62
         * @param cmd Command to execute
 
63
         */
 
64
 
 
65
        public boolean run(IPage viewInstance) {
 
66
                backup(viewInstance);
 
67
                return true;
 
68
        }
 
69
 
 
70
        public boolean run(IPage viewInstance, String cmd) {
 
71
                backup(viewInstance);
 
72
                return true;
 
73
        }
 
74
 
 
75
        private void backup(IPage viewInstance) {               
 
76
                /* Do it as a dialog */
 
77
                JFrame frame = viewInstance.getFramework().getJFrame();
 
78
                IDSModel model =
 
79
                        (IDSModel)getConsoleInfo().get( "dsresmodel" );
 
80
                
 
81
                BackupPanel child = new BackupPanel( model );
 
82
                SimpleDialog dlg = new SimpleDialog( frame,
 
83
                                                                                         child.getTitle(),
 
84
                                                                                         SimpleDialog.OK |
 
85
                                                                                         SimpleDialog.CANCEL |
 
86
                                                                                         SimpleDialog.HELP,
 
87
                                                                                         child );
 
88
                dlg.setComponent( child );
 
89
                dlg.setDefaultButton( SimpleDialog.OK );
 
90
                ModalDialogUtil.setWindowLocation(dlg);
 
91
                dlg.getAccessibleContext().setAccessibleDescription(DSUtil._resource.getString(
 
92
                                                                                                                                                                           "dirtask","backup-description"));
 
93
                dlg.packAndShow();
 
94
                if ( dlg.isCancel() )
 
95
                        return;
 
96
                else {
 
97
                        String fileName = child.getFilename();
 
98
                        
 
99
                        String databaseType = LDBM_DATABASE;
 
100
 
 
101
                        Hashtable attributes = new Hashtable();
 
102
                        attributes.put(LDAPBackup.ARCHIVE_DIR, new LDAPAttribute(LDAPBackup.ARCHIVE_DIR, fileName));
 
103
                        attributes.put(LDAPBackup.DATABASE_TYPE, new LDAPAttribute(LDAPBackup.DATABASE_TYPE, databaseType));
 
104
                
 
105
                        LDAPBackup task = new LDAPBackup(model, attributes);
 
106
                }
 
107
        }
 
108
        final String LDBM_DATABASE = "ldbm database";
 
109
}