blob: 2b7f26379c1d30351a50424fc84a0bb3b33bc808 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*******************************************************************************
* Copyright (c) 2006 Oracle Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Justin Chen
*******************************************************************************/
package org.eclipse.jst.jsf.core.internal.jsflibraryconfig;
import java.util.ArrayList;
import java.util.List;
/**
* To construct implementation library and component libraries from sticky values
* in DialogSettings as saved libraries.
*
* @author Justin Chen - Oracle
* @deprecated
*/
public class JSFLibraryConfigDialogSettingData {
/**
* Delimintor for parsing a persistent property string.
*/
final protected static String SEPARATOR =":"; //$NON-NLS-1$
/**
* Parsing delimnitor for elements in a tuple.
*/
final protected static String SPTR_TUPLE = ":"; //$NON-NLS-1$
/**
* Parsing delimintor for tuples in a persistent property string.
*/
final protected static String EO_TUPLE = ";"; //$NON-NLS-1$
final private JSFLibraryRegistryUtil jsfLibReg;
private String[] savedCompLibs;
private List selJSFLibComp; // lazy initialized
/**
* Constructor where implementation type was chosen to be USER_SPECIFIED. Created for backwards compatibilty when server supplied was not an option.
* @param compLibs
*/
public JSFLibraryConfigDialogSettingData( String[] compLibs) {
this.jsfLibReg = JSFLibraryRegistryUtil.getInstance();
this.savedCompLibs = compLibs;
// Verify and log a message if a saved component library no longer exists.
verifySavedLibAvailability();
}
/**
* Return the list of saved component libraries and their deployment settings.
*
* @return selJSFLibComp List
*/
public List getJSFComponentLibraries() {
if (selJSFLibComp == null) {
selJSFLibComp = new ArrayList();
if (savedCompLibs != null && savedCompLibs.length > 0) {
JSFLibraryInternalReference lib = null;
String item;
String[] attributes;
String id;
boolean deploy = false;
for (int i = 0; i < savedCompLibs.length; i++) {
item = savedCompLibs[i];
attributes = item.split(SEPARATOR);
id = attributes[0];
deploy = Boolean.valueOf(attributes[1]).booleanValue();
lib = jsfLibReg.getJSFLibraryReferencebyID(id);
if (lib != null) {
selJSFLibComp.add(new JSFLibraryInternalReference(lib.getLibrary(), true, deploy));
} /*else {
// already logged if a saved component library is no longer available.
}*/
}
}
}
return selJSFLibComp;
}
/**
* Only need to verify component library availability from sticky settings.
*/
private void verifySavedLibAvailability() {
List validLibs = new ArrayList();
if (savedCompLibs != null && savedCompLibs.length > 0) {
String item = null;
String[] attributes;
boolean invalidRefs = false;
for (int i = 0; i < savedCompLibs.length; i++) {
item = savedCompLibs[i];
attributes = item.split(SEPARATOR);
if (jsfLibReg.getJSFLibraryReferencebyID(attributes[0]) != null) {
validLibs.add(item);
} else {
invalidRefs = true;
// JSFCorePlugin.log(IStatus.INFO, Messages.JSFLibCfgDialogSettingData_Sticky_Component_Lib_Not_Exist);
}
}
if (invalidRefs){
String [] validCompLibs = (String[])validLibs.toArray(new String[validLibs.size()]);
if (validCompLibs.length > 0)
System.arraycopy(validCompLibs, 0, savedCompLibs, 0, validCompLibs.length);
else
savedCompLibs = new String[]{};
}
}
}
}
|