Index: branches/prototype-v0/zoo-project/zoo-services/gdal/dem/cgi-env/Gdal_Dem.zcfg
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/gdal/dem/cgi-env/Gdal_Dem.zcfg	(revision 839)
+++ branches/prototype-v0/zoo-project/zoo-services/gdal/dem/cgi-env/Gdal_Dem.zcfg	(revision 854)
@@ -44,4 +44,13 @@
     <Default />
    </LiteralData>
+  [co]
+   Title = Creation Option
+   Abstract = string representing options (NAME=VALUE)
+   minOccurs = 0
+   maxOccurs = 1
+   <LiteralData>
+    DataType = string
+    <Default />
+   </LiteralData>
  </DataInputs>
  <DataOutputs>
Index: branches/prototype-v0/zoo-project/zoo-services/gdal/dem/service.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/gdal/dem/service.c	(revision 839)
+++ branches/prototype-v0/zoo-project/zoo-services/gdal/dem/service.c	(revision 854)
@@ -2486,4 +2486,19 @@
       setMapInMaps(outputs,"Result","value",tmpMap->value);
     }
+    
+    tmpMap=getMapFromMaps(inputs,"co","value");
+    if(tmpMap!=NULL){
+      papszCreateOptions = CSLAddString( papszCreateOptions, tmpMap->value );  
+      map* tmpMap1;
+      maps* tmpMaps=getMaps(inputs,"co");
+      if((tmpMap1=getMapFromMaps(inputs,"co","length"))!=NULL){
+        int i=1;
+        int length=atoi(tmpMap1->value);
+        for(;i<length;i++){
+          tmpMap=getMapArray(tmpMaps->content,"value",i);
+          papszCreateOptions = CSLAddString( papszCreateOptions, tmpMap->value );
+        }
+      } 
+    }    
 
     tmpMap=NULL;
Index: branches/prototype-v0/zoo-project/zoo-services/utils/hpc/Makefile
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/utils/hpc/Makefile	(revision 839)
+++ branches/prototype-v0/zoo-project/zoo-services/utils/hpc/Makefile	(revision 854)
@@ -4,5 +4,5 @@
 
 cgi-env/wps_hpc.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_hpc.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service ${ZRPATH}/zoo-kernel/sshapi.o ${HPCLDFLAGS}
+	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_hpc.zo service.c service2.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service ${ZRPATH}/zoo-kernel/sshapi.o ${HPCLDFLAGS}
 
 install:
Index: branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c	(revision 839)
+++ branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c	(revision 854)
@@ -3,4 +3,8 @@
  *
  * Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ *
+ * This work was supported by public funds received in the framework of GEOSUD,
+ * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
+ * by the French National Research Agency
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,4 +31,5 @@
 #include "service_internal.h"
 #include "sshapi.h"
+#include "server_internal.h"
 
 #include <sys/socket.h>
@@ -57,10 +62,33 @@
     int fd,rc=NULL;
     int i=0;
+    map* usid=getMapFromMaps(conf,"lenv","usid");
+    map* tmpPath=getMapFromMaps(conf,"main","tmpPath");
+
+    char *flenv =
+      (char *) malloc ((strlen (tmpPath->value) + 
+			strlen (jobid->value) + 12) * sizeof (char));
+    sprintf (flenv, "%s/%s_lenv.cfg", tmpPath->value, jobid->value);
+    maps* m = (maps *) malloc (MAPS_SIZE);
+    m->child=NULL;
+    m->next=NULL;
+    map* configId=NULL;
+
+    
+    if(conf_read(flenv, m) != 2){
+      configId=getMapFromMaps(m,"lenv","configId");
+      setMapInMaps(conf,"lenv","configId",configId->value);
+    }else{
+      setMapInMaps(conf,"lenv","message",_("Unable to read the lenv section file of the requested jobid"));
+      return SERVICE_FAILED;
+    }
+    unlink(flenv);
+    free(flenv);
+
     SSHCON *test=ssh_connect(conf);
     if(test==NULL){
-      return SERVICE_FAILED;
-    }
-    map* usid=getMapFromMaps(conf,"lenv","usid");
-    map* tmpPath=getMapFromMaps(conf,"main","tmpPath");
+      setMapInMaps(conf,"lenv","message",_("Unable to connect using through ssh."));
+      return SERVICE_FAILED;
+    }
+
     char *logPath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+12)*sizeof(char));
     sprintf(logPath,"%s/exec_out_%s",tmpPath->value,jobid->value);
@@ -80,5 +108,5 @@
     }
     free(logPath);
-    // Run scontrol to see if the service execution ends
+    // Run scontrol to check if the service execution ended.
     // Store all the informations returned by scontrol command as a cfg file to
     // be parsed back by the ZOO-Kernel waiting for the execution of the remote
@@ -86,9 +114,9 @@
     maps* tmpMaps=createMaps("henv");
     char* command=(char*)malloc((126)*sizeof(char));
-    //memset(&command,0,34);
-    sprintf(command,"scontrol show jobid | grep -A24 %s",fcontent);    
+    sprintf(command,"scontrol show jobid | grep -A24 JobId=%s",fcontent);    
     if(ssh_exec(conf,command,ssh_get_cnt(conf))==0){
       free(command);
       setMapInMaps(conf,"lenv","message",_("Failed to run scontrol remotely"));
+      // TODO: check status in db and if available continue in other case return SERVICE_FAILED
       return SERVICE_FAILED;
     }else{
@@ -98,67 +126,53 @@
       int ts=stat(logPath, &f_status);
       if(ts==0) {
-        fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
-        FILE* f=fopen(logPath,"rb");
-        fread(fcontent,f_status.st_size,1,f);
-        int fsize=f_status.st_size;
-        fcontent[fsize]=0;
-        fclose(f);
-        free(logPath);
-        fprintf(stderr,"%s \n",fcontent);
-        char *token, *saveptr;
-        token = strtok_r (fcontent, " ", &saveptr);
-        while (token != NULL)
-          {
-            //fprintf(stderr,"%s %d\n",token,__LINE__);
-            char *token1, *saveptr1;
-            char *tmpToken=strdup(token);
-            token1 = strtok_r (tmpToken, "=", &saveptr1);
-            int isNext=-1;
-            int hasTwoElements=0;
-            char *name=NULL;
-            while (token1 != NULL)
-              {
-                if(hasTwoElements==0)
-                  name=strdup(token1);
-                if(hasTwoElements<1)
-                  hasTwoElements+=1;
-                else{
-                  char *value=strdup(token1);
-                  if(value[strlen(value)-1]=='\n')
-                    value[strlen(value)-1]=0;
-                  if(strlen(name)>0 && strlen(value)>0){
-                    if(tmpMaps->content==NULL)
-                      tmpMaps->content=createMap(name,value);
-                    else
-                      addToMap(tmpMaps->content,name,value);
-                    free(value);
-                  }
-                  free(name);
-                  hasTwoElements=0;
-                }
-                token1 = strtok_r (NULL, "=", &saveptr1);
-              }
-            free(tmpToken);
-            token = strtok_r (NULL, " ", &saveptr);
-          }
+	fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+	FILE* f=fopen(logPath,"rb");
+	fread(fcontent,f_status.st_size,1,f);
+	int fsize=f_status.st_size;
+	fcontent[fsize]=0;
+	fclose(f);
+	free(logPath);
+	char *token, *saveptr;
+	token = strtok_r (fcontent, " ", &saveptr);
+	while (token != NULL)
+	  {
+	    char *token1, *saveptr1;
+	    char *tmpToken=strdup(token);
+	    token1 = strtok_r (tmpToken, "=", &saveptr1);
+	    int isNext=-1;
+	    int hasTwoElements=0;
+	    char *name=NULL;
+	    while (token1 != NULL)
+	      {
+		if(hasTwoElements==0)
+		  name=strdup(token1);
+		if(hasTwoElements<1)
+		  hasTwoElements+=1;
+		else{
+		  char *value=strdup(token1);
+		  if(value[strlen(value)-1]=='\n')
+		    value[strlen(value)-1]=0;
+		  if(strlen(name)>0 && strlen(value)>0){
+		    if(tmpMaps->content==NULL)
+		      tmpMaps->content=createMap(name,value);
+		    else
+		      addToMap(tmpMaps->content,name,value);
+		    free(value);
+		  }
+		  free(name);
+		  hasTwoElements=0;
+		}
+		token1 = strtok_r (NULL, "=", &saveptr1);
+	      }
+	    free(tmpToken);
+	    token = strtok_r (NULL, " ", &saveptr);
+	  }
       }else{
-        setMapInMaps(conf,"lenv","message",_("Unable to access the downloaded execution log file"));
-        return SERVICE_FAILED;
+	setMapInMaps(conf,"lenv","message",_("Unable to access the downloaded execution log file"));
+	return SERVICE_FAILED;
       }
     }
-    logPath=(char*)malloc((strlen(tmpPath->value)+strlen(usid->value)+15)*sizeof(char));
-    sprintf(logPath,"%s/exec_status_%s",tmpPath->value,usid->value);
-    dumpMapsToFile(tmpMaps,logPath,0);
-
-    char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+21));
-    sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,jobid->value);
-    if ( (fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
-      perror("socket error");
-      setMapInMaps(conf,"lenv","message",_("Socket error"));
-      return SERVICE_FAILED;
-      }
-    }
-    logPath=(char*)malloc((strlen(tmpPath->value)+strlen(usid->value)+15)*sizeof(char));
-    sprintf(logPath,"%s/exec_status_%s",tmpPath->value,usid->value);
+    logPath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char));
+    sprintf(logPath,"%s/exec_status_%s",tmpPath->value,jobid->value);
     dumpMapsToFile(tmpMaps,logPath,0);
     char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+21));
@@ -179,8 +193,8 @@
     if (write(fd, "3", 1) != rc) {
       if (rc < 0) {
-        perror("write error");
-        setMapInMaps(conf,"lenv","message",_("Unable to announce the successful execution of the HPC service"));
-        close(fd);
-        return SERVICE_FAILED;
+	perror("write error");
+	setMapInMaps(conf,"lenv","message",_("Unable to announce the successful execution of the HPC service"));
+	close(fd);
+	return SERVICE_FAILED;
       }
     }
Index: branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c	(revision 854)
+++ branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c	(revision 854)
@@ -0,0 +1,203 @@
+/**
+ * Author : Gérald FENOY
+ *
+ * Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ * 
+ * This work was supported by public funds received in the framework of GEOSUD,
+ * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
+ * by the French National Research Agency
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+#include "service.h"
+#include "service_internal.h"
+
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <libxslt/xslt.h>
+#include <libxslt/xsltInternals.h>
+#include <libxslt/transform.h>
+#include <libxslt/xsltutils.h>
+
+#include <dirent.h>
+extern "C" {
+
+  /**
+   * Try to delete a cache file.
+   * 
+   * @param storage the full path to store the file
+   * @param filename the filename to store
+   * @param ext the extention of the file
+   * @return 0 in case of success
+   */
+  int tryDeleteCacheFile(const char* storage,const char* filename,const char* ext){
+    char *filename_noext=(char*)malloc((strlen(filename)-3)*sizeof(char));
+    snprintf(filename_noext,strlen(filename)-4,"%s",filename);
+    char* filename_full=(char*)malloc((strlen(filename)+1)*sizeof(char));
+    sprintf(filename_full,"%s.%s",filename_noext,ext);
+    char* fullpath=(char*)malloc((strlen(storage)+strlen(filename_full)+2)*sizeof(char));
+    sprintf(fullpath,"%s/%s",storage,filename_full);
+    if(unlink(fullpath)==0){
+      // TODO store the filename_full in the deletedfiles
+      fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,filename_full);
+    }else{
+      fprintf(stderr,"#### DeleteData #### unable to delete %s \n",fullpath);
+    }
+    free(fullpath);
+    free(filename_full);
+    return 0;
+  }  
+
+  /**
+   * Try to delete a data file.
+   * 
+   * @param storage the full path to store the file
+   * @param filename the filename to store
+   * @return 0 in case of success
+   */
+  int tryDeleteDataFile(const char* storage,const char* filename){
+    char* fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char));
+    sprintf(fullpath,"%s/%s",storage,filename);
+    if(unlink(fullpath)==0){
+      // TODO store the filename_full in the deletedfiles
+      fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,filename);
+    }else{
+      fprintf(stderr,"#### DeleteData #### unable to delete %s \n",fullpath);
+    }
+    free(fullpath);
+    return 0;
+  }  
+  
+  
+  /**
+   * DeleteData ZOO-Service :
+   * This service is used in the ZOO-Project to delete the data file
+   * associated with input or output.
+   */
+  ZOO_DLL_EXPORT int DeleteData(maps*& conf,maps*& inputs,maps*& outputs){
+    map* dataPath=getMapFromMaps(conf,"main","dataPath");
+    map* tmpPath=getMapFromMaps(conf,"main","tmpPath");
+    map* cacheDir=getMapFromMaps(conf,"main","cacheDir");
+    map* jobid=getMapFromMaps(inputs,"jobid","value");
+    map* filename=getMapFromMaps(inputs,"filename","value");
+    map* ioname=getMapFromMaps(inputs,"ioname","value");
+    char tmp0[4];
+    sprintf(tmp0,"%c%c%c",filename->value[strlen(filename->value)-4],filename->value[strlen(filename->value)-3],filename->value[strlen(filename->value)-2]);
+    char *cfilename=NULL;
+    if(strcasecmp(tmp0,"zca")==0){
+      cfilename=(char*) malloc((strlen(filename->value)+strlen(cacheDir->value)+2)*sizeof(char));
+      sprintf(cfilename,"%s/%s",cacheDir->value,filename->value);
+    }
+    else{
+      cfilename=(char*) malloc((strlen(filename->value)+strlen(tmpPath->value)+2)*sizeof(char));
+      sprintf(cfilename,"%s/%s",tmpPath->value,filename->value);
+    }
+    zooLock* lck=lockFile(conf,cfilename,'w');
+    char** deletedfiles;
+    if(lck!=NULL){
+      if(strcasecmp(tmp0,"zca")==0){
+	// Read the zcp file to verify if it comes from a shared source
+	char *filename_noext=(char*)malloc((strlen(filename->value)-3)*sizeof(char));
+	snprintf(filename_noext,strlen(filename->value)-4,"%s",filename->value);
+	char* filename_full=(char*)malloc((strlen(filename->value)+1)*sizeof(char));
+	sprintf(filename_full,"%s.zcp",filename_noext);
+	char* fullpath=(char*)malloc((strlen(cacheDir->value)+strlen(filename_full)+2)*sizeof(char));
+	sprintf(fullpath,"%s/%s",cacheDir->value,filename_full);
+	FILE* f0=fopen(fullpath,"rb");
+	char *fcontent=NULL;
+	if(f0!=NULL){
+	  long flen;
+	  fseek (f0, 0, SEEK_END);
+	  flen = ftell (f0);
+	  fseek (f0, 0, SEEK_SET);
+	  fcontent = (char *) malloc ((flen + 1) * sizeof (char));
+	  fread(fcontent,flen,1,f0);
+	  fcontent[flen]=0;
+	  fclose(f0);
+	}
+	if(fcontent!=NULL && strcasecmp(fcontent,"SHARED")!=0){
+	  // Delete associated zcm and zcp
+	  tryDeleteCacheFile(cacheDir->value,filename->value,"zca");
+	  tryDeleteCacheFile(cacheDir->value,filename->value,"zcm");
+	  tryDeleteCacheFile(cacheDir->value,filename->value,"zcp");
+	  // Delete ZOO_DATA_<input>_<sid>.data and <input>_<sid>.map
+	  char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
+	  sprintf(datafile,"ZOO_DATA_%s_%s.data",ioname->value,jobid->value);
+	  tryDeleteDataFile(dataPath->value,datafile);
+	  free(datafile);
+	  datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
+	  sprintf(datafile,"%s_%s.map",ioname->value,jobid->value);
+	  tryDeleteDataFile(dataPath->value,datafile);
+	  free(datafile);
+	}else{
+	  setMapInMaps(conf,"lenv","message",_ss("The file you try to delete is a shared ressource and cannot be deleted by nature."));
+	  unlockFile(conf,lck);
+	  return SERVICE_FAILED;
+	}
+	setMapInMaps(outputs,"Result","value",_ss("The input data has been correclty removed"));
+      }else{
+	char tmp1[8];
+	snprintf(tmp1,7,"%s",filename->value);
+	if(strcasecmp(tmp1,"output")==0){
+	  tryDeleteDataFile(tmpPath->value,filename->value);
+	  // Delete ZOO_DATA_<output>_<sid>.data and <output>_<sid>.map
+	  char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
+	  sprintf(datafile,"ZOO_DATA_%s_%s.data",ioname->value,jobid->value);
+	  tryDeleteDataFile(dataPath->value,datafile);
+	  free(datafile);
+	  datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
+	  sprintf(datafile,"%s_%s.map",ioname->value,jobid->value);
+	  tryDeleteDataFile(dataPath->value,datafile);
+	  free(datafile);
+	  char* webServices[3]={"wms","wfs","wcs"};
+	  int i=0;
+	  // Delete ZOO_DATA_<ws>_link_<sid>.data and <ws>_link_<sid>.map
+	  // with <ws> is the corresponding OGC web service (wms,wfs,wcs)
+	  for(i=0;i<3;i++){
+	    datafile=(char*)malloc((strlen(jobid->value)+24)*sizeof(char));
+	    sprintf(datafile,"ZOO_DATA_%s_link_%s.data",webServices[i],jobid->value);
+	    tryDeleteDataFile(dataPath->value,datafile);
+	    free(datafile);
+	    datafile=(char*)malloc((strlen(jobid->value)+14)*sizeof(char));
+	    sprintf(datafile,"%s_link_%s.map",webServices[i],jobid->value);
+	    tryDeleteDataFile(dataPath->value,datafile);
+	    free(datafile);
+	  }
+	  setMapInMaps(outputs,"Result","value",_ss("The output data has been correclty removed"));
+	}else{
+	  setMapInMaps(conf,"lenv","message",_ss("The file you try to delete is nor an input, nor and output."));
+	  unlockFile(conf,lck);
+	  return SERVICE_FAILED;
+	}
+      }
+      unlockFile(conf,lck);
+    }
+    else{
+      setMapInMaps(conf,"lenv","message",_ss("Failed to acquire lock for deletion, please try again later."));
+      return SERVICE_FAILED;
+    }
+    return SERVICE_SUCCEEDED;
+  }
+
+}
Index: branches/prototype-v0/zoo-project/zoo-services/utils/status/Makefile
===================================================================
--- branches/prototype-v0/zoo-project/zoo-services/utils/status/Makefile	(revision 839)
+++ branches/prototype-v0/zoo-project/zoo-services/utils/status/Makefile	(revision 854)
@@ -4,5 +4,5 @@
 
 cgi-env/wps_status.zo: service.c
-	g++ ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service
+	g++ -rdynamic ${CFLAGS} -shared -fpic -o cgi-env/wps_status.zo ./service.c ${GDAL_LIBS} ${XML2LDFLAGS} ${MACOS_LD_FLAGS} ${ZOO_LDFLAGS} ${MACOS_LD_NET_FLAGS} ${XSLT_LDFLAGS} ${FCGI_LDFLAGS} -L${ZRPATH}/zoo-kernel/ -lzoo_service
 
 install:
