]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
upload operation from client to server is improved
authormka <mka@opencascade.com>
Mon, 19 Nov 2012 11:08:33 +0000 (11:08 +0000)
committermka <mka@opencascade.com>
Mon, 19 Nov 2012 11:08:33 +0000 (11:08 +0000)
Workspace/Siman-Stub/service_wsdl/service/salome/SimanSalomeService.wsdl
Workspace/Siman-Stub/src/org/splat/ws_client/service/salome/SimanSalomeServiceStub.java
Workspace/Siman-Stub/test/org/splat/ws_client/service/salome/SimanSalomeServiceTestDownloadFile.java
Workspace/Siman-Stub/test/org/splat/ws_client/service/salome/SimanSalomeServiceTestUploadFile.java
Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeService.java
Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java

index 3831a723e77e8c893ac58fdb926ae2917bdfe8be..433d2232fefd549bced645dbdccedb2ce5633894 100644 (file)
@@ -8,6 +8,7 @@
                     <xs:sequence>
                         <xs:element minOccurs="0" name="args0" nillable="true" type="xs:base64Binary"/>
                         <xs:element minOccurs="0" name="args1" nillable="true" type="xs:string"/>
+                        <xs:element minOccurs="0" name="args2" type="xs:long"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
index ecf0a9328103569f7b33c04e123cdaa71c46bc2c..19c39f3b0db19289e5147750ceb88c47c50b2a3c 100644 (file)
                                }
                             
 
+                        /**
+                        * field for Args2
+                        */
+
+                        
+                                    protected long localArgs2 ;
+                                
+                           /*  This tracker boolean wil be used to detect whether the user called the set method
+                          *   for this attribute. It will be used to determine whether to include this field
+                           *   in the serialized XML
+                           */
+                           protected boolean localArgs2Tracker = false ;
+
+                           public boolean isArgs2Specified(){
+                               return localArgs2Tracker;
+                           }
+
+                           
+
+                           /**
+                           * Auto generated getter method
+                           * @return long
+                           */
+                           public  long getArgs2(){
+                               return localArgs2;
+                           }
+
+                           
+                        
+                            /**
+                               * Auto generated setter method
+                               * @param param Args2
+                               */
+                               public void setArgs2(long param){
+                            
+                                       // setting primitive attribute tracker to true
+                                       localArgs2Tracker =
+                                       param != java.lang.Long.MIN_VALUE;
+                                   
+                                            this.localArgs2=param;
+                                    
+
+                               }
+                            
+
      
      
         /**
                                             
                                           }
                                     
+                                   xmlWriter.writeEndElement();
+                             } if (localArgs2Tracker){
+                                    namespace = "http://salome.service.ws_server.splat.org";
+                                    writeStartElement(null, namespace, "args2", xmlWriter);
+                             
+                                               if (localArgs2==java.lang.Long.MIN_VALUE) {
+                                           
+                                                         throw new org.apache.axis2.databinding.ADBException("args2 cannot be null!!");
+                                                      
+                                               } else {
+                                                    xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localArgs2));
+                                               }
+                                    
                                    xmlWriter.writeEndElement();
                              }
                     xmlWriter.writeEndElement();
                                  
                                          elementList.add(localArgs1==null?null:
                                          org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localArgs1));
-                                    }
+                                    } if (localArgs2Tracker){
+                                      elementList.add(new javax.xml.namespace.QName("http://salome.service.ws_server.splat.org",
+                                                                      "args2"));
+                                 
+                                elementList.add(
+                                   org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localArgs2));
+                            }
 
                 return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray());
             
                                     else {
                                         
                                     }
+                                
+                                    
+                                    while (!reader.isStartElement() && !reader.isEndElement()) reader.next();
+                                
+                                    if (reader.isStartElement() && new javax.xml.namespace.QName("http://salome.service.ws_server.splat.org","args2").equals(reader.getName())){
+                                
+                                    nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
+                                    if ("true".equals(nillableValue) || "1".equals(nillableValue)){
+                                        throw new org.apache.axis2.databinding.ADBException("The element: "+"args2" +"  cannot be null");
+                                    }
+                                    
+
+                                    java.lang.String content = reader.getElementText();
+                                    
+                                              object.setArgs2(
+                                                    org.apache.axis2.databinding.utils.ConverterUtil.convertToLong(content));
+                                              
+                                        reader.next();
+                                    
+                              }  // End of if for expected property start element
+                                
+                                    else {
+                                        
+                                               object.setArgs2(java.lang.Long.MIN_VALUE);
+                                           
+                                    }
                                   
                             while (!reader.isStartElement() && !reader.isEndElement())
                                 reader.next();
index 1a7e559be702a60da351275f7ddaf7ea4c8d8a99..f317790e9db82d2890bfb3c062cbacaf4139786d 100644 (file)
@@ -48,15 +48,15 @@ public class SimanSalomeServiceTestDownloadFile {
                org.splat.ws_client.service.salome.SimanSalomeServiceStub.GetFile request = new org.splat.ws_client.service.salome.SimanSalomeServiceStub.GetFile();
                
                //request.setArgs0("W:/Eclipse workspace/SIMAN/Repository/vault/SimanSalome/100010018/siman-salome.conf");
-               request.setArgs0("W:/testvideo/IMG_5792.JPG");
+               request.setArgs0("W:\\testvideo\\IMG_5792.JPG");
                
                org.splat.ws_client.service.salome.SimanSalomeServiceStub.GetFileResponse response;
                
                response = stub.getFile(request);
                
-               File clientFile = new File("W:/client_temp2/IMG_5792_out.JPG");
+               File clientFile = new File("W:\\client_temp2\\IMG_5792_out.JPG");
                //File clientFile = new File("W:/client_temp2/siman-salome.conf");
-               File clientFilePath = new File("W:/client_temp2");
+               File clientFilePath = new File("W:\\client_temp2");
                clientFilePath.mkdirs();
                clientFile.createNewFile();
                
index 669ceda3290a9ecfba2ad4cfc128561c5cc4b082..420d70a83bb334f543f99ec3316216ec1316a45f 100644 (file)
@@ -20,7 +20,7 @@ public class SimanSalomeServiceTestUploadFile {
 
                options.setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_TRUE);
                options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS, Constants.VALUE_TRUE);
-               options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR, "w:/temp");
+               options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR, "w:\\temp");
                options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, "4000");
                
                // Increase the time out when sending large attachments
@@ -34,14 +34,15 @@ public class SimanSalomeServiceTestUploadFile {
                
                org.splat.ws_client.service.salome.SimanSalomeServiceStub.PutFileResponse response;
                
-               String clientFile = "w:/client_temp2/MKA_test.txt";
+               String clientFile = "w:\\client_temp2\\MKA_test.txt";
                DataSource dataSource = new FileDataSource(clientFile);
                DataHandler requestDH = new DataHandler(dataSource);
                
-               String requestFilePath = "W:/Eclipse workspace/SIMAN/Repository/vault/SimanSalome/100010018/MKA_test.txt";
+               String requestFilePath = "MKA_test.txt";
                
                request.setArgs0(requestDH);
                request.setArgs1(requestFilePath);
+               request.setArgs2(8);
                
                response = stub.putFile(request);
                        
index 9f7b7798f383f23d8b4955db1f4cb5749cb7e65e..ec54456b9d47ce6fdc8aeb501549dcea52c01840 100644 (file)
@@ -25,8 +25,9 @@ public interface SimanSalomeService {
        /**
         * Put the file from client to server.
         * @param dataHandler the data handler
-        * @param vaultURL the target URL in vault
+        * @param fileName the name of the uploaded file
+        * @param userId the user ID
         * @return the result URL in vault
         **/
-       String /*DataHandler*/ putFile(final DataHandler dataHandler, final String vaultURL);
+       String /*DataHandler*/ putFile(final DataHandler dataHandler, final String fileName, final Long userId);
 }
index 4d902285e40feb91268d3845651b0af92740c677..a258fe8c27117bccc352ef9dce9d77307b4514f1 100644 (file)
@@ -54,7 +54,7 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
                        
                        try {
                                //_projectSettingsService.configure("WebContent/conf/som.xml");
-                               _projectSettingsService.configure("W:/Eclipse workspace/SIMAN/SIMAN_SRC/Workspace/Siman-WS/WebContent/conf/som.xml");
+                               _projectSettingsService.configure("W:\\Eclipse workspace\\SIMAN\\SIMAN_SRC\\Workspace\\Siman-WS\\WebContent\\conf\\som.xml");
                                //ClassLoader loader = ClassLoader.getSystemClassLoader();
                                //URL pathToSOM = loader.getResource("WebContent/conf/som.xml");
                                
@@ -97,9 +97,9 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
 
                        List<StepDTO> listSteps = _scenarioService.getScenarioInfo(scenarioId);
                        
-                       File configFilePath = new File(_repositoryService.getRepositoryVaultPath() + "/SimanSalome/" + studyId.toString() + scenarioId.toString() + userId.toString());
+                       File configFilePath = new File(_repositoryService.getRepositoryVaultPath() + "\\SimanSalome\\" + studyId.toString() + scenarioId.toString() + userId.toString());
                        configFilePath.mkdirs();
-                       File configFile = new File(configFilePath + "/siman-salome.conf");
+                       File configFile = new File(configFilePath + "\\siman-salome.conf");
                        
                        //build the result file.
                FileWriter fstream;
@@ -185,11 +185,22 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
         * @see org.splat.ws_server.service.salome.SimanSalomeService#putFile(javax.activation.DataHandler, java.io.File)
         */
        @Override
-       public String /*DataHandler*/ putFile(final DataHandler dataHandler, final String vaultURL) {
+       public String /*DataHandler*/ putFile(final DataHandler dataHandler, final String fileName, final Long userId) {
                
-               File vaultURLFile = new File(vaultURL);
-               File serverFilePath = vaultURLFile.getParentFile();
-               serverFilePath.mkdirs();
+               //will be removed in future
+               try {
+                       _projectSettingsService.configure("W:\\Eclipse workspace\\SIMAN\\SIMAN_SRC\\Workspace\\Siman-WS\\WebContent\\conf\\som.xml");
+
+               } catch (IOException ioException) {
+                       LOG.debug("Sorry, IOException is throws", ioException);
+               } catch (SQLException sqlException) {
+                       LOG.debug("Sorry, impossible to populate the database", sqlException);
+               }       
+               
+               File pathToDownloadDirectory = new File(_repositoryService.getDownloadDirectory(userId).getPath());
+               File vaultURLFile = new File(pathToDownloadDirectory + "\\" + fileName);
+               
+               pathToDownloadDirectory.mkdirs();
                
                try {
                        vaultURLFile.createNewFile();
@@ -211,7 +222,7 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
                        e.printStackTrace();
                }
                
-               return vaultURL;
+               return vaultURLFile.getPath();
                /*FileDataSource fileDataSource = new FileDataSource(vaultURL);
                DataHandler fileDataHandler = new DataHandler(fileDataSource);
                return fileDataHandler;*/