[jboss-svn-commits] JBoss Portal SVN: r5603 - in trunk: cms/src/main/org/jboss/portal/cms/impl cms/src/main/org/jboss/portal/cms/impl/jcr/command cms/src/main/org/jboss/portal/cms/model core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Nov 8 12:44:46 EST 2006
Author: roy.russo at jboss.com
Date: 2006-11-08 12:44:42 -0500 (Wed, 08 Nov 2006)
New Revision: 5603
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java
trunk/cms/src/main/org/jboss/portal/cms/model/Content.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp
Log:
JBPORTAL-1098 - fixed getting of file size logic, for performance.
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java 2006-11-08 17:25:19 UTC (rev 5602)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java 2006-11-08 17:44:42 UTC (rev 5603)
@@ -60,6 +60,8 @@
protected String mimeType;
+ protected int size;
+
public String getTitle()
{
return title;
@@ -161,9 +163,9 @@
isLive = live;
}
- public long getSize()
+ public int getSize()
{
- return this.bytes.length;
+ return this.size;
}
public String getMimeType()
@@ -175,6 +177,11 @@
{
this.mimeType = mimeType;
}
+
+ public void setSize(int size)
+ {
+ this.size = size;
+ }
}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java 2006-11-08 17:25:19 UTC (rev 5602)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java 2006-11-08 17:44:42 UTC (rev 5603)
@@ -62,6 +62,7 @@
contentNode.setProperty("portalcms:description", new StringValue(mFile.getContent().getDescription()));
contentNode.setProperty("portalcms:title", new StringValue(mFile.getContent().getTitle()));
contentNode.setProperty("portalcms:language", new StringValue(mFile.getContent().getLocale().getLanguage()));
+ contentNode.setProperty("portalcms:size", new StringValue(String.valueOf(mFile.getContent().getBytes().length)));
if (mFile.getContent().getMimeType() != null)
{
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java 2006-11-08 17:25:19 UTC (rev 5602)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java 2006-11-08 17:44:42 UTC (rev 5603)
@@ -89,22 +89,14 @@
content.setBasePath(session.getNodeByUUID(content.getBaseUUID()).getPath());
content.setVersionUUID(node.getUUID());
- /**
- * TODO: integate content size as a node property instead of a derived value
- * see explanation in comments
- */
- //this is the hacked code for now, until the size property is integrated end-to-end.
- //getting the size this way leads to unnecessary extraction of actual content
- //which slows the system down dramatically
content.setBytes("".getBytes());
-
- //this should be the new code
- /*int size = 0;
+ int size = 0;
if(node.hasProperty("portalcms:size"))
{
size = Integer.parseInt(node.getProperty("portalcms:size").getString());
- }*/
+ }
+ content.setSize(size);
content.setMimeType(node.getProperty("jcr:mimeType").getString());
content.setLastModified(node.getProperty("jcr:lastModified").getDate().getTime());
content.setName(node.getName());
Modified: trunk/cms/src/main/org/jboss/portal/cms/model/Content.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/model/Content.java 2006-11-08 17:25:19 UTC (rev 5602)
+++ trunk/cms/src/main/org/jboss/portal/cms/model/Content.java 2006-11-08 17:44:42 UTC (rev 5603)
@@ -38,8 +38,10 @@
void setMimeType(String type);
/** @return the */
- long getSize();
+ int getSize();
+ void setSize(int size);
+
/** @return Returns the content. */
InputStream getStream();
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2006-11-08 17:25:19 UTC (rev 5602)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2006-11-08 17:44:42 UTC (rev 5603)
@@ -212,7 +212,7 @@
}
%>
</td>
- <td><%= version.getBytes().length / 1024 %>kb</td>
+ <td><%= version.getSize() / 1024 %>kb</td>
<td>
<%
if (sType.equals("text/html") || sType.equals("text/plain"))
More information about the jboss-svn-commits
mailing list