KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > webdav > UsageEntry


1 package org.jahia.services.webdav;
2
3 import org.jahia.data.fields.JahiaField;
4 import org.jahia.data.fields.LoadFlags;
5 import org.jahia.exceptions.JahiaException;
6 import org.jahia.params.ParamBean;
7 import org.jahia.registries.ServicesRegistry;
8 import org.jahia.services.pages.JahiaPage;
9 import org.jahia.services.usermanager.JahiaUser;
10 import org.jahia.services.version.EntryLoadRequest;
11 import org.jahia.utils.LanguageCodeConverters;
12
13 import java.util.ArrayList JavaDoc;
14
15
16 /**
17  * Created by IntelliJ IDEA.
18  * User: toto
19  * Date: Jul 18, 2003
20  * Time: 12:51:15 AM
21  * To change this template use Options | File Templates.
22  */

23 public class UsageEntry {
24     private int id;
25     private int version;
26     private int workflow;
27     private String JavaDoc lang;
28     private String JavaDoc val;
29     private JahiaField aField;
30     // private ContentField contentField;
31
private JahiaPage aPage;
32     private String JavaDoc url;
33
34     UsageEntry (int id, int version, int workflow, String JavaDoc lang, String JavaDoc val, ParamBean jParams)
35             throws JahiaException {
36         this.id = id;
37         this.version = version;
38         this.workflow = workflow;
39         this.lang = lang;
40         this.val = val;
41
42         ArrayList JavaDoc list = new ArrayList JavaDoc();
43         list.add(LanguageCodeConverters.languageCodeToLocale(lang));
44         EntryLoadRequest loadRequest = new EntryLoadRequest(workflow, version, list);
45         if (jParams != null) {
46             ServicesRegistry sReg = ServicesRegistry.getInstance ();
47
48             aField = sReg.getJahiaFieldService ().loadField (id, LoadFlags.NOTHING, jParams, loadRequest);
49             // contentField = ContentField.getField(id);
50
JahiaUser currentUser = jParams.getUser ();
51             if (aField != null) {
52 // boolean processField
53
// = (jParams.getEntryLoadRequest().isCurrent()
54
// || (workflow == EntryLoadRequest.STAGING_WORKFLOW_STATE)
55
// || (workflow == EntryLoadRequest.ACTIVE_WORKFLOW_STATE
56
// && !contentField.hasStagingEntry(lang) ) );
57
aPage = sReg.getJahiaPageService ()
58                         .lookupPage (aField.getPageID (), loadRequest);
59                 if ((workflow == EntryLoadRequest.STAGING_WORKFLOW_STATE)
60                         || (workflow == EntryLoadRequest.ACTIVE_WORKFLOW_STATE)
61                         || (workflow == EntryLoadRequest.WAITING_WORKFLOW_STATE)) {
62
63                     if (aPage != null) {
64                         String JavaDoc opMode = jParams.getOperationMode ();
65                         if (workflow == EntryLoadRequest.STAGING_WORKFLOW_STATE) {
66                             jParams.setOperationMode (ParamBean.EDIT);
67                         } else if (workflow == EntryLoadRequest.ACTIVE_WORKFLOW_STATE) {
68                             jParams.setOperationMode (ParamBean.NORMAL);
69                         } else if (workflow == EntryLoadRequest.WAITING_WORKFLOW_STATE) {
70                             jParams.setOperationMode (ParamBean.PREVIEW);
71                         }
72                         url = aPage.getURL (jParams);
73                         jParams.setOperationMode (opMode);
74                     }
75                 }
76             }
77         }
78     }
79
80     public int getId () {
81         return id;
82     }
83
84     public int getVersion () {
85         return version;
86     }
87
88     public int getWorkflow () {
89         return workflow;
90     }
91
92     public String JavaDoc getLang () {
93         return lang;
94     }
95
96     public String JavaDoc getVal () {
97         return val;
98     }
99
100
101     public String JavaDoc getUrl () {
102         return url;
103     }
104
105     public String JavaDoc getPageTitle () {
106         if (aPage != null) {
107             return aPage.getTitle ();
108         }
109         return null;
110     }
111
112     public JahiaField getField () {
113         return aField;
114     }
115
116 }
117
Popular Tags