KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > workflowtool > function > PathContentProvider


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23 package org.infoglue.cms.applications.workflowtool.function;
24
25 import org.apache.log4j.Logger;
26 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController;
27 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController;
28 import org.infoglue.cms.entities.management.Repository;
29
30 import com.opensymphony.workflow.WorkflowException;
31
32 /**
33  *
34  */

35 public class PathContentProvider extends ContentProvider
36 {
37     private final static Logger logger = Logger.getLogger(PathContentProvider.class.getName());
38
39     /**
40      *
41      */

42     private static final String JavaDoc CONTENT_PARAMETER_NAME_ARGUMENT = "contentParameterName";
43     
44     /**
45      *
46      */

47     private static final String JavaDoc CONTENT_VERSION_PARAMETER_NAME_ARGUMENT = "contentVersionParameterName";
48     
49     /**
50      * The name of the path argument.
51      */

52     private static final String JavaDoc PATH_ARGUMENT = "path";
53     
54     /**
55      * The name of the repository argument.
56      */

57     private static final String JavaDoc REPOSITORY_NAME_ARGUMENT = "repository";
58     
59     /**
60      * The name of the repository.
61      */

62     private String JavaDoc repositoryName;
63     
64     /**
65      * The path identifying the content inside the specified <code>repository</code>.
66      */

67     private String JavaDoc path;
68     
69     /**
70      *
71      */

72     private String JavaDoc contentParameterName;
73     
74     /**
75      *
76      */

77     private String JavaDoc contentVersionParameterName;
78     
79     /**
80      * Default constructor.
81      */

82     public PathContentProvider()
83     {
84         super();
85     }
86
87     /**
88      *
89      */

90     protected String JavaDoc getContentParameterName()
91     {
92         return contentParameterName;
93     }
94     
95     /**
96      *
97      */

98     protected String JavaDoc getContentVersionParameterName()
99     {
100         return contentVersionParameterName;
101     }
102     
103     /**
104      *
105      */

106     protected void initializeContentVO() throws WorkflowException
107     {
108         try
109         {
110             logger.debug("Using repository=["+ repositoryName + "] path=["+ path + "]");
111             final Repository repository = RepositoryController.getController().getRepositoryWithName(repositoryName, getDatabase());
112             if(repository == null)
113             {
114                 throwException("No repository with the name [" + repositoryName + "] found.");
115             }
116             setContentVO(ContentController.getContentController().getContentVOWithPath(repository.getId(), path, false, getPrincipal(), getDatabase()));
117         }
118         catch(Exception JavaDoc e)
119         {
120             throwException(e);
121         }
122     }
123
124     /**
125      * Method used for initializing the function; will be called before <code>execute</code> is called.
126      * <p><strong>Note</strong>! You must call <code>super.initialize()</code> first.</p>
127      *
128      * @throws WorkflowException if an error occurs during the initialization.
129      */

130     protected void initialize() throws WorkflowException
131     {
132         super.initialize();
133         path = getArgument(PATH_ARGUMENT);
134         repositoryName = getArgument(REPOSITORY_NAME_ARGUMENT);
135         contentParameterName = getArgument(CONTENT_PARAMETER_NAME_ARGUMENT, ContentFunction.CONTENT_PARAMETER);
136         contentVersionParameterName = getArgument(CONTENT_VERSION_PARAMETER_NAME_ARGUMENT, ContentFunction.CONTENT_VERSION_PARAMETER);
137     }
138 }
139
Popular Tags