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 ; 14 15 16 23 public class UsageEntry { 24 private int id; 25 private int version; 26 private int workflow; 27 private String lang; 28 private String val; 29 private JahiaField aField; 30 private JahiaPage aPage; 32 private String url; 33 34 UsageEntry (int id, int version, int workflow, String lang, String 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 list = new ArrayList (); 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 JahiaUser currentUser = jParams.getUser (); 51 if (aField != null) { 52 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 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 getLang () { 93 return lang; 94 } 95 96 public String getVal () { 97 return val; 98 } 99 100 101 public String getUrl () { 102 return url; 103 } 104 105 public String 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 |