01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.admin.common;
06:
07: /**
08: * This class handles construct/deconstruct backup version number that
09: * is used by the par file.
10: */
11: public class BackupVersion {
12:
13: public static final String DELIMITER = ";";
14: public static final String BACKUP_VERSION = "V1.0";
15:
16: public static String generateBackupVersion(String domain,
17: String portal, String type) {
18:
19: StringBuffer backupVersion = new StringBuffer();
20: backupVersion.append(domain).append(DELIMITER).append(portal)
21: .append(DELIMITER).append(type).append(DELIMITER)
22: .append(BACKUP_VERSION);
23:
24: return backupVersion.toString();
25: }
26:
27: public static String getDomain(String backupVersion) {
28:
29: String domain = null;
30:
31: if (checkBackupVersion(backupVersion)) {
32: domain = backupVersion.substring(0, backupVersion
33: .indexOf(DELIMITER));
34: }
35:
36: return domain;
37: }
38:
39: public static String getPortal(String backupVersion) {
40: String portal = null;
41:
42: if (checkBackupVersion(backupVersion)) {
43: String domain = backupVersion.substring(0, backupVersion
44: .indexOf(DELIMITER));
45:
46: String rem = backupVersion.substring(domain.length() + 1,
47: backupVersion.length());
48:
49: portal = rem.substring(0, rem.indexOf(DELIMITER));
50: }
51:
52: return portal;
53: }
54:
55: public static String getType(String backupVersion) {
56: String type = null;
57: if (checkBackupVersion(backupVersion)) {
58: String str = backupVersion.substring(0, backupVersion
59: .lastIndexOf(DELIMITER));
60:
61: type = str.substring(str.lastIndexOf(DELIMITER) + 1, str
62: .length());
63: }
64: return type;
65: }
66:
67: private static boolean checkBackupVersion(String backupVersion) {
68: boolean valid = true;
69:
70: String version = backupVersion.substring(backupVersion
71: .lastIndexOf(DELIMITER) + 1, backupVersion.length());
72:
73: if (!version.equals(BACKUP_VERSION)) {
74: valid = false;
75: }
76: return valid;
77: }
78: }
|