Source Code Cross Referenced for VFSMessageBuilder.java in  » Content-Management-System » harmonise » org » openharmonise » him » window » messages » builders » 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 » Content Management System » harmonise » org.openharmonise.him.window.messages.builders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.him.window.messages.builders;
020:
021:        import java.util.ArrayList;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:        import java.util.List;
025:
026:        import org.openharmonise.him.actions.dir.*;
027:        import org.openharmonise.him.actions.file.*;
028:        import org.openharmonise.him.actions.move.*;
029:        import org.openharmonise.him.actions.publish.*;
030:        import org.openharmonise.him.actions.system.*;
031:        import org.openharmonise.him.harmonise.*;
032:        import org.openharmonise.him.window.messages.*;
033:        import org.openharmonise.vfs.status.*;
034:        import org.openharmonise.webdav.client.*;
035:
036:        /**
037:         * 
038:         * @author Matthew Large
039:         * @version $Revision: 1.1 $
040:         *
041:         */
042:        public class VFSMessageBuilder extends AbstractMessageBuilder implements 
043:                MessageBuilder {
044:
045:            private static MessageBuilder m_instance = null;
046:
047:            private HashMap m_statusStatementMapping = new HashMap();
048:
049:            /**
050:             * 
051:             */
052:            private VFSMessageBuilder() {
053:                super ();
054:                this .setup();
055:            }
056:
057:            private void setup() {
058:                // Action Statements
059:                ActionStatement actionStatement = new ActionStatement();
060:                actionStatement
061:                        .setKnownResourceOK("You have successfully ordered %NAME%.");
062:                actionStatement
063:                        .setUnknownResourceOK("You have successfully ordered this collection.");
064:                actionStatement
065:                        .setKnownResourceERROR("There was a problem ordering %NAME%.");
066:                actionStatement
067:                        .setUnknownResourceERROR("There was a problem ordering this collection.");
068:                super .addActionStatementMapping(ActionOrder.ACTION_NAME,
069:                        actionStatement);
070:
071:                actionStatement = new ActionStatement();
072:                actionStatement
073:                        .setKnownResourceOK("You have successfully created a copy of %NAME%.");
074:                actionStatement
075:                        .setUnknownResourceOK("You have successfully created a copy of this resource.");
076:                actionStatement
077:                        .setKnownResourceERROR("There was a problem creating a copy of %NAME%.");
078:                actionStatement
079:                        .setUnknownResourceERROR("There was a problem creating a copy of this resource.");
080:                super .addActionStatementMapping(ActionCreateCopy.ACTION_NAME,
081:                        actionStatement);
082:
083:                actionStatement = new ActionStatement();
084:                actionStatement
085:                        .setKnownResourceOK("You have successfully locked %NAME%.");
086:                actionStatement
087:                        .setUnknownResourceOK("You have successfully locked this resource.");
088:                actionStatement
089:                        .setKnownResourceERROR("There was a problem locking %NAME%, it is locked by %DESTINATION%.");
090:                actionStatement
091:                        .setUnknownResourceERROR("There was a problem locking this resource.");
092:                super .addActionStatementMapping(ActionLock.ACTION_NAME,
093:                        actionStatement);
094:
095:                actionStatement = new ActionStatement();
096:                actionStatement
097:                        .setKnownResourceOK("You have successfully created the collection %NAME%.");
098:                actionStatement
099:                        .setUnknownResourceOK("You have successfully created a new collection.");
100:                actionStatement
101:                        .setKnownResourceERROR("There was a problem creating the collection %NAME%.");
102:                actionStatement
103:                        .setUnknownResourceERROR("There was a problem creating this new collection.");
104:                super .addActionStatementMapping(
105:                        ActionNewCollection.ACTION_NAME, actionStatement);
106:
107:                actionStatement = new ActionStatement();
108:                actionStatement
109:                        .setKnownResourceOK("You have successfully created the resource %NAME%.");
110:                actionStatement
111:                        .setUnknownResourceOK("You have successfully created a new resource.");
112:                actionStatement
113:                        .setKnownResourceERROR("There was a problem creating the resource %NAME%.");
114:                actionStatement
115:                        .setUnknownResourceERROR("There was a problem creating this new resource.");
116:                super .addActionStatementMapping(ActionNewFile.ACTION_NAME,
117:                        actionStatement);
118:
119:                actionStatement = new ActionStatement();
120:                actionStatement.setKnownResourceOK("%NAME% opened.");
121:                actionStatement.setUnknownResourceOK("Resource opened.");
122:                actionStatement
123:                        .setKnownResourceERROR("There was a problem opening the resource %NAME%.");
124:                actionStatement
125:                        .setUnknownResourceERROR("There was a problem opening this new resource.");
126:                super .addActionStatementMapping(ActionOpen.ACTION_NAME,
127:                        actionStatement);
128:
129:                actionStatement = new ActionStatement();
130:                actionStatement
131:                        .setKnownResourceOK("You have successfully renamed %NAME% to %DESTINATION%.");
132:                actionStatement
133:                        .setUnknownResourceOK("You have successfully renamed this resource.");
134:                actionStatement
135:                        .setKnownResourceERROR("There was a problem renaming %NAME% to %DESTINATION%.");
136:                actionStatement
137:                        .setUnknownResourceERROR("There was a problem renaming this resource.");
138:                super .addActionStatementMapping(ActionRename.ACTION_NAME,
139:                        actionStatement);
140:
141:                actionStatement = new ActionStatement();
142:                actionStatement
143:                        .setKnownResourceOK("You have successfully submitted %NAME% to the server.");
144:                actionStatement
145:                        .setUnknownResourceOK("You have successfully submitted this resource to the server.");
146:                actionStatement
147:                        .setKnownResourceERROR("There was a problem submitting %NAME% to the server.");
148:                actionStatement
149:                        .setUnknownResourceERROR("There was a problem submitting this resource to the server.");
150:                super .addActionStatementMapping(ActionSynchronise.ACTION_NAME,
151:                        actionStatement);
152:
153:                actionStatement = new ActionStatement();
154:                actionStatement
155:                        .setKnownResourceOK("You have successfully unlocked %NAME%.");
156:                actionStatement
157:                        .setUnknownResourceOK("You have successfully unlocked this resource.");
158:                actionStatement
159:                        .setKnownResourceERROR("There was a problem unlocking %NAME%, it is locked by %DESTINATION%.");
160:                actionStatement
161:                        .setUnknownResourceERROR("There was a problem unlocking this resource.");
162:                super .addActionStatementMapping(ActionUnlock.ACTION_NAME,
163:                        actionStatement);
164:
165:                actionStatement = new ActionStatement();
166:                actionStatement
167:                        .setKnownResourceOK("You have successfully uploaded %NAME%.");
168:                actionStatement
169:                        .setUnknownResourceOK("You have successfully uploaded this resource.");
170:                actionStatement
171:                        .setKnownResourceERROR("There was a problem uploading %NAME%.");
172:                actionStatement
173:                        .setUnknownResourceERROR("There was a problem uploading this resource.");
174:                super .addActionStatementMapping(ActionUpload.ACTION_NAME,
175:                        actionStatement);
176:
177:                actionStatement = new ActionStatement();
178:                actionStatement.setKnownResourceOK("ALIAS %NAME%.");
179:                actionStatement.setUnknownResourceOK("ALIAS.");
180:                actionStatement.setKnownResourceERROR("ALIAS %NAME%.");
181:                actionStatement.setUnknownResourceERROR("ALIAS.");
182:                super .addActionStatementMapping(ActionAlias.ACTION_NAME,
183:                        actionStatement);
184:
185:                actionStatement = new ActionStatement();
186:                actionStatement = new ActionStatement();
187:                actionStatement
188:                        .setKnownResourceOK("You have successfully copied %NAME% to %DESTINATION%.");
189:                actionStatement
190:                        .setUnknownResourceOK("You have successfully copied this resource.");
191:                actionStatement
192:                        .setKnownResourceERROR("There was a problem copying %NAME% to %DESTINATION%.");
193:                actionStatement
194:                        .setUnknownResourceERROR("There was a problem copying this resource.");
195:                super .addActionStatementMapping(ActionCopy.ACTION_NAME,
196:                        actionStatement);
197:
198:                actionStatement = new ActionStatement();
199:                actionStatement
200:                        .setKnownResourceOK("You have successfully moved %NAME% to %DESTINATION%.");
201:                actionStatement
202:                        .setUnknownResourceOK("You have successfully moved this resource.");
203:                actionStatement
204:                        .setKnownResourceERROR("There was a problem moving %NAME% to %DESTINATION%.");
205:                actionStatement
206:                        .setUnknownResourceERROR("There was a problem moving this resource.");
207:                super .addActionStatementMapping(ActionMove.ACTION_NAME,
208:                        actionStatement);
209:
210:                actionStatement = new ActionStatement();
211:                actionStatement
212:                        .setKnownResourceOK("You have successfully archived %NAME%.");
213:                actionStatement
214:                        .setUnknownResourceOK("You have successfully archived this resource.");
215:                actionStatement
216:                        .setKnownResourceERROR("There was a problem archiving %NAME%.");
217:                actionStatement
218:                        .setUnknownResourceERROR("There was a problem archiving this resource.");
219:                super .addActionStatementMapping(ActionArchive.ACTION_NAME,
220:                        actionStatement);
221:
222:                actionStatement = new ActionStatement();
223:                actionStatement
224:                        .setKnownResourceOK("You have successfully exported %NAME%.");
225:                actionStatement
226:                        .setUnknownResourceOK("You have successfully exported this resource.");
227:                actionStatement
228:                        .setKnownResourceERROR("There was a problem exporting %NAME%.");
229:                actionStatement
230:                        .setUnknownResourceERROR("There was a problem exporting this resource.");
231:                super .addActionStatementMapping(ActionExport.ACTION_NAME,
232:                        actionStatement);
233:
234:                actionStatement = new ActionStatement();
235:                actionStatement
236:                        .setKnownResourceOK("%NAME% opened for preview.");
237:                actionStatement
238:                        .setUnknownResourceOK("Resource opened for preview.");
239:                actionStatement
240:                        .setKnownResourceERROR("There was a problem opening %NAME% for preview.");
241:                actionStatement
242:                        .setUnknownResourceERROR("There was a problem opening this resource for preview.");
243:                super .addActionStatementMapping(ActionPreview.ACTION_NAME,
244:                        actionStatement);
245:
246:                actionStatement = new ActionStatement();
247:                actionStatement
248:                        .setKnownResourceOK("You have successfully published %NAME%.");
249:                actionStatement
250:                        .setUnknownResourceOK("You have successfully published this resource.");
251:                actionStatement
252:                        .setKnownResourceERROR("There was a problem publishing %NAME%.");
253:                actionStatement
254:                        .setUnknownResourceERROR("There was a problem publishing this resource.");
255:                super .addActionStatementMapping(
256:                        ActionPublishToInternet.ACTION_NAME, actionStatement);
257:
258:                actionStatement = new ActionStatement();
259:                actionStatement
260:                        .setKnownResourceOK("You have successfully unpublished %NAME%.");
261:                actionStatement
262:                        .setUnknownResourceOK("You have successfully unpublished this resource.");
263:                actionStatement
264:                        .setKnownResourceERROR("There was a problem unpublishing %NAME%.");
265:                actionStatement
266:                        .setUnknownResourceERROR("There was a problem unpublishing this resource.");
267:                super .addActionStatementMapping(
268:                        ActionRemoveFromInternet.ACTION_NAME, actionStatement);
269:
270:                actionStatement = new ActionStatement();
271:                actionStatement
272:                        .setKnownResourceOK("You have successfully retrieved %NAME%.");
273:                actionStatement
274:                        .setUnknownResourceOK("You have successfully retrieved this resource.");
275:                actionStatement
276:                        .setKnownResourceERROR("There was a problem retrieving %NAME%.");
277:                actionStatement
278:                        .setUnknownResourceERROR("There was a problem retrieving this resource.");
279:                super .addActionStatementMapping(ActionRetrieve.ACTION_NAME,
280:                        actionStatement);
281:
282:                actionStatement = new ActionStatement();
283:                actionStatement.setKnownResourceOK("NO STATEMENT.");
284:                actionStatement
285:                        .setUnknownResourceOK("You have successfully submitted these resources to the server.");
286:                actionStatement.setKnownResourceERROR("NO STATEMENT.");
287:                actionStatement
288:                        .setUnknownResourceERROR("There was a problem submitting these resources to the server.");
289:                super .addActionStatementMapping(
290:                        ActionSyncWithServer.ACTION_NAME, actionStatement);
291:
292:                actionStatement = new ActionStatement();
293:                actionStatement.setKnownResourceOK("NO STATEMENT.");
294:                actionStatement
295:                        .setUnknownResourceOK("The search was successful.");
296:                actionStatement.setKnownResourceERROR("NO STATEMENT.");
297:                actionStatement
298:                        .setUnknownResourceERROR("There was a problem searching.");
299:                super .addActionStatementMapping("ACTION_SEARCH",
300:                        actionStatement);
301:
302:                // Generic status messages
303:                this .m_statusStatementMapping
304:                        .put(
305:                                Integer
306:                                        .toString(StatusData.STATUS_INVALID_PERMISSIONS),
307:                                "You do not have the correct permissions, please contact an administrator. To view your permissions select the Help Menu > About > Who am I tab. ");
308:                this .m_statusStatementMapping
309:                        .put(
310:                                Integer
311:                                        .toString(StatusData.STATUS_INVALID_REQUEST),
312:                                "There was a problem with the information sent to the server, this is probably because some metadata was invalid (indicated by  a red cross next to the invalid metadata). If all the metadata tabs for the resource have green ticks on them there is a problem with the metadata definiations and you should inform an administrator.");
313:                this .m_statusStatementMapping
314:                        .put(
315:                                Integer
316:                                        .toString(StatusData.STATUS_COMMUNICATIONS_FAILURE),
317:                                "There was a problem communicating with the server. Please check that you network connection is okay, if it is you should inform an administrator about this problem.");
318:                this .m_statusStatementMapping
319:                        .put(
320:                                Integer
321:                                        .toString(StatusData.STATUS_RESOURCE_NOT_FOUND),
322:                                "The resource was not found, it may have been archived or moved. Refresh the collection (System menu). If there is a still a problem you should inform a system adminstrator.");
323:                this .m_statusStatementMapping
324:                        .put(
325:                                Integer
326:                                        .toString(StatusData.STATUS_INVALID_RESOURCE_STATE),
327:                                "The state of the resource is not valid for this action. Refresh the collection. If there is a still a problem you should inform a system adminstrator.");
328:                this .m_statusStatementMapping
329:                        .put(
330:                                Integer.toString(StatusData.STATUS_TIMEOUT),
331:                                "The connection with the server timed out. Please check that you network connection is okay, if it is you should inform an administrator about this problem.");
332:                this .m_statusStatementMapping
333:                        .put(Integer.toString(StatusData.STATUS_SERVER_ERROR),
334:                                "There was an error on the server. Please inform an administrator.");
335:                this .m_statusStatementMapping
336:                        .put(Integer
337:                                .toString(StatusData.STATUS_RESOURCE_LOCKED),
338:                                "The resource is already locked. Please contact the lock owner.");
339:                this .m_statusStatementMapping
340:                        .put(
341:                                Integer
342:                                        .toString(StatusData.STATUS_REQUEST_CONDITIONS_NOT_MET),
343:                                "The resource is already locked. Please contact the lock owner.");
344:                this .m_statusStatementMapping.put(Integer
345:                        .toString(StatusData.STATUS_OK), "");
346:                this .m_statusStatementMapping
347:                        .put(Integer
348:                                .toString(StatusData.STATUS_RESOURCE_EXISTS),
349:                                "A resource of this name already exists in the collection.");
350:
351:                // Action specific status messages
352:                this .m_statusStatementMapping
353:                        .put(
354:                                ActionCopy.ACTION_NAME
355:                                        + "#"
356:                                        + Integer
357:                                                .toString(StatusData.STATUS_REQUEST_CONDITIONS_NOT_MET),
358:                                "There is already a resource with that name in the destination collection.");
359:                this .m_statusStatementMapping
360:                        .put(
361:                                ActionMove.ACTION_NAME
362:                                        + "#"
363:                                        + Integer
364:                                                .toString(StatusData.STATUS_REQUEST_CONDITIONS_NOT_MET),
365:                                "Either the resource is locked by another user or there is already a resource with that name in the destination collection.");
366:                this .m_statusStatementMapping
367:                        .put(
368:                                ActionRetrieve.ACTION_NAME
369:                                        + "#"
370:                                        + Integer
371:                                                .toString(StatusData.STATUS_REQUEST_CONDITIONS_NOT_MET),
372:                                "There is already a resource with that name in the destination collection.");
373:                this .m_statusStatementMapping
374:                        .put(
375:                                ActionNewCollection.ACTION_NAME
376:                                        + "#"
377:                                        + Integer
378:                                                .toString(StatusData.STATUS_INVALID_PERMISSIONS),
379:                                "Either the collection you are in has never been published or you do not have permission to create collections here.");
380:                this .m_statusStatementMapping
381:                        .put(
382:                                ActionNewFile.ACTION_NAME
383:                                        + "#"
384:                                        + Integer
385:                                                .toString(StatusData.STATUS_INVALID_PERMISSIONS),
386:                                "Either the collection you are in has never been published or you do not have permission to create resources here.");
387:            }
388:
389:            public static MessageBuilder getInstance() {
390:                if (m_instance == null) {
391:                    m_instance = new VFSMessageBuilder();
392:                }
393:                return m_instance;
394:            }
395:
396:            /* (non-Javadoc)
397:             * @see com.simulacramedia.contentmanager.window.messages.builders.MessageBuilder#fireMessage(java.lang.String, java.lang.Object)
398:             */
399:            public void fireMessage(String sActionName, Object statusInformation) {
400:                StringBuffer sBuff = new StringBuffer();
401:                String sMessageLevel = MessageHandler.TYPE_CONFIRM;
402:                if (statusInformation != null
403:                        && !((StatusData) statusInformation).isOK()) {
404:                    sMessageLevel = MessageHandler.TYPE_ERROR;
405:                }
406:
407:                sBuff.append(this 
408:                        .getActionStatement(sMessageLevel, sActionName));
409:                sBuff.append(this .buildStatusStatements(sActionName,
410:                        (StatusData) statusInformation));
411:
412:                System.out.println(sBuff.toString());
413:
414:                MessageHandler.getInstance().fireMessageEvent(sBuff.toString(),
415:                        sMessageLevel);
416:            }
417:
418:            /* (non-Javadoc)
419:             * @see com.simulacramedia.contentmanager.window.messages.builders.MessageBuilder#fireMessage(java.lang.String, java.lang.Object, java.lang.String)
420:             */
421:            public void fireMessage(String sActionName,
422:                    Object statusInformation, String sResourceTitle) {
423:                StringBuffer sBuff = new StringBuffer();
424:                String sMessageLevel = MessageHandler.TYPE_CONFIRM;
425:                if (statusInformation != null
426:                        && !((StatusData) statusInformation).isOK()) {
427:                    sMessageLevel = MessageHandler.TYPE_ERROR;
428:                }
429:
430:                sBuff.append(this .getActionStatement(sMessageLevel,
431:                        sActionName, sResourceTitle));
432:                sBuff.append(this .buildStatusStatements(sActionName,
433:                        (StatusData) statusInformation));
434:
435:                System.out.println(sBuff.toString());
436:
437:                MessageHandler.getInstance().fireMessageEvent(sBuff.toString(),
438:                        sMessageLevel);
439:            }
440:
441:            /* (non-Javadoc)
442:             * @see com.simulacramedia.contentmanager.window.messages.builders.MessageBuilder#fireMessage(java.lang.String, java.lang.String, java.lang.Object, java.lang.String, java.lang.String)
443:             */
444:            public void fireMessage(String sActionName,
445:                    Object statusInformation, String sResourceTitle,
446:                    String sDestinationTitle) {
447:                StringBuffer sBuff = new StringBuffer();
448:                String sMessageLevel = MessageHandler.TYPE_CONFIRM;
449:                if (statusInformation != null
450:                        && !((StatusData) statusInformation).isOK()) {
451:                    sMessageLevel = MessageHandler.TYPE_ERROR;
452:                }
453:
454:                sBuff.append(this .getActionStatement(sMessageLevel,
455:                        sActionName, sResourceTitle, sDestinationTitle));
456:                sBuff.append(this .buildStatusStatements(sActionName,
457:                        (StatusData) statusInformation));
458:
459:                System.out.println(sBuff.toString());
460:
461:                MessageHandler.getInstance().fireMessageEvent(sBuff.toString(),
462:                        sMessageLevel);
463:            }
464:
465:            /* (non-Javadoc)
466:             * @see com.simulacramedia.contentmanager.window.messages.builders.MessageBuilder#fireMessage(com.simulacramedia.contentmanager.window.messages.builders.StatusMessage)
467:             */
468:            public void fireMessage(StatusMessage statusMessage) {
469:                if (statusMessage.getPath() == null) {
470:                    if (statusMessage.getResourceTitle() != null
471:                            && statusMessage.getDestinationTitle() != null) {
472:                        this .fireMessage(statusMessage.getActionName(),
473:                                statusMessage.getStatusInformation(),
474:                                statusMessage.getResourceTitle(), statusMessage
475:                                        .getDestinationTitle());
476:                    } else if (statusMessage.getResourceTitle() != null) {
477:                        this .fireMessage(statusMessage.getActionName(),
478:                                statusMessage.getStatusInformation(),
479:                                statusMessage.getResourceTitle());
480:                    } else {
481:                        this .fireMessage(statusMessage.getActionName(),
482:                                statusMessage.getStatusInformation());
483:                    }
484:                } else {
485:                    StringBuffer sBuff = new StringBuffer();
486:                    String sMessageLevel = MessageHandler.TYPE_CONFIRM;
487:                    if (statusMessage.getStatusInformation() != null
488:                            && !((StatusData) statusMessage
489:                                    .getStatusInformation()).isOK()) {
490:                        sMessageLevel = MessageHandler.TYPE_ERROR;
491:                    }
492:
493:                    if (statusMessage.getResourceTitle() != null
494:                            && statusMessage.getDestinationTitle() != null) {
495:                        sBuff.append(this .getActionStatement(sMessageLevel,
496:                                statusMessage.getActionName(), statusMessage
497:                                        .getResourceTitle(), statusMessage
498:                                        .getDestinationTitle()));
499:                    } else if (statusMessage.getResourceTitle() != null) {
500:                        sBuff.append(this .getActionStatement(sMessageLevel,
501:                                statusMessage.getActionName(), statusMessage
502:                                        .getResourceTitle()));
503:                    } else {
504:                        sBuff.append(this .getActionStatement(sMessageLevel,
505:                                statusMessage.getActionName()));
506:                    }
507:
508:                    if (statusMessage.getPath() != null) {
509:                        sBuff.append(this .buildStatusStatements(statusMessage
510:                                .getActionName(), (StatusData) statusMessage
511:                                .getStatusInformation(), statusMessage
512:                                .getPath()));
513:                    } else {
514:                        sBuff.append(this .buildStatusStatements(statusMessage
515:                                .getActionName(), (StatusData) statusMessage
516:                                .getStatusInformation()));
517:                    }
518:
519:                    System.out.println(sBuff.toString());
520:
521:                    MessageHandler.getInstance().fireMessageEvent(
522:                            sBuff.toString(), sMessageLevel);
523:                }
524:            }
525:
526:            private StringBuffer buildStatusStatements(String sActionName,
527:                    StatusData status, String sPath) {
528:                StringBuffer sBuff = new StringBuffer();
529:
530:                ArrayList aCodes = new ArrayList();
531:
532:                List aWorstStatus = this .getWorstStatusData(status);
533:                Iterator itor = aWorstStatus.iterator();
534:                while (itor.hasNext()) {
535:                    StatusData element = (StatusData) itor.next();
536:                    aCodes.add(new Integer(element.getStatusCode()));
537:                }
538:
539:                if (sPath.startsWith(HarmonisePaths.PATH_USERS)
540:                        && aCodes.contains(new Integer(
541:                                StatusData.STATUS_INVALID_PERMISSIONS))) {
542:                    sBuff
543:                            .append(" Either you do not have permission to do this, the user group you are in has never been published or there is another user with this name.");
544:                } else if (sPath.startsWith(HarmonisePaths.PATH_PROPERTIES)
545:                        && aCodes.contains(new Integer(
546:                                StatusData.STATUS_INVALID_PERMISSIONS))) {
547:                    sBuff
548:                            .append(" Either you do not have permission to do this, the property group you are in has never been published or there is another property with this name.");
549:                } else if (sPath
550:                        .startsWith(HarmonisePaths.PATH_WORKFLOW_STAGES)
551:                        && aCodes.contains(new Integer(
552:                                StatusData.STATUS_INVALID_PERMISSIONS))) {
553:                    sBuff
554:                            .append(" Either there is a Workflow Stage in this collection (you cannot create a new collection if there is a Workflow Stage at the same level), you do not have permission to do this or the collection you are in has never been published.");
555:                } else if (sActionName
556:                        .equals(ActionPublishToInternet.ACTION_NAME)
557:                        && sPath.startsWith(HarmonisePaths.PATH_WORKFLOW_PROPS)
558:                        && aCodes.contains(new Integer(
559:                                StatusData.STATUS_INVALID_RESOURCE_STATE))) {
560:                    sBuff
561:                            .append(" This Workflow either has missing metadata or its Domain overlaps with that of another Workflow. This is not permitted, please ensure that Workflow Domains do not overlap.");
562:                } else {
563:                    sBuff.append(this 
564:                            .buildStatusStatements(sActionName, status));
565:                }
566:
567:                return sBuff;
568:            }
569:
570:            private StringBuffer buildStatusStatements(String sActionName,
571:                    StatusData status) {
572:                StringBuffer sBuff = new StringBuffer();
573:                if (status != null) {
574:                    sBuff.append(" ");
575:
576:                    String sMessage = (String) this .m_statusStatementMapping
577:                            .get(sActionName + "#"
578:                                    + Integer.toString(status.getStatusCode()));
579:                    if (sMessage == null) {
580:                        sMessage = (String) this .m_statusStatementMapping
581:                                .get(Integer.toString(status.getStatusCode()));
582:                    }
583:                    if (sMessage != null) {
584:                        sBuff.append(sMessage);
585:                    }
586:
587:                    List aStatus = this .getWorstStatusData(status);
588:                    Iterator itor = aStatus.iterator();
589:                    while (itor.hasNext()) {
590:                        StatusData element = (StatusData) itor.next();
591:                        sBuff.append(" ");
592:
593:                        sMessage = (String) this .m_statusStatementMapping
594:                                .get(sActionName
595:                                        + "#"
596:                                        + Integer.toString(element
597:                                                .getStatusCode()));
598:                        if (sMessage == null) {
599:                            sMessage = (String) this .m_statusStatementMapping
600:                                    .get(Integer.toString(element
601:                                            .getStatusCode()));
602:                        }
603:                        sBuff.append(sMessage);
604:                    }
605:                }
606:
607:                return sBuff;
608:            }
609:
610:            private List getWorstStatusData(StatusData status) {
611:                List aStatus = new ArrayList();
612:
613:                if (!status.isOK()) {
614:                    List tempStatus = status.getStatusData(status
615:                            .getWorstLevel());
616:                    Iterator itor = tempStatus.iterator();
617:                    while (itor.hasNext()) {
618:                        StatusData tempStatusData = (StatusData) itor.next();
619:                        aStatus.addAll(this .getWorstStatusData(tempStatusData));
620:                    }
621:                    aStatus.addAll(tempStatus);
622:                }
623:
624:                return aStatus;
625:            }
626:
627:            public static void main(String[] args) {
628:                StatusData status = new VFSStatusWebDAV();
629:                StatusData status2 = new VFSStatusWebDAV(408);
630:                ((VFSStatusWebDAV) status).addStatusData(status2);
631:                StatusData status3 = new VFSStatusWebDAV(409);
632:                ((VFSStatusWebDAV) status).addStatusData(status3);
633:                VFSMessageBuilder.getInstance().fireMessage(
634:                        ActionOrder.ACTION_NAME, status);
635:
636:                status = new VFSStatusWebDAV();
637:                VFSMessageBuilder.getInstance().fireMessage(
638:                        ActionOrder.ACTION_NAME, status, "Matt Col");
639:
640:                status = new VFSStatusWebDAV();
641:                status2 = new VFSStatusWebDAV(401);
642:                ((VFSStatusWebDAV) status).addStatusData(status2);
643:                status3 = new VFSStatusWebDAV(402);
644:                ((VFSStatusWebDAV) status).addStatusData(status3);
645:                VFSMessageBuilder.getInstance().fireMessage(
646:                        ActionOrder.ACTION_NAME, status, "Matt Col");
647:
648:                status = new VFSStatusWebDAV();
649:                status2 = new VFSStatusWebDAV(401);
650:                ((VFSStatusWebDAV) status).addStatusData(status2);
651:                status3 = new VFSStatusWebDAV(402);
652:                ((VFSStatusWebDAV) status).addStatusData(status3);
653:                VFSMessageBuilder.getInstance().fireMessage(
654:                        ActionCopy.ACTION_NAME, status, "resource1", "col2");
655:
656:                VFSMessageBuilder.getInstance().fireMessage(
657:                        ActionMove.ACTION_NAME, null, "resource1", "col2");
658:
659:            }
660:
661:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.