1 23 package org.infoglue.deliver.taglib.content; 24 25 import java.util.ArrayList ; 26 import java.util.HashMap ; 27 import java.util.List ; 28 import java.util.Map ; 29 30 import javax.servlet.jsp.JspException ; 31 import javax.servlet.jsp.JspTagException ; 32 33 import org.infoglue.cms.webservices.elements.RemoteAttachment; 34 import org.infoglue.deliver.taglib.AbstractTag; 35 36 42 public class ContentVersionParameterTag extends AbstractTag implements ContentVersionParameterInterface 43 { 44 47 private static final long serialVersionUID = 4482006814634520239L; 48 49 52 private Map contentVersion = new HashMap (); 53 54 55 58 public ContentVersionParameterTag() 59 { 60 super(); 61 } 62 63 69 public int doStartTag() throws JspException 70 { 71 return EVAL_BODY_INCLUDE; 72 } 73 74 81 public int doEndTag() throws JspException  82 { 83 addContentVersion(); 84 85 contentVersion = new HashMap (); 86 87 return EVAL_PAGE; 88 } 89 90 95 protected void addContentVersion() throws JspException  96 { 97 final ContentParameterTag parent = (ContentParameterTag) findAncestorWithClass(this, ContentParameterTag.class); 98 if(parent == null) 99 { 100 throw new JspTagException ("ContentVersionParameterTag must have a ContentParameterTag ancestor."); 101 } 102 ((ContentParameterTag) parent).addContentVersion(contentVersion); 103 } 104 105 110 public void addContentVersionAttribute(String name, String value) throws JspException  111 { 112 Map contentVersionAttributes = (Map )this.contentVersion.get("contentVersionAttributes"); 113 if(contentVersionAttributes == null) 114 { 115 contentVersionAttributes = new HashMap (); 116 this.contentVersion.put("contentVersionAttributes", contentVersionAttributes); 117 } 118 119 contentVersionAttributes.put(name, value); 120 } 121 122 127 public void addDigitalAsset(RemoteAttachment remoteAttachment) throws JspException  128 { 129 List digitalAssets = (List )this.contentVersion.get("digitalAssets"); 130 if(digitalAssets == null) 131 { 132 digitalAssets = new ArrayList (); 133 this.contentVersion.put("digitalAssets", digitalAssets); 134 } 135 136 digitalAssets.add(remoteAttachment); 137 } 138 139 142 public void setLanguageId(final String languageId) throws JspException  143 { 144 this.contentVersion.put("languageId", evaluateInteger("remoteContentService", "languageId", languageId)); 145 } 146 147 150 public void setStateId(final String stateId) throws JspException  151 { 152 this.contentVersion.put("stateId", evaluateInteger("remoteContentService", "stateId", stateId)); 153 } 154 155 } 156 | Popular Tags |