01: package com.bostechcorp.cbesb.common.util.project;
02:
03: import java.io.File;
04:
05: import com.bostechcorp.cbesb.common.util.EsbPathHelper;
06:
07: public class ProjectRuntimeUtil {
08: public static boolean isESBProj(String projName) {
09:
10: String esbProj = getDependentESBProjName(projName);
11: if (esbProj.equalsIgnoreCase(projName)) {
12: return true;
13: }
14: return false;
15: }
16:
17: public static String getDependentESBProjName(String projName) {
18:
19: return getDependentESBProjNameByLoaction(getProjectLocationByName(projName));
20: }
21:
22: public static String getDependentESBProjNameByLoaction(
23: String projLocation) {
24:
25: return getDependentESBProjNameByInfoFile(projLocation
26: + File.separator + "projectinfo.xml");
27: }
28:
29: public static String getDependentESBProjNameByInfoFile(
30: String projInfoFile) {
31: File file = new File(projInfoFile);
32: // System.out.println("projectInfo:"+file.getAbsolutePath());
33: if (file.exists()) {
34: ProjectInfoDocument doc = ProjectInfoParser.load(file);
35: if (doc.getProject().getType().equals("ESB")) {
36: // System.out.println("Workspace:"+ResourcesPlugin.getWorkspace().getRoot().getLocation().toString());
37: return doc.getProject().getName();
38: } else {
39: return doc.getProject().getAllSubProjects()[0]
40: .getName();
41: }
42: }
43: return "";
44: }
45:
46: public static String getProjectLocationByName(String projName) {
47:
48: return EsbPathHelper.getCbesbUiWorkSpace() + File.separator
49: + projName;
50: }
51:
52: public static String getProjectNameFromFilePath(String filePath) {
53:
54: String ws = EsbPathHelper.getCbesbUiWorkSpace();
55: if (filePath.toLowerCase().startsWith(ws.toLowerCase())) {
56: return filePath.substring((ws + File.separator).length(),
57: filePath.indexOf(File.separator,
58: (ws + File.separator).length()));
59: }
60: return null;
61: }
62:
63: }
|