incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r149292 [1/2] - in incubator/graffito/trunk: api/src/java/org/apache/portals/graffito/model/ components/src/java/META-INF/ components/src/java/org/apache/portals/graffito/model/impl/ components/src/schema/ portlets/src/java/org/apache/portals/graffito/portlets/ portlets/src/webapp/WEB-INF/velocity/
Date Mon, 31 Jan 2005 20:23:17 GMT
Author: clombart
Date: Mon Jan 31 12:23:11 2005
New Revision: 149292

URL: http://svn.apache.org/viewcvs?view=rev&rev=149292
Log:
Apply patch provided by Shinsuke in order to support content encoding

Modified:
    incubator/graffito/trunk/api/src/java/org/apache/portals/graffito/model/Content.java
    incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml
    incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java
    incubator/graffito/trunk/components/src/schema/graffitostore-schema.xml
    incubator/graffito/trunk/portlets/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java
    incubator/graffito/trunk/portlets/src/webapp/WEB-INF/velocity/velocity.properties

Modified: incubator/graffito/trunk/api/src/java/org/apache/portals/graffito/model/Content.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/api/src/java/org/apache/portals/graffito/model/Content.java?view=diff&r1=149291&r2=149292
==============================================================================
--- incubator/graffito/trunk/api/src/java/org/apache/portals/graffito/model/Content.java (original)
+++ incubator/graffito/trunk/api/src/java/org/apache/portals/graffito/model/Content.java Mon Jan 31 12:23:11 2005
@@ -1,63 +1,73 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.model;
-
-import java.io.InputStream;
-
-
-
-/**
- * CMS content interface.
- *
- * @author <a href="mailto:christophe.lombart">Christophe Lombart</a>
- * @version $Id: Content.java,v 1.1 2004/12/22 21:16:10 christophe Exp $
- */
-public interface Content extends Cloneable
-{
-    /**
-     * @return Returns the content.
-     */
-    public InputStream getContentStream();
-    
-    
-    /**
-     * @return Returns the content.
-     */
-    public byte[] getContentByte();
-    
-    /**
-     * @return Returns the content in the String format
-     */
-    public String getContentAsString();
-    
-    /**
-     * @param stream The content to set.
-     */    
-    public void setContent(InputStream stream);
-    
-    
-    /**
-     * @param content The content to set.
-     */
-    public void setContent(byte[] content);
- 
-    /**
-     *  Clone the content object
-     *  @return the new clone instante created
-     */
-    Object clone();
-}
-
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.model;
+
+import java.io.InputStream;
+
+
+
+/**
+ * CMS content interface.
+ *
+ * @author <a href="mailto:christophe.lombart">Christophe Lombart</a>
+ * @version $Id: Content.java,v 1.1 2004/12/22 21:16:10 christophe Exp $
+ */
+public interface Content extends Cloneable
+{
+    /**
+     * @return Returns the content.
+     */
+    public InputStream getContentStream();
+    
+    
+    /**
+     * @return Returns the content.
+     */
+    public byte[] getContentByte();
+    
+    /**
+     * @return Returns the content in the String format
+     */
+    public String getContentAsString();
+    
+    /**
+     * @param stream The content to set.
+     */    
+    public void setContent(InputStream stream);
+    
+    
+    /**
+     * @param content The content to set.
+     */
+    public void setContent(byte[] content);
+ 
+    /**
+     * @return Returns the encoding.
+     */
+    public String getEncoding();
+
+    /**
+     * @param encoding The encoding to set.
+     */
+    public void setEncoding(String encoding);
+
+    /**
+     *  Clone the content object
+     *  @return the new clone instante created
+     */
+    Object clone();
+}
+

Modified: incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml?view=diff&r1=149291&r2=149292
==============================================================================
--- incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml (original)
+++ incubator/graffito/trunk/components/src/java/META-INF/repository_graffito.xml Mon Jan 31 12:23:11 2005
@@ -1,690 +1,696 @@
-<!-- 
- Copyright 2002-2004 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- -->
- <!--
-    G R A F F I T  I     S T O R E 
--->	
-<descriptor-repository version="1.0">
-
-	<class-descriptor class="org.apache.portals.graffito.model.CmsObject">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FolderImpl" />
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.DocumentImpl" />
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.LinkImpl" />
-	</class-descriptor>
-
-	<class-descriptor class="org.apache.portals.graffito.model.Folder">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FolderImpl" />
-	</class-descriptor>       
-
-	<class-descriptor class="org.apache.portals.graffito.model.Link">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.LinkImpl" />
-	</class-descriptor>  	
-	<class-descriptor class="org.apache.portals.graffito.model.Document">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.DocumentImpl" />
-	</class-descriptor> 
-	
-	<class-descriptor class="org.apache.portals.graffito.model.Content">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.ContentImpl" />
-	</class-descriptor>	
-	
-	<class-descriptor class="org.apache.portals.graffito.model.HistoryElement">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.HistoryElementImpl" />
-	</class-descriptor>  	
-	
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.FolderImpl"
-	    table="CMS_OBJECT" >
-	    <field-descriptor 
-		name="objectId" 
-		jdbc-type="BIGINT"
-		column="OBJECT_ID" 
-		primarykey="true"
-		autoincrement="true"
-	    />
-	    
-	    <field-descriptor 
-		name="parentId" 
-		jdbc-type="BIGINT"
-		column="PARENT_ID" 
-		
-	    />
-		
-	    <field-descriptor 
-		name="versionNumber" 
-		jdbc-type="VARCHAR"
-		column="VERSION_NUM"		
-	    />  	    
-	    
-	    <field-descriptor 
-		name="isLastVersion" 
-		jdbc-type="INTEGER"
-		column="IS_LAST_VERSION"	
-               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"		
-	    />  		    
-				
-	    <field-descriptor 
-		name="name" 
-		jdbc-type="VARCHAR"
-		column="NAME" 
-	    />
-	    <field-descriptor 
-		name="uri" 
-		jdbc-type="VARCHAR"
-		column="URI" 
-	    />
-	
-	    <field-descriptor 
-		name="creationDate" 
-		jdbc-type="TIMESTAMP"
-		column="CREATION_DATE" 
-	       
-	    />
-	    <field-descriptor 
-		name="lastModified" 
-		jdbc-type="TIMESTAMP"
-		column="DELTA" 
-		
-	    />
-	    <field-descriptor 
-		name="description" 
-		jdbc-type="VARCHAR"
-		column="DESCRIPTION" 
-	    />
-	    <field-descriptor 
-		name="title" 
-		jdbc-type="VARCHAR"
-		column="TITLE"                 
-	    />
-	
-	    <field-descriptor 
-		name="ojbConcreteClass" 
-		jdbc-type="VARCHAR"
-		column="CLASS_NAME"                 
-	    />
-	    
-	    <reference-descriptor name="parentFolder" 
-		 class-ref="org.apache.portals.graffito.model.Folder"
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="link" 
-		 auto-delete="false" >
-		 <foreignkey field-ref="parentId"/>
-	    </reference-descriptor> 
-	    
-	   <collection-descriptor
-	     name="folders"
-	     element-class-ref="org.apache.portals.graffito.model.Folder"        
-	     auto-retrieve="true"      
-	     auto-update="link"
-	     auto-delete="true"
-	     proxy="true"
-             > 
-	       <inverse-foreignkey field-ref="parentId"/>
-	   </collection-descriptor>    
-	
-	
-	   <collection-descriptor
-	     name="documents"
-	     element-class-ref="org.apache.portals.graffito.model.Document"   
-	     auto-retrieve="true"      
-	     auto-update="link"
-	     auto-delete="true" 
-	     proxy="true"
-	     > 
-	       <inverse-foreignkey field-ref="parentId"/>
-	   </collection-descriptor>    
-	    
-	</class-descriptor>
-	
-	
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.LinkImpl"
-	    table="CMS_OBJECT" >
-	    <field-descriptor 
-		name="objectId" 
-		jdbc-type="BIGINT"
-		column="OBJECT_ID" 
-		primarykey="true"
-		autoincrement="true"
-	    />
-		
-	    <field-descriptor 
-		name="versionNumber" 
-		jdbc-type="VARCHAR"
-		column="VERSION_NUM"		
-	    />  	    
-	    
-	    <field-descriptor 
-		name="isLastVersion" 
-		jdbc-type="INTEGER"
-		column="IS_LAST_VERSION"	
-               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"		
-	    />  		    
-		
-	    <field-descriptor 
-		name="parentId" 
-		jdbc-type="BIGINT"
-		column="PARENT_ID" 
-		
-	    />
-	    
-	    <field-descriptor 
-		name="targetCmsObjectId" 
-		jdbc-type="BIGINT"
-		column="LINK_TARGET_ID" 
-		
-	    />
-		
-	    <field-descriptor 
-		name="name" 
-		jdbc-type="VARCHAR"
-		column="NAME" 
-	    />
-	    <field-descriptor 
-		name="uri" 
-		jdbc-type="VARCHAR"
-		column="URI" 
-	    />
-	
-	    <field-descriptor 
-		name="creationDate" 
-		jdbc-type="TIMESTAMP"
-		column="CREATION_DATE" 
-	       
-	    />
-	    <field-descriptor 
-		name="lastModified" 
-		jdbc-type="TIMESTAMP"
-		column="DELTA" 
-		
-	    />
-	    <field-descriptor 
-		name="description" 
-		jdbc-type="VARCHAR"
-		column="DESCRIPTION" 
-	    />
-	    <field-descriptor 
-		name="title" 
-		jdbc-type="VARCHAR"
-		column="TITLE"                 
-	    />
-	
-	    <field-descriptor 
-		name="ojbConcreteClass" 
-		jdbc-type="VARCHAR"
-		column="CLASS_NAME"                 
-	    />
-	    
-	    <reference-descriptor name="parentFolder" 
-		 class-ref="org.apache.portals.graffito.model.impl.FolderImpl"
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="link" 
-		 auto-delete="false" >
-		 <foreignkey field-ref="parentId"/>
-	    </reference-descriptor> 
-	    
-	    <reference-descriptor name="targetCmsObject" 
-		 class-ref="org.apache.portals.graffito.model.CmsObject"
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="true" 
-		 auto-delete="false" >
-		 <foreignkey field-ref="targetCmsObjectId"/>
-	    </reference-descriptor>    
-	    
-	</class-descriptor>
-	
-	
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.DocumentImpl"
-	    table="CMS_OBJECT" >
-	    <field-descriptor 
-		name="objectId" 
-		jdbc-type="BIGINT"
-		column="OBJECT_ID" 
-		primarykey="true"
-		autoincrement="true"
-	    />
-
-	    <field-descriptor 
-		name="contentId" 
-		jdbc-type="BIGINT"
-		column="CONTENT_ID" 
-	    />	    
-	    
-	    <field-descriptor 
-		name="versionNumber" 
-		jdbc-type="VARCHAR"
-		column="VERSION_NUM"		
-	    />  	    
-	    
-	    <field-descriptor 
-		name="isLastVersion" 
-		jdbc-type="INTEGER"
-		column="IS_LAST_VERSION"	
-               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"		
-	    />  		    
-		
-	    <field-descriptor 
-		name="parentId" 
-		jdbc-type="BIGINT"
-		column="PARENT_ID" 		
-	    />
-	   	    
-	    <field-descriptor 
-		name="name" 
-		jdbc-type="VARCHAR"
-		column="NAME" 
-	    />
-	    <field-descriptor 
-		name="uri" 
-		jdbc-type="VARCHAR"
-		column="URI" 
-	    />
-	
-	    <field-descriptor 
-		name="creationDate" 
-		jdbc-type="TIMESTAMP"
-		column="CREATION_DATE" 
-	       
-	    />
-	    <field-descriptor 
-		name="lastModified" 
-		jdbc-type="TIMESTAMP"
-		column="DELTA" 
-		
-	    />
-	    <field-descriptor 
-		name="description" 
-		jdbc-type="VARCHAR"
-		column="DESCRIPTION" 
-	    />
-	    <field-descriptor 
-		name="title" 
-		jdbc-type="VARCHAR"
-		column="TITLE"                 
-	    />
-  
-	    <field-descriptor 
-		name="size" 
-		jdbc-type="BIGINT"
-		column="CONTENT_SIZE"
-	    />
-	    <field-descriptor 
-		name="language" 
-		jdbc-type="VARCHAR"
-		column="LANGUAGE" 
-	    />
-	    
-	    <field-descriptor 
-		name="owner" 
-		jdbc-type="VARCHAR"
-		column="OWNER" 
-	    />
-	
-	    <field-descriptor 
-		name="contentType" 
-		jdbc-type="VARCHAR"
-		column="CONTENT_TYPE" 
-	    />    
-	    
-	    <field-descriptor 
-		name="ojbConcreteClass" 
-		jdbc-type="VARCHAR"
-		column="CLASS_NAME"                 
-	    />
-	    
-	    <reference-descriptor name="parentFolder" 
-		 class-ref="org.apache.portals.graffito.model.impl.FolderImpl"
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="link" 
-		 auto-delete="false" >
-		 <foreignkey field-ref="parentId"/>
-	    </reference-descriptor>		
-
-	    <reference-descriptor name="content" 
-		 class-ref="org.apache.portals.graffito.model.impl.ContentImpl"		 
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="true" 
-		 auto-delete="true" >
-		 <foreignkey field-ref="contentId"/>
-	    </reference-descriptor>		    
-	</class-descriptor>
-	
-	    
-	<class-descriptor 
-	
-	    class="org.apache.portals.graffito.model.impl.ContentImpl"
-	    table="CONTENT" >
-	    
- 	    <field-descriptor 	        
-		name="contentId" 
-		jdbc-type="BIGINT"
-		column="CONTENT_ID" 
-		primarykey="true"
-                autoincrement="true"		
-	    />
-	      
-	    <field-descriptor 
-		name="content" 
-		jdbc-type="BLOB"
-		column="CONTENT"        
-	    /> 
-	        
-	</class-descriptor>
-	
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.HistoryElementImpl"
-	    table="VERSION_HISTORY" >
-
-	    <field-descriptor 
-		name="historyElementId" 
-		jdbc-type="BIGINT"
-		column="HISTORY_ID" 
-		primarykey="true"		
-		autoincrement="true"
-	    />
-	    
-	    <field-descriptor 
-		name="documentId" 
-		jdbc-type="BIGINT"
-		column="OBJECT_ID" 
-		
-	    />
-	    
-	    <field-descriptor 
-		name="previousId" 
-		jdbc-type="BIGINT"
-		column="PREVIOUS_ID" 		
-	    />	    
-	    	    
-	    <reference-descriptor name="document" 
-		 class-ref="org.apache.portals.graffito.model.impl.DocumentImpl"
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="link" 
-		 auto-delete="false" >
-		 <foreignkey field-ref="documentId"/>
-	    </reference-descriptor>		
-
-	    <reference-descriptor name="previous" 
-		 class-ref="org.apache.portals.graffito.model.HistoryElement"
-		 proxy="true" 
-		 auto-retrieve="true"
-		 auto-update="link" 
-		 auto-delete="true" >
-		 <foreignkey field-ref="previousId"/>
-	    </reference-descriptor>		
-
-		
-	</class-descriptor>
-	
-	<!--
-	
-		    S E R V E R                   
-	-->
-	
-	<class-descriptor class="org.apache.portals.graffito.model.Server">	      
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.WebdavServerImpl" />
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.GraffitoServerImpl" />      
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FileSystemServerImpl" />		  
-	</class-descriptor>       
-	
-	<class-descriptor class="org.apache.portals.graffito.model.WebdavServer">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.WebdavServerImpl" />
-	</class-descriptor>       
-	
-	<class-descriptor class="org.apache.portals.graffito.model.GraffitoServer">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.GraffitoServerImpl" />
-	</class-descriptor>       
-	
-	<class-descriptor class="org.apache.portals.graffito.model.FileSystemServer">
-	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FileSystemServerImpl" />
-	</class-descriptor>       
-		
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.ServerImpl"
-	    table="SERVER"
-	>
-	    <field-descriptor
-		name="serverId"
-		column="SERVER_ID"
-		jdbc-type="INTEGER"
-		primarykey="true"
-		autoincrement="true"
-	    />
-	    <field-descriptor
-		name="scope"
-		column="SCOPE"
-		jdbc-type="VARCHAR"
-	    />
-	    <field-descriptor
-		name="alias"
-		column="ALIAS"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="description"
-		column="DESCRIPTION"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="storeClassName"
-		column="PLUGIN_CLASS_NAME"
-		jdbc-type="VARCHAR"
-	    />
-		
-	    <field-descriptor
-		name="title"
-		column="TITLE"
-		jdbc-type="VARCHAR"
-	    />
-			
-	</class-descriptor>
-	
-	
-	
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.WebdavServerImpl"
-	    table="WEBDAV_SERVER"
-	>
-	    <field-descriptor
-		name="serverId"
-		column="SERVER_ID"
-		jdbc-type="INTEGER"
-		primarykey="true"
-		autoincrement="true"
-	    />
-	
-	    <field-descriptor
-		name="url"
-		column="URL"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="isSecureServer"
-		column= "IS_SECURE_SERVER"
-		jdbc-type="VARCHAR"
-	
-	    />
-	    <field-descriptor
-		name="useCurrentLogin"
-		column="USE_CURRENT_LOGIN"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="login"
-		column="LOGIN"
-		jdbc-type="VARCHAR"
-	    />
-	    
-	    <field-descriptor
-		name="password"
-		column="PASSWORD"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <reference-descriptor name="super"
-		class-ref="org.apache.portals.graffito.model.impl.ServerImpl"
-		auto-retrieve="true"
-		auto-update="true"
-		auto-delete="true"
-	    >
-		<foreignkey field-ref="serverId"/>
-	    </reference-descriptor>
-	    
-	</class-descriptor>
-	
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.GraffitoServerImpl"
-	    table="GRAFFITO_DB_SERVER"
-	>
-	    <field-descriptor
-		name="serverId"
-		column="SERVER_ID"
-		jdbc-type="INTEGER"
-		primarykey="true"
-		autoincrement="true"
-	    />
-	
-	    <field-descriptor
-		name="plateform"
-		column="PLATEFORM"
-		jdbc-type="VARCHAR"
-	    />
-	    
-	    <field-descriptor
-		name="dbAlias"
-		column="DB_ALIAS"
-		jdbc-type="VARCHAR"
-	    />
-		
-	    <field-descriptor
-		name="jdbcLevel"
-		column="JDBC_LEVEL"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="datasource"
-		column="DATASOURCE"
-		jdbc-type="VARCHAR"
-	    />     
-	    
-	    <field-descriptor
-		name="driver"
-		column="DRIVER"
-		jdbc-type="VARCHAR"
-	    />       
-	
-	    <field-descriptor
-		name="protocol"
-		column="PROTOCOL"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="subProtocol"
-		column="SUBPROTOCOL"
-		jdbc-type="VARCHAR"
-	    />
-		     
-	    <field-descriptor
-		name="login"
-		column="LOGIN"
-		jdbc-type="VARCHAR"
-	    />
-	
-	    <field-descriptor
-		name="password"
-		column="PASSWORD"
-		jdbc-type="VARCHAR"
-	    />
-		    
-	    <reference-descriptor name="super"
-		class-ref="org.apache.portals.graffito.model.impl.ServerImpl"
-		auto-retrieve="true"
-		auto-update="true"
-		auto-delete="true"
-	    >
-		<foreignkey field-ref="serverId"/>
-	    </reference-descriptor>
-	    
-	</class-descriptor>
-
-
-	<class-descriptor
-	    class="org.apache.portals.graffito.model.impl.FileSystemServerImpl"
-	    table="GRAFFITO_FS_SERVER"
-	>
-	    <field-descriptor
-		name="serverId"
-		column="SERVER_ID"
-		jdbc-type="INTEGER"
-		primarykey="true"
-		autoincrement="true"
-	    />
-	
-	    <field-descriptor
-		name="root"
-		column="ROOT"
-		jdbc-type="VARCHAR"
-	    />
-	    		    
-	    <reference-descriptor name="super"
-		class-ref="org.apache.portals.graffito.model.impl.ServerImpl"
-		auto-retrieve="true"
-		auto-update="true"
-		auto-delete="true"
-	    >
-		<foreignkey field-ref="serverId"/>
-	    </reference-descriptor>
-	    
-	</class-descriptor>
-	
-	<!--
-	
-		    J C M S  METADATA  CLASSES	
-			   
-	-->
-	
-	<class-descriptor 
-	
-	    class="org.apache.portals.graffito.model.impl.SysCmsClass"
-	    table="SYS_CMS_CLASSES" >
-	    
-	    <field-descriptor 
-		name="cmsClassId" 
-		jdbc-type="VARCHAR"
-		column="CMS_CLASS_ID" 
-		primarykey="true"
-	
-	    />
-	    <field-descriptor 
-		name="cmsClass" 
-		jdbc-type="VARCHAR"
-		column="CMS_CLASS"
-		
-	    />
-	 
-	</class-descriptor>
-</descriptor-repository>
+<!-- 
+ Copyright 2002-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ -->
+ <!--
+    G R A F F I T  I     S T O R E 
+-->	
+<descriptor-repository version="1.0">
+
+	<class-descriptor class="org.apache.portals.graffito.model.CmsObject">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FolderImpl" />
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.DocumentImpl" />
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.LinkImpl" />
+	</class-descriptor>
+
+	<class-descriptor class="org.apache.portals.graffito.model.Folder">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FolderImpl" />
+	</class-descriptor>       
+
+	<class-descriptor class="org.apache.portals.graffito.model.Link">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.LinkImpl" />
+	</class-descriptor>  	
+	<class-descriptor class="org.apache.portals.graffito.model.Document">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.DocumentImpl" />
+	</class-descriptor> 
+	
+	<class-descriptor class="org.apache.portals.graffito.model.Content">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.ContentImpl" />
+	</class-descriptor>	
+	
+	<class-descriptor class="org.apache.portals.graffito.model.HistoryElement">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.HistoryElementImpl" />
+	</class-descriptor>  	
+	
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.FolderImpl"
+	    table="CMS_OBJECT" >
+	    <field-descriptor 
+		name="objectId" 
+		jdbc-type="BIGINT"
+		column="OBJECT_ID" 
+		primarykey="true"
+		autoincrement="true"
+	    />
+	    
+	    <field-descriptor 
+		name="parentId" 
+		jdbc-type="BIGINT"
+		column="PARENT_ID" 
+		
+	    />
+		
+	    <field-descriptor 
+		name="versionNumber" 
+		jdbc-type="VARCHAR"
+		column="VERSION_NUM"		
+	    />  	    
+	    
+	    <field-descriptor 
+		name="isLastVersion" 
+		jdbc-type="INTEGER"
+		column="IS_LAST_VERSION"	
+               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"		
+	    />  		    
+				
+	    <field-descriptor 
+		name="name" 
+		jdbc-type="VARCHAR"
+		column="NAME" 
+	    />
+	    <field-descriptor 
+		name="uri" 
+		jdbc-type="VARCHAR"
+		column="URI" 
+	    />
+	
+	    <field-descriptor 
+		name="creationDate" 
+		jdbc-type="TIMESTAMP"
+		column="CREATION_DATE" 
+	       
+	    />
+	    <field-descriptor 
+		name="lastModified" 
+		jdbc-type="TIMESTAMP"
+		column="DELTA" 
+		
+	    />
+	    <field-descriptor 
+		name="description" 
+		jdbc-type="VARCHAR"
+		column="DESCRIPTION" 
+	    />
+	    <field-descriptor 
+		name="title" 
+		jdbc-type="VARCHAR"
+		column="TITLE"                 
+	    />
+	
+	    <field-descriptor 
+		name="ojbConcreteClass" 
+		jdbc-type="VARCHAR"
+		column="CLASS_NAME"                 
+	    />
+	    
+	    <reference-descriptor name="parentFolder" 
+		 class-ref="org.apache.portals.graffito.model.Folder"
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="link" 
+		 auto-delete="false" >
+		 <foreignkey field-ref="parentId"/>
+	    </reference-descriptor> 
+	    
+	   <collection-descriptor
+	     name="folders"
+	     element-class-ref="org.apache.portals.graffito.model.Folder"        
+	     auto-retrieve="true"      
+	     auto-update="link"
+	     auto-delete="true"
+	     proxy="true"
+             > 
+	       <inverse-foreignkey field-ref="parentId"/>
+	   </collection-descriptor>    
+	
+	
+	   <collection-descriptor
+	     name="documents"
+	     element-class-ref="org.apache.portals.graffito.model.Document"   
+	     auto-retrieve="true"      
+	     auto-update="link"
+	     auto-delete="true" 
+	     proxy="true"
+	     > 
+	       <inverse-foreignkey field-ref="parentId"/>
+	   </collection-descriptor>    
+	    
+	</class-descriptor>
+	
+	
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.LinkImpl"
+	    table="CMS_OBJECT" >
+	    <field-descriptor 
+		name="objectId" 
+		jdbc-type="BIGINT"
+		column="OBJECT_ID" 
+		primarykey="true"
+		autoincrement="true"
+	    />
+		
+	    <field-descriptor 
+		name="versionNumber" 
+		jdbc-type="VARCHAR"
+		column="VERSION_NUM"		
+	    />  	    
+	    
+	    <field-descriptor 
+		name="isLastVersion" 
+		jdbc-type="INTEGER"
+		column="IS_LAST_VERSION"	
+               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"		
+	    />  		    
+		
+	    <field-descriptor 
+		name="parentId" 
+		jdbc-type="BIGINT"
+		column="PARENT_ID" 
+		
+	    />
+	    
+	    <field-descriptor 
+		name="targetCmsObjectId" 
+		jdbc-type="BIGINT"
+		column="LINK_TARGET_ID" 
+		
+	    />
+		
+	    <field-descriptor 
+		name="name" 
+		jdbc-type="VARCHAR"
+		column="NAME" 
+	    />
+	    <field-descriptor 
+		name="uri" 
+		jdbc-type="VARCHAR"
+		column="URI" 
+	    />
+	
+	    <field-descriptor 
+		name="creationDate" 
+		jdbc-type="TIMESTAMP"
+		column="CREATION_DATE" 
+	       
+	    />
+	    <field-descriptor 
+		name="lastModified" 
+		jdbc-type="TIMESTAMP"
+		column="DELTA" 
+		
+	    />
+	    <field-descriptor 
+		name="description" 
+		jdbc-type="VARCHAR"
+		column="DESCRIPTION" 
+	    />
+	    <field-descriptor 
+		name="title" 
+		jdbc-type="VARCHAR"
+		column="TITLE"                 
+	    />
+	
+	    <field-descriptor 
+		name="ojbConcreteClass" 
+		jdbc-type="VARCHAR"
+		column="CLASS_NAME"                 
+	    />
+	    
+	    <reference-descriptor name="parentFolder" 
+		 class-ref="org.apache.portals.graffito.model.impl.FolderImpl"
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="link" 
+		 auto-delete="false" >
+		 <foreignkey field-ref="parentId"/>
+	    </reference-descriptor> 
+	    
+	    <reference-descriptor name="targetCmsObject" 
+		 class-ref="org.apache.portals.graffito.model.CmsObject"
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="true" 
+		 auto-delete="false" >
+		 <foreignkey field-ref="targetCmsObjectId"/>
+	    </reference-descriptor>    
+	    
+	</class-descriptor>
+	
+	
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.DocumentImpl"
+	    table="CMS_OBJECT" >
+	    <field-descriptor 
+		name="objectId" 
+		jdbc-type="BIGINT"
+		column="OBJECT_ID" 
+		primarykey="true"
+		autoincrement="true"
+	    />
+
+	    <field-descriptor 
+		name="contentId" 
+		jdbc-type="BIGINT"
+		column="CONTENT_ID" 
+	    />	    
+	    
+	    <field-descriptor 
+		name="versionNumber" 
+		jdbc-type="VARCHAR"
+		column="VERSION_NUM"		
+	    />  	    
+	    
+	    <field-descriptor 
+		name="isLastVersion" 
+		jdbc-type="INTEGER"
+		column="IS_LAST_VERSION"	
+               conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"		
+	    />  		    
+		
+	    <field-descriptor 
+		name="parentId" 
+		jdbc-type="BIGINT"
+		column="PARENT_ID" 		
+	    />
+	   	    
+	    <field-descriptor 
+		name="name" 
+		jdbc-type="VARCHAR"
+		column="NAME" 
+	    />
+	    <field-descriptor 
+		name="uri" 
+		jdbc-type="VARCHAR"
+		column="URI" 
+	    />
+	
+	    <field-descriptor 
+		name="creationDate" 
+		jdbc-type="TIMESTAMP"
+		column="CREATION_DATE" 
+	       
+	    />
+	    <field-descriptor 
+		name="lastModified" 
+		jdbc-type="TIMESTAMP"
+		column="DELTA" 
+		
+	    />
+	    <field-descriptor 
+		name="description" 
+		jdbc-type="VARCHAR"
+		column="DESCRIPTION" 
+	    />
+	    <field-descriptor 
+		name="title" 
+		jdbc-type="VARCHAR"
+		column="TITLE"                 
+	    />
+  
+	    <field-descriptor 
+		name="size" 
+		jdbc-type="BIGINT"
+		column="CONTENT_SIZE"
+	    />
+	    <field-descriptor 
+		name="language" 
+		jdbc-type="VARCHAR"
+		column="LANGUAGE" 
+	    />
+	    
+	    <field-descriptor 
+		name="owner" 
+		jdbc-type="VARCHAR"
+		column="OWNER" 
+	    />
+	
+	    <field-descriptor 
+		name="contentType" 
+		jdbc-type="VARCHAR"
+		column="CONTENT_TYPE" 
+	    />    
+	    
+	    <field-descriptor 
+		name="ojbConcreteClass" 
+		jdbc-type="VARCHAR"
+		column="CLASS_NAME"                 
+	    />
+	    
+	    <reference-descriptor name="parentFolder" 
+		 class-ref="org.apache.portals.graffito.model.impl.FolderImpl"
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="link" 
+		 auto-delete="false" >
+		 <foreignkey field-ref="parentId"/>
+	    </reference-descriptor>		
+
+	    <reference-descriptor name="content" 
+		 class-ref="org.apache.portals.graffito.model.impl.ContentImpl"		 
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="true" 
+		 auto-delete="true" >
+		 <foreignkey field-ref="contentId"/>
+	    </reference-descriptor>		    
+	</class-descriptor>
+	
+	    
+	<class-descriptor 
+	
+	    class="org.apache.portals.graffito.model.impl.ContentImpl"
+	    table="CONTENT" >
+	    
+ 	    <field-descriptor 	        
+		name="contentId" 
+		jdbc-type="BIGINT"
+		column="CONTENT_ID" 
+		primarykey="true"
+                autoincrement="true"		
+	    />
+	      
+	    <field-descriptor 
+		name="content" 
+		jdbc-type="BLOB"
+		column="CONTENT"        
+	    /> 
+
+        <field-descriptor
+        name="encoding"
+        jdbc-type="VARCHAR"
+        column="ENCODING"
+        />
+	        
+	</class-descriptor>
+	
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.HistoryElementImpl"
+	    table="VERSION_HISTORY" >
+
+	    <field-descriptor 
+		name="historyElementId" 
+		jdbc-type="BIGINT"
+		column="HISTORY_ID" 
+		primarykey="true"		
+		autoincrement="true"
+	    />
+	    
+	    <field-descriptor 
+		name="documentId" 
+		jdbc-type="BIGINT"
+		column="OBJECT_ID" 
+		
+	    />
+	    
+	    <field-descriptor 
+		name="previousId" 
+		jdbc-type="BIGINT"
+		column="PREVIOUS_ID" 		
+	    />	    
+	    	    
+	    <reference-descriptor name="document" 
+		 class-ref="org.apache.portals.graffito.model.impl.DocumentImpl"
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="link" 
+		 auto-delete="false" >
+		 <foreignkey field-ref="documentId"/>
+	    </reference-descriptor>		
+
+	    <reference-descriptor name="previous" 
+		 class-ref="org.apache.portals.graffito.model.HistoryElement"
+		 proxy="true" 
+		 auto-retrieve="true"
+		 auto-update="link" 
+		 auto-delete="true" >
+		 <foreignkey field-ref="previousId"/>
+	    </reference-descriptor>		
+
+		
+	</class-descriptor>
+	
+	<!--
+	
+		    S E R V E R                   
+	-->
+	
+	<class-descriptor class="org.apache.portals.graffito.model.Server">	      
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.WebdavServerImpl" />
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.GraffitoServerImpl" />      
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FileSystemServerImpl" />		  
+	</class-descriptor>       
+	
+	<class-descriptor class="org.apache.portals.graffito.model.WebdavServer">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.WebdavServerImpl" />
+	</class-descriptor>       
+	
+	<class-descriptor class="org.apache.portals.graffito.model.GraffitoServer">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.GraffitoServerImpl" />
+	</class-descriptor>       
+	
+	<class-descriptor class="org.apache.portals.graffito.model.FileSystemServer">
+	      <extent-class class-ref="org.apache.portals.graffito.model.impl.FileSystemServerImpl" />
+	</class-descriptor>       
+		
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.ServerImpl"
+	    table="SERVER"
+	>
+	    <field-descriptor
+		name="serverId"
+		column="SERVER_ID"
+		jdbc-type="INTEGER"
+		primarykey="true"
+		autoincrement="true"
+	    />
+	    <field-descriptor
+		name="scope"
+		column="SCOPE"
+		jdbc-type="VARCHAR"
+	    />
+	    <field-descriptor
+		name="alias"
+		column="ALIAS"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="description"
+		column="DESCRIPTION"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="storeClassName"
+		column="PLUGIN_CLASS_NAME"
+		jdbc-type="VARCHAR"
+	    />
+		
+	    <field-descriptor
+		name="title"
+		column="TITLE"
+		jdbc-type="VARCHAR"
+	    />
+			
+	</class-descriptor>
+	
+	
+	
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.WebdavServerImpl"
+	    table="WEBDAV_SERVER"
+	>
+	    <field-descriptor
+		name="serverId"
+		column="SERVER_ID"
+		jdbc-type="INTEGER"
+		primarykey="true"
+		autoincrement="true"
+	    />
+	
+	    <field-descriptor
+		name="url"
+		column="URL"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="isSecureServer"
+		column= "IS_SECURE_SERVER"
+		jdbc-type="VARCHAR"
+	
+	    />
+	    <field-descriptor
+		name="useCurrentLogin"
+		column="USE_CURRENT_LOGIN"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="login"
+		column="LOGIN"
+		jdbc-type="VARCHAR"
+	    />
+	    
+	    <field-descriptor
+		name="password"
+		column="PASSWORD"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <reference-descriptor name="super"
+		class-ref="org.apache.portals.graffito.model.impl.ServerImpl"
+		auto-retrieve="true"
+		auto-update="true"
+		auto-delete="true"
+	    >
+		<foreignkey field-ref="serverId"/>
+	    </reference-descriptor>
+	    
+	</class-descriptor>
+	
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.GraffitoServerImpl"
+	    table="GRAFFITO_DB_SERVER"
+	>
+	    <field-descriptor
+		name="serverId"
+		column="SERVER_ID"
+		jdbc-type="INTEGER"
+		primarykey="true"
+		autoincrement="true"
+	    />
+	
+	    <field-descriptor
+		name="plateform"
+		column="PLATEFORM"
+		jdbc-type="VARCHAR"
+	    />
+	    
+	    <field-descriptor
+		name="dbAlias"
+		column="DB_ALIAS"
+		jdbc-type="VARCHAR"
+	    />
+		
+	    <field-descriptor
+		name="jdbcLevel"
+		column="JDBC_LEVEL"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="datasource"
+		column="DATASOURCE"
+		jdbc-type="VARCHAR"
+	    />     
+	    
+	    <field-descriptor
+		name="driver"
+		column="DRIVER"
+		jdbc-type="VARCHAR"
+	    />       
+	
+	    <field-descriptor
+		name="protocol"
+		column="PROTOCOL"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="subProtocol"
+		column="SUBPROTOCOL"
+		jdbc-type="VARCHAR"
+	    />
+		     
+	    <field-descriptor
+		name="login"
+		column="LOGIN"
+		jdbc-type="VARCHAR"
+	    />
+	
+	    <field-descriptor
+		name="password"
+		column="PASSWORD"
+		jdbc-type="VARCHAR"
+	    />
+		    
+	    <reference-descriptor name="super"
+		class-ref="org.apache.portals.graffito.model.impl.ServerImpl"
+		auto-retrieve="true"
+		auto-update="true"
+		auto-delete="true"
+	    >
+		<foreignkey field-ref="serverId"/>
+	    </reference-descriptor>
+	    
+	</class-descriptor>
+
+
+	<class-descriptor
+	    class="org.apache.portals.graffito.model.impl.FileSystemServerImpl"
+	    table="GRAFFITO_FS_SERVER"
+	>
+	    <field-descriptor
+		name="serverId"
+		column="SERVER_ID"
+		jdbc-type="INTEGER"
+		primarykey="true"
+		autoincrement="true"
+	    />
+	
+	    <field-descriptor
+		name="root"
+		column="ROOT"
+		jdbc-type="VARCHAR"
+	    />
+	    		    
+	    <reference-descriptor name="super"
+		class-ref="org.apache.portals.graffito.model.impl.ServerImpl"
+		auto-retrieve="true"
+		auto-update="true"
+		auto-delete="true"
+	    >
+		<foreignkey field-ref="serverId"/>
+	    </reference-descriptor>
+	    
+	</class-descriptor>
+	
+	<!--
+	
+		    J C M S  METADATA  CLASSES	
+			   
+	-->
+	
+	<class-descriptor 
+	
+	    class="org.apache.portals.graffito.model.impl.SysCmsClass"
+	    table="SYS_CMS_CLASSES" >
+	    
+	    <field-descriptor 
+		name="cmsClassId" 
+		jdbc-type="VARCHAR"
+		column="CMS_CLASS_ID" 
+		primarykey="true"
+	
+	    />
+	    <field-descriptor 
+		name="cmsClass" 
+		jdbc-type="VARCHAR"
+		column="CMS_CLASS"
+		
+	    />
+	 
+	</class-descriptor>
+</descriptor-repository>

Modified: incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java?view=diff&r1=149291&r2=149292
==============================================================================
--- incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java (original)
+++ incubator/graffito/trunk/components/src/java/org/apache/portals/graffito/model/impl/ContentImpl.java Mon Jan 31 12:23:11 2005
@@ -1,120 +1,149 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.model.impl;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.Serializable;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.util.StreamUtil;
-import org.apache.portals.graffito.model.Content;
-
-
-/**
- * CMS Version implementation.
- *
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
- * 
- */
-public class ContentImpl implements Content, Serializable
-{
-    protected final static Log log = LogFactory.getLog(ContentImpl.class);
-  
-    protected Long contentId;    
-   
-    protected byte[] content;
-
-
-    /**
-     * @return Returns the content.
-     */
-    public InputStream getContentStream()
-    {
-        return new ByteArrayInputStream(content);        
-    }
-
-    /**
-     * @return Returns the content.
-     */
-    public byte[] getContentByte()
-    {
-        
-        return content;
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.model.Content#getContentAsString()
-     */
-    public String getContentAsString()
-    {        
-        return new String(content);
-    }
-    
-    /**
-     * @param stream The content to set.
-     */
-    public void setContent(InputStream stream)
-    {        
-
-        content = StreamUtil.getContentByte(stream);
-
-    }
-
-    /**
-     * @param stream The content to set.
-     */
-    public void setContent(byte[] stream)
-    {
-        
-        content = stream;
-
-    }
-    
-    /**
-     * @return Returns the contentId.
-     */
-    public Long getContentId()
-    {
-        return contentId;
-    }
-    /**
-     * @param contentId The contentId to set.
-     */
-    public void setContentId(Long contentId)
-    {
-        this.contentId = contentId;
-    }
-    
-
-    /**
-     * 
-     * @see java.lang.Object#clone()
-     */
-    public Object clone()
-    {
-       Content clone = new ContentImpl();
-       clone.setContent(this.getContentByte());
-       
-       return clone;
-       
-    }    
-}
-
-
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.model.impl;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.util.StreamUtil;
+import org.apache.portals.graffito.model.Content;
+
+
+/**
+ * CMS Version implementation.
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ */
+public class ContentImpl implements Content, Serializable
+{
+    protected final static Log log = LogFactory.getLog(ContentImpl.class);
+  
+    protected Long contentId;    
+   
+    protected byte[] content;
+    
+    protected String encoding;
+
+
+    /**
+     * @return Returns the content.
+     */
+    public InputStream getContentStream()
+    {
+        return new ByteArrayInputStream(content);        
+    }
+
+    /**
+     * @return Returns the content.
+     */
+    public byte[] getContentByte()
+    {
+        
+        return content;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.Content#getContentAsString()
+     */
+    public String getContentAsString()
+    {        
+        if (encoding != null)
+        {
+            try
+            {
+                return new String(content, encoding);
+            }
+            catch (UnsupportedEncodingException e)
+            {
+            }
+        }
+        return new String(content);        
+    }
+    
+    /**
+     * @param stream The content to set.
+     */
+    public void setContent(InputStream stream)
+    {        
+
+        content = StreamUtil.getContentByte(stream);
+
+    }
+
+    /**
+     * @param stream The content to set.
+     */
+    public void setContent(byte[] stream)
+    {
+        
+        content = stream;
+
+    }
+    
+    /**
+     * @return Returns the contentId.
+     */
+    public Long getContentId()
+    {
+        return contentId;
+    }
+    /**
+     * @param contentId The contentId to set.
+     */
+    public void setContentId(Long contentId)
+    {
+        this.contentId = contentId;
+    }
+    
+
+    /**
+     * 
+     * @see java.lang.Object#clone()
+     */
+    public Object clone()
+    {
+       Content clone = new ContentImpl();
+       clone.setContent(this.getContentByte());
+       
+       return clone;
+       
+    }    
+    
+    /**
+     * @return Returns the encoding.
+     */
+    public String getEncoding()
+    {
+        return encoding;
+    }
+    
+    /**
+     * @param encoding The encoding to set.
+     */
+    public void setEncoding(String encoding)
+    {
+        this.encoding = encoding;
+    }
+}
+
+

Modified: incubator/graffito/trunk/components/src/schema/graffitostore-schema.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/components/src/schema/graffitostore-schema.xml?view=diff&r1=149291&r2=149292
==============================================================================
--- incubator/graffito/trunk/components/src/schema/graffitostore-schema.xml (original)
+++ incubator/graffito/trunk/components/src/schema/graffitostore-schema.xml Mon Jan 31 12:23:11 2005
@@ -1,25 +1,25 @@
 <?xml version="1.0"?>
-<!--
-Copyright 2004 The Apache Software Foundation
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+<!--
+Copyright 2004 The Apache Software Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 -->
 <!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_1.dtd">
 <!-- Autogenerated by JDBCToXMLSchema! -->
 <database>
-	<!--
-    	CREATING TABLES FOR GRAFFITO
-    	
+	<!--
+    	CREATING TABLES FOR GRAFFITO
+    	
     -->
 	<table name="SERVER">
 		<column name="SERVER_ID" primaryKey="true" required="true" type="INTEGER"/>
@@ -82,6 +82,7 @@
 	<table name="CONTENT">
 		<column name="CONTENT_ID" primaryKey="true" required="true" type="INTEGER"/>
 		<column name="CONTENT" type="BLOB"/>
+		<column name="ENCODING" size="30" type="VARCHAR"/>
 	</table>
 	<table name="CMS_OBJECT">
 		<column name="OBJECT_ID" primaryKey="true" required="true" type="INTEGER"/>

Modified: incubator/graffito/trunk/portlets/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/portlets/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java?view=diff&r1=149291&r2=149292
==============================================================================
--- incubator/graffito/trunk/portlets/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java (original)
+++ incubator/graffito/trunk/portlets/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java Mon Jan 31 12:23:11 2005
@@ -1,510 +1,525 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.portlets;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
-import org.apache.portals.graffito.ContentModelService;
-import org.apache.portals.graffito.ContentServerService;
-import org.apache.portals.graffito.exception.ContentManagementException;
-import org.apache.portals.graffito.model.CmsObject;
-import org.apache.portals.graffito.model.Document;
-import org.apache.portals.graffito.model.Folder;
-import org.apache.portals.graffito.util.CmsUtil;
-import org.apache.velocity.context.Context;
-
-/**
- * Graffito Content Browser. 
- * 
- *  In the view mode, this browser gives a way to navigate across the complete content tree.
- *  In the edit mode, this browser can manager folders & documents (edit, add, delete, manage security, versionning, ...).
- * 
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
- * @version $Id: BrowserPortlet.java,v 1.1 2004/12/28 14:29:11 christophe Exp $
- */
-public class BrowserPortlet extends GenericTabVelocityPortlet
-{
-
-    /** Velocity variable to set the browser info object in the Velocity context */
-    private static final String VELOCITY_BROWSER_INFO = "browserInfo";
-
-    /** Portlet session attribute name used to set the Browser info*/
-    private static final String SESSION_BROWSER_INFO = "graffito.browser.info";
-
-    /** Default uri used to display the content browser */
-    private static final String DEFAULT_CONTENT_SCOPE = "/graffito";
-
-    /** Portlet preference attritube containing the root uri used to display the content browser */
-    private static final String CONTENT_SCOPE = "gaffito.content.scope";
-
-    /** Portlet init param containing all available document types */
-    private ArrayList documentTypes = new ArrayList();
-
-    /** Portlet init param containing all available document languages */
-    private ArrayList documentLanguages = new ArrayList();
-
-    private ContentModelService modelService;
-
-    private ContentServerService serverService;
-
-    /**
-     * @see javax.portlet.Portlet#init(javax.portlet.PortletConfig)
-     */
-    public void init(PortletConfig config) throws PortletException
-    {
-        super.init(config);
-
-        PortletContext context = getPortletContext();
-
-        modelService = (ContentModelService) context.getAttribute("cps:ContentModel");
-        if (null == modelService)
-        {
-            throw new PortletException("Failed to find the content model service on portlet initialization");
-        }
-
-        serverService = (ContentServerService) context.getAttribute("cps:ContentServer");
-        if (null == serverService)
-        {
-            throw new PortletException("Failed to find the content server service on portlet initialization");
-        }
-
-        String param = config.getInitParameter("DocumentTypes");
-        if (null == param)
-        {
-            throw new PortletException("Failed to read the init paramater : DocumentTypes");
-        }
-        initDocumentTypes(param);
-
-        param = config.getInitParameter("DocumentLanguages");
-        if (null == param)
-        {
-            throw new PortletException("Failed to read the init paramater : DocumentLanguages");
-        }
-
-        initDocumentLanguages(param);
-
-    }
-
-    /**
-     * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
-     */
-    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
-    {
-
-        response.setContentType("text/html");
-        Context velocityContext = this.getContext(request);
-
-        BrowserInfo browserInfo = null;
-        String uri = request.getParameter("uri");
-        if (uri == null)
-        {
-            uri = this.getDefaultContentScope(request);
-            browserInfo = this.getSessionBrowserInfo(request);
-        }
-
-        if (null == browserInfo)
-        {
-            browserInfo = this.initBrowserInfo(uri, request, response);
-            this.setSessionContentBrowser(request, browserInfo);
-        }
-
-        this.selectViewTemplate(browserInfo, request, response );
-        
-        velocityContext.put(VELOCITY_BROWSER_INFO, browserInfo);
-        super.doView(request, response);
-
-    }
-
-    /**
-     * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
-     */
-    public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException
-    {
-
-        response.setContentType("text/html");
-
-        BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
-        Context velocityContext = this.getContext(request);
-        velocityContext.put(VELOCITY_BROWSER_INFO, browserInfo);
-
-        super.doEdit(request, response);
-    }
-
-    /**
-     * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
-     */
-    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
-    {
-
-        if (request.getPortletMode() == PortletMode.EDIT)
-        {
-
-            String action = request.getParameter("folder.add");
-            if (action != null)
-            {
-                this.createFolder(request, response);
-                return;
-            }
-
-            action = request.getParameter("document.add");
-            if (action != null)
-            {
-                this.createDocument(request, response);
-                return;
-            }
-
-            action = request.getParameter("document.new.step2");
-            if (action != null)
-            {
-                this.createDocumentStep2(request, response);
-                return;
-            }
-
-            action = request.getParameter("folder.save");
-            if (action != null)
-            {
-                this.saveFolder(request, response);
-                return;
-            }
-
-            action = request.getParameter("document.save");
-            if (action != null)
-            {
-                this.saveDocument(request, response);
-                return;
-            }
-
-            action = request.getParameter("cmsobject.delete");
-            if (action != null)
-            {
-                this.deleteCmsObject(request, response);
-                return;
-            }
-
-            action = request.getParameter("cancel");
-            if (action != null)
-            {
-                response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
-                return;
-            }
-
-            super.processAction(request, response);
-
-        }
-
-    }
-
-    protected BrowserInfo getSessionBrowserInfo(PortletRequest request)
-    {
-        return (BrowserInfo) request.getPortletSession().getAttribute(SESSION_BROWSER_INFO, PortletSession.PORTLET_SCOPE);
-    }
-
-    protected void setSessionContentBrowser(PortletRequest request, BrowserInfo browserInfo)
-    {
-        request.getPortletSession().setAttribute(SESSION_BROWSER_INFO, browserInfo);
-    }
-
-    protected void removeSessionContentBrowser(PortletRequest request)
-    {
-        request.getPortletSession().removeAttribute(SESSION_BROWSER_INFO);
-    }
-
-    protected String getDefaultContentScope(PortletRequest request)
-    {
-
-        return request.getPreferences().getValue(CONTENT_SCOPE, DEFAULT_CONTENT_SCOPE);
-    }
-
-    protected void createFolder(ActionRequest request, ActionResponse response) throws PortletException
-    {
-
-        try
-        {
-            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
-            Folder folder = modelService.createFolder();
-            browserInfo.setCurrentCmsObject(folder);
-            this.setSessionContentBrowser(request, browserInfo);
-            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-detail.vm");
-        }
-        catch (ContentManagementException e)
-        {
-            throw new PortletException("Impossible to create a folder ", e);
-        }
-    }
-
-    protected void createDocument(ActionRequest request, ActionResponse response) throws PortletException
-    {
-
-        try
-        {
-            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
-            Document document = modelService.createDocument();
-            browserInfo.setCurrentCmsObject(document);
-            this.setSessionContentBrowser(request, browserInfo);
-            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/document/document-type.vm");
-        }
-        catch (ContentManagementException e)
-        {
-            throw new PortletException("Impossible to create a document ", e);
-        }
-    }
-
-    protected void createDocumentStep2(ActionRequest request, ActionResponse response) throws PortletException
-    {
-
-        //        try
-        //        {
-        BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
-        Document document = (Document) browserInfo.getCurrentCmsObject();
-        String name = request.getParameter("name");
-        String title = request.getParameter("title");
-        String description = request.getParameter("description");
-        String owner = request.getParameter("owner");
-        String language = request.getParameter("language");
-
-        document.setCreationDate(new Date());
-        document.setDescription(description);
-        document.setLastModified(new Date());
-        document.setName(name);
-        document.setTitle(title);
-        document.setOwner(owner);
-        document.setLanguage(language);
-
-        String parentFolderUri = null;
-        if (browserInfo.getCurrentFolder() == null)
-        {
-            parentFolderUri = browserInfo.getCurrentServer().getScope();
-        }
-        else
-        {
-            parentFolderUri = browserInfo.getCurrentFolder().getUri();
-        }
-
-        document.setUri(parentFolderUri + "/" + name);
-        document.setVersionNumber("1.0");
-
-        //            document.getContent().setContent("Totot".getBytes());
-        //            document.setContentType("text/xml");            
-        //document.setSize(xmlContent.length);
-
-        String type = request.getParameter("documentType");
-        if (type.equals("document.type.text"))
-            ;
-        {
-            document.setContentType("text/plain");
-            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/document/document-text-edit.vm");
-        }
-        browserInfo.setCurrentCmsObject(document);
-        this.setSessionContentBrowser(request, browserInfo);
-
-        //        }
-        //        catch (ContentManagementException e)
-        //        {
-        //            throw new PortletException("Impossible to create a document ", e);
-        //        }               
-    }
-
-    protected void saveFolder(ActionRequest request, ActionResponse response) throws PortletException
-    {
-        try
-        {
-            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
-            Folder folder = (Folder) browserInfo.getCurrentCmsObject();
-            String name = request.getParameter("name");
-            String title = request.getParameter("title");
-            String description = request.getParameter("description");
-
-            folder.setCreationDate(new Date());
-            folder.setDescription(description);
-            folder.setLastModified(new Date());
-            folder.setName(name);
-            folder.setTitle(title);
-
-            String parentFolderUri = null;
-            if (browserInfo.getCurrentFolder() == null)
-            {
-                parentFolderUri = browserInfo.getCurrentServer().getScope();
-            }
-            else
-            {
-                parentFolderUri = browserInfo.getCurrentFolder().getUri();
-            }
-
-            folder.setUri(parentFolderUri + "/" + name);
-
-            modelService.addFolder(folder);
-
-            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
-            response.setPortletMode(PortletMode.VIEW);
-            this.removeSessionContentBrowser(request);
-        }
-        catch (ContentManagementException e)
-        {
-            throw new PortletException("Impossible to create a folder ", e);
-        }
-    }
-
-    protected void saveDocument(ActionRequest request, ActionResponse response) throws PortletException
-    {
-        try
-        {
-            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
-            Document document = (Document) browserInfo.getCurrentCmsObject();
-
-            //Other attributes has been initialised in the method createDocumentStep2
-            String content = request.getParameter("content");
-            document.getContent().setContent(content.getBytes());
-            document.setSize(content.length());
-            modelService.addDocument(document);
-
-            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
-            response.setPortletMode(PortletMode.VIEW);
-            this.removeSessionContentBrowser(request);
-        }
-        catch (ContentManagementException e)
-        {
-            throw new PortletException("Impossible to create a document ", e);
-        }
-    }
-
-    protected void deleteCmsObject(ActionRequest request, ActionResponse response) throws PortletException
-    {
-        try
-        {
-            String[] uriToDelete = request.getParameterValues("uri");
-            if (uriToDelete == null)
-            {
-                // No cms object has been selected
-                return;
-            }
-
-            for (int i = 0; i < uriToDelete.length; i++)
-            {
-                modelService.removeAll(uriToDelete);
-            }
-            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
-            response.setPortletMode(PortletMode.VIEW);
-            this.removeSessionContentBrowser(request);
-
-        }
-        catch (ContentManagementException e)
-        {
-            throw new PortletException("Impossible to delete all cms objects ", e);
-        }
-    }
-
-    /**
-     * Initialise the list of the available document types
-     * @param documentTypes comma separated document types
-     */
-    private void initDocumentTypes(String documentTypes)
-    {
-        String[] types = documentTypes.split(",");
-
-        for (int i = 0; i < types.length; i++)
-        {
-            this.documentTypes.add(types[i].trim());
-        }
-    }
-
-    /**
-     * Initialise the list of the available document types
-     * @param documentLanguages comma separated document types
-     */
-    private void initDocumentLanguages(String documentLanguages)
-    {
-        String[] types = documentLanguages.split(",");
-
-        for (int i = 0; i < types.length; i++)
-        {
-            this.documentLanguages.add(types[i].trim());
-        }
-    }
-
-    /**
-     * Initialise the DTO browserInfo. 
-     * This DTO is used by the velocity templates to display the content browser infos.
-     *  
-     * @param uri The uri associated to the cms object to display
-     * @param request RenderRequest
-     * @param response RenderResponse
-     * @return a new initialised {@link BrowserInfo}
-     * @throws PortletException when it is not possible to initialise the 
-     */
-    private BrowserInfo initBrowserInfo(String uri, RenderRequest request, RenderResponse response) throws PortletException
-    {
-        try
-        {
-            BrowserInfo browserInfo = new BrowserInfo(this.documentTypes, this.documentLanguages);
-            CmsObject cmsObject = modelService.getCmsObject(uri);            
-            browserInfo.setCurrentCmsObject(cmsObject);
-            if ((cmsObject instanceof Folder) || (cmsObject == null))  // cms object is null if the uri match to a server root
-            {
-               browserInfo.setDocuments(modelService.getDocuments(uri));
-               browserInfo.setFolders(modelService.getFolders(uri));
-               browserInfo.setCurrentFolder(modelService.getFolder(uri));
-               
-            }
-            else
-            {
-                browserInfo.setCurrentFolder(cmsObject.getParentFolder());
-            }
-            String scopeServer = CmsUtil.getServerScope(uri);
-            browserInfo.setCurrentServer(serverService.getServer(scopeServer));
-                        
-            return browserInfo;
-            
-        }
-        catch (ContentManagementException e)
-        {
-            throw new PortletException("Failed to view the portlet - impossible to access to Graffito content store : "
-                    + e.getMessage());
-        }
-
-    }
-    
-    
-    private void selectViewTemplate (BrowserInfo browserInfo, RenderRequest request, RenderResponse response) throws PortletException
-    {
-        CmsObject cmsObject = browserInfo.getCurrentCmsObject();
-        if ((cmsObject instanceof Folder) || (cmsObject == null))
-        {
-              request.setAttribute(PARAM_VIEW_PAGE, "/WEB-INF/view/folder/folder-browser.vm" ); 
-        }
-        else
-        {
-            Document document = (Document) cmsObject;
-            if (document.getContentType().equals("text/plain"))
-            {
-                request.setAttribute(PARAM_VIEW_PAGE, "/WEB-INF/view/document/document-text-view.vm" );
-            }
-        }
-    }
-
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.portlets;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.portals.graffito.ContentModelService;
+import org.apache.portals.graffito.ContentServerService;
+import org.apache.portals.graffito.exception.ContentManagementException;
+import org.apache.portals.graffito.model.CmsObject;
+import org.apache.portals.graffito.model.Document;
+import org.apache.portals.graffito.model.Folder;
+import org.apache.portals.graffito.util.CmsUtil;
+import org.apache.velocity.context.Context;
+
+/**
+ * Graffito Content Browser. 
+ * 
+ *  In the view mode, this browser gives a way to navigate across the complete content tree.
+ *  In the edit mode, this browser can manager folders & documents (edit, add, delete, manage security, versionning, ...).
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * @version $Id: BrowserPortlet.java,v 1.1 2004/12/28 14:29:11 christophe Exp $
+ */
+public class BrowserPortlet extends GenericTabVelocityPortlet
+{
+
+    /** Velocity variable to set the browser info object in the Velocity context */
+    private static final String VELOCITY_BROWSER_INFO = "browserInfo";
+
+    /** Portlet session attribute name used to set the Browser info*/
+    private static final String SESSION_BROWSER_INFO = "graffito.browser.info";
+
+    /** Default uri used to display the content browser */
+    private static final String DEFAULT_CONTENT_SCOPE = "/graffito";
+
+    /** Portlet preference attritube containing the root uri used to display the content browser */
+    private static final String CONTENT_SCOPE = "gaffito.content.scope";
+
+    /** Portlet init param containing all available document types */
+    private ArrayList documentTypes = new ArrayList();
+
+    /** Portlet init param containing all available document languages */
+    private ArrayList documentLanguages = new ArrayList();
+
+    private ContentModelService modelService;
+
+    private ContentServerService serverService;
+
+    /**
+     * @see javax.portlet.Portlet#init(javax.portlet.PortletConfig)
+     */
+    public void init(PortletConfig config) throws PortletException
+    {
+        super.init(config);
+
+        PortletContext context = getPortletContext();
+
+        modelService = (ContentModelService) context.getAttribute("cps:ContentModel");
+        if (null == modelService)
+        {
+            throw new PortletException("Failed to find the content model service on portlet initialization");
+        }
+
+        serverService = (ContentServerService) context.getAttribute("cps:ContentServer");
+        if (null == serverService)
+        {
+            throw new PortletException("Failed to find the content server service on portlet initialization");
+        }
+
+        String param = config.getInitParameter("DocumentTypes");
+        if (null == param)
+        {
+            throw new PortletException("Failed to read the init paramater : DocumentTypes");
+        }
+        initDocumentTypes(param);
+
+        param = config.getInitParameter("DocumentLanguages");
+        if (null == param)
+        {
+            throw new PortletException("Failed to read the init paramater : DocumentLanguages");
+        }
+
+        initDocumentLanguages(param);
+
+    }
+
+    /**
+     * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
+     */
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+    {
+
+        response.setContentType("text/html");
+        Context velocityContext = this.getContext(request);
+
+        BrowserInfo browserInfo = null;
+        String uri = request.getParameter("uri");
+        if (uri == null)
+        {
+            uri = this.getDefaultContentScope(request);
+            browserInfo = this.getSessionBrowserInfo(request);
+        }
+
+        if (null == browserInfo)
+        {
+            browserInfo = this.initBrowserInfo(uri, request, response);
+            this.setSessionContentBrowser(request, browserInfo);
+        }
+
+        this.selectViewTemplate(browserInfo, request, response );
+        
+        velocityContext.put(VELOCITY_BROWSER_INFO, browserInfo);
+        super.doView(request, response);
+
+    }
+
+    /**
+     * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
+     */
+    public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException
+    {
+
+        response.setContentType("text/html");
+
+        BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
+        Context velocityContext = this.getContext(request);
+        velocityContext.put(VELOCITY_BROWSER_INFO, browserInfo);
+
+        super.doEdit(request, response);
+    }
+
+    /**
+     * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
+     */
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+    {
+
+        if (request.getPortletMode() == PortletMode.EDIT)
+        {
+
+            String action = request.getParameter("folder.add");
+            if (action != null)
+            {
+                this.createFolder(request, response);
+                return;
+            }
+
+            action = request.getParameter("document.add");
+            if (action != null)
+            {
+                this.createDocument(request, response);
+                return;
+            }
+
+            action = request.getParameter("document.new.step2");
+            if (action != null)
+            {
+                this.createDocumentStep2(request, response);
+                return;
+            }
+
+            action = request.getParameter("folder.save");
+            if (action != null)
+            {
+                this.saveFolder(request, response);
+                return;
+            }
+
+            action = request.getParameter("document.save");
+            if (action != null)
+            {
+                this.saveDocument(request, response);
+                return;
+            }
+
+            action = request.getParameter("cmsobject.delete");
+            if (action != null)
+            {
+                this.deleteCmsObject(request, response);
+                return;
+            }
+
+            action = request.getParameter("cancel");
+            if (action != null)
+            {
+                response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
+                return;
+            }
+
+            super.processAction(request, response);
+
+        }
+
+    }
+
+    protected BrowserInfo getSessionBrowserInfo(PortletRequest request)
+    {
+        return (BrowserInfo) request.getPortletSession().getAttribute(SESSION_BROWSER_INFO, PortletSession.PORTLET_SCOPE);
+    }
+
+    protected void setSessionContentBrowser(PortletRequest request, BrowserInfo browserInfo)
+    {
+        request.getPortletSession().setAttribute(SESSION_BROWSER_INFO, browserInfo);
+    }
+
+    protected void removeSessionContentBrowser(PortletRequest request)
+    {
+        request.getPortletSession().removeAttribute(SESSION_BROWSER_INFO);
+    }
+
+    protected String getDefaultContentScope(PortletRequest request)
+    {
+
+        return request.getPreferences().getValue(CONTENT_SCOPE, DEFAULT_CONTENT_SCOPE);
+    }
+
+    protected void createFolder(ActionRequest request, ActionResponse response) throws PortletException
+    {
+
+        try
+        {
+            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
+            Folder folder = modelService.createFolder();
+            browserInfo.setCurrentCmsObject(folder);
+            this.setSessionContentBrowser(request, browserInfo);
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-detail.vm");
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Impossible to create a folder ", e);
+        }
+    }
+
+    protected void createDocument(ActionRequest request, ActionResponse response) throws PortletException
+    {
+
+        try
+        {
+            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
+            Document document = modelService.createDocument();
+            browserInfo.setCurrentCmsObject(document);
+            this.setSessionContentBrowser(request, browserInfo);
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/document/document-type.vm");
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Impossible to create a document ", e);
+        }
+    }
+
+    protected void createDocumentStep2(ActionRequest request, ActionResponse response) throws PortletException
+    {
+
+        //        try
+        //        {
+        BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
+        Document document = (Document) browserInfo.getCurrentCmsObject();
+        String name = request.getParameter("name");
+        String title = request.getParameter("title");
+        String description = request.getParameter("description");
+        String owner = request.getParameter("owner");
+        String language = request.getParameter("language");
+
+        document.setCreationDate(new Date());
+        document.setDescription(description);
+        document.setLastModified(new Date());
+        document.setName(name);
+        document.setTitle(title);
+        document.setOwner(owner);
+        document.setLanguage(language);
+
+        String parentFolderUri = null;
+        if (browserInfo.getCurrentFolder() == null)
+        {
+            parentFolderUri = browserInfo.getCurrentServer().getScope();
+        }
+        else
+        {
+            parentFolderUri = browserInfo.getCurrentFolder().getUri();
+        }
+
+        document.setUri(parentFolderUri + "/" + name);
+        document.setVersionNumber("1.0");
+
+        //            document.getContent().setContent("Totot".getBytes());
+        //            document.setContentType("text/xml");            
+        //document.setSize(xmlContent.length);
+
+        String type = request.getParameter("documentType");
+        if (type.equals("document.type.text"))          
+        {
+            document.setContentType("text/plain");
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/document/document-text-edit.vm");
+        }
+        
+        if (type.equals("document.type.html"))          
+        {
+            document.getContent().setContent("[Add your text here]".getBytes());
+            document.setContentType("text/html");
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/fckeditor/htmleditor.vm");
+            
+        }
+        
+        browserInfo.setCurrentCmsObject(document);
+        this.setSessionContentBrowser(request, browserInfo);
+
+        //        }
+        //        catch (ContentManagementException e)
+        //        {
+        //            throw new PortletException("Impossible to create a document ", e);
+        //        }               
+    }
+
+    protected void saveFolder(ActionRequest request, ActionResponse response) throws PortletException
+    {
+        try
+        {
+            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
+            Folder folder = (Folder) browserInfo.getCurrentCmsObject();
+            String name = request.getParameter("name");
+            String title = request.getParameter("title");
+            String description = request.getParameter("description");
+
+            folder.setCreationDate(new Date());
+            folder.setDescription(description);
+            folder.setLastModified(new Date());
+            folder.setName(name);
+            folder.setTitle(title);
+
+            String parentFolderUri = null;
+            if (browserInfo.getCurrentFolder() == null)
+            {
+                parentFolderUri = browserInfo.getCurrentServer().getScope();
+            }
+            else
+            {
+                parentFolderUri = browserInfo.getCurrentFolder().getUri();
+            }
+
+            folder.setUri(parentFolderUri + "/" + name);
+
+            modelService.addFolder(folder);
+
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
+            response.setPortletMode(PortletMode.VIEW);
+            this.removeSessionContentBrowser(request);
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Impossible to create a folder ", e);
+        }
+    }
+
+    protected void saveDocument(ActionRequest request, ActionResponse response) throws PortletException
+    {
+        try
+        {
+            BrowserInfo browserInfo = this.getSessionBrowserInfo(request);
+            Document document = (Document) browserInfo.getCurrentCmsObject();
+
+            //Other attributes has been initialised in the method createDocumentStep2
+            String content = request.getParameter("content");
+            document.getContent().setContent(content.getBytes());
+            document.setSize(content.length());
+            modelService.addDocument(document);
+
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
+            response.setPortletMode(PortletMode.VIEW);
+            this.removeSessionContentBrowser(request);
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Impossible to create a document ", e);
+        }
+    }
+
+    protected void deleteCmsObject(ActionRequest request, ActionResponse response) throws PortletException
+    {
+        try
+        {
+            String[] uriToDelete = request.getParameterValues("uri");
+            if (uriToDelete == null)
+            {
+                // No cms object has been selected
+                return;
+            }
+
+            for (int i = 0; i < uriToDelete.length; i++)
+            {
+                modelService.removeAll(uriToDelete);
+            }
+            response.setRenderParameter(PARAM_EDIT_PAGE, "/WEB-INF/view/folder/folder-edit.vm");
+            response.setPortletMode(PortletMode.VIEW);
+            this.removeSessionContentBrowser(request);
+
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Impossible to delete all cms objects ", e);
+        }
+    }
+
+    /**
+     * Initialise the list of the available document types
+     * @param documentTypes comma separated document types
+     */
+    private void initDocumentTypes(String documentTypes)
+    {
+        String[] types = documentTypes.split(",");
+
+        for (int i = 0; i < types.length; i++)
+        {
+            this.documentTypes.add(types[i].trim());
+        }
+    }
+
+    /**
+     * Initialise the list of the available document types
+     * @param documentLanguages comma separated document types
+     */
+    private void initDocumentLanguages(String documentLanguages)
+    {
+        String[] types = documentLanguages.split(",");
+
+        for (int i = 0; i < types.length; i++)
+        {
+            this.documentLanguages.add(types[i].trim());
+        }
+    }
+
+    /**
+     * Initialise the DTO browserInfo. 
+     * This DTO is used by the velocity templates to display the content browser infos.
+     *  
+     * @param uri The uri associated to the cms object to display
+     * @param request RenderRequest
+     * @param response RenderResponse
+     * @return a new initialised {@link BrowserInfo}
+     * @throws PortletException when it is not possible to initialise the 
+     */
+    private BrowserInfo initBrowserInfo(String uri, RenderRequest request, RenderResponse response) throws PortletException
+    {
+        try
+        {
+            BrowserInfo browserInfo = new BrowserInfo(this.documentTypes, this.documentLanguages);
+            CmsObject cmsObject = modelService.getCmsObject(uri);            
+            browserInfo.setCurrentCmsObject(cmsObject);
+            if ((cmsObject instanceof Folder) || (cmsObject == null))  // cms object is null if the uri match to a server root
+            {
+               browserInfo.setDocuments(modelService.getDocuments(uri));
+               browserInfo.setFolders(modelService.getFolders(uri));
+               browserInfo.setCurrentFolder(modelService.getFolder(uri));
+               
+            }
+            else
+            {
+                browserInfo.setCurrentFolder(cmsObject.getParentFolder());                
+            }
+            String scopeServer = CmsUtil.getServerScope(uri);
+            browserInfo.setCurrentServer(serverService.getServer(scopeServer));
+                        
+            return browserInfo;
+            
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Failed to view the portlet - impossible to access to Graffito content store : "
+                    + e.getMessage());
+        }
+
+    }
+    
+    
+    private void selectViewTemplate (BrowserInfo browserInfo, RenderRequest request, RenderResponse response) throws PortletException
+    {
+        CmsObject cmsObject = browserInfo.getCurrentCmsObject();
+        if ((cmsObject instanceof Folder) || (cmsObject == null))
+        {
+              request.setAttribute(PARAM_VIEW_PAGE, "/WEB-INF/view/folder/folder-browser.vm" ); 
+        }
+        else
+        {
+            Document document = (Document) cmsObject;
+            if (document.getContentType().equals("text/plain"))
+            {
+                request.setAttribute(PARAM_VIEW_PAGE, "/WEB-INF/view/document/document-text-html-view.vm" );
+            }
+            
+            if (document.getContentType().equals("text/html"))
+            {
+                request.setAttribute(PARAM_VIEW_PAGE, "/WEB-INF/view/document/document-text-html-view.vm" );
+            }
+            
+        }
+    }
+
 }



Mime
View raw message