Source Code Cross Referenced for LibresourceBugTrackerServiceBean.java in  » Groupware » LibreSource » org » libresource » bugtracker » ejb » 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 » Groupware » LibreSource » org.libresource.bugtracker.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * LibreSource
0003:         * Copyright (C) 2004-2008 Artenum SARL / INRIA
0004:         * http://www.libresource.org - contact@artenum.com
0005:         *
0006:         * This file is part of the LibreSource software, 
0007:         * which can be used and distributed under license conditions.
0008:         * The license conditions are provided in the LICENSE.TXT file 
0009:         * at the root path of the packaging that enclose this file. 
0010:         * More information can be found at 
0011:         * - http://dev.libresource.org/home/license
0012:         *
0013:         * Initial authors :
0014:         *
0015:         * Guillaume Bort / INRIA
0016:         * Francois Charoy / Universite Nancy 2
0017:         * Julien Forest / Artenum
0018:         * Claude Godart / Universite Henry Poincare
0019:         * Florent Jouille / INRIA
0020:         * Sebastien Jourdain / INRIA / Artenum
0021:         * Yves Lerumeur / Artenum
0022:         * Pascal Molli / Universite Henry Poincare
0023:         * Gerald Oster / INRIA
0024:         * Mariarosa Penzi / Artenum
0025:         * Gerard Sookahet / Artenum
0026:         * Raphael Tani / INRIA
0027:         *
0028:         * Contributors :
0029:         *
0030:         * Stephane Bagnier / Artenum
0031:         * Amadou Dia / Artenum-IUP Blois
0032:         * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0033:         */package org.libresource.bugtracker.ejb;
0034:
0035:        import org.libresource.Libresource;
0036:        import org.libresource.LibresourceEvent;
0037:        import org.libresource.LibresourceException;
0038:        import org.libresource.LibresourceResourceIdentifier;
0039:        import org.libresource.LibresourceResourceValue;
0040:        import org.libresource.LibresourceServiceBase;
0041:
0042:        import org.libresource.bugtracker.BugTrackerConstants;
0043:        import org.libresource.bugtracker.BugTrackerExportHandler;
0044:        import org.libresource.bugtracker.BugTrackerImportHandler;
0045:        import org.libresource.bugtracker.IssueExportHandler;
0046:        import org.libresource.bugtracker.IssueImportHandler;
0047:        import org.libresource.bugtracker.LibresourceBugTrackerException;
0048:        import org.libresource.bugtracker.ejb.model.BugTrackerResourceValue;
0049:        import org.libresource.bugtracker.ejb.model.IssueResourceValue;
0050:        import org.libresource.bugtracker.interfaces.BugTrackerResourceLocal;
0051:        import org.libresource.bugtracker.interfaces.IssueResourceLocal;
0052:        import org.libresource.bugtracker.util.BugTrackerResourceUtil;
0053:        import org.libresource.bugtracker.util.IssueResourceUtil;
0054:
0055:        import org.libresource.core.FileData;
0056:
0057:        import org.libresource.files.LibresourceFilesException;
0058:        import org.libresource.files.ejb.model.FileResourceValue;
0059:        import org.libresource.files.interfaces.LibresourceFilesService;
0060:
0061:        import org.libresource.forum.LibresourceForumException;
0062:        import org.libresource.forum.MessageComparator;
0063:        import org.libresource.forum.ejb.model.MessageResourceValue;
0064:        import org.libresource.forum.interfaces.LibresourceForumService;
0065:
0066:        import org.libresource.kernel.KernelConstants;
0067:        import org.libresource.kernel.LibresourceSecurityException;
0068:        import org.libresource.kernel.URINotExistException;
0069:        import org.libresource.kernel.interfaces.KernelService;
0070:
0071:        import org.libresource.membership.MembershipConstants;
0072:        import org.libresource.membership.interfaces.MembershipService;
0073:
0074:        import org.libresource.search.LibresourceIndexableContent;
0075:
0076:        import org.libresource.xml.LibresourceExportHandler;
0077:        import org.libresource.xml.LibresourceImportHandler;
0078:
0079:        import java.net.URI;
0080:
0081:        import java.util.Arrays;
0082:        import java.util.Collection;
0083:        import java.util.Date;
0084:        import java.util.Iterator;
0085:        import java.util.Vector;
0086:
0087:        /**
0088:         * The Libresource BugTracker service
0089:         *
0090:         * @libresource.service name="LibresourceBugTracker" depends="Kernel,
0091:         *                      Membership, LibresourceCore, LibresourceFiles,
0092:         *                      LibresourceForum"
0093:         */
0094:        public abstract class LibresourceBugTrackerServiceBean extends
0095:                LibresourceServiceBase {
0096:            private Vector issuesTypes = new Vector();
0097:            private Vector issuesPriorities = new Vector();
0098:            private Vector issuesResolution = new Vector();
0099:
0100:            /**
0101:             * @ejb.interface-method
0102:             * @ejb.transaction type="Supports"
0103:             */
0104:            public LibresourceBugTrackerServiceBean() {
0105:                issuesTypes.add("BUG");
0106:                issuesTypes.add("IMPROVEMENT");
0107:                issuesTypes.add("NEWFEATURE");
0108:                issuesTypes.add("TASK");
0109:
0110:                issuesPriorities.add("BLOCKER");
0111:                issuesPriorities.add("CRITICAL");
0112:                issuesPriorities.add("MAJOR");
0113:                issuesPriorities.add("MINOR");
0114:                issuesPriorities.add("TRIVIAL");
0115:
0116:                issuesResolution.add("FIXED");
0117:                issuesResolution.add("WONTFIX");
0118:                issuesResolution.add("UNRESOLVED");
0119:                issuesResolution.add("CANNOTREPRODUCE");
0120:                issuesResolution.add("DUPLICATE");
0121:                issuesResolution.add("INCOMPLETE");
0122:            }
0123:
0124:            /**
0125:             * @ejb.interface-method
0126:             * @ejb.transaction type="Required"
0127:             */
0128:            public void createIssue(URI uri, int issueId, String summary,
0129:                    String body, String type, String priority,
0130:                    String resolution, String author)
0131:                    throws LibresourceBugTrackerException,
0132:                    LibresourceSecurityException {
0133:                try {
0134:                    KernelService kernelService = (KernelService) Libresource
0135:                            .getService(KernelConstants.SERVICE);
0136:                    MembershipService membershipService = (MembershipService) Libresource
0137:                            .getService(MembershipConstants.SERVICE);
0138:                    String assignee = membershipService.getProfile().getUri()
0139:                            .getPath();
0140:
0141:                    if (issueId == -1) {
0142:                        issueId = IssueResourceUtil.getLocalHome()
0143:                                .countIssues() + 1;
0144:                    }
0145:
0146:                    IssueResourceLocal issueResourceLocal = IssueResourceUtil
0147:                            .getLocalHome().create(issueId, summary, body,
0148:                                    type, priority, resolution, author,
0149:                                    assignee, new Date());
0150:                    kernelService.bind(issueResourceLocal
0151:                            .getLibresourceResourceIdentifier(), uri, summary);
0152:                    kernelService.systemCopyAcl(kernelService.getParent(uri),
0153:                            uri);
0154:                    kernelService.systemChown(uri, kernelService
0155:                            .getOwner(kernelService.getParent(uri)), false);
0156:
0157:                    // event
0158:                    LibresourceEvent event = new LibresourceEvent(uri,
0159:                            issueResourceLocal
0160:                                    .getLibresourceResourceIdentifier(),
0161:                            kernelService.getConnectedResource(),
0162:                            BugTrackerConstants.EVENT_ISSUE_CREATE);
0163:                    Libresource.throwEvent(event);
0164:                } catch (LibresourceSecurityException se) {
0165:                    ctx.setRollbackOnly();
0166:                    throw se;
0167:                } catch (Exception e) {
0168:                    ctx.setRollbackOnly();
0169:                    throw new LibresourceBugTrackerException(
0170:                            "Error in createIssue : " + e.getMessage(), e);
0171:                }
0172:            }
0173:
0174:            /**
0175:             * @ejb.interface-method
0176:             * @ejb.transaction type="Required"
0177:             */
0178:            public void createIssue(URI uri, int issueId, String summary,
0179:                    String body, String type, String priority,
0180:                    String resolution, String author, String assignee,
0181:                    Date creationDate, Date updateDate)
0182:                    throws LibresourceBugTrackerException,
0183:                    LibresourceSecurityException {
0184:                try {
0185:                    KernelService kernelService = (KernelService) Libresource
0186:                            .getService(KernelConstants.SERVICE);
0187:
0188:                    if (issueId == -1) {
0189:                        issueId = IssueResourceUtil.getLocalHome()
0190:                                .countIssues() + 1;
0191:                    }
0192:
0193:                    IssueResourceLocal issueResourceLocal = IssueResourceUtil
0194:                            .getLocalHome().create(issueId, summary, body,
0195:                                    type, priority, resolution, author,
0196:                                    assignee, creationDate);
0197:                    issueResourceLocal.setUpdateDate(updateDate);
0198:                    kernelService.bind(issueResourceLocal
0199:                            .getLibresourceResourceIdentifier(), uri, summary);
0200:                    kernelService.systemCopyAcl(kernelService.getParent(uri),
0201:                            uri);
0202:                    kernelService.systemChown(uri, kernelService
0203:                            .getOwner(kernelService.getParent(uri)), false);
0204:
0205:                    // event
0206:                    LibresourceEvent event = new LibresourceEvent(uri,
0207:                            issueResourceLocal
0208:                                    .getLibresourceResourceIdentifier(),
0209:                            kernelService.getConnectedResource(),
0210:                            BugTrackerConstants.EVENT_ISSUE_CREATE);
0211:                    Libresource.throwEvent(event);
0212:                } catch (LibresourceSecurityException se) {
0213:                    ctx.setRollbackOnly();
0214:                    throw se;
0215:                } catch (Exception e) {
0216:                    ctx.setRollbackOnly();
0217:                    throw new LibresourceBugTrackerException(
0218:                            "Error in createIssue : " + e.getMessage(), e);
0219:                }
0220:            }
0221:
0222:            /**
0223:             * @ejb.interface-method
0224:             * @ejb.transaction type="Required"
0225:             */
0226:            public void editIssue(URI uri, int issueId, String summary,
0227:                    String body, String type, String priority,
0228:                    String resolution, String assignee)
0229:                    throws LibresourceBugTrackerException,
0230:                    LibresourceSecurityException, URINotExistException {
0231:                try {
0232:                    KernelService kernelService = (KernelService) Libresource
0233:                            .getService(KernelConstants.SERVICE);
0234:                    MembershipService membershipService = (MembershipService) Libresource
0235:                            .getService(MembershipConstants.SERVICE);
0236:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0237:                            .lookup(uri);
0238:                    IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
0239:                            .findResource(resourceIdentifier,
0240:                                    IssueResourceLocal.class);
0241:
0242:                    if (!(kernelService.getConnectedResource().getPath()
0243:                            .compareTo(issueResourceLocal.getAssignee()) == 0)) {
0244:                        if (!kernelService.checkSecurity(uri,
0245:                                KernelConstants.SECURITY_UPDATE)) {
0246:                            throw new LibresourceSecurityException(uri,
0247:                                    KernelConstants.SECURITY_UPDATE);
0248:                        }
0249:                    }
0250:
0251:                    if (!kernelService.exist(new URI(assignee))) {
0252:                        throw new URINotExistException(assignee);
0253:                    }
0254:
0255:                    if (issueId != -1) {
0256:                        issueResourceLocal.setIssueId(issueId);
0257:                    }
0258:
0259:                    issueResourceLocal.setSummary(summary);
0260:                    issueResourceLocal.setBody(body);
0261:                    issueResourceLocal.setType(type);
0262:                    issueResourceLocal.setPriority(priority);
0263:                    issueResourceLocal.setResolution(resolution);
0264:                    issueResourceLocal.setUpdateDate(new Date());
0265:                    issueResourceLocal.setAssignee(assignee);
0266:
0267:                    // update node
0268:                    kernelService.setShortName(uri, summary);
0269:                    kernelService.setUpdateDate(uri, new Date());
0270:
0271:                    // event
0272:                    LibresourceEvent event = new LibresourceEvent(uri,
0273:                            resourceIdentifier, kernelService
0274:                                    .getConnectedResource(),
0275:                            BugTrackerConstants.EVENT_ISSUE_EDIT);
0276:                    Libresource.throwEvent(event);
0277:
0278:                    // indexation
0279:                    Libresource.index(uri);
0280:                } catch (LibresourceSecurityException se) {
0281:                    ctx.setRollbackOnly();
0282:                    throw se;
0283:                } catch (URINotExistException se) {
0284:                    ctx.setRollbackOnly();
0285:                    throw se;
0286:                } catch (Exception e) {
0287:                    ctx.setRollbackOnly();
0288:                    throw new LibresourceBugTrackerException(
0289:                            "Error in editIssue : " + e.getMessage(), e);
0290:                }
0291:            }
0292:
0293:            /**
0294:             * @ejb.interface-method
0295:             * @ejb.transaction type="Required"
0296:             */
0297:            public void deleteIssue(URI uri)
0298:                    throws LibresourceBugTrackerException,
0299:                    LibresourceSecurityException, URINotExistException {
0300:                try {
0301:                    KernelService kernelService = (KernelService) Libresource
0302:                            .getService(KernelConstants.SERVICE);
0303:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0304:                            .lookup(uri);
0305:
0306:                    // event
0307:                    LibresourceEvent event = new LibresourceEvent(uri,
0308:                            resourceIdentifier, kernelService
0309:                                    .getConnectedResource(),
0310:                            BugTrackerConstants.EVENT_ISSUE_DELETE);
0311:                    Libresource.throwEvent(event);
0312:
0313:                    Libresource.checkType(resourceIdentifier,
0314:                            IssueResourceLocal.class);
0315:                    kernelService.deleteURI(uri);
0316:                } catch (LibresourceSecurityException se) {
0317:                    ctx.setRollbackOnly();
0318:                    throw se;
0319:                } catch (URINotExistException se) {
0320:                    ctx.setRollbackOnly();
0321:                    throw se;
0322:                } catch (Exception e) {
0323:                    ctx.setRollbackOnly();
0324:                    throw new LibresourceBugTrackerException(
0325:                            "Error in deleteIssue : " + e.getMessage(), e);
0326:                }
0327:            }
0328:
0329:            /**
0330:             * @ejb.interface-method
0331:             * @ejb.transaction type="Supports"
0332:             */
0333:            public IssueResourceValue getIssue(URI uri)
0334:                    throws LibresourceBugTrackerException,
0335:                    LibresourceSecurityException, URINotExistException {
0336:                try {
0337:                    KernelService kernelService = (KernelService) Libresource
0338:                            .getService(KernelConstants.SERVICE);
0339:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0340:                            .lookup(uri);
0341:                    IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
0342:                            .findResource(resourceIdentifier,
0343:                                    IssueResourceLocal.class);
0344:                    IssueResourceValue resourceValue = issueResourceLocal
0345:                            .getIssueResourceValue();
0346:                    resourceValue.setUri(kernelService.normalizeURI(uri));
0347:
0348:                    return resourceValue;
0349:                } catch (LibresourceSecurityException se) {
0350:                    throw se;
0351:                } catch (URINotExistException se) {
0352:                    throw se;
0353:                } catch (Exception e) {
0354:                    throw new LibresourceBugTrackerException(
0355:                            "Error in getIssue : " + e.getMessage(), e);
0356:                }
0357:            }
0358:
0359:            /**
0360:             * @ejb.interface-method
0361:             * @ejb.transaction type="Supports"
0362:             */
0363:            public IssueResourceValue[] listIssuesAt(URI uri)
0364:                    throws LibresourceBugTrackerException,
0365:                    LibresourceSecurityException, URINotExistException {
0366:                try {
0367:                    KernelService kernelService = (KernelService) Libresource
0368:                            .getService(KernelConstants.SERVICE);
0369:                    LibresourceResourceValue[] pages = kernelService
0370:                            .listResourcesAt(
0371:                                    uri,
0372:                                    IssueResourceLocal.LIBRESOURCE_RESOURCE_SERVICE,
0373:                                    IssueResourceLocal.LIBRESOURCE_RESOURCE_TYPE);
0374:                    IssueResourceValue[] issueResourceValues = new IssueResourceValue[pages.length];
0375:
0376:                    for (int i = 0; i < issueResourceValues.length; i++) {
0377:                        LibresourceResourceIdentifier resourceIdentifier = pages[i]
0378:                                .getLibresourceResourceIdentifier();
0379:                        issueResourceValues[i] = ((IssueResourceLocal) Libresource
0380:                                .findResource(resourceIdentifier))
0381:                                .getIssueResourceValue();
0382:                        issueResourceValues[i].setUri(kernelService
0383:                                .normalizeURI(pages[i].getUri()));
0384:                    }
0385:
0386:                    return issueResourceValues;
0387:                } catch (LibresourceSecurityException se) {
0388:                    throw se;
0389:                } catch (URINotExistException se) {
0390:                    throw se;
0391:                } catch (Exception e) {
0392:                    throw new LibresourceBugTrackerException(
0393:                            "Error in listIssuesAt : " + e.getMessage(), e);
0394:                }
0395:            }
0396:
0397:            /**
0398:             * @ejb.interface-method
0399:             * @ejb.transaction type="Required"
0400:             */
0401:            public void createBugTracker(URI uri, String name,
0402:                    String description) throws LibresourceBugTrackerException,
0403:                    LibresourceSecurityException {
0404:                try {
0405:                    KernelService kernelService = (KernelService) Libresource
0406:                            .getService(KernelConstants.SERVICE);
0407:                    MembershipService membershipService = (MembershipService) Libresource
0408:                            .getService(MembershipConstants.SERVICE);
0409:                    String assignee = membershipService.getProfile().getUri()
0410:                            .getPath();
0411:                    BugTrackerResourceLocal bugTrackerResourceLocal = BugTrackerResourceUtil
0412:                            .getLocalHome().create(name, description, assignee);
0413:                    kernelService.bind(bugTrackerResourceLocal
0414:                            .getLibresourceResourceIdentifier(), uri, name);
0415:
0416:                    // event
0417:                    LibresourceEvent event = new LibresourceEvent(uri,
0418:                            bugTrackerResourceLocal
0419:                                    .getLibresourceResourceIdentifier(),
0420:                            kernelService.getConnectedResource(),
0421:                            BugTrackerConstants.EVENT_BUGTRACKER_CREATE);
0422:                    Libresource.throwEvent(event);
0423:                } catch (LibresourceSecurityException se) {
0424:                    ctx.setRollbackOnly();
0425:                    throw se;
0426:                } catch (Exception e) {
0427:                    ctx.setRollbackOnly();
0428:                    throw new LibresourceBugTrackerException(
0429:                            "Error in createBugTracker : " + e.getMessage(), e);
0430:                }
0431:            }
0432:
0433:            /**
0434:             * @ejb.interface-method
0435:             * @ejb.transaction type="Required"
0436:             */
0437:            public void createBugTracker(URI uri, String name,
0438:                    String description, String assignee)
0439:                    throws LibresourceBugTrackerException,
0440:                    LibresourceSecurityException {
0441:                try {
0442:                    KernelService kernelService = (KernelService) Libresource
0443:                            .getService(KernelConstants.SERVICE);
0444:                    MembershipService membershipService = (MembershipService) Libresource
0445:                            .getService(MembershipConstants.SERVICE);
0446:                    BugTrackerResourceLocal bugTrackerResourceLocal = BugTrackerResourceUtil
0447:                            .getLocalHome().create(name, description, assignee);
0448:                    kernelService.bind(bugTrackerResourceLocal
0449:                            .getLibresourceResourceIdentifier(), uri, name);
0450:
0451:                    // event
0452:                    LibresourceEvent event = new LibresourceEvent(uri,
0453:                            bugTrackerResourceLocal
0454:                                    .getLibresourceResourceIdentifier(),
0455:                            kernelService.getConnectedResource(),
0456:                            BugTrackerConstants.EVENT_BUGTRACKER_CREATE);
0457:                    Libresource.throwEvent(event);
0458:                } catch (LibresourceSecurityException se) {
0459:                    ctx.setRollbackOnly();
0460:                    throw se;
0461:                } catch (Exception e) {
0462:                    ctx.setRollbackOnly();
0463:                    throw new LibresourceBugTrackerException(
0464:                            "Error in createBugTracker : " + e.getMessage(), e);
0465:                }
0466:            }
0467:
0468:            /**
0469:             * @ejb.interface-method
0470:             * @ejb.transaction type="Required"
0471:             */
0472:            public void editBugTracker(URI uri, String name,
0473:                    String description, String assignee)
0474:                    throws LibresourceBugTrackerException,
0475:                    LibresourceSecurityException, URINotExistException {
0476:                try {
0477:                    KernelService kernelService = (KernelService) Libresource
0478:                            .getService(KernelConstants.SERVICE);
0479:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0480:                            .lookup(uri);
0481:                    BugTrackerResourceLocal bugTrackerResourceLocal = (BugTrackerResourceLocal) Libresource
0482:                            .findResource(resourceIdentifier,
0483:                                    BugTrackerResourceLocal.class);
0484:
0485:                    if (!(kernelService.getConnectedResource().getPath()
0486:                            .compareTo(bugTrackerResourceLocal.getAssignee()) == 0)) {
0487:                        if (!kernelService.checkSecurity(uri,
0488:                                KernelConstants.SECURITY_UPDATE)) {
0489:                            throw new LibresourceSecurityException(uri,
0490:                                    KernelConstants.SECURITY_UPDATE);
0491:                        }
0492:                    }
0493:
0494:                    bugTrackerResourceLocal.setName(name);
0495:                    bugTrackerResourceLocal.setDescription(description);
0496:
0497:                    // update node
0498:                    kernelService.setShortName(uri, name);
0499:                    kernelService.setUpdateDate(uri, new Date());
0500:
0501:                    if (!kernelService.exist(new URI(assignee))) {
0502:                        throw new URINotExistException(assignee);
0503:                    }
0504:
0505:                    bugTrackerResourceLocal.setAssignee(assignee);
0506:
0507:                    // event
0508:                    LibresourceEvent event = new LibresourceEvent(uri,
0509:                            resourceIdentifier, kernelService
0510:                                    .getConnectedResource(),
0511:                            BugTrackerConstants.EVENT_BUGTRACKER_EDIT);
0512:                    Libresource.throwEvent(event);
0513:
0514:                    // indexation
0515:                    Libresource.index(uri);
0516:                } catch (LibresourceSecurityException se) {
0517:                    ctx.setRollbackOnly();
0518:                    throw se;
0519:                } catch (URINotExistException se) {
0520:                    ctx.setRollbackOnly();
0521:                    throw se;
0522:                } catch (Exception e) {
0523:                    ctx.setRollbackOnly();
0524:                    throw new LibresourceBugTrackerException(
0525:                            "Error in editBugTracker : " + e.getMessage(), e);
0526:                }
0527:            }
0528:
0529:            /**
0530:             * @ejb.interface-method
0531:             * @ejb.transaction type="Required"
0532:             */
0533:            public void deleteBugTracker(URI uri)
0534:                    throws LibresourceBugTrackerException,
0535:                    LibresourceSecurityException, URINotExistException {
0536:                try {
0537:                    KernelService kernelService = (KernelService) Libresource
0538:                            .getService(KernelConstants.SERVICE);
0539:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0540:                            .lookup(uri);
0541:
0542:                    // event
0543:                    LibresourceEvent event = new LibresourceEvent(uri,
0544:                            resourceIdentifier, kernelService
0545:                                    .getConnectedResource(),
0546:                            BugTrackerConstants.EVENT_BUGTRACKER_DELETE);
0547:                    Libresource.throwEvent(event);
0548:
0549:                    Libresource.checkType(resourceIdentifier,
0550:                            BugTrackerResourceLocal.class);
0551:                    kernelService.deleteURI(uri);
0552:                } catch (LibresourceSecurityException se) {
0553:                    ctx.setRollbackOnly();
0554:                    throw se;
0555:                } catch (URINotExistException se) {
0556:                    ctx.setRollbackOnly();
0557:                    throw se;
0558:                } catch (Exception e) {
0559:                    ctx.setRollbackOnly();
0560:                    throw new LibresourceBugTrackerException(
0561:                            "Error in deleteBugTracker : " + e.getMessage(), e);
0562:                }
0563:            }
0564:
0565:            /**
0566:             * @ejb.interface-method
0567:             * @ejb.transaction type="Supports"
0568:             */
0569:            public BugTrackerResourceValue getBugTracker(URI uri)
0570:                    throws LibresourceBugTrackerException,
0571:                    LibresourceSecurityException, URINotExistException {
0572:                try {
0573:                    KernelService kernelService = (KernelService) Libresource
0574:                            .getService(KernelConstants.SERVICE);
0575:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0576:                            .lookup(uri);
0577:                    BugTrackerResourceLocal bugTrackerResourceLocal = (BugTrackerResourceLocal) Libresource
0578:                            .findResource(resourceIdentifier,
0579:                                    BugTrackerResourceLocal.class);
0580:                    BugTrackerResourceValue resourceValue = bugTrackerResourceLocal
0581:                            .getBugTrackerResourceValue();
0582:                    resourceValue.setUri(kernelService.normalizeURI(uri));
0583:
0584:                    return resourceValue;
0585:                } catch (LibresourceSecurityException se) {
0586:                    throw se;
0587:                } catch (URINotExistException se) {
0588:                    throw se;
0589:                } catch (Exception e) {
0590:                    throw new LibresourceBugTrackerException(
0591:                            "Error in getBugTracker : " + e.getMessage(), e);
0592:                }
0593:            }
0594:
0595:            /**
0596:             * @ejb.interface-method
0597:             * @ejb.transaction type="Supports"
0598:             */
0599:            public BugTrackerResourceValue[] listBugTrackersAt(URI uri)
0600:                    throws LibresourceBugTrackerException,
0601:                    LibresourceSecurityException, URINotExistException {
0602:                try {
0603:                    KernelService kernelService = (KernelService) Libresource
0604:                            .getService(KernelConstants.SERVICE);
0605:                    LibresourceResourceValue[] pages = kernelService
0606:                            .listResourcesAt(
0607:                                    uri,
0608:                                    BugTrackerResourceLocal.LIBRESOURCE_RESOURCE_SERVICE,
0609:                                    BugTrackerResourceLocal.LIBRESOURCE_RESOURCE_TYPE);
0610:                    BugTrackerResourceValue[] bugTrackerResourceValues = new BugTrackerResourceValue[pages.length];
0611:
0612:                    for (int i = 0; i < bugTrackerResourceValues.length; i++) {
0613:                        LibresourceResourceIdentifier resourceIdentifier = pages[i]
0614:                                .getLibresourceResourceIdentifier();
0615:                        bugTrackerResourceValues[i] = ((BugTrackerResourceLocal) Libresource
0616:                                .findResource(resourceIdentifier))
0617:                                .getBugTrackerResourceValue();
0618:                        bugTrackerResourceValues[i].setUri(kernelService
0619:                                .normalizeURI(pages[i].getUri()));
0620:                    }
0621:
0622:                    return bugTrackerResourceValues;
0623:                } catch (LibresourceSecurityException se) {
0624:                    throw se;
0625:                } catch (URINotExistException se) {
0626:                    throw se;
0627:                } catch (Exception e) {
0628:                    throw new LibresourceBugTrackerException(
0629:                            "Error in listBugTrackersAt : " + e.getMessage(), e);
0630:                }
0631:            }
0632:
0633:            /**
0634:             * @ejb.interface-method
0635:             * @ejb.transaction type="Required"
0636:             */
0637:            public void addFileInIssue(URI uri, String description,
0638:                    String author, FileData fileData)
0639:                    throws LibresourceFilesException,
0640:                    LibresourceSecurityException, URINotExistException {
0641:                try {
0642:                    KernelService kernelService = (KernelService) Libresource
0643:                            .getService(KernelConstants.SERVICE);
0644:                    IssueResourceValue issueResourceValue = (IssueResourceValue) getIssue(uri);
0645:
0646:                    if (!(kernelService.getConnectedResource().getPath()
0647:                            .compareTo(issueResourceValue.getAssignee()) == 0)) {
0648:                        if (!kernelService.checkSecurity(uri,
0649:                                BugTrackerConstants.SECURITY_POSTCOMMENT)) {
0650:                            throw new LibresourceSecurityException(uri,
0651:                                    BugTrackerConstants.SECURITY_POSTCOMMENT);
0652:                        }
0653:                    }
0654:
0655:                    // update the issue
0656:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0657:                            .lookup(uri);
0658:                    IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
0659:                            .findResource(resourceIdentifier,
0660:                                    IssueResourceLocal.class);
0661:                    issueResourceLocal.setUpdateDate(new Date());
0662:
0663:                    // update node
0664:                    kernelService.setUpdateDate(uri, new Date());
0665:
0666:                    //String id = FileResourceUtil.generateGUID(uri);
0667:                    String id = Libresource.convertStringToId(fileData
0668:                            .getName());
0669:                    URI fileUri = new URI(kernelService
0670:                            .normalizeAbsoluteURIPath(uri)
0671:                            + "/" + id);
0672:                    int suffix = 0;
0673:
0674:                    while (kernelService.exist(fileUri)) {
0675:                        fileUri = new URI(kernelService
0676:                                .normalizeAbsoluteURIPath(uri)
0677:                                + "/" + id + "_" + suffix);
0678:                        suffix++;
0679:                    }
0680:
0681:                    MembershipService membershipService = (MembershipService) Libresource
0682:                            .getService(MembershipConstants.SERVICE);
0683:                    LibresourceFilesService libresourceFilesService = (LibresourceFilesService) Libresource
0684:                            .getService("LibresourceFiles");
0685:                    libresourceFilesService.systemCreateFile(fileUri,
0686:                            description, author, fileData, false);
0687:                    kernelService.systemResetAcls(fileUri);
0688:                    kernelService.systemCopyAcl(uri, fileUri);
0689:                    kernelService.systemCreateAcl(fileUri, kernelService
0690:                            .getConnectedResource(), new String[] {
0691:                            KernelConstants.SECURITY_READ,
0692:                            KernelConstants.SECURITY_UPDATE });
0693:                    kernelService.systemChown(fileUri, kernelService
0694:                            .getOwner(uri), false);
0695:
0696:                    LibresourceEvent event = new LibresourceEvent(uri,
0697:                            kernelService.lookup(uri), kernelService
0698:                                    .getConnectedResource(),
0699:                            BugTrackerConstants.EVENT_ISSUE_ADD_FILE, fileData
0700:                                    .getName());
0701:                    Libresource.throwEvent(event);
0702:                } catch (LibresourceSecurityException se) {
0703:                    ctx.setRollbackOnly();
0704:                    throw se;
0705:                } catch (URINotExistException se) {
0706:                    ctx.setRollbackOnly();
0707:                    throw se;
0708:                } catch (Exception e) {
0709:                    ctx.setRollbackOnly();
0710:                    throw new LibresourceFilesException(
0711:                            "Error in addFileInIssue : " + e.getMessage(), e);
0712:                }
0713:            }
0714:
0715:            /**
0716:             * @ejb.interface-method
0717:             * @ejb.transaction type="Supports"
0718:             */
0719:            public FileResourceValue[] listFilesInIssue(URI issueUri)
0720:                    throws LibresourceBugTrackerException,
0721:                    LibresourceFilesException, LibresourceSecurityException,
0722:                    URINotExistException {
0723:                try {
0724:                    KernelService kernelService = (KernelService) Libresource
0725:                            .getService(KernelConstants.SERVICE);
0726:
0727:                    if (!kernelService.checkSecurity(issueUri,
0728:                            KernelConstants.SECURITY_READ)) {
0729:                        throw new LibresourceSecurityException(issueUri,
0730:                                KernelConstants.SECURITY_READ);
0731:                    }
0732:
0733:                    LibresourceFilesService filesService = (LibresourceFilesService) Libresource
0734:                            .getService("LibresourceFiles");
0735:
0736:                    return filesService.listFilesAt(issueUri);
0737:                } catch (LibresourceSecurityException se) {
0738:                    throw se;
0739:                } catch (URINotExistException se) {
0740:                    throw se;
0741:                } catch (LibresourceFilesException se) {
0742:                    throw se;
0743:                } catch (Exception e) {
0744:                    throw new LibresourceBugTrackerException(
0745:                            "Error in listFilesInIssue : " + e.getMessage(), e);
0746:                }
0747:            }
0748:
0749:            /**
0750:             * @ejb.interface-method
0751:             * @ejb.transaction type="Required"
0752:             */
0753:            public void addCommentInIssue(URI uri, String title, String body)
0754:                    throws LibresourceBugTrackerException,
0755:                    LibresourceForumException, LibresourceSecurityException,
0756:                    URINotExistException {
0757:                try {
0758:                    KernelService kernelService = (KernelService) Libresource
0759:                            .getService(KernelConstants.SERVICE);
0760:
0761:                    //String id = MessageResourceUtil.generateGUID(uri);
0762:                    String id = Libresource.convertStringToId(title);
0763:                    URI msgUri = new URI(kernelService
0764:                            .normalizeAbsoluteURIPath(uri)
0765:                            + "/" + id);
0766:                    int suffix = 0;
0767:
0768:                    while (kernelService.exist(msgUri)) {
0769:                        msgUri = new URI(kernelService
0770:                                .normalizeAbsoluteURIPath(uri)
0771:                                + "/" + id + "_" + suffix);
0772:                        suffix++;
0773:                    }
0774:
0775:                    IssueResourceValue issueResourceValue = (IssueResourceValue) getIssue(uri);
0776:
0777:                    if (!(kernelService.getConnectedResource().getPath()
0778:                            .compareTo(issueResourceValue.getAssignee()) == 0)) {
0779:                        if (!kernelService.checkSecurity(uri,
0780:                                BugTrackerConstants.SECURITY_POSTCOMMENT)) {
0781:                            throw new LibresourceSecurityException(uri,
0782:                                    BugTrackerConstants.SECURITY_POSTCOMMENT);
0783:                        }
0784:                    }
0785:
0786:                    // update the issue
0787:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
0788:                            .lookup(uri);
0789:                    IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
0790:                            .findResource(resourceIdentifier,
0791:                                    IssueResourceLocal.class);
0792:                    issueResourceLocal.setUpdateDate(new Date());
0793:
0794:                    // update node
0795:                    kernelService.setUpdateDate(uri, new Date());
0796:
0797:                    LibresourceForumService libresourceForumService = (LibresourceForumService) Libresource
0798:                            .getService("LibresourceForum");
0799:                    libresourceForumService.systemCreateMessage(msgUri, title,
0800:                            body);
0801:                    kernelService.systemResetAcls(msgUri);
0802:                    kernelService.systemCopyAcl(uri, msgUri);
0803:                    kernelService.systemCreateAcl(msgUri, kernelService
0804:                            .getConnectedResource(), new String[] {
0805:                            KernelConstants.SECURITY_READ,
0806:                            KernelConstants.SECURITY_UPDATE });
0807:                    kernelService.systemChown(msgUri, kernelService
0808:                            .getOwner(uri), false);
0809:
0810:                    LibresourceEvent event = new LibresourceEvent(uri,
0811:                            kernelService.lookup(uri), kernelService
0812:                                    .getConnectedResource(),
0813:                            BugTrackerConstants.EVENT_BUGTRACKER_ADD_COMMENT,
0814:                            title);
0815:                    Libresource.throwEvent(event);
0816:                } catch (LibresourceSecurityException se) {
0817:                    ctx.setRollbackOnly();
0818:                    throw se;
0819:                } catch (URINotExistException se) {
0820:                    ctx.setRollbackOnly();
0821:                    throw se;
0822:                } catch (LibresourceForumException se) {
0823:                    ctx.setRollbackOnly();
0824:                    throw se;
0825:                } catch (Exception e) {
0826:                    ctx.setRollbackOnly();
0827:                    throw new LibresourceBugTrackerException(
0828:                            "Error in addCommentInIssue : " + e.getMessage(), e);
0829:                }
0830:            }
0831:
0832:            /**
0833:             * @ejb.interface-method
0834:             * @ejb.transaction type="Required"
0835:             */
0836:            public MessageResourceValue[] listCommentsInIssue(URI issueUri)
0837:                    throws LibresourceBugTrackerException,
0838:                    LibresourceForumException, LibresourceSecurityException,
0839:                    URINotExistException {
0840:                try {
0841:                    KernelService kernelService = (KernelService) Libresource
0842:                            .getService(KernelConstants.SERVICE);
0843:
0844:                    if (!kernelService.checkSecurity(issueUri,
0845:                            KernelConstants.SECURITY_READ)) {
0846:                        throw new LibresourceSecurityException(issueUri,
0847:                                KernelConstants.SECURITY_READ);
0848:                    }
0849:
0850:                    LibresourceForumService forumService = (LibresourceForumService) Libresource
0851:                            .getService("LibresourceForum");
0852:                    MessageResourceValue[] comments = forumService
0853:                            .listMessagesAt(issueUri);
0854:
0855:                    Arrays.sort(comments, new MessageComparator());
0856:
0857:                    return comments;
0858:                } catch (LibresourceSecurityException se) {
0859:                    ctx.setRollbackOnly();
0860:                    throw se;
0861:                } catch (URINotExistException se) {
0862:                    ctx.setRollbackOnly();
0863:                    throw se;
0864:                } catch (LibresourceForumException se) {
0865:                    ctx.setRollbackOnly();
0866:                    throw se;
0867:                } catch (Exception e) {
0868:                    throw new LibresourceBugTrackerException(
0869:                            "Error in listCommentsInIssue : " + e.getMessage(),
0870:                            e);
0871:                }
0872:            }
0873:
0874:            /**
0875:             * @ejb.interface-method
0876:             * @ejb.transaction type="Required"
0877:             */
0878:            public void addIssueToBugTracker(URI uri, String summary,
0879:                    String body, String type, String priority, String resolution)
0880:                    throws LibresourceBugTrackerException,
0881:                    LibresourceSecurityException, URINotExistException {
0882:                try {
0883:                    KernelService kernelService = (KernelService) Libresource
0884:                            .getService(KernelConstants.SERVICE);
0885:
0886:                    //String id = BugTrackerResourceUtil.generateGUID(uri);
0887:                    String id = Libresource.convertStringToId(summary);
0888:                    URI issueUri = new URI(kernelService
0889:                            .normalizeAbsoluteURIPath(uri)
0890:                            + "/" + id);
0891:                    int suffix = 0;
0892:
0893:                    while (kernelService.exist(issueUri)) {
0894:                        issueUri = new URI(kernelService
0895:                                .normalizeAbsoluteURIPath(uri)
0896:                                + "/" + id + "_" + suffix);
0897:                        suffix++;
0898:                    }
0899:
0900:                    BugTrackerResourceValue bugtrackerResourceValue = (BugTrackerResourceValue) getBugTracker(uri);
0901:
0902:                    if (!(kernelService.getConnectedResource().getPath()
0903:                            .compareTo(bugtrackerResourceValue.getAssignee()) == 0)) {
0904:                        if (!kernelService.checkSecurity(uri,
0905:                                BugTrackerConstants.SECURITY_ADDBUG)) {
0906:                            throw new LibresourceSecurityException(uri,
0907:                                    BugTrackerConstants.SECURITY_ADDBUG);
0908:                        }
0909:                    }
0910:
0911:                    // update node
0912:                    kernelService.setUpdateDate(uri, new Date());
0913:
0914:                    MembershipService membershipService = (MembershipService) Libresource
0915:                            .getService(MembershipConstants.SERVICE);
0916:                    String author = membershipService.getProfile()
0917:                            .getFullName();
0918:                    String assignee = bugtrackerResourceValue.getAssignee();
0919:                    int issueId = IssueResourceUtil.getLocalHome()
0920:                            .countIssues() + 1;
0921:                    IssueResourceLocal issueResourceLocal = IssueResourceUtil
0922:                            .getLocalHome().create(issueId, summary, body,
0923:                                    type, priority, resolution, author,
0924:                                    assignee, new Date());
0925:                    kernelService.systemCreateURI(issueUri);
0926:                    kernelService.systemBind(issueResourceLocal
0927:                            .getLibresourceResourceIdentifier(), issueUri,
0928:                            summary);
0929:                    kernelService.systemCopyAcl(uri, issueUri);
0930:                    kernelService.systemChown(issueUri, kernelService
0931:                            .getOwner(uri), false);
0932:
0933:                    // event
0934:                    LibresourceEvent event = new LibresourceEvent(issueUri,
0935:                            kernelService.lookup(uri), kernelService
0936:                                    .getConnectedResource(),
0937:                            BugTrackerConstants.EVENT_ISSUE_CREATE);
0938:                    Libresource.throwEvent(event);
0939:                    event = new LibresourceEvent(uri,
0940:                            kernelService.lookup(uri), kernelService
0941:                                    .getConnectedResource(),
0942:                            BugTrackerConstants.EVENT_BUGTRACKER_ADD_ISSUE,
0943:                            issueResourceLocal.getSummary());
0944:                    Libresource.throwEvent(event);
0945:                    event = new LibresourceEvent(issueUri, kernelService
0946:                            .lookup(issueUri), kernelService
0947:                            .getConnectedResource(),
0948:                            BugTrackerConstants.EVENT_ISSUE_ASSIGN,
0949:                            kernelService.normalizeAbsoluteURIPath(new URI(
0950:                                    assignee)));
0951:                    Libresource.throwEvent(event);
0952:                } catch (LibresourceSecurityException se) {
0953:                    ctx.setRollbackOnly();
0954:                    throw se;
0955:                } catch (URINotExistException se) {
0956:                    ctx.setRollbackOnly();
0957:                    throw se;
0958:                } catch (Exception e) {
0959:                    ctx.setRollbackOnly();
0960:                    throw new LibresourceBugTrackerException(
0961:                            "Error in addIssueToBugTracker : " + e.getMessage(),
0962:                            e);
0963:                }
0964:            }
0965:
0966:            /**
0967:             * @ejb.interface-method
0968:             * @ejb.transaction type="Supports"
0969:             */
0970:            public IssueResourceValue[] listIssuesInBugTracker(URI bugtrackerUri)
0971:                    throws LibresourceBugTrackerException,
0972:                    LibresourceSecurityException, URINotExistException {
0973:                try {
0974:                    IssueResourceValue[] list = (IssueResourceValue[]) listIssuesAt(bugtrackerUri);
0975:
0976:                    return list;
0977:                } catch (LibresourceSecurityException se) {
0978:                    throw se;
0979:                } catch (URINotExistException se) {
0980:                    throw se;
0981:                } catch (Exception e) {
0982:                    throw new LibresourceBugTrackerException(
0983:                            "Error in listIssuesInBugTracker : "
0984:                                    + e.getMessage(), e);
0985:                }
0986:            }
0987:
0988:            /**
0989:             * @ejb.interface-method
0990:             * @ejb.transaction type="Supports"
0991:             */
0992:            public Vector listAssigneeIssuesInBugTracker(URI bugtrackerUri,
0993:                    URI userUri) throws LibresourceBugTrackerException,
0994:                    LibresourceSecurityException, URINotExistException {
0995:                try {
0996:                    IssueResourceValue[] bugTrackerIssues = (IssueResourceValue[]) listIssuesInBugTracker(bugtrackerUri);
0997:                    Vector issues = new Vector();
0998:
0999:                    for (int i = 0; i < bugTrackerIssues.length; i++) {
1000:                        try {
1001:                            if (bugTrackerIssues[i].getAssignee().compareTo(
1002:                                    userUri.getPath()) == 0) {
1003:                                if (bugTrackerIssues[i].getResolution()
1004:                                        .compareTo("UNRESOLVED") == 0) {
1005:                                    issues.add(bugTrackerIssues[i]);
1006:                                }
1007:                            }
1008:                        } catch (Exception e) {
1009:                            // TODO: handle exception
1010:                        }
1011:                    }
1012:
1013:                    return issues;
1014:                } catch (LibresourceSecurityException se) {
1015:                    throw se;
1016:                } catch (URINotExistException se) {
1017:                    throw se;
1018:                } catch (Exception e) {
1019:                    throw new LibresourceBugTrackerException(
1020:                            "Error in listAssigneeIssuesInBugTracker : "
1021:                                    + e.getMessage(), e);
1022:                }
1023:            }
1024:
1025:            /**
1026:             * @ejb.interface-method
1027:             * @ejb.transaction type="Supports"
1028:             */
1029:            public Object[] listAssigneeIssues(URI userUri)
1030:                    throws LibresourceBugTrackerException,
1031:                    LibresourceSecurityException, URINotExistException {
1032:                try {
1033:                    Collection issuesByAssignee = IssueResourceUtil
1034:                            .getLocalHome().findByAssignee(userUri.getPath());
1035:                    KernelService kernelService = (KernelService) Libresource
1036:                            .getService(KernelConstants.SERVICE);
1037:                    Vector bugtrackers = new Vector();
1038:                    Vector issues = new Vector();
1039:                    IssueResourceLocal issueLocal;
1040:                    IssueResourceValue issue;
1041:                    BugTrackerResourceValue bugtracker;
1042:
1043:                    for (Iterator i = issuesByAssignee.iterator(); i.hasNext();) {
1044:                        issueLocal = (IssueResourceLocal) i.next();
1045:                        issue = issueLocal.getIssueResourceValue();
1046:
1047:                        try {
1048:                            issue
1049:                                    .setUri(kernelService
1050:                                            .getMyURI(new LibresourceResourceIdentifier(
1051:                                                    BugTrackerConstants.SERVICE,
1052:                                                    BugTrackerConstants.RESOURCE_ISSUE,
1053:                                                    issueLocal.getId())));
1054:                            issues.add(issue);
1055:                        } catch (Exception e) {
1056:                            issueLocal.remove();
1057:                        }
1058:
1059:                        try {
1060:                            URI bugtrackerUri = kernelService.getParent(issue
1061:                                    .getUri());
1062:                            bugtracker = getBugTracker(bugtrackerUri);
1063:                            bugtrackers.add(bugtracker);
1064:                        } catch (Exception e) {
1065:                            //
1066:                        }
1067:                    }
1068:
1069:                    Object[] tab = new Object[2];
1070:                    tab[0] = issues;
1071:                    tab[1] = bugtrackers;
1072:
1073:                    return tab;
1074:                } catch (Exception e) {
1075:                    throw new LibresourceBugTrackerException(
1076:                            "Error in listAssigneeIssues : " + e.getMessage(),
1077:                            e);
1078:                }
1079:            }
1080:
1081:            /**
1082:             * @ejb.interface-method
1083:             * @ejb.transaction type="Supports"
1084:             */
1085:            public int nbAssigneeIssues()
1086:                    throws LibresourceBugTrackerException,
1087:                    LibresourceSecurityException, URINotExistException {
1088:                try {
1089:                    KernelService kernelService = (KernelService) Libresource
1090:                            .getService(KernelConstants.SERVICE);
1091:                    URI userUri = kernelService.getConnectedResource();
1092:                    Collection issuesByAssignee = IssueResourceUtil
1093:                            .getLocalHome().findByAssignee(userUri.getPath());
1094:                    IssueResourceLocal issueLocal;
1095:                    IssueResourceValue issue;
1096:                    int size = 0;
1097:
1098:                    for (Iterator i = issuesByAssignee.iterator(); i.hasNext();) {
1099:                        issueLocal = (IssueResourceLocal) i.next();
1100:                        issue = issueLocal.getIssueResourceValue();
1101:
1102:                        try {
1103:                            issue
1104:                                    .setUri(kernelService
1105:                                            .getMyURI(new LibresourceResourceIdentifier(
1106:                                                    BugTrackerConstants.SERVICE,
1107:                                                    BugTrackerConstants.RESOURCE_ISSUE,
1108:                                                    issueLocal.getId())));
1109:                            size++;
1110:                        } catch (Exception e) {
1111:                            issueLocal.remove();
1112:                        }
1113:                    }
1114:
1115:                    return size;
1116:                } catch (Exception e) {
1117:                    throw new LibresourceBugTrackerException(
1118:                            "Error in nbAssigneeIssues : " + e.getMessage(), e);
1119:                }
1120:            }
1121:
1122:            /**
1123:             * @ejb.interface-method
1124:             * @ejb.transaction type="Required"
1125:             */
1126:            public void assignIssue(URI issueUri, URI assignee)
1127:                    throws LibresourceBugTrackerException,
1128:                    LibresourceSecurityException, URINotExistException {
1129:                try {
1130:                    KernelService kernelService = (KernelService) Libresource
1131:                            .getService(KernelConstants.SERVICE);
1132:                    MembershipService membershipService = (MembershipService) Libresource
1133:                            .getService(MembershipConstants.SERVICE);
1134:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
1135:                            .lookup(issueUri);
1136:                    IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
1137:                            .findResource(resourceIdentifier,
1138:                                    IssueResourceLocal.class);
1139:
1140:                    if (!(kernelService.getConnectedResource().getPath()
1141:                            .compareTo(issueResourceLocal.getAssignee()) == 0)) {
1142:                        if (!kernelService.checkSecurity(issueUri,
1143:                                KernelConstants.SECURITY_UPDATE)) {
1144:                            throw new LibresourceSecurityException(issueUri,
1145:                                    KernelConstants.SECURITY_UPDATE);
1146:                        }
1147:                    }
1148:
1149:                    issueResourceLocal.setUpdateDate(new Date());
1150:                    issueResourceLocal.setAssignee(assignee.getPath());
1151:
1152:                    // update node
1153:                    kernelService.setUpdateDate(issueUri, new Date());
1154:
1155:                    // event
1156:                    LibresourceEvent event = new LibresourceEvent(issueUri,
1157:                            resourceIdentifier, kernelService
1158:                                    .getConnectedResource(),
1159:                            BugTrackerConstants.EVENT_ISSUE_ASSIGN,
1160:                            kernelService.normalizeAbsoluteURIPath(assignee));
1161:                    Libresource.throwEvent(event);
1162:
1163:                    // indexation
1164:                    Libresource.index(issueUri);
1165:                } catch (LibresourceSecurityException se) {
1166:                    ctx.setRollbackOnly();
1167:                    throw se;
1168:                } catch (URINotExistException se) {
1169:                    ctx.setRollbackOnly();
1170:                    throw se;
1171:                } catch (Exception e) {
1172:                    ctx.setRollbackOnly();
1173:                    throw new LibresourceBugTrackerException(
1174:                            "Error in assignIssue : " + e.getMessage(), e);
1175:                }
1176:            }
1177:
1178:            /**
1179:             * @ejb.interface-method
1180:             * @ejb.transaction type="Required"
1181:             */
1182:            public void resolveIssue(URI issueUri, String resolution)
1183:                    throws LibresourceBugTrackerException,
1184:                    LibresourceSecurityException, URINotExistException {
1185:                try {
1186:                    KernelService kernelService = (KernelService) Libresource
1187:                            .getService(KernelConstants.SERVICE);
1188:                    MembershipService membershipService = (MembershipService) Libresource
1189:                            .getService(MembershipConstants.SERVICE);
1190:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
1191:                            .lookup(issueUri);
1192:                    IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
1193:                            .findResource(resourceIdentifier,
1194:                                    IssueResourceLocal.class);
1195:
1196:                    if (!(kernelService.getConnectedResource().getPath()
1197:                            .compareTo(issueResourceLocal.getAssignee()) == 0)) {
1198:                        if (!kernelService.checkSecurity(issueUri,
1199:                                KernelConstants.SECURITY_UPDATE)) {
1200:                            throw new LibresourceSecurityException(issueUri,
1201:                                    KernelConstants.SECURITY_UPDATE);
1202:                        }
1203:                    }
1204:
1205:                    issueResourceLocal.setUpdateDate(new Date());
1206:                    issueResourceLocal.setResolution(resolution);
1207:
1208:                    // update node
1209:                    kernelService.setUpdateDate(issueUri, new Date());
1210:
1211:                    // event
1212:                    LibresourceEvent event = new LibresourceEvent(issueUri,
1213:                            resourceIdentifier, kernelService
1214:                                    .getConnectedResource(),
1215:                            BugTrackerConstants.EVENT_ISSUE_RESOLVE, resolution);
1216:                    Libresource.throwEvent(event);
1217:
1218:                    // indexation
1219:                    Libresource.index(issueUri);
1220:                } catch (LibresourceSecurityException se) {
1221:                    ctx.setRollbackOnly();
1222:                    throw se;
1223:                } catch (URINotExistException se) {
1224:                    ctx.setRollbackOnly();
1225:                    throw se;
1226:                } catch (Exception e) {
1227:                    ctx.setRollbackOnly();
1228:                    throw new LibresourceBugTrackerException(
1229:                            "Error in resolveIssue : " + e.getMessage(), e);
1230:                }
1231:            }
1232:
1233:            /**
1234:             * @ejb.interface-method
1235:             * @ejb.transaction type="Supports"
1236:             */
1237:            public Vector getListOfType()
1238:                    throws LibresourceBugTrackerException,
1239:                    LibresourceSecurityException {
1240:                return issuesTypes;
1241:            }
1242:
1243:            /**
1244:             * @ejb.interface-method
1245:             * @ejb.transaction type="Supports"
1246:             */
1247:            public Vector getListOfPriority()
1248:                    throws LibresourceBugTrackerException,
1249:                    LibresourceSecurityException {
1250:                return issuesPriorities;
1251:            }
1252:
1253:            /**
1254:             * @ejb.interface-method
1255:             * @ejb.transaction type="Supports"
1256:             */
1257:            public Vector getListOfResolution()
1258:                    throws LibresourceBugTrackerException,
1259:                    LibresourceSecurityException {
1260:                return issuesResolution;
1261:            }
1262:
1263:            /**
1264:             * @ejb.interface-method
1265:             * @ejb.transaction type="Supports"
1266:             */
1267:            public LibresourceIndexableContent getIndexableContent(
1268:                    LibresourceResourceIdentifier resourceIdentifier)
1269:                    throws LibresourceException {
1270:                try {
1271:                    try {
1272:                        Libresource.checkType(resourceIdentifier,
1273:                                IssueResourceLocal.class);
1274:
1275:                        LibresourceIndexableContent content = new LibresourceIndexableContent();
1276:                        IssueResourceLocal issueResourceLocal = (IssueResourceLocal) Libresource
1277:                                .findResource(resourceIdentifier);
1278:                        content.addContentPart(issueResourceLocal.getSummary());
1279:
1280:                        if (issueResourceLocal.getBody() != null) {
1281:                            content.addContentPart(issueResourceLocal.getBody()
1282:                                    .replaceAll("\\{.*\\}", ""));
1283:                        }
1284:
1285:                        return content;
1286:                    } catch (LibresourceException e) {
1287:                        //
1288:                    }
1289:
1290:                    try {
1291:                        Libresource.checkType(resourceIdentifier,
1292:                                BugTrackerResourceLocal.class);
1293:
1294:                        LibresourceIndexableContent content = new LibresourceIndexableContent();
1295:                        BugTrackerResourceLocal bugtrackerResourceLocal = (BugTrackerResourceLocal) Libresource
1296:                                .findResource(resourceIdentifier);
1297:                        content.addContentPart(bugtrackerResourceLocal
1298:                                .getName());
1299:                        content.addContentPart(bugtrackerResourceLocal
1300:                                .getDescription());
1301:
1302:                        return content;
1303:                    } catch (LibresourceException e) {
1304:                        //
1305:                    }
1306:
1307:                    return null;
1308:                } catch (Exception e) {
1309:                    throw new LibresourceException(
1310:                            "error in LibresourceBugTracker.getIndexableContent("
1311:                                    + resourceIdentifier + ")", e);
1312:                }
1313:            }
1314:
1315:            /**
1316:             * @ejb.interface-method
1317:             * @ejb.transaction type="Supports"
1318:             */
1319:            public String[] listAvailablesPermissions(
1320:                    LibresourceResourceIdentifier resourceIdentifier)
1321:                    throws LibresourceException {
1322:                if (resourceIdentifier.getService().equals(
1323:                        BugTrackerConstants.SERVICE)) {
1324:                    if (resourceIdentifier.getResourceType().equals(
1325:                            BugTrackerConstants.RESOURCE_BUGTRACKER)) {
1326:                        return new String[] {
1327:                                BugTrackerConstants.SECURITY_ADDBUG,
1328:                                BugTrackerConstants.SECURITY_POSTCOMMENT };
1329:                    }
1330:
1331:                    if (resourceIdentifier.getResourceType().equals(
1332:                            BugTrackerConstants.RESOURCE_ISSUE)) {
1333:                        return new String[] { BugTrackerConstants.SECURITY_POSTCOMMENT };
1334:                    }
1335:                }
1336:
1337:                return super .listAvailablesPermissions(resourceIdentifier);
1338:            }
1339:
1340:            /**
1341:             * @ejb.interface-method
1342:             * @ejb.transaction type="Supports"
1343:             */
1344:            public String[] listAvailablesEvents(
1345:                    LibresourceResourceIdentifier resourceIdentifier)
1346:                    throws LibresourceException {
1347:                if (resourceIdentifier.getService().equals(
1348:                        BugTrackerConstants.SERVICE)) {
1349:                    if (resourceIdentifier.getResourceType().equals(
1350:                            "BugTracker")) {
1351:                        return new String[] {
1352:                                BugTrackerConstants.EVENT_BUGTRACKER_CREATE,
1353:                                BugTrackerConstants.EVENT_BUGTRACKER_EDIT,
1354:                                BugTrackerConstants.EVENT_BUGTRACKER_DELETE,
1355:                                BugTrackerConstants.EVENT_BUGTRACKER_ADD_ISSUE };
1356:                    }
1357:
1358:                    if (resourceIdentifier.getResourceType().equals("Issue")) {
1359:                        return new String[] {
1360:                                BugTrackerConstants.EVENT_ISSUE_CREATE,
1361:                                BugTrackerConstants.EVENT_ISSUE_EDIT,
1362:                                BugTrackerConstants.EVENT_ISSUE_DELETE,
1363:                                BugTrackerConstants.EVENT_ISSUE_ADD_FILE,
1364:                                BugTrackerConstants.EVENT_BUGTRACKER_ADD_COMMENT,
1365:                                BugTrackerConstants.EVENT_ISSUE_ASSIGN,
1366:                                BugTrackerConstants.EVENT_ISSUE_RESOLVE };
1367:                    }
1368:                }
1369:
1370:                return super .listAvailablesPermissions(resourceIdentifier);
1371:            }
1372:
1373:            /**
1374:             * @ejb.interface-method
1375:             * @ejb.transaction type="Supports"
1376:             */
1377:            public LibresourceExportHandler getXmlExportHandlerForResource(
1378:                    URI uri) throws LibresourceException {
1379:                try {
1380:                    KernelService kernelService = (KernelService) Libresource
1381:                            .getService(KernelConstants.SERVICE);
1382:                    LibresourceResourceIdentifier resourceIdentifier = kernelService
1383:                            .lookup(uri);
1384:
1385:                    try {
1386:                        Libresource.checkType(resourceIdentifier,
1387:                                BugTrackerResourceLocal.class);
1388:
1389:                        return new BugTrackerExportHandler(uri);
1390:                    } catch (Exception e) {
1391:                        //
1392:                    }
1393:
1394:                    try {
1395:                        Libresource.checkType(resourceIdentifier,
1396:                                IssueResourceLocal.class);
1397:
1398:                        return new IssueExportHandler(uri);
1399:                    } catch (Exception e) {
1400:                        //
1401:                    }
1402:
1403:                    return super .getXmlExportHandlerForResource(uri);
1404:                } catch (Exception e) {
1405:                    throw new LibresourceException(
1406:                            "Can't obtain exportHandler for uri " + uri, e);
1407:                }
1408:            }
1409:
1410:            /**
1411:             * @ejb.interface-method
1412:             * @ejb.transaction type="Supports"
1413:             */
1414:            public LibresourceImportHandler getXmlImportHandler(String type)
1415:                    throws LibresourceException {
1416:                if (type.equals("BugTracker")) {
1417:                    return new BugTrackerImportHandler();
1418:                }
1419:
1420:                if (type.equals("Issue")) {
1421:                    return new IssueImportHandler();
1422:                }
1423:
1424:                return super.getXmlImportHandler(type);
1425:            }
1426:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.