]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Now som.xml can be loaded
authormka <mka@opencascade.com>
Tue, 4 Dec 2012 15:35:43 +0000 (15:35 +0000)
committermka <mka@opencascade.com>
Tue, 4 Dec 2012 15:35:43 +0000 (15:35 +0000)
Workspace/Siman-WS/src/org/splat/ws_server/service/salome/SimanSalomeServiceImpl.java

index d3c58bdb272f0dad913d7fb4a2863c26dbbeb07b..b20e945cbcbb6b00cd9961a2e23830650a756753 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Scanner;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
+import javax.servlet.ServletContext;
 
 import org.apache.log4j.Logger;
 import org.splat.kernel.InvalidPropertyException;
@@ -29,8 +30,9 @@ import org.splat.service.dto.FileDTO;
 import org.splat.service.dto.StepDTO;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.technical.RepositoryService;
+import org.springframework.web.context.ServletContextAware;
 
-public class SimanSalomeServiceImpl implements SimanSalomeService {
+public class SimanSalomeServiceImpl implements SimanSalomeService, ServletContextAware {
        
        /**
         * The logger for the service.
@@ -53,6 +55,11 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
         */
        private ProjectSettingsService _projectSettingsService;
 
+       /**
+        * The Servlet Context.
+        */
+       private ServletContext _servletContext;
+
        /**
         * 
         * {@inheritDoc}
@@ -63,42 +70,7 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
                        final Long userId) {
                        
                        try {
-                               //_projectSettingsService.configure("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");
-                               
-                               /*ClassLoader cl = Thread.currentThread().getContextClassLoader();
-                               URL testURL = ClassLoader.getSystemResource("conf/som.xml");
-                               URL test2URL = ClassLoader.getSystemResource("som.xml");
-                               String          path    = System.getProperty("user.dir");
-                               
-                               File textfile = new File("w:/testfile.txt");
-                               
-                                FileWriter fstream;
-                               try {
-                                     fstream = new FileWriter(textfile);
-                                     BufferedWriter out = new BufferedWriter(fstream);  
-                                     if (testURL != null)
-                                         out.write("testURL " + testURL.getPath());
-                                     else
-                                         out.write("testURL == null\n");
-                                     
-                                     if (test2URL != null)
-                                         out.write("test2URL " + test2URL.getPath());
-                                     else
-                                         out.write("test2URL == null\n");
-                                     
-                                     out.write("path = " + path);
-                                     
-                                     out.close();
-                                   } catch (IOException e) {
-                                         // TODO Auto-generated catch block
-                                         e.printStackTrace();
-                                   }*/
-
-                               //_projectSettingsService.configure(ClassLoader.getSystemResource("som.xml").getPath());
-                               //_projectSettingsService.configure(pathToSOM.getPath());
+                               _projectSettingsService.configure(_servletContext.getRealPath("/conf/som.xml"));                        
                        } catch (IOException ioException) {
                                LOG.debug("Sorry, IOException is throws", ioException);
                        } catch (SQLException sqlException) {
@@ -205,7 +177,7 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
                
                //will be removed in future
                try {
-                       _projectSettingsService.configure("W:\\Eclipse workspace\\SIMAN\\SIMAN_SRC\\Workspace\\Siman-WS\\WebContent\\conf\\som.xml");
+                       _projectSettingsService.configure(_servletContext.getRealPath("/conf/som.xml"));
 
                } catch (IOException ioException) {
                        LOG.debug("Sorry, IOException is throws", ioException);
@@ -266,7 +238,9 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
                StepDTO step;
                long ScenarioId = 0;
                
-               LOG.debug("The fileURL = " + fileURL);
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("The fileURL = " + fileURL);
+               }
 
                try {
                        Scanner input = new Scanner(configFile);
@@ -384,6 +358,12 @@ public class SimanSalomeServiceImpl implements SimanSalomeService {
                        final ProjectSettingsService projectSettingsService) {
                _projectSettingsService = projectSettingsService;
        }
+
+
+       @Override
+       public void setServletContext(final ServletContext ctx) {
+               _servletContext = ctx;
+       }
        
        
 }