import javax.activation.DataHandler;
import javax.activation.FileDataSource;
+import javax.servlet.ServletContext;
import org.apache.log4j.Logger;
import org.splat.kernel.InvalidPropertyException;
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.
*/
private ProjectSettingsService _projectSettingsService;
+ /**
+ * The Servlet Context.
+ */
+ private ServletContext _servletContext;
+
/**
*
* {@inheritDoc}
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) {
//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);
StepDTO step;
long ScenarioId = 0;
- LOG.debug("The fileURL = " + fileURL);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("The fileURL = " + fileURL);
+ }
try {
Scanner input = new Scanner(configFile);
final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
+
+
+ @Override
+ public void setServletContext(final ServletContext ctx) {
+ _servletContext = ctx;
+ }
}