portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vku...@apache.org
Subject svn commit: r758939 [3/3] - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets: site/ wicket/component/
Date Fri, 27 Mar 2009 00:15:59 GMT
Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java?rev=758939&r1=758938&r2=758939&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManagerUtil.java
Fri Mar 27 00:15:58 2009
@@ -23,14 +23,11 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.jetspeed.exception.JetspeedException;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.page.Link;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.request.RequestContext;
 
 /**
  * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
@@ -41,10 +38,10 @@
     private static String pathSeprator = System.getProperty("file.separator");
     private static String pageRoot = System.getProperty("java.io.tmpdir");
 
-    public static String getDownloadLink(HttpServletRequest servletRequest, String ObjectName,
String userName, String objectType) throws Exception
+    public static String getDownloadLink(String ObjectName, String userName, String objectType)
throws Exception
     {
         String link = "";
-        String basePath = servletRequest.getContextPath() + "/fileserver/_content/";
+        String basePath = System.getProperty("java.io.tmpdir");
         if (objectType.equalsIgnoreCase("folder"))
         {
             String sourcePath = getUserFolder(userName, false);
@@ -52,11 +49,11 @@
             boolean success = zipObject(sourcePath, target);
             if (!success)
                 throw new Exception("Error Occurered in zipping the file");
-            link = basePath + ObjectName + ".zip";
+            link = target;
         }
         else
         {
-            link = basePath + userName + "/" + ObjectName;
+            link = basePath + "/" + userName + "/" + ObjectName;
         }
         return link;
     }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java?rev=758939&r1=758938&r2=758939&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/SiteTreeNode.java
Fri Mar 27 00:15:58 2009
@@ -39,6 +39,14 @@
     public enum FileType {Folder,Page,Link};
     private FileType docType;
 
+    public SiteTreeNode(Folder folder,boolean loaded)
+    {
+        this.nodeName = folder.getName();
+        this.nodePath = folder.getPath();
+        docType = FileType.Folder;
+        this.loaded = loaded;
+    }
+
     public SiteTreeNode(Folder folder)
     {
         this.nodeName = folder.getName();
@@ -46,6 +54,7 @@
         docType = FileType.Folder;
     }
 
+
     public SiteTreeNode(Page page)
     {
         this.nodeName = page.getName();

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/DynamicResourceLink.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/DynamicResourceLink.java?rev=758939&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/DynamicResourceLink.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/DynamicResourceLink.java
Fri Mar 27 00:15:58 2009
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jetspeed.portlets.wicket.component;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+
+import org.apache.wicket.IResourceListener;
+import org.apache.wicket.Response;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.WicketURLEncoder;
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
+import org.apache.wicket.util.resource.IResourceStream;
+import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
+import org.apache.wicket.util.time.Time;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id:
+ */
+public class DynamicResourceLink extends Link implements IResourceListener
+{
+    private ResourceProvider resourceProvider;       
+    public DynamicResourceLink(String id, IModel model)
+    {
+        super(id, model);
+        resourceProvider = (ResourceProvider)model.getObject();
+    }
+
+    public void onResourceRequested()
+    {
+        final String filename = WicketURLEncoder.QUERY_INSTANCE.encode(resourceProvider.getName());
       
+        IResourceStream resourceStream = new IResourceStream()
+        {
+            /** Transient input stream to resource */
+            private transient InputStream inputStream = null;
+            private transient Locale locale = null;
+
+            /**
+             * @see org.apache.wicket.util.resource.IResourceStream#close()
+             */
+            public void close() throws IOException
+            {
+                resourceProvider.close();
+            }
+
+            /**
+             * @see org.apache.wicket.util.resource.IResourceStream#getContentType()
+             */
+            
+            public String getContentType()
+            {
+                resourceProvider.open();
+                return resourceProvider.getContentType();
+            }
+
+            /**
+             * @see org.apache.wicket.util.resource.IResourceStream#getInputStream()
+             */
+            public InputStream getInputStream() throws ResourceStreamNotFoundException
+            {
+                if (inputStream == null)
+                {
+                    try
+                    {                        
+                        inputStream = resourceProvider.getResource();
+                        
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+                return inputStream;
+            }
+
+            /**
+             * @see org.apache.wicket.util.watch.IModifiable#lastModifiedTime()
+             */
+            public Time lastModifiedTime()
+            {
+                return Time.valueOf(resourceProvider.getLastModified());
+            }
+
+            /**
+             * @see org.apache.wicket.util.resource.IResourceStream#length()
+             */
+            public long length()
+            {
+                return resourceProvider.getLength();
+            }
+
+            /**
+             * @see org.apache.wicket.util.resource.IResourceStream#getLocale()
+             */
+            public Locale getLocale()
+            {
+                return locale;
+            }
+
+            /**
+             * @see org.apache.wicket.util.resource.IResourceStream#setLocale(java.util.Locale)
+             */
+            public void setLocale(Locale loc)
+            {
+                locale = loc;
+            }
+        };
+        // Get servlet response to use when responding with resource
+        final Response response = getRequestCycle().getResponse();
+        // set not cacheable
+        response.setLastModifiedTime(Time.valueOf(-1));
+        getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream,
filename));
+    }
+
+    protected final CharSequence getURL()
+    {
+        return urlFor(IResourceListener.INTERFACE);
+    }
+
+    @Override
+    public void onClick()
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+  
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/DynamicResourceLink.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/ResourceProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/ResourceProvider.java?rev=758939&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/ResourceProvider.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/ResourceProvider.java
Fri Mar 27 00:15:58 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jetspeed.portlets.wicket.component;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:vkumar@apache.org">Vivek Kumar</a>
+ * @version $Id:
+ */
+public interface ResourceProvider
+{
+    void open();
+    void close();
+    InputStream getResource();
+    long getLastModified();
+    long getLength();
+    String getContentType();
+    String getName();
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/ResourceProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message