001: /**
002: * LibreSource Community
003: * Copyright (C) 2004-2007 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This software is not a free software; you can modify it under the
007: * LibreSource Enterprise user license but you can't redistribute it.
008: * See licenses details in LSE-user-license.txt
009: *
010: * Initial authors :
011: *
012: * Guillaume Bort / INRIA
013: * Francois Charoy / Universite Nancy 2
014: * Julien Forest / Artenum
015: * Claude Godart / Universite Henry Poincare
016: * Florent Jouille / INRIA
017: * Sebastien Jourdain / INRIA / Artenum
018: * Yves Lerumeur / Artenum
019: * Pascal Molli / Universite Henry Poincare
020: * Gerald Oster / INRIA
021: * Mariarosa Penzi / Artenum
022: * Gerard Sookahet / Artenum
023: * Raphael Tani / INRIA
024: *
025: * Contributors :
026: *
027: * Stephane Bagnier / Artenum
028: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
029: */package org.libresource.form.ejb;
030:
031: import java.net.URI;
032: import java.util.Date;
033: import java.util.Vector;
034:
035: import org.libresource.Libresource;
036: import org.libresource.LibresourceEvent;
037: import org.libresource.LibresourceException;
038: import org.libresource.LibresourceResourceIdentifier;
039: import org.libresource.LibresourceResourceValue;
040: import org.libresource.LibresourceServiceBase;
041: import org.libresource.form.Form;
042: import org.libresource.form.FormConstants;
043: import org.libresource.form.FormExportHandler;
044: import org.libresource.form.FormField;
045: import org.libresource.form.FormImportHandler;
046: import org.libresource.form.LibresourceFormException;
047: import org.libresource.form.ejb.model.FormResourceValue;
048: import org.libresource.form.interfaces.FormResourceLocal;
049: import org.libresource.form.util.FormResourceUtil;
050: import org.libresource.forum.ForumConstants;
051: import org.libresource.forum.interfaces.LibresourceForumService;
052: import org.libresource.kernel.KernelConstants;
053: import org.libresource.kernel.LibresourceSecurityException;
054: import org.libresource.kernel.URINotExistException;
055: import org.libresource.kernel.interfaces.KernelService;
056: import org.libresource.search.LibresourceIndexableContent;
057: import org.libresource.wiki.WikiConstants;
058: import org.libresource.wiki.interfaces.LibresourceWikiService;
059: import org.libresource.xml.LibresourceExportHandler;
060: import org.libresource.xml.LibresourceImportHandler;
061:
062: /**
063: * The Libresource Form service
064: *
065: * @libresource.service name="LibresourceForm" depends="Kernel, LibresourceCore, LibresourceWiki, LibresourceForum"
066: */
067: public abstract class LibresourceFormServiceBean extends
068: LibresourceServiceBase {
069: /**
070: * @ejb.interface-method
071: * @ejb.transaction type="Required"
072: */
073: public void createForm(URI uri, String name)
074: throws LibresourceFormException,
075: LibresourceSecurityException {
076: try {
077: KernelService kernelService = (KernelService) Libresource
078: .getService(KernelConstants.SERVICE);
079:
080: if (!kernelService.checkSecurity(uri,
081: KernelConstants.SECURITY_CREATE)) {
082: throw new LibresourceSecurityException(uri,
083: KernelConstants.SECURITY_CREATE);
084: }
085:
086: FormResourceLocal formResourceLocal = FormResourceUtil
087: .getLocalHome().create(name);
088: kernelService.bind(formResourceLocal
089: .getLibresourceResourceIdentifier(), uri, name);
090: formResourceLocal.setDescription("");
091: formResourceLocal.setDestinationURI(".");
092: formResourceLocal.setRedirectionURI(".");
093: formResourceLocal
094: .setResourceTypeToCreate(WikiConstants.RESOURCE);
095:
096: // event
097: LibresourceEvent event = new LibresourceEvent(uri,
098: formResourceLocal
099: .getLibresourceResourceIdentifier(),
100: kernelService.getConnectedResource(),
101: FormConstants.EVENT_FORM_CREATE);
102: Libresource.throwEvent(event);
103: } catch (LibresourceSecurityException se) {
104: ctx.setRollbackOnly();
105: throw se;
106: } catch (Exception e) {
107: ctx.setRollbackOnly();
108: throw new LibresourceFormException("Error in createForm : "
109: + e.getMessage(), e);
110: }
111: }
112:
113: /**
114: * @ejb.interface-method
115: * @ejb.transaction type="Required"
116: */
117: public void editForm(URI uri, String name, String description,
118: String destinationURI, String resourceTypeToCreate,
119: String webRedirection) throws LibresourceFormException,
120: LibresourceSecurityException, URINotExistException {
121: try {
122: KernelService kernelService = (KernelService) Libresource
123: .getService(KernelConstants.SERVICE);
124: LibresourceResourceIdentifier resourceIdentifier = kernelService
125: .lookup(uri);
126:
127: if (!kernelService.checkSecurity(uri,
128: KernelConstants.SECURITY_UPDATE)) {
129: throw new LibresourceSecurityException(uri,
130: KernelConstants.SECURITY_UPDATE);
131: }
132:
133: // Change data
134: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
135: .findResource(resourceIdentifier,
136: FormResourceLocal.class);
137: formResourceLocal.setName(name);
138: formResourceLocal.setDescription(description);
139: formResourceLocal.setDestinationURI(destinationURI);
140: formResourceLocal
141: .setResourceTypeToCreate(resourceTypeToCreate);
142: formResourceLocal.setRedirectionURI(webRedirection);
143:
144: // update node
145: kernelService.setShortName(uri, name);
146: kernelService.setUpdateDate(uri, new Date());
147:
148: // event
149: LibresourceEvent event = new LibresourceEvent(uri,
150: resourceIdentifier, kernelService
151: .getConnectedResource(),
152: FormConstants.EVENT_FORM_EDIT);
153: Libresource.throwEvent(event);
154: } catch (LibresourceSecurityException se) {
155: ctx.setRollbackOnly();
156: throw se;
157: } catch (URINotExistException se) {
158: ctx.setRollbackOnly();
159: throw se;
160: } catch (Exception e) {
161: ctx.setRollbackOnly();
162: throw new LibresourceFormException("Error in editForm : "
163: + e.getClass().getName() + " : " + e.getMessage(),
164: e);
165: }
166: }
167:
168: /**
169: * @ejb.interface-method
170: * @ejb.transaction type="Required"
171: */
172: public void addFormField(URI uri, FormField formField)
173: throws LibresourceFormException,
174: LibresourceSecurityException, URINotExistException {
175: try {
176: KernelService kernelService = (KernelService) Libresource
177: .getService(KernelConstants.SERVICE);
178: LibresourceResourceIdentifier resourceIdentifier = kernelService
179: .lookup(uri);
180:
181: if (!kernelService.checkSecurity(uri,
182: KernelConstants.SECURITY_UPDATE)) {
183: throw new LibresourceSecurityException(uri,
184: KernelConstants.SECURITY_UPDATE);
185: }
186:
187: // Change data
188: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
189: .findResource(resourceIdentifier,
190: FormResourceLocal.class);
191: formField.resetValue();
192: formResourceLocal.addField(formField);
193:
194: // update node
195: kernelService.setUpdateDate(uri, new Date());
196:
197: // event
198: LibresourceEvent event = new LibresourceEvent(uri,
199: resourceIdentifier, kernelService
200: .getConnectedResource(),
201: FormConstants.EVENT_FORM_EDIT);
202: Libresource.throwEvent(event);
203: } catch (LibresourceSecurityException se) {
204: ctx.setRollbackOnly();
205: throw se;
206: } catch (URINotExistException se) {
207: ctx.setRollbackOnly();
208: throw se;
209: } catch (Exception e) {
210: ctx.setRollbackOnly();
211: throw new LibresourceFormException(
212: "Error in addFormField : " + e.getClass().getName()
213: + " : " + e.getMessage(), e);
214: }
215: }
216:
217: /**
218: * @ejb.interface-method
219: * @ejb.transaction type="Required"
220: */
221: public void addFormField(URI uri, int position, FormField formField)
222: throws LibresourceFormException,
223: LibresourceSecurityException, URINotExistException {
224: try {
225: KernelService kernelService = (KernelService) Libresource
226: .getService(KernelConstants.SERVICE);
227: LibresourceResourceIdentifier resourceIdentifier = kernelService
228: .lookup(uri);
229:
230: if (!kernelService.checkSecurity(uri,
231: KernelConstants.SECURITY_UPDATE)) {
232: throw new LibresourceSecurityException(uri,
233: KernelConstants.SECURITY_UPDATE);
234: }
235:
236: // Change data
237: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
238: .findResource(resourceIdentifier,
239: FormResourceLocal.class);
240: formField.resetValue();
241: formResourceLocal.addField(position, formField);
242:
243: // update node
244: kernelService.setUpdateDate(uri, new Date());
245:
246: // event
247: LibresourceEvent event = new LibresourceEvent(uri,
248: resourceIdentifier, kernelService
249: .getConnectedResource(),
250: FormConstants.EVENT_FORM_EDIT);
251: Libresource.throwEvent(event);
252: } catch (LibresourceSecurityException se) {
253: ctx.setRollbackOnly();
254: throw se;
255: } catch (URINotExistException se) {
256: ctx.setRollbackOnly();
257: throw se;
258: } catch (Exception e) {
259: ctx.setRollbackOnly();
260: throw new LibresourceFormException(
261: "Error in addFormField : " + e.getClass().getName()
262: + " : " + e.getMessage(), e);
263: }
264: }
265:
266: /**
267: * @ejb.interface-method
268: * @ejb.transaction type="Required"
269: */
270: public void setFormFields(URI uri, Vector formFields)
271: throws LibresourceFormException,
272: LibresourceSecurityException, URINotExistException {
273: try {
274: KernelService kernelService = (KernelService) Libresource
275: .getService(KernelConstants.SERVICE);
276: LibresourceResourceIdentifier resourceIdentifier = kernelService
277: .lookup(uri);
278:
279: if (!kernelService.checkSecurity(uri,
280: KernelConstants.SECURITY_UPDATE)) {
281: throw new LibresourceSecurityException(uri,
282: KernelConstants.SECURITY_UPDATE);
283: }
284:
285: // Change data
286: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
287: .findResource(resourceIdentifier,
288: FormResourceLocal.class);
289: formResourceLocal.setFormFields(formFields);
290: formResourceLocal.resetValues();
291:
292: // update node
293: kernelService.setUpdateDate(uri, new Date());
294:
295: // event
296: LibresourceEvent event = new LibresourceEvent(uri,
297: resourceIdentifier, kernelService
298: .getConnectedResource(),
299: FormConstants.EVENT_FORM_EDIT);
300: Libresource.throwEvent(event);
301: } catch (LibresourceSecurityException se) {
302: ctx.setRollbackOnly();
303: throw se;
304: } catch (URINotExistException se) {
305: ctx.setRollbackOnly();
306: throw se;
307: } catch (Exception e) {
308: ctx.setRollbackOnly();
309: throw new LibresourceFormException(
310: "Error in addFormField : " + e.getClass().getName()
311: + " : " + e.getMessage(), e);
312: }
313: }
314:
315: /**
316: * @ejb.interface-method
317: * @ejb.transaction type="Required"
318: */
319: public void removeFormField(URI uri, String fieldID)
320: throws LibresourceFormException,
321: LibresourceSecurityException, URINotExistException {
322: try {
323: KernelService kernelService = (KernelService) Libresource
324: .getService(KernelConstants.SERVICE);
325: LibresourceResourceIdentifier resourceIdentifier = kernelService
326: .lookup(uri);
327:
328: if (!kernelService.checkSecurity(uri,
329: KernelConstants.SECURITY_UPDATE)) {
330: throw new LibresourceSecurityException(uri,
331: KernelConstants.SECURITY_UPDATE);
332: }
333:
334: // Change data
335: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
336: .findResource(resourceIdentifier,
337: FormResourceLocal.class);
338: formResourceLocal.removeField(fieldID);
339:
340: // update node
341: kernelService.setUpdateDate(uri, new Date());
342:
343: // event
344: LibresourceEvent event = new LibresourceEvent(uri,
345: resourceIdentifier, kernelService
346: .getConnectedResource(),
347: FormConstants.EVENT_FORM_EDIT);
348: Libresource.throwEvent(event);
349: } catch (LibresourceSecurityException se) {
350: ctx.setRollbackOnly();
351: throw se;
352: } catch (URINotExistException se) {
353: ctx.setRollbackOnly();
354: throw se;
355: } catch (Exception e) {
356: ctx.setRollbackOnly();
357: throw new LibresourceFormException(
358: "Error in removeFormField : "
359: + e.getClass().getName() + " : "
360: + e.getMessage(), e);
361: }
362: }
363:
364: /**
365: * @ejb.interface-method
366: * @ejb.transaction type="Required"
367: */
368: public void moveFormFieldUp(URI uri, String fieldID)
369: throws LibresourceFormException,
370: LibresourceSecurityException, URINotExistException {
371: try {
372: KernelService kernelService = (KernelService) Libresource
373: .getService(KernelConstants.SERVICE);
374: LibresourceResourceIdentifier resourceIdentifier = kernelService
375: .lookup(uri);
376:
377: if (!kernelService.checkSecurity(uri,
378: KernelConstants.SECURITY_UPDATE)) {
379: throw new LibresourceSecurityException(uri,
380: KernelConstants.SECURITY_UPDATE);
381: }
382:
383: // Change data
384: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
385: .findResource(resourceIdentifier,
386: FormResourceLocal.class);
387: formResourceLocal.moveFieldUp(fieldID);
388:
389: // update node
390: kernelService.setUpdateDate(uri, new Date());
391:
392: // event
393: LibresourceEvent event = new LibresourceEvent(uri,
394: resourceIdentifier, kernelService
395: .getConnectedResource(),
396: FormConstants.EVENT_FORM_EDIT);
397: Libresource.throwEvent(event);
398: } catch (LibresourceSecurityException se) {
399: ctx.setRollbackOnly();
400: throw se;
401: } catch (URINotExistException se) {
402: ctx.setRollbackOnly();
403: throw se;
404: } catch (Exception e) {
405: ctx.setRollbackOnly();
406: throw new LibresourceFormException(
407: "Error in moveFormFieldUp : "
408: + e.getClass().getName() + " : "
409: + e.getMessage(), e);
410: }
411: }
412:
413: /**
414: * @ejb.interface-method
415: * @ejb.transaction type="Required"
416: */
417: public void moveFormFieldDown(URI uri, String fieldID)
418: throws LibresourceFormException,
419: LibresourceSecurityException, URINotExistException {
420: try {
421: KernelService kernelService = (KernelService) Libresource
422: .getService(KernelConstants.SERVICE);
423: LibresourceResourceIdentifier resourceIdentifier = kernelService
424: .lookup(uri);
425:
426: if (!kernelService.checkSecurity(uri,
427: KernelConstants.SECURITY_UPDATE)) {
428: throw new LibresourceSecurityException(uri,
429: KernelConstants.SECURITY_UPDATE);
430: }
431:
432: // Change data
433: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
434: .findResource(resourceIdentifier,
435: FormResourceLocal.class);
436: formResourceLocal.moveFieldDown(fieldID);
437:
438: // update node
439: kernelService.setUpdateDate(uri, new Date());
440:
441: // event
442: LibresourceEvent event = new LibresourceEvent(uri,
443: resourceIdentifier, kernelService
444: .getConnectedResource(),
445: FormConstants.EVENT_FORM_EDIT);
446: Libresource.throwEvent(event);
447: } catch (LibresourceSecurityException se) {
448: ctx.setRollbackOnly();
449: throw se;
450: } catch (URINotExistException se) {
451: ctx.setRollbackOnly();
452: throw se;
453: } catch (Exception e) {
454: ctx.setRollbackOnly();
455: throw new LibresourceFormException(
456: "Error in moveFormFieldUp : "
457: + e.getClass().getName() + " : "
458: + e.getMessage(), e);
459: }
460: }
461:
462: /**
463: * @ejb.interface-method
464: * @ejb.transaction type="Required"
465: */
466: public void deleteForm(URI uri) throws LibresourceFormException,
467: LibresourceSecurityException, URINotExistException {
468: try {
469: KernelService kernelService = (KernelService) Libresource
470: .getService(KernelConstants.SERVICE);
471: LibresourceResourceIdentifier resourceIdentifier = kernelService
472: .lookup(uri);
473:
474: // event
475: LibresourceEvent event = new LibresourceEvent(uri,
476: resourceIdentifier, kernelService
477: .getConnectedResource(),
478: FormConstants.EVENT_FORM_DELETE);
479: Libresource.throwEvent(event);
480:
481: Libresource.checkType(resourceIdentifier,
482: FormResourceLocal.class);
483: kernelService.deleteURI(uri);
484: } catch (LibresourceSecurityException se) {
485: ctx.setRollbackOnly();
486: throw se;
487: } catch (URINotExistException se) {
488: ctx.setRollbackOnly();
489: throw se;
490: } catch (Exception e) {
491: ctx.setRollbackOnly();
492: throw new LibresourceFormException("Error in deleteForm : "
493: + e.getClass().getName() + " : " + e.getMessage(),
494: e);
495: }
496: }
497:
498: /**
499: * @ejb.interface-method
500: * @ejb.transaction type="Required"
501: */
502: public void submitForm(URI uri, Form formValues)
503: throws LibresourceFormException,
504: LibresourceSecurityException, URINotExistException {
505: try {
506: KernelService kernelService = (KernelService) Libresource
507: .getService(KernelConstants.SERVICE);
508: LibresourceResourceIdentifier resourceIdentifier = kernelService
509: .lookup(uri);
510:
511: // Check security
512: if (!kernelService.checkSecurity(uri,
513: FormConstants.SECURITY_FORM_SUBMIT)) {
514: throw new LibresourceSecurityException(uri,
515: FormConstants.SECURITY_FORM_SUBMIT);
516: }
517:
518: // Get form
519: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
520: .findResource(resourceIdentifier,
521: FormResourceLocal.class);
522:
523: // Find the destination URI
524: URI absoluteParentURI = Libresource.getAbsoluteURI(uri,
525: formResourceLocal.getDestinationURI());
526: URI destinationURI = new URI(absoluteParentURI + "/1");
527: int suffix = 1;
528:
529: while (kernelService.exist(destinationURI)) {
530: destinationURI = new URI(kernelService
531: .normalizeAbsoluteURIPath(absoluteParentURI)
532: + "/" + suffix);
533: suffix++;
534: }
535:
536: // Create the resource
537: String resourceName = formResourceLocal.getName();
538:
539: if (formValues.getFields().size() > 0) {
540: resourceName = ((FormField) formValues.getFields()
541: .iterator().next()).getValue();
542: }
543:
544: if (formResourceLocal.getResourceTypeToCreate().equals(
545: WikiConstants.RESOURCE)) {
546: // Wiki page
547: LibresourceWikiService libresourceWikiService = (LibresourceWikiService) Libresource
548: .getService(WikiConstants.SERVICE);
549: libresourceWikiService.systemCreatePage(destinationURI,
550: resourceName, false);
551: libresourceWikiService.systemEditPageContent(
552: destinationURI, "{printField:field="
553: + formValues.getFieldsId()
554: + "|print=label,value,edit}", "");
555: } else if (formResourceLocal.getResourceTypeToCreate()
556: .equals("Message")) {
557: // Forum message
558: LibresourceForumService libresourceForumService = (LibresourceForumService) Libresource
559: .getService(ForumConstants.SERVICE);
560: libresourceForumService.systemCreateMessage(
561: destinationURI, resourceName,
562: "{printField:field=" + formValues.getFieldsId()
563: + "|print=label,value,edit}");
564: }
565:
566: // General security setting
567: kernelService.systemChown(destinationURI, kernelService
568: .getOwner(uri), false);
569:
570: // Set forms values
571: kernelService.systemSetProperty(destinationURI,
572: FormConstants.NODE_PROPERTY_FORM, formValues);
573:
574: // event
575: LibresourceEvent event = new LibresourceEvent(uri,
576: resourceIdentifier, kernelService
577: .getConnectedResource(),
578: FormConstants.EVENT_FORM_SUBMIT);
579: Libresource.throwEvent(event);
580: } catch (LibresourceSecurityException se) {
581: ctx.setRollbackOnly();
582: throw se;
583: } catch (URINotExistException se) {
584: ctx.setRollbackOnly();
585: throw se;
586: } catch (Exception e) {
587: ctx.setRollbackOnly();
588: throw new LibresourceFormException("Error in submitForm : "
589: + e.getClass().getName() + " : " + e.getMessage(),
590: e);
591: }
592: }
593:
594: /**
595: * @ejb.interface-method
596: * @ejb.transaction type="Supports"
597: */
598: public FormResourceValue getForm(URI uri)
599: throws LibresourceFormException,
600: LibresourceSecurityException, URINotExistException {
601: try {
602: KernelService kernelService = (KernelService) Libresource
603: .getService(KernelConstants.SERVICE);
604: LibresourceResourceIdentifier resourceIdentifier = kernelService
605: .lookup(uri);
606: FormResourceLocal formResourceLocal = (FormResourceLocal) Libresource
607: .findResource(resourceIdentifier,
608: FormResourceLocal.class);
609: FormResourceValue resourceValue = formResourceLocal
610: .getFormResourceValue();
611: resourceValue.setUri(kernelService.normalizeURI(uri));
612:
613: return resourceValue;
614: } catch (LibresourceSecurityException se) {
615: throw se;
616: } catch (URINotExistException se) {
617: throw se;
618: } catch (Exception e) {
619: throw new LibresourceFormException("Error in getForm : "
620: + e.getMessage(), e);
621: }
622: }
623:
624: /**
625: * @ejb.interface-method
626: * @ejb.transaction type="Supports"
627: */
628: public FormResourceValue[] listFormAt(URI uri)
629: throws LibresourceFormException,
630: LibresourceSecurityException, URINotExistException {
631: try {
632: KernelService kernelService = (KernelService) Libresource
633: .getService(KernelConstants.SERVICE);
634: LibresourceResourceValue[] forms = kernelService
635: .listResourcesAt(
636: uri,
637: FormResourceLocal.LIBRESOURCE_RESOURCE_SERVICE,
638: FormResourceLocal.LIBRESOURCE_RESOURCE_TYPE);
639: FormResourceValue[] formResourceValues = new FormResourceValue[forms.length];
640:
641: for (int i = 0; i < formResourceValues.length; i++) {
642: LibresourceResourceIdentifier resourceIdentifier = forms[i]
643: .getLibresourceResourceIdentifier();
644: formResourceValues[i] = ((FormResourceLocal) Libresource
645: .findResource(resourceIdentifier))
646: .getFormResourceValue();
647: formResourceValues[i].setUri(kernelService
648: .normalizeURI(forms[i].getUri()));
649: }
650:
651: return formResourceValues;
652: } catch (LibresourceSecurityException se) {
653: throw se;
654: } catch (URINotExistException se) {
655: throw se;
656: } catch (Exception e) {
657: throw new LibresourceFormException("Error in listFormAt : "
658: + e.getMessage(), e);
659: }
660: }
661:
662: // libresource service
663:
664: /**
665: * @ejb.interface-method
666: * @ejb.transaction type="Supports"
667: */
668: public LibresourceIndexableContent getIndexableContent(
669: LibresourceResourceIdentifier resourceIdentifier)
670: throws LibresourceException {
671: return null;
672: }
673:
674: /**
675: * @ejb.interface-method
676: * @ejb.transaction type="Supports"
677: */
678: public String[] listAvailablesEvents(
679: LibresourceResourceIdentifier resourceIdentifier)
680: throws LibresourceException {
681: if (resourceIdentifier.getService().equals(
682: FormConstants.SERVICE)) {
683: if (resourceIdentifier.getResourceType().equals(
684: FormConstants.RESOURCE_FORM)) {
685: return new String[] { FormConstants.EVENT_FORM_CREATE,
686: FormConstants.EVENT_FORM_DELETE,
687: FormConstants.EVENT_FORM_EDIT };
688: }
689: }
690:
691: return super .listAvailablesPermissions(resourceIdentifier);
692: }
693:
694: /**
695: * @ejb.interface-method
696: * @ejb.transaction type="Supports"
697: */
698: public String[] listAvailablesPermissions(
699: LibresourceResourceIdentifier resourceIdentifier)
700: throws LibresourceException {
701: try {
702: Libresource.checkType(resourceIdentifier,
703: FormResourceLocal.class);
704:
705: return new String[] { FormConstants.SECURITY_FORM_SUBMIT };
706: } catch (LibresourceException e) {
707: //
708: }
709:
710: return null;
711: }
712:
713: /**
714: * @ejb.interface-method
715: * @ejb.transaction type="Supports"
716: */
717: public LibresourceExportHandler getXmlExportHandlerForResource(
718: URI uri) throws LibresourceException {
719: try {
720: KernelService kernelService = (KernelService) Libresource
721: .getService(KernelConstants.SERVICE);
722: LibresourceResourceIdentifier resourceIdentifier = kernelService
723: .lookup(uri);
724:
725: try {
726: Libresource.checkType(resourceIdentifier,
727: FormResourceLocal.class);
728:
729: return new FormExportHandler(uri);
730: } catch (Exception e) {
731: //
732: }
733:
734: return super .getXmlExportHandlerForResource(uri);
735: } catch (Exception e) {
736: throw new LibresourceException(
737: "Can't obtain exportHandler for uri " + uri, e);
738: }
739: }
740:
741: /**
742: * @ejb.interface-method
743: * @ejb.transaction type="Supports"
744: */
745: public LibresourceImportHandler getXmlImportHandler(String type)
746: throws LibresourceException {
747: if (type.equals("Form")) {
748: return new FormImportHandler();
749: }
750:
751: return super.getXmlImportHandler(type);
752: }
753: }
|