KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > bean > wizard > NewReplyWizard


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the GNU Lesser General Public License as
5  * published by the Free Software Foundation; either version
6  * 2.1 of the License, or (at your option) any later version.
7  * You may obtain a copy of the License at
8  *
9  * http://www.gnu.org/licenses/lgpl.txt
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the
16  * License.
17  */

18 package org.alfresco.web.bean.wizard;
19
20 import javax.faces.event.ActionEvent;
21
22 import org.alfresco.model.ContentModel;
23 import org.alfresco.service.cmr.repository.ContentReader;
24 import org.alfresco.service.cmr.repository.NodeRef;
25 import org.alfresco.web.app.AlfrescoNavigationHandler;
26 import org.alfresco.web.ui.common.Utils;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29
30
31 /**
32  * Backing bean for posting replies to forum articles.
33  *
34  * @author gavinc
35  */

36 public class NewReplyWizard extends NewPostWizard
37 {
38    private static Log logger = LogFactory.getLog(NewReplyWizard.class);
39    
40    private String JavaDoc replyContent = null;
41    
42    /**
43     * Returns the content of the post we are replying to
44     *
45     * @return The content
46     */

47    public String JavaDoc getReplyContent()
48    {
49       if (this.replyContent == null)
50       {
51          // get the content reader of the node we are replying to
52
NodeRef replyNode = this.browseBean.getDocument().getNodeRef();
53          if (replyNode != null)
54          {
55             ContentReader reader = this.contentService.getReader(replyNode, ContentModel.PROP_CONTENT);
56             
57             if (reader != null)
58             {
59                this.replyContent = reader.getContentString();
60             }
61          }
62       }
63       
64       return this.replyContent;
65    }
66    
67    /**
68     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#init()
69     */

70    @Override JavaDoc
71    public void init()
72    {
73       super.init();
74       
75       this.replyContent = null;
76    }
77
78    /**
79     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#startWizard(javax.faces.event.ActionEvent)
80     */

81    @Override JavaDoc
82    public void startWizard(ActionEvent event)
83    {
84       super.startWizard(event);
85       
86       // also setup the content in the browse bean
87
this.browseBean.setupContentAction(event);
88    }
89
90    /**
91     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
92     */

93    @Override JavaDoc
94    public String JavaDoc finish()
95    {
96       // remove link breaks and replace with <br/>
97
this.content = Utils.replaceLineBreaks(this.content);
98       
99       String JavaDoc outcome = super.finish();
100       
101       // if we had a successful outcome from the creation close the dialog
102
if (outcome != null);
103       {
104          outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
105       }
106       
107       return outcome;
108    }
109
110    /**
111     * @see org.alfresco.web.bean.wizard.BaseContentWizard#performCustomProcessing()
112     */

113    @Override JavaDoc
114    protected void performCustomProcessing()
115    {
116       if (this.editMode == false)
117       {
118          // setup the referencing aspect with the references association
119
// between the new post and the one being replied to
120
this.nodeService.addAspect(this.createdNode, ContentModel.ASPECT_REFERENCING, null);
121          this.nodeService.createAssociation(this.createdNode, this.browseBean.getDocument().getNodeRef(),
122                ContentModel.ASSOC_REFERENCES);
123          
124          if (logger.isDebugEnabled())
125          {
126             logger.debug("created new node: " + this.createdNode);
127             logger.debug("existing node: " + this.browseBean.getDocument().getNodeRef());
128          }
129       }
130    }
131
132    /**
133     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#cancel()
134     */

135    @Override JavaDoc
136    public String JavaDoc cancel()
137    {
138       super.cancel();
139       
140       return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
141    }
142 }
143
Popular Tags