author | Ed Swartz <ed.swartz@nokia.com> |
Wed, 08 Sep 2010 17:12:10 -0500 | |
changeset 1965 | 0dd7f79ee65d |
parent 1627 | 769102b0e024 |
permissions | -rw-r--r-- |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
1 |
/* |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
3 |
* All rights reserved. |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
8 |
* |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
9 |
* Initial Contributors: |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
11 |
* |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
12 |
* Contributors: |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
13 |
* |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
14 |
* Description: |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
15 |
* |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
16 |
*/ |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
17 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
18 |
package com.nokia.carbide.installpackages; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
19 |
|
1622 | 20 |
import java.io.BufferedOutputStream; |
21 |
import java.io.ByteArrayInputStream; |
|
22 |
import java.io.File; |
|
23 |
import java.io.FileInputStream; |
|
24 |
import java.io.FileOutputStream; |
|
25 |
import java.io.IOException; |
|
26 |
import java.io.InputStream; |
|
27 |
import java.lang.reflect.InvocationTargetException; |
|
28 |
import java.net.MalformedURLException; |
|
29 |
import java.net.URL; |
|
30 |
import java.util.ArrayList; |
|
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
31 |
import java.util.Arrays; |
1622 | 32 |
import java.util.Collections; |
33 |
import java.util.Comparator; |
|
34 |
import java.util.List; |
|
35 |
import java.util.Properties; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
36 |
|
1622 | 37 |
import org.apache.commons.httpclient.ConnectTimeoutException; |
38 |
import org.apache.commons.httpclient.HttpClient; |
|
39 |
import org.apache.commons.httpclient.UsernamePasswordCredentials; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
40 |
import org.apache.commons.httpclient.auth.AuthScope; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
41 |
import org.apache.commons.httpclient.methods.GetMethod; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
42 |
import org.eclipse.core.net.proxy.IProxyData; |
1622 | 43 |
import org.eclipse.core.runtime.IPath; |
44 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
45 |
import org.eclipse.core.runtime.IStatus; |
|
46 |
import org.eclipse.core.runtime.Path; |
|
47 |
import org.eclipse.core.runtime.Platform; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
48 |
import org.eclipse.emf.common.util.EList; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
49 |
import org.eclipse.emf.common.util.URI; |
1197 | 50 |
import org.eclipse.emf.ecore.EObject; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
51 |
import org.eclipse.emf.ecore.resource.Resource; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
52 |
import org.eclipse.jface.operation.IRunnableContext; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
53 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
54 |
import org.eclipse.osgi.service.datalocation.Location; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
55 |
|
1622 | 56 |
import com.nokia.carbide.installpackages.gen.InstallPackages.DocumentRoot; |
57 |
import com.nokia.carbide.installpackages.gen.InstallPackages.PackageType; |
|
58 |
import com.nokia.carbide.installpackages.gen.InstallPackages.PackagesType; |
|
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
59 |
import com.nokia.carbide.installpackages.gen.InstallPackages.SDKFamilyType; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
60 |
import com.nokia.carbide.installpackages.gen.InstallPackages.SDKVersionType; |
1622 | 61 |
import com.nokia.carbide.installpackages.gen.InstallPackages.util.InstallPackagesResourceFactoryImpl; |
62 |
import com.nokia.carbide.remoteconnections.Messages; |
|
63 |
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
|
64 |
import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider; |
|
65 |
import com.nokia.carbide.remoteconnections.interfaces.IService; |
|
66 |
import com.nokia.cpp.internal.api.utils.core.Check; |
|
67 |
import com.nokia.cpp.internal.api.utils.core.FileUtils; |
|
68 |
import com.nokia.cpp.internal.api.utils.core.ProxyUtils; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
69 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
70 |
/** |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
71 |
* |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
72 |
*/ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
73 |
public class InstallPackages { |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
74 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
75 |
private static final String ORDER_DELIM = ";"; //$NON-NLS-1$ |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
76 |
|
1624 | 77 |
/** |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
78 |
* @deprecated server data completely taken from |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
79 |
* configuration/server.properties |
1624 | 80 |
*/ |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
81 |
public interface IServerData { |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
82 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
83 |
/** |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
84 |
* The file name of the master xml file |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
85 |
* |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
86 |
* @return String |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
87 |
*/ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
88 |
String getMasterFileName(); |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
89 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
90 |
/** |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
91 |
* Return the IRemoteAgentInstallerProvider for this server data |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
92 |
* |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
93 |
* @return IRemoteAgentInstallerProvider |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
94 |
*/ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
95 |
IRemoteAgentInstallerProvider getRemoteAgentInstallerProvider(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
96 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
97 |
|
1622 | 98 |
private final IService service; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
99 |
private List<PackageType> packageList; |
656
4b577b57a028
Use String, not IPath, for URL
Ed Swartz <ed.swartz@nokia.com>
parents:
421
diff
changeset
|
100 |
private String serverPath; |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
101 |
private List<String> sdkFamilyOrder; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
102 |
private List<String> sdkVersionOrder; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
103 |
|
1622 | 104 |
public InstallPackages(IService service, IRunnableContext runnableContext) { |
105 |
Check.checkArg(service); |
|
106 |
this.service = service; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
107 |
if (runnableContext == null) |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
108 |
getPackageList(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
109 |
else { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
110 |
try { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
111 |
runnableContext.run(true, false, new IRunnableWithProgress() { |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
112 |
public void run(IProgressMonitor monitor) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
113 |
throws InvocationTargetException, |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
114 |
InterruptedException { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
115 |
monitor.beginTask( |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
116 |
Messages.getString("InstallPackages.GettingPackagesJobLabel"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
117 |
getPackageList(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
118 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
119 |
}); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
120 |
} catch (Exception e) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
121 |
RemoteConnectionsActivator.logError(e); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
122 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
123 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
124 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
125 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
126 |
private void getPackageList() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
127 |
try { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
128 |
PackagesType packages = getAvailablePackagesFromServer(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
129 |
if (packages != null) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
130 |
EList<PackageType> elist = packages.getPackage(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
131 |
packageList = new ArrayList<PackageType>(elist); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
132 |
Collections.sort(packageList, new Comparator<PackageType>() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
133 |
public int compare(PackageType o1, PackageType o2) { |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
134 |
return o1.getDisplayName().compareToIgnoreCase( |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
135 |
o2.getDisplayName()); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
136 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
137 |
}); |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
138 |
getSDKFamilyOrder(packages); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
139 |
getSDKVersionOrder(packages); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
140 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
141 |
} catch (Exception e) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
142 |
RemoteConnectionsActivator.logError(e); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
143 |
if (e.getCause() instanceof ConnectTimeoutException) |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
144 |
RemoteConnectionsActivator |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
145 |
.logMessage( |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
146 |
Messages.getString("InstallPackages.TimeoutMissingProxyMessage"), IStatus.INFO); //$NON-NLS-1$ |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
147 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
148 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
149 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
150 |
private void getSDKFamilyOrder(PackagesType packages) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
151 |
SDKFamilyType sdkFamily = packages.getSDKFamily(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
152 |
if (sdkFamily != null) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
153 |
String order = sdkFamily.getOrder(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
154 |
sdkFamilyOrder = Arrays.asList(order.split(ORDER_DELIM)); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
155 |
} else |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
156 |
sdkFamilyOrder = Collections.emptyList(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
157 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
158 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
159 |
private void getSDKVersionOrder(PackagesType packages) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
160 |
SDKVersionType sdkVersion = packages.getSDKVersion(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
161 |
if (sdkVersion != null) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
162 |
String order = sdkVersion.getOrder(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
163 |
sdkVersionOrder = Arrays.asList(order.split(ORDER_DELIM)); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
164 |
} else |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
165 |
sdkVersionOrder = Collections.emptyList(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
166 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
167 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
168 |
public Comparator<String> getSDKFamilyComparator() { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
169 |
return getOrderListStringComparator(sdkFamilyOrder); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
170 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
171 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
172 |
public Comparator<String> getSDKVersionComparator() { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
173 |
if (sdkVersionOrder.isEmpty()) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
174 |
return Collections.reverseOrder(); // for backward compatibility |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
175 |
return getOrderListStringComparator(sdkVersionOrder); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
176 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
177 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
178 |
private static Comparator<String> getOrderListStringComparator( |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
179 |
final List<String> orderList) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
180 |
return new Comparator<String>() { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
181 |
public int compare(String o1, String o2) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
182 |
if (o1.equals(o2)) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
183 |
return 0; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
184 |
|
1965
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
185 |
// EJS HACK: I tried using the ';' separator in the sdkFamily but it |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
186 |
// sorted to the bottom and also showed up in the UI...? |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
187 |
if (o1.equals("Symbian")) |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
188 |
return -1; |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
189 |
|
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
190 |
for (String orderString : orderList) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
191 |
if (o1.equals(orderString)) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
192 |
return -1; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
193 |
else if (o2.equals(orderString)) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
194 |
return 1; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
195 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
196 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
197 |
return o1.compareTo(o2); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
198 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
199 |
}; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
200 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
201 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
202 |
public List<PackageType> getAvailablePackageList() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
203 |
return packageList; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
204 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
205 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
206 |
private static PackagesType loadPackages(URL url) throws Exception { |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
207 |
if (url == null) |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
208 |
return null; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
209 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
210 |
URI xmlURI = URI.createURI(url.toString()); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
211 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
212 |
InstallPackagesResourceFactoryImpl factory = new InstallPackagesResourceFactoryImpl(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
213 |
Resource r = factory.createResource(xmlURI); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
214 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
215 |
r.load(null); |
1197 | 216 |
EList<EObject> contents = r.getContents(); |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
217 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
218 |
DocumentRoot root = (DocumentRoot) contents.get(0); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
219 |
PackagesType packages = root.getPackages(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
220 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
221 |
return packages; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
222 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
223 |
|
1965
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
224 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
225 |
private URL getAvailablePackagesURL() throws Exception { |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
226 |
URL url = null; |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
227 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
228 |
// see if the file is local (Ed's hack for testing...) |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
229 |
String masterFilePathStr = getMasterFilePath(); |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
230 |
url = new URL(masterFilePathStr); |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
231 |
if (url.getProtocol().equals("file")) { |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
232 |
return url; |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
233 |
} |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
234 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
235 |
// else, read the file to a local temporary location |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
236 |
GetMethod getMethod = new GetMethod(masterFilePathStr); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
237 |
HttpClient client = new HttpClient(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
238 |
setProxyData(client, getMethod); |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
239 |
client.getHttpConnectionManager().getParams() |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
240 |
.setConnectionTimeout(8000); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
241 |
int serverStatus = 0; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
242 |
byte[] responseBody; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
243 |
try { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
244 |
serverStatus = client.executeMethod(getMethod); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
245 |
responseBody = getMethod.getResponseBody(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
246 |
} catch (Exception e) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
247 |
// could be HttpException or IOException |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
248 |
throw new Exception(e); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
249 |
} finally { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
250 |
getMethod.releaseConnection(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
251 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
252 |
|
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
253 |
// HTTP status codes: 2xx = Success |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
254 |
if (serverStatus >= 200 && serverStatus < 300) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
255 |
File tempDir = FileUtils.getTemporaryDirectory(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
256 |
IPath path = new Path(tempDir.getAbsolutePath()); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
257 |
IPath masterFilePath = path.append(getMasterFileName()); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
258 |
File masterFile = masterFilePath.toFile(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
259 |
if (masterFile.exists()) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
260 |
masterFile.delete(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
261 |
FileOutputStream fos = new FileOutputStream(masterFile); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
262 |
BufferedOutputStream out = new BufferedOutputStream(fos); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
263 |
ByteArrayInputStream in = new ByteArrayInputStream(responseBody); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
264 |
boolean foundOpenBrace = false; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
265 |
int c; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
266 |
while ((c = in.read()) != -1) { |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
267 |
if (c == '<') |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
268 |
foundOpenBrace = true; |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
269 |
if (foundOpenBrace) |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
270 |
out.write(c); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
271 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
272 |
out.close(); |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
273 |
in.close(); |
1965
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
274 |
url = masterFile.toURI().toURL(); |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
275 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
276 |
return url; |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
277 |
} |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
278 |
return null; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
279 |
} |
1965
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
280 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
281 |
private PackagesType getAvailablePackagesFromServer() throws Exception { |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
282 |
URL url = getAvailablePackagesURL(); |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
283 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
284 |
if (url == null) |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
285 |
return null; |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
286 |
|
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
287 |
return loadPackages(url); |
0dd7f79ee65d
Support testing package XML locally
Ed Swartz <ed.swartz@nokia.com>
parents:
1627
diff
changeset
|
288 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
289 |
|
421 | 290 |
private static java.net.URI getURI(GetMethod getMethod) { |
291 |
try { |
|
292 |
return new java.net.URI(getMethod.getURI().toString()); |
|
293 |
} catch (Exception e) { |
|
294 |
RemoteConnectionsActivator.logError(e); |
|
295 |
} |
|
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
296 |
|
421 | 297 |
return null; |
298 |
} |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
299 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
300 |
public static void setProxyData(HttpClient client, GetMethod getMethod) { |
421 | 301 |
java.net.URI uri = getURI(getMethod); |
302 |
if (uri == null) |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
303 |
return; |
421 | 304 |
IProxyData proxyData = ProxyUtils.getProxyData(uri); |
305 |
if (proxyData == null) |
|
306 |
return; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
307 |
String host = proxyData.getHost(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
308 |
int port = proxyData.getPort(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
309 |
client.getHostConfiguration().setProxy(host, port); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
310 |
if (proxyData.isRequiresAuthentication()) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
311 |
String userId = proxyData.getUserId(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
312 |
String password = proxyData.getPassword(); |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
313 |
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials( |
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
314 |
userId, password); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
315 |
AuthScope authScope = new AuthScope(host, port); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
316 |
client.getState().setCredentials(authScope, credentials); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
317 |
getMethod.setDoAuthentication(true); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
318 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
319 |
} |
1627
769102b0e024
add install tree node ordering based on augmented xml data
dadubrow
parents:
1624
diff
changeset
|
320 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
321 |
public String getInstallUrlString(String installFilePath) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
322 |
URL url; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
323 |
try { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
324 |
url = new URL(installFilePath); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
325 |
} catch (MalformedURLException e) { |
1622 | 326 |
StringBuilder sb = new StringBuilder(); |
327 |
sb.append(getMasterFileParentPath()); |
|
328 |
sb.append('/'); |
|
329 |
sb.append(installFilePath); |
|
330 |
return sb.toString(); |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
331 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
332 |
return url.toString(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
333 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
334 |
|
1622 | 335 |
private String getMasterFilePath() { |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
336 |
if (serverPath != null) |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
337 |
return serverPath; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
338 |
Location installLocation = Platform.getInstallLocation(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
339 |
URL url = installLocation.getURL(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
340 |
IPath path = new Path(url.getPath()); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
341 |
path = path.append("configuration/server.properties"); //$NON-NLS-1$ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
342 |
try { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
343 |
File file = path.toFile(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
344 |
InputStream is = new FileInputStream(file); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
345 |
Properties properties = new Properties(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
346 |
properties.load(is); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
347 |
is.close(); |
1622 | 348 |
String key = service.getIdentifier(); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
349 |
String pathStr = (String) properties.get(key); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
350 |
if (pathStr != null) |
656
4b577b57a028
Use String, not IPath, for URL
Ed Swartz <ed.swartz@nokia.com>
parents:
421
diff
changeset
|
351 |
return serverPath = pathStr; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
352 |
} catch (IOException e) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
353 |
RemoteConnectionsActivator.logError(e); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
354 |
} |
656
4b577b57a028
Use String, not IPath, for URL
Ed Swartz <ed.swartz@nokia.com>
parents:
421
diff
changeset
|
355 |
return ""; //$NON-NLS-1$ |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
356 |
} |
1622 | 357 |
|
358 |
private String getMasterFileParentPath() { |
|
359 |
String path = getMasterFilePath(); |
|
360 |
int fileNameLoc = path.lastIndexOf('/'); |
|
361 |
return path.substring(0, fileNameLoc); |
|
362 |
} |
|
363 |
||
364 |
private String getMasterFileName() { |
|
365 |
String path = getMasterFilePath(); |
|
366 |
int fileNameLoc = path.lastIndexOf('/'); |
|
367 |
return path.substring(fileNameLoc + 1); |
|
1197 | 368 |
} |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
369 |
} |