01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: *
22: * $Id:$
23: */
24: package com.bostechcorp.cbesb.ui.util.ucm;
25:
26: import java.util.List;
27:
28: import org.eclipse.core.internal.resources.Project;
29: import org.eclipse.core.resources.ResourcesPlugin;
30:
31: import com.bostechcorp.cbesb.ui.util.ProjectUtil;
32:
33: public class UCMClassUtil {
34:
35: public static String getClassDescription(Object parentClass,
36: String projectName, String className) {
37: String projectLocation = ResourcesPlugin.getWorkspace()
38: .getRoot().getProject(projectName).getLocation()
39: .toString();
40: List projectList = ProjectUtil.getRelatedProject(projectName);
41: UcmClassLoader ucmClassLoader = null;
42: String description = "";
43: try {
44: ucmClassLoader = UcmClassLoader.getInstance(
45: UcmClassURLHelper.getURL(projectName,
46: projectLocation), parentClass.getClass()
47: .getClassLoader(), projectName,
48: projectLocation);
49: description = ucmClassLoader.getClassDescription(className);
50:
51: } catch (Exception e) {
52:
53: if (projectList.size() != 1) {
54: String parentProjectName = ((Project) projectList
55: .get(1)).getName();
56: String parentProjectLocation = ResourcesPlugin
57: .getWorkspace().getRoot().getProject(
58: parentProjectName).getLocation()
59: .toString();
60: try {
61: ucmClassLoader = UcmClassLoader.getInstance(
62: UcmClassURLHelper.getURL(parentProjectName,
63: parentProjectLocation), parentClass
64: .getClass().getClassLoader(),
65: parentProjectName, parentProjectLocation);
66: description = ucmClassLoader
67: .getClassDescription(className);
68: } catch (Exception e1) {
69:
70: e1.printStackTrace();
71: }
72: }
73: e.printStackTrace();
74:
75: }
76: // should release the sa url
77: UcmClassURLHelper.clearSaPath(projectName);
78:
79: if (!description.equals("")) {
80: return description;
81: } else
82: return className;
83: }
84:
85: public static String handleEntryName(String entryName) {
86: String name = entryName
87: .substring(0, entryName.lastIndexOf('.'));
88: name = name.replace('/', '.');
89: return name;
90: }
91:
92: public static String restoreEntryName(String name) {
93: String entryName = name.replace('.', '/');
94: entryName += ".class";
95: return entryName;
96: }
97: }
|