1 2 14 26 package org.jahia.data; 27 28 import org.jahia.data.containers.JahiaContainerSet; 29 import org.jahia.data.fields.JahiaFieldSet; 30 import org.jahia.exceptions.JahiaException; 31 import org.jahia.gui.GuiBean; 32 import org.jahia.params.ParamBean; 33 import org.jahia.registries.ServicesRegistry; 34 import org.jahia.services.pages.JahiaPage; 35 import org.jahia.services.usermanager.JahiaUser; 36 import org.jahia.utils.JahiaConsole; 37 38 39 public class JahiaData { 40 41 public static final String JAHIA_DATA = "org.jahia.data.JahiaData"; 42 43 private ParamBean jParams; 44 45 private JahiaFieldSet fieldSet; 46 private JahiaContainerSet containerSet; 47 private GuiBean guiBean; 48 49 59 public JahiaData (ParamBean jParams, boolean doBuildData) 60 throws JahiaException 61 { 62 this.jParams = jParams; 63 if ( doBuildData ){ 64 buildData(); } else { 66 guiBean = new GuiBean( this.params() ); 67 } 68 } 70 71 72 78 public JahiaData (ParamBean jParams) 79 throws JahiaException 80 { 81 this.jParams = jParams; 82 83 buildData(); } 86 87 88 93 private void buildData() 94 throws JahiaException 95 { 96 try { 97 98 JahiaPage currentPage = params().getPage(); 100 JahiaUser currentUser = params().getUser(); 101 102 if (currentPage != null) 103 { 104 if (currentUser != null) 105 { 106 if (currentPage.checkReadAccess (currentUser)) 108 { 109 110 fieldSet = ServicesRegistry.getInstance().getJahiaFieldService( 111 ).buildFieldStructureForPage( this, params().getEntryLoadRequest() ); 112 containerSet = ServicesRegistry.getInstance().getJahiaContainersService( 113 ).buildContainerStructureForPage( this, params().getEntryLoadRequest() ); 114 guiBean = new GuiBean( this.params() ); 115 } 116 117 } else { 118 throw new JahiaException ("No user present !", 119 "No current user defined in the params in buildData() method.", 120 JahiaException.USER_ERROR, JahiaException.ERROR_SEVERITY); 121 } 122 } else { 123 String errorMsg = "Page does not exist : " + jParams.getPageID(); 124 JahiaConsole.println ( "OperationManager", errorMsg + " -> BAILING OUT" ); 125 throw new JahiaException ("404 Page not found", 126 errorMsg, JahiaException.PAGE_ERROR, JahiaException.ERROR_SEVERITY ); 127 } 128 129 } catch (JahiaException je) { 130 if (je.getSeverity() > JahiaException.WARNING_SEVERITY) { 131 JahiaConsole.println( "JahiaData", "Error in buildData -> BAILING OUT" ); 132 throw je; 133 } else { 134 JahiaConsole.println( "JahiaData", "Warning in buildData. Continuing..." ); 135 } 136 } 137 } 139 140 145 public ParamBean params() { return jParams; } 146 public JahiaPage page() { return jParams.getPage(); } public JahiaFieldSet fields() { return fieldSet; } 148 public JahiaContainerSet containers() { return containerSet; } 149 public GuiBean gui() { return guiBean; } 150 152 public ParamBean getParamBean() { 153 return jParams; 154 } 155 156 public JahiaFieldSet getFields() { 157 return fieldSet; 158 } 159 160 public JahiaContainerSet getContainerLists() { 161 return containerSet; 162 } 163 164 } 166 | Popular Tags |