Source Code Cross Referenced for EmForgeURLConstructor.java in  » Project-Management » EmForce » ru » emdev » EmForge » wiki » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Project Management » EmForce » ru.emdev.EmForge.wiki 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.wiki;
002:
003:        import java.util.Properties;
004:
005:        import org.apache.commons.lang.StringUtils;
006:        import org.apache.commons.logging.Log;
007:        import org.apache.commons.logging.LogFactory;
008:        import org.emforge.BpmService;
009:        import org.emforge.jbpm.web.bean.TaskController;
010:        import org.emforge.jbpm.web.bean.WorkflowController;
011:        import org.emforge.projectmanager.ProjectService;
012:        import org.emforge.projectmanager.base.MilestoneDO;
013:        import org.emforge.projectmanager.base.ProjectDO;
014:        import org.emforge.projectmanager.web.bean.MilestoneController;
015:        import org.emforge.projectmanager.web.bean.ProjectController;
016:        import org.springframework.context.ApplicationContext;
017:        import org.springframework.context.ApplicationContextAware;
018:
019:        import ru.emdev.EmForge.util.Helper;
020:
021:        import com.ecyrd.jspwiki.WikiContext;
022:        import com.ecyrd.jspwiki.WikiEngine;
023:        import com.ecyrd.jspwiki.plugin.WeblogEntryPlugin;
024:        import com.ecyrd.jspwiki.providers.ProviderException;
025:        import com.ecyrd.jspwiki.url.DefaultURLConstructor;
026:
027:        /** EmForge URL Constructor used ShortURLCOnstructor
028:         * 
029:         * But it also checked, is page related to some project, milestone or process
030:         * If so - it included reference to specified object instead of reference to page
031:         */
032:        public class EmForgeURLConstructor extends DefaultURLConstructor
033:                implements  ApplicationContextAware {
034:            protected final Log logger = LogFactory.getLog(getClass());
035:
036:            private ProjectService m_projectService;
037:            ApplicationContext m_appContext;
038:
039:            public void setApplicationContext(ApplicationContext i_appContext) {
040:                m_appContext = i_appContext;
041:            }
042:
043:            public void setProjectService(ProjectService i_projectService) {
044:                m_projectService = i_projectService;
045:            }
046:
047:            public void initialize(WikiEngine engine, Properties properties) {
048:                super .initialize(engine, properties);
049:            }
050:
051:            /** makes url to page by specified params
052:             * 
053:             * @todo absolute and parameters is not processed yet
054:             * @todo only VIEW, EDIT,INFO,ATTACH is supported
055:             */
056:            public String makeURL(String context, String name,
057:                    boolean absolute, String parameters) {
058:                String url = processLinksToObjects(context, name, absolute,
059:                        parameters);
060:                if (url != null) {
061:                    url = Helper.concatUrl(Helper.getPath(), url);
062:                }
063:
064:                if (url == null) {
065:                    // makes links to the specified wiki-page
066:                    if (StringUtils.equals(context, WikiContext.NONE)
067:                            || StringUtils.equals(context, WikiContext.VIEW)) {
068:                        // check - is it link to the image
069:                        if (StringUtils.contains(name, "images/")) {
070:                            return Helper.concatUrl(Helper.getPath(),
071:                                    "resources/" + name);
072:                        }
073:                        //
074:                        // this is temporary code until it is not implemented own BlogEntry.
075:                        // Currently we use url like this "NewBlogEntry.htm?page=weblogName"
076:                        // to add a blog entry to News
077:                        //
078:                        if (StringUtils.equals(name, "NewBlogEntry.jsp")) {
079:                            // get blog name
080:                            // params shoudl begin from page=
081:                            String blogName = parameters.substring(5);
082:
083:                            WeblogEntryPlugin p = new WeblogEntryPlugin();
084:                            String newEntry = null;
085:                            try {
086:                                newEntry = p
087:                                        .getNewEntryPage(m_engine, blogName);
088:                            } catch (ProviderException ex) {
089:                                logger.error("Cannot generate new blog entry",
090:                                        ex);
091:                            }
092:                            return Helper.concatUrl(Helper.getPath(), "edit/"
093:                                    + newEntry);
094:                        }
095:
096:                        url = "wiki";
097:                    } else if (context.equals(WikiContext.EDIT)) {
098:                        url = "edit";
099:                    } else if (context.equals(WikiContext.INFO)) {
100:                        url = "pageinfo";
101:                    } else if (context.equals(WikiContext.ATTACH)) {
102:                        url = "attach";
103:                    } else if (context.equals(WikiContext.DIFF)) {
104:                        return Helper.concatUrl(Helper.getPath(), "diff.faces?"
105:                                + parameters);
106:                    }
107:
108:                    if (url == null) {
109:                        logger.error("Unknown WikiContext State: " + context);
110:                        return null;
111:                    }
112:
113:                    url = Helper.concatUrl(Helper.getPath(), url + "/" + name);
114:                }
115:
116:                return url;
117:            }
118:
119:            private String processLinksToObjects(String context, String name,
120:                    boolean absolute, String parameters) {
121:                // processing of special string
122:                if (context.equals(WikiContext.VIEW)
123:                        || context.equals(WikiContext.EDIT)) {
124:                    // processing for links to the different objects in the emforge
125:                    // check - is it name of the project?
126:                    if (m_projectService != null) {
127:                        ProjectDO project = m_projectService.getProject(name);
128:
129:                        if (project != null) {
130:                            return ProjectController.PROJECT_PAGE_NAME + "/"
131:                                    + project.getName();
132:                        }
133:                    }
134:
135:                    if (m_projectService != null) {
136:                        // check, is it name of the milestone?
137:                        MilestoneDO milestone = m_projectService
138:                                .getMilestone(name);
139:
140:                        if (milestone != null) {
141:                            /** @todo Place all link generation into one place */
142:                            return ProjectController.PROJECT_PAGE_NAME + "/"
143:                                    + milestone.getProject().getName() + "/"
144:                                    + MilestoneController.MILESTONE_PAGE_NAME
145:                                    + "/" + milestone.getName();
146:                        }
147:                    }
148:
149:                    // check, is it name of the process definition
150:                    // try to get bpm context
151:                    //get repository factory
152:                    BpmService bpmService = null;
153:                    try {
154:                        bpmService = (BpmService) m_appContext
155:                                .getBean("bpmService");
156:                    } catch (Exception ex) {
157:                        // just ignore this exception
158:                    }
159:
160:                    if (bpmService != null && name != null) {
161:                        if (bpmService.hasWorkflow(name,
162:                                BpmService.WORKFLOW_LAST_VERSION)) {
163:                            return WorkflowController.WORKFLOW_PAGE_NAME + "/"
164:                                    + name;
165:                        }
166:
167:                        // check, is it name of the process instance which should be a number
168:                        if (Helper.isNumber(name)) {
169:                            if (bpmService.hasTask(Long.parseLong(name))) {
170:                                return TaskController.TASK_PAGE_NAME + "/"
171:                                        + name;
172:                            }
173:                        }
174:                    }
175:                }
176:
177:                return null;
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.