Changeset 18861

Show
Ignore:
Timestamp:
05/16/07 21:07:37 (3 years ago)
Author:
atchertchian
Message:

NXP-244: Relations actions do not appear in the document's history

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/java/org/nuxeo/ecm/platform/relations/web/listener/RelationActions.java

    r18850 r18861  
    7373    public String addStatement() throws ClientException; 
    7474 
    75     public String deleteStatement(Statement selectedStatement); 
     75    public String deleteStatement(Statement selectedStatement) 
     76            throws ClientException; 
    7677 
    7778    public QNameResource getDocumentResource(); 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/java/org/nuxeo/ecm/platform/relations/web/listener/ejb/RelationActionsBean.java

    r18850 r18861  
    1919 
    2020import java.util.ArrayList; 
     21import java.util.HashMap; 
    2122import java.util.List; 
     23import java.util.Map; 
    2224 
    2325import javax.ejb.PostActivate; 
     
    3840import org.jboss.seam.annotations.Observer; 
    3941import org.jboss.seam.annotations.Scope; 
     42import org.nuxeo.ecm.core.NXCore; 
    4043import org.nuxeo.ecm.core.api.ClientException; 
     44import org.nuxeo.ecm.core.api.CoreSession; 
    4145import org.nuxeo.ecm.core.api.DocumentModel; 
    4246import org.nuxeo.ecm.core.api.Filter; 
    4347import org.nuxeo.ecm.core.api.ejb.EJBExceptionHandler; 
     48import org.nuxeo.ecm.core.api.event.CoreEvent; 
     49import org.nuxeo.ecm.core.api.event.CoreEventConstants; 
     50import org.nuxeo.ecm.core.api.event.impl.CoreEventImpl; 
    4451import org.nuxeo.ecm.core.api.impl.FacetFilter; 
     52import org.nuxeo.ecm.core.listener.CoreEventListenerService; 
    4553import org.nuxeo.ecm.platform.relations.api.Node; 
    4654import org.nuxeo.ecm.platform.relations.api.QNameResource; 
     
    4856import org.nuxeo.ecm.platform.relations.api.Resource; 
    4957import org.nuxeo.ecm.platform.relations.api.Statement; 
     58import org.nuxeo.ecm.platform.relations.api.event.RelationEvents; 
    5059import org.nuxeo.ecm.platform.relations.api.impl.LiteralImpl; 
    5160import org.nuxeo.ecm.platform.relations.api.impl.QNameResourceImpl; 
     
    8695    public static final String DOCUMENT_NAMESPACE = "http://www.nuxeo.org/document/uid/"; 
    8796 
     97    @In(create = true, required = false) 
     98    CoreSession documentManager; 
     99 
    88100    @In(create = true) 
    89101    RelationManager relationManager; 
     
    281293    } 
    282294 
     295    protected void notifyEvent(String eventId, DocumentModel source, 
     296            Map<String, Object> options, String comment) { 
     297        CoreEvent coreEvent = new CoreEventImpl(eventId, source, options, 
     298                documentManager.getPrincipal(), RelationEvents.CATEGORY, 
     299                comment); 
     300        CoreEventListenerService service = NXCore.getCoreEventListenerService(); 
     301        if (service != null) { 
     302            log.debug("Notify RepositoryEventListener listeners list for event=" 
     303                    + eventId); 
     304            service.notifyEventListeners(coreEvent); 
     305        } else { 
     306            log.error("Impossible to notify core events ! " 
     307                    + "CoreEventListenerService service is missing..."); 
     308        } 
     309    } 
     310 
    283311    public String addStatement() throws ClientException { 
    284         if (getDocumentResource() == null) { 
     312        Resource documentResource = getDocumentResource(); 
     313        if (documentResource == null) { 
    285314            throw new ClientException( 
    286315                    "Document resource could not be retrieved"); 
     
    301330        } 
    302331 
    303         Statement stmt = new StatementImpl(getDocumentResource(), predicate, 
    304                 object); 
     332        Statement stmt = new StatementImpl(documentResource, predicate, object); 
    305333        if (!outgoingStatementList.contains(stmt)) { 
    306334            // add statement to the graph 
    307335            List<Statement> stmts = new ArrayList<Statement>(); 
     336            String eventComment = null; 
    308337            if (comment != null) { 
    309338                comment = comment.trim(); 
     
    312341                            "http://www.nuxeo.org/comment"); 
    313342                    stmt.addProperty(commentPred, new LiteralImpl(comment)); 
     343                    eventComment = comment; 
    314344                } 
    315345            } 
    316346            stmts.add(stmt); 
     347 
     348            // notifications 
     349 
     350            Map<String, Object> options = new HashMap<String, Object>(); 
     351            DocumentModel source = navigationContext.getCurrentDocument(); 
     352            String currentLifeCycleState = source.getCurrentLifeCycleState(); 
     353            options.put(CoreEventConstants.DOC_LIFE_CYCLE, 
     354                    currentLifeCycleState); 
     355            options.put(RelationEvents.NEW_STATEMENT_EVENT_KEY, stmt); 
     356 
     357            // before notification 
     358            notifyEvent(RelationEvents.BEFORE_RELATION_CREATION, source, 
     359                    options, eventComment); 
     360 
     361            // add statement 
    317362            relationManager.add(GRAPH_NAME, stmts); 
     363 
     364            // after notification 
     365            notifyEvent(RelationEvents.AFTER_RELATION_CREATION, source, 
     366                    options, eventComment); 
     367 
    318368            outgoingStatementList.add(stmt); 
    319369            // take care of relation to oneself 
     
    348398    } 
    349399 
    350     public String deleteStatement(Statement selectedOutgoingStatement) { 
     400    public String deleteStatement(Statement selectedOutgoingStatement) 
     401            throws ClientException { 
    351402        if (selectedOutgoingStatement != null 
    352403                && outgoingStatementList.contains(selectedOutgoingStatement)) { 
     404            // notifications 
     405            Map<String, Object> options = new HashMap<String, Object>(); 
     406            DocumentModel source = navigationContext.getCurrentDocument(); 
     407            String currentLifeCycleState = source.getCurrentLifeCycleState(); 
     408            options.put(CoreEventConstants.DOC_LIFE_CYCLE, 
     409                    currentLifeCycleState); 
     410            options.put(RelationEvents.NEW_STATEMENT_EVENT_KEY, 
     411                    selectedOutgoingStatement); 
     412 
     413            // before notification 
     414            notifyEvent(RelationEvents.BEFORE_RELATION_CREATION, source, 
     415                    options, null); 
     416 
     417            // remove statement 
    353418            List<Statement> stmts = new ArrayList<Statement>(); 
    354419            stmts.add(selectedOutgoingStatement); 
    355420            relationManager.remove(GRAPH_NAME, stmts); 
     421 
     422            // after notification 
     423            notifyEvent(RelationEvents.AFTER_RELATION_CREATION, source, 
     424                    options, null); 
     425 
    356426            outgoingStatementList.remove(selectedOutgoingStatement); 
    357427            // take care of relation to oneself 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/resources/META-INF/MANIFEST.MF

    r15967 r18861  
    66Require-Bundle: org.nuxeo.ecm.webapp.core 
    77Nuxeo-Component: OSGI-INF/actions-contrib.xml, 
     8 OSGI-INF/audit-contrib.xml, 
    89 OSGI-INF/directories-contrib.xml 
    910Nuxeo-RequiredBy: org.nuxeo.ecm.war 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/resources/OSGI-INF/deployment-fragment.xml

    r16248 r18861  
    7474    </unzip> 
    7575 
    76     <append from="NXRelationsWeb.tmp/OSGI-INF/l10n/messages.properties" 
     76    <append from="NXRelationsWeb.tmp/OSGI-INF/l10n/messages_en.properties" 
    7777      to="nuxeo.war/WEB-INF/classes/messages.properties" addNewLine="true" /> 
    7878    <append from="NXRelationsWeb.tmp/OSGI-INF/l10n/messages_en.properties" 
     
    8282    <append from="NXRelationsWeb.tmp/OSGI-INF/l10n/messages_de.properties" 
    8383      to="nuxeo.war/WEB-INF/classes/messages_de.properties" addNewLine="true" /> 
     84    <append from="NXRelationsWeb.tmp/OSGI-INF/l10n/messages_it.properties" 
     85      to="nuxeo.war/WEB-INF/classes/messages_it.properties" addNewLine="true" /> 
    8486 
    8587    <copy from="NXRelationsWeb.tmp/META-INF/nxrelations.taglib.xml" 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/resources/OSGI-INF/l10n/messages_de.properties

    r16025 r18861  
    55#Verbesserungen wären natürlich sehr herzlich willkommen 
    66 
    7 action.view.relation=Relationen 
     7action.view.relations=Relationen 
    88 
    99command.show.create.relation=Eine Relation erstellen 
     
    1212title.create.relation=Eine Relation erstellen 
    1313title.relation.outgoing=Ausgehende Relationen 
    14 title.relation.ingoing=Einkomennde Relationen 
     14title.relation.incoming=Einkomennde Relationen 
    1515 
    1616label.relation.subject=Subjekt 
     
    4545label.relation.deleted=Relation deleted 
    4646 
     47afterRelationCreation=Relation created 
     48afterRelationModification=Relation modified 
     49afterRelationRemoval=Relation deleted 
     50relationNotificationCategory=Relations 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/resources/OSGI-INF/l10n/messages_en.properties

    r16025 r18861  
    3939label.relation.deleted=Relation deleted 
    4040 
     41# for notification logs 
     42afterRelationCreation=Relation created 
     43afterRelationModification=Relation modified 
     44afterRelationRemoval=Relation deleted 
     45relationNotificationCategory=Relations 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/resources/OSGI-INF/l10n/messages_fr.properties

    r16025 r18861  
    3737label.relation.created=Relation créée 
    3838label.relation.already.exists=La relation existe déjà 
    39 label.relation.deleted=Relation effacée 
     39label.relation.deleted=Relation supprimée 
    4040 
    41  
     41afterRelationCreation=Relation créée 
     42afterRelationModification=Relation modifiée 
     43afterRelationRemoval=Relation supprimée 
     44relationNotificationCategory=Relations 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-relations-web/src/main/resources/OSGI-INF/l10n/messages_it.properties

    r18411 r18861  
    1  
    2 action.view.relation  = Relazione 
    31action.view.relations = Relazioni 
    42 
     
    3634title.create.relation   = Aggiungere una nuova relazione 
    3735title.relation.incoming = Relazioni in ingresso 
    38 title.relation.ingoing  = Relazioni in ingresso 
    3936title.relation.outgoing = Relazioni in uscita 
     37 
     38afterRelationCreation=Relation created 
     39afterRelationModification=Relation modified 
     40afterRelationRemoval=Relation deleted 
     41relationNotificationCategory=Relations