KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > BackupRestoreManager


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.config.backup;
25
26 import com.sun.enterprise.config.backup.util.*;
27 import java.io.*;
28 import java.util.*;
29
30 /**
31  * Baseclass for BackupManager and RestoreManager. Common code between the two goes
32  * in here.
33  * @author Byron Nevins
34  */

35
36 abstract class BackupRestoreManager
37 {
38     public BackupRestoreManager(BackupRequest req) throws BackupException
39     {
40         if(req == null)
41             throw new BackupException("backup-res.InternalError", getClass().getName() + ".ctor: null BackupRequest object");
42         
43         this.request = req;
44         init();
45         LoggerHelper.finest("Request DUMP **********\n" + req);
46     }
47     
48     ///////////////////////////////////////////////////////////////////////////////
49

50     void init() throws BackupException
51     {
52         // only do once!
53
if(wasInitialized)
54             return;
55         
56         if(request == null)
57             throw new BackupException("backup-res.InternalError", "null BackupRequest reference");
58         
59         // add a timestamp
60
request.timestamp = System.currentTimeMillis();
61         
62         if(request.description == null || request.description.length() <= 0)
63             request.description = "" + request.timestamp;
64         // validate domains dir
65
if(request.domainsDir == null || !FileUtils.safeIsDirectory(request.domainsDir))
66             throw new BackupException("backup-res.NoDomainsDir", request.domainsDir);
67         
68         // validate the domain-name
69
if(!StringUtils.ok(request.domainName))
70             throw new BackupException("backup-res.InternalError", "No domain-name was specified");
71
72         request.domainDir = new File(request.domainsDir, request.domainName);
73         
74         LoggerHelper.setLevel(request);
75     }
76
77     ///////////////////////////////////////////////////////////////////////////
78

79     BackupRequest request;
80     private boolean wasInitialized = false;
81 }
82
Popular Tags