📄 jahiafilefieldwrapper.java
字号:
// JahiaFileFieldWrapper// YG 17.07.2001package org.jahia.data.fields;import java.util.*; // Vectorimport org.jahia.utils.*; import org.jahia.data.files.*; import org.jahia.services.filemanager.*; // Filemanager, Folderimport org.jahia.params.*; // ParamBeanimport org.jahia.registries.*; // Registriesimport org.jahia.engines.filemanager.*; // Filemanager_Engineimport org.jahia.exceptions.JahiaException;public class JahiaFileFieldWrapper extends JahiaField{ /*** * constructor * YG 17.07.2001 * */ public JahiaFileFieldWrapper(Integer ID, Integer jahiaID, Integer pageID, Integer ctnid, Integer fieldDefID, Integer fieldType, Integer connectType, String fieldValue, Integer rank, Integer aclID ) { super(ID, jahiaID, pageID, ctnid, fieldDefID, fieldType, connectType, fieldValue, rank, aclID); } // end constructor public void load(int loadFlag, ParamBean jParams) throws JahiaException { //System.out.println("JahiaFieldBaseService::loadField() " + theField.getID() ); JahiaFileField fField = (JahiaFileField)ServicesRegistry. getInstance().getJahiaFilemanagerService(). getFileField(this.getID()); // set the download url String dUrl = "#"; if (fField != null) { //System.out.println("JahiaFieldBaseService::loadField() fField is not null and id=" + fField.getFileID() ); if ( fField.getFileID() != -1 ) { this.setObject(fField); Vector params = new Vector(); params.add("actionFileDownload"); params.add(this); dUrl = ((Filemanager_Engine)EnginesRegistry.getInstance(). getEngine("filemanager")).renderLink(jParams, params); } fField.setDownloadUrl(dUrl); this.setObject(fField); } } public void save(ParamBean jParams) throws JahiaException { if ( this.getObject() != null ){ JahiaFileField fField = (JahiaFileField)this.getObject(); if (fField != null && (fField.getFieldID() != -1) ) { // save Jahia File Field ServicesRegistry.getInstance().getJahiaFilemanagerService(). saveJahiaFileField( fField ); } } } public void delete(ParamBean jParams) throws JahiaException { JahiaFileField fField = ServicesRegistry.getInstance(). getJahiaFilemanagerService().getFileField(this.getID()); if ( fField != null ){ ServicesRegistry.getInstance().getJahiaFilemanagerService(). deleteJahiaFileField(fField); } } /** * Returns an hashtable of indexable attributes , pairs [attribute name/value]. * Returned pairs: * ("size",size) the file size * * @return Hashtable a map of indexable attributes , pairs [attribute name/value] */ public Hashtable getIndexableAttributes(){ Hashtable hash = new Hashtable(); JahiaFileField fField = (JahiaFileField)getObject(); if ( fField != null ){ hash.put("size",String.valueOf(fField.getSize())); } return hash; } public String getEngineName() { return "org.jahia.engines.shared.File_Field"; } public String getFieldContent4Ranking() { String fieldInfo = ""; JahiaFileField fle = (JahiaFileField)this.getObject(); if (fle != null) { fieldInfo = fle.getFileFieldTitle(); } else { fieldInfo = this.getValue(); } return fieldInfo; } public String getIconNameOff() { return "file"; } public String getIconNameOn() { return "file_on"; } public JahiaField cloneField(int newctnid, int newPageID, int clonedAclID, boolean childrenCloned) throws JahiaException { JahiaField clonedField = ServicesRegistry.getInstance().getJahiaFieldService(). createJahiaField(0, this.getJahiaID(), newPageID, newctnid, this.getFieldDefID(), this.getType(), this.getConnectType(), this.getValue(), this.getRank(), clonedAclID ); //toDebug("cloneField(): value = "+this.getValue()); if (clonedField == null) { throw new JahiaException ("Could not clone field.", "Could not instanciate a new JahiaField object.", JahiaException.PAGE_ERROR, JahiaException.CRITICAL); } clonedField.setRawValue(this.getRawValue()); // clonedField.setObject( this.getObject() ); clonedField.setProperties( (Hashtable)(this.getProperties()).clone() ); int theFieldID = ServicesRegistry.getInstance().getJahiaIncrementorsDBService().autoIncrement( "jahia_fields_data" ); clonedField.setID(theFieldID); clonedField.setObject("createFieldWithCurrentID"); boolean flag = ServicesRegistry.getInstance().getJahiaFilemanagerService(). copyFileField(this.getID(), clonedField.getID(), clonedField.getPageID()); return clonedField; } public Object clone() { Object objItem = this.getObject(); JahiaFileFieldWrapper filef = new JahiaFileFieldWrapper (new Integer(ID), new Integer(jahiaID), new Integer(pageID), new Integer(ctnid), new Integer(fieldDefID), new Integer(fieldType), new Integer(connectType), fieldValue, new Integer(rank), new Integer(aclID) ); filef.setObject(objItem); return filef; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -