001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.kernel.ejb;
034:
035: import org.libresource.Libresource;
036: import org.libresource.LibresourceResourceBase;
037:
038: import org.libresource.kernel.util.SymbolicLinkResourceUtil;
039:
040: import java.net.URI;
041:
042: import javax.ejb.CreateException;
043:
044: /**
045: * LibreSource
046: *
047: * @author <a href="mailto:bort@loria.fr">Guillaume Bort</a> - <a
048: * href="http://www.inria.fr">INRIA Lorraine</a>
049: *
050: * A Symbolic Link
051: *
052: * @libresource.resource name="SymbolicLink" service="Kernel"
053: */
054: public abstract class SymbolicLinkResourceBean extends
055: LibresourceResourceBase {
056: /**
057: * @ejb.create-method
058: */
059: public String ejbCreate(String uri) throws CreateException {
060: setId(SymbolicLinkResourceUtil.generateGUID(this ));
061: setLinkURI(uri);
062:
063: return null;
064: }
065:
066: // persistents fields
067:
068: /**
069: * @ejb.persistent-field
070: * @ejb.interface-method
071: * @ejb.value-object match="libresource"
072: * @ejb.transaction type="Supports"
073: */
074: public abstract String getId();
075:
076: /**
077: * @ejb.persistent-field
078: * @ejb.interface-method
079: * @ejb.transaction type="Mandatory"
080: */
081: public abstract void setId(String id);
082:
083: /**
084: * @ejb.interface-method
085: * @ejb.value-object match="libresource"
086: * @ejb.transaction type="Supports"
087: */
088: public String getShortResourceName() {
089: try {
090: return Libresource.getShortName(new URI(getLinkURI()));
091: } catch (Exception e) {
092: return "Invalid Symbolic Link to " + getLinkURI();
093: }
094: }
095:
096: /**
097: * @ejb.persistent-field
098: * @ejb.interface-method
099: * @ejb.value-object match="libresource"
100: * @ejb.transaction type="Supports"
101: */
102: public abstract String getLinkURI();
103:
104: /**
105: * @ejb.persistent-field
106: * @ejb.interface-method
107: * @ejb.transaction type="Mandatory"
108: */
109: public abstract void setLinkURI(String uri);
110: }
|