You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/12/04 13:41:22 UTC

svn commit: r600912 - in /lenya/branches/branch_1_2_x_shibboleth: lenya.sh src/webapp/lenya/usecases/neutron/jx/meta.jx src/webapp/lenya/usecases/neutron/neutron.js

Author: andreas
Date: Tue Dec  4 04:41:21 2007
New Revision: 600912

URL: http://svn.apache.org/viewvc?rev=600912&view=rev
Log:
Merging changes from BRANCH_2_1_X (r5754354:600871)

Added:
    lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/jx/meta.jx
Modified:
    lenya/branches/branch_1_2_x_shibboleth/lenya.sh
    lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/neutron.js

Modified: lenya/branches/branch_1_2_x_shibboleth/lenya.sh
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/lenya.sh?rev=600912&r1=600911&r2=600912&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/lenya.sh (original)
+++ lenya/branches/branch_1_2_x_shibboleth/lenya.sh Tue Dec  4 04:41:21 2007
@@ -18,11 +18,12 @@
 # -----------------------------------------------------------------------------
 # Lenya Unix Shell Script
 #
-# $Id: lenya.sh 473841 2006-11-12 00:46:38Z gregor $
+# $Id: lenya.sh 599401 2007-11-29 12:08:11Z solprovider $
 # -----------------------------------------------------------------------------
 
 # Configuration variables
-#
+JETTY_PORT="8888"
+
 # LENYA_HOME
 #   The root of the Lenya distribution
 #
@@ -61,6 +62,7 @@
     echo "  servlet-admin     Run Lenya in a servlet container and turn on container web administration"
     echo "  servlet-debug     Run Lenya in a servlet container and turn on JVM remote debug"
     echo "  servlet-profile   Run Lenya in a servlet container and turn on JVM profiling"
+    echo "  stop              Stop Lenya in a servlet container"
     exit 1
 }
 
@@ -88,9 +90,10 @@
   JAVA_OPTIONS='-Xms32M -Xmx512M'
 fi
 
-if [ "$LENYA_HOME" = "" ] ; then
-  LENYA_HOME='.'
-fi
+# Set Lenya home to directory containing this script
+LENYA_HOME=${0%/*}
+cd $LENYA_HOME
+LENYA_HOME=`pwd -P`
 
 if [ "$LENYA_WEBAPP_HOME" = "" ] ; then
   STANDALONE_WEBAPP=../webapp
@@ -154,6 +157,22 @@
 JETTY_ADMIN_ARGS="-Djetty.admin.port=$JETTY_ADMIN_PORT"
 JETTY_LIBRARIES="-Dloader.jar.repositories=$LENYA_HOME/tools/jetty/lib${PATHSEP}${ENDORSED_LIBS}"
 
+# ---- Stop Lenya ------------------------------------------------------------- 
+    if [ -f $LENYA_HOME/lenya.pid ] ; then
+       echo -n $"Stopping $prog: "
+       kill -9 `cat lenya.pid`
+       rm -f $LENYA_HOME/lenya.pid
+       if [ "stop" = $ACTION ]; then  
+         exit 0
+       fi
+       sleep 10
+    else
+       if [ "stop" = $ACTION ]; then
+         echo "Cannot stop Lenya.  No lenya.pid."
+         exit 1
+       fi
+    fi
+
 # ----- Do the action ----------------------------------------------------------
 
 if [ -d build ]; then
@@ -177,22 +196,26 @@
 case "$ACTION" in
   cli)
         $JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $CLI_LIBRARIES $CLI $LOADER $ARGS
-        ;;
+	;;
 
   servlet)
-        $JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN
+        $JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN &
+        echo $! >lenya.pid
         ;;
 
   servlet-admin)
-        $JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_ADMIN_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN $JETTY_ADMIN
+        $JAVA $JAVA_OPTIONS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_ADMIN_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN $JETTY_ADMIN &
+        echo $! >lenya.pid
         ;;
 
   servlet-debug)
-        $JAVA $JAVA_OPTIONS $JAVA_DEBUG_ARGS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN
+        $JAVA $JAVA_OPTIONS $JAVA_DEBUG_ARGS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_PORT_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN &
+        echo $! >lenya.pid
         ;;
 
   servlet-profile)
-        $JAVA $JAVA_OPTIONS $JAVA_PROFILE_ARGS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN
+        $JAVA $JAVA_OPTIONS $JAVA_PROFILE_ARGS -cp $LOADER_LIB $ENDORSED $PARSER $JETTY_ARGS $JETTY_LIBRARIES $JETTY_WEBAPP $JETTY_HOME $JETTY $LOADER $JETTY_MAIN &
+        echo $! >lenya.pid
         ;;
 
   *)

Added: lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/jx/meta.jx
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/jx/meta.jx?rev=600912&view=auto
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/jx/meta.jx (added)
+++ lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/jx/meta.jx Tue Dec  4 04:41:21 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<dc:metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+  <dc:title>${title}</dc:title>
+  <dc:type></dc:type>
+  <dc:rights>All rights reserved.</dc:rights>
+  <dc:publisher></dc:publisher>
+  <dc:date></dc:date>
+  <dc:language></dc:language>
+  <dc:creator>${creator}</dc:creator>
+  <dc:coverage></dc:coverage>
+  <dc:description></dc:description>
+  <dc:extent></dc:extent>
+  <dc:identifier></dc:identifier>
+  <dc:subject></dc:subject>
+  <dc:relation></dc:relation>
+  <dc:contributor></dc:contributor>
+  <dc:source></dc:source>
+  <dc:format>${mimeType}</dc:format>
+  <jx:if test="${dimensions}">
+    <lenya:meta xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0">
+      <lenya:width>${dimensions.width}</lenya:width>
+      <lenya:height>${dimensions.height}</lenya:height>
+    </lenya:meta>
+  </jx:if>
+</dc:metadata>

Modified: lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/neutron.js
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/neutron.js?rev=600912&r1=600911&r2=600912&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/neutron.js (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/webapp/lenya/usecases/neutron/neutron.js Tue Dec  4 04:41:21 2007
@@ -22,6 +22,11 @@
 importClass(Packages.org.apache.lenya.ac.Identity);
 importClass(Packages.org.apache.lenya.cms.publication.DefaultDocumentIdToPathMapper);
 importClass(Packages.org.apache.lenya.ac.AccreditableManager);
+importClass(Packages.org.apache.lenya.cms.authoring.UploadHelper);
+importClass(Packages.org.apache.lenya.cms.publication.ResourcesManager);
+importClass(Packages.java.io.File);
+importClass(Packages.java.io.FileInputStream);
+
 
 /**
  * Provides flow functions for Neutron protocol support.
@@ -39,7 +44,7 @@
    var document = flowHelper.getPageEnvelope(cocoon).getDocument();
 
    var path = "/" + document.getId() + "/index_" + document.getLanguage() + ".xml";
-   cocoon.sendPage("xml/" + path);
+   cocoon.sendPage("xmlsource/" + path);
   
 }
 
@@ -96,10 +101,13 @@
     
   } catch (e) {
     cocoon.response.setStatus(500);
-    cocoon.sendPage("exception-checkout.jx", {"message": e});
+
+    var user = e.getCheckOutUsername();
+    var date = e.getCheckOutDate(); 
+    cocoon.sendPage("exception-checkout.jx", {"user": user, "date": date });
     return;
   }
-  cocoon.sendPage("xml/" + path);
+  cocoon.sendPage("xmlsource/" + path);
 }
 
 
@@ -153,7 +161,7 @@
     cocoon.sendPage("exception-checkout.jx", {"message" : e});
     return;
   }
-  cocoon.sendPage("xml/" + path);
+  cocoon.sendPage("xmlsource/" + path);
  
 }
 
@@ -179,6 +187,95 @@
     return;
   }
 }
+
+
+/**
+ * Upload
+ */
+
+
+function upload () {
+
+  var flowHelper = new FlowHelper();
+  var uploadHelper = new UploadHelper("/tmp");
+
+  var uploadFile = cocoon.request.get("upload-file");
+  var title = cocoon.request.get("title");
+  var creator = cocoon.request.get("creator");
+  var rights = cocoon.request.get("rights");
+  var mimeType = cocoon.request.get("mimeType");
+
+  var width = cocoon.request.get("width");
+  var height = cocoon.request.get("height");  
+
+  cocoon.log.error("Width, height: " + width + ", " + height);   
+
+  if (!uploadFile) {
+    cocoon.sendStatus(403);
+    return;
+  }
+
+
+  cocoon.log.error("Upload File: " + uploadFile + "\n");
+
+  var document = flowHelper.getPageEnvelope(cocoon).getDocument();
+  var file = uploadHelper.save(cocoon.request, "upload-file"); 
+  var fileName = file.getName();
+  var extent = file.length(); 
+
+  var resolver = cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
+  var resourcesManager = new ResourcesManager(document);
+    
+  var assetDirectoryPath = resourcesManager.getPath();
+  var assetPath = assetDirectoryPath +  File.separator + fileName;
+  var targetSource = resolver.resolveURI(assetPath);
+
+  var is = new FileInputStream(file);
+  var os = targetSource.getOutputStream();
+
+  var buffer = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024);
+  var len;
+
+  try {
+    while((len = is.read(buffer)) >= 0)
+      os.write(buffer, 0, len);
+  } catch (e) {
+
+  } finally {
+    is.close();
+    os.close();
+  }
+
+  // remove tmp file 
+  try {
+    file["delete"](); 
+  } catch(e) {}
+
+
+  var metaFilePath = resolver.resolveURI(assetPath + ".meta");
+  var metaOs = metaFilePath.getOutputStream();
+
+  if (width && height) {
+    var dimensions = new Object(); 
+    dimensions.width = width; 
+    dimensions.height = height; 
+    cocoon.processPipelineTo("createmetadata", {"mimeType" : mimeType, "extent" : extent, "title" : title, "creator": creator, "dimensions": dimensions }, metaOs);
+  } else {
+    cocoon.processPipelineTo("createmetadata", {"mimeType" : mimeType, "extent" : extent, "title" : title, "creator": creator }, metaOs);
+  }
+
+  metaOs.close();
+
+  var assetFile = new File(assetPath);
+
+  if (assetFile.exists()) {
+    cocoon.sendPage("upload-success.jx", {"filename" : fileName});  
+  } else {
+    cocoon.sendStatus(403);
+  }  
+
+}
+
 
 
 /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org