fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [6818] Error handling changes


From: Petur Thorsteinsson
Subject: [Fmsystem-commits] [6818] Error handling changes
Date: Fri, 21 Jan 2011 08:32:39 +0000

Revision: 6818
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6818
Author:   peturbjorn
Date:     2011-01-21 08:32:39 +0000 (Fri, 21 Jan 2011)
Log Message:
-----------
Error handling changes

Modified Paths:
--------------
    thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImpl.java
    thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImplTest.java

Added Paths:
-----------
    thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/InvalidIfcFileException.java

Removed Paths:
-------------
    thirdparty/BIM_converter/trunk/WebContent/WEB-INF/lib/log4j.properties

Deleted: thirdparty/BIM_converter/trunk/WebContent/WEB-INF/lib/log4j.properties
===================================================================
--- thirdparty/BIM_converter/trunk/WebContent/WEB-INF/lib/log4j.properties      
2011-01-21 08:31:36 UTC (rev 6817)
+++ thirdparty/BIM_converter/trunk/WebContent/WEB-INF/lib/log4j.properties      
2011-01-21 08:32:39 UTC (rev 6818)
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-# An example log4j configuration file that outputs to System.out.  The
-# output information consists of relative time, log level, thread
-# name, logger name, nested diagnostic context and the message in that
-# order.
-
-# For the general syntax of property based configuration files see the
-# documenation of org.apache.log4j.PropertyConfigurator.
-
-log4j.rootLogger=DEBUG, A1
-
-# A1 is set to be a ConsoleAppender which outputs to System.out. 
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-
-# The conversion pattern uses format specifiers. You might want to
-# change the pattern an watch the output format change.
-log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
-
-# In this example, we are not really interested in INNER loop or SWAP
-# messages. See the effects of uncommenting and changing the levels of
-# the following loggers.
-# log4j.logger.org.apache.log4j.examples.SortAlgo.INNER=WARN
-# log4j.logger.org.apache.log4j.examples.SortAlgo.SWAP=WARN
- 
\ No newline at end of file

Added: 
thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/InvalidIfcFileException.java
===================================================================
--- 
thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/InvalidIfcFileException.java    
                            (rev 0)
+++ 
thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/InvalidIfcFileException.java    
    2011-01-21 08:32:39 UTC (rev 6818)
@@ -0,0 +1,22 @@
+package no.bimfm.ifc;
+/*
+ * Uc = Unchecked... should probably change this
+ */
+public class InvalidIfcFileException extends RuntimeException {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = -7670769841469006165L;
+       
+       public InvalidIfcFileException() {
+               super();
+       }
+       public InvalidIfcFileException(String exception) {
+               super(exception);
+       }
+       public InvalidIfcFileException(String exception, Throwable t) {
+               super(exception, t);
+       }
+       
+}

Modified: thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImpl.java
===================================================================
--- thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImpl.java       
2011-01-21 08:31:36 UTC (rev 6817)
+++ thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImpl.java       
2011-01-21 08:32:39 UTC (rev 6818)
@@ -143,16 +143,17 @@
        }
        @Override
        public boolean addRepository(String repoName, String fileName) {
-               try {
+               return importRepository(repoName, fileName);
+               /*try {
                        return importRepository(repoName, fileName);
-               } catch (RepositoryException e) {
-                       throw new RepositoryExceptionUc(e.getMessage());
-               }
+               } catch (RepositoryExceptionUc e) {
+                       throw e;
+               }*/
        }
-       private boolean importRepository(String repoName, String fileName) 
throws RepositoryException {
+       private boolean importRepository(String repoName, String fileName) {
                try {
                        if(checkIfRepositoryExists(repoName)) {
-                               throw new RepositoryException("Repository 
already exists!");
+                               throw new RepositoryExceptionUc("Repository 
already exists!");
                        } else {
                                super.openSdaiSession();
                                
@@ -179,8 +180,20 @@
                                return true;
                        }
                } catch (SdaiException e) {
-                       e.printStackTrace();
-                       throw new RepositoryException("Error adding 
repository", e);
+                       super.closeSdaiSession();
+                       logger.error("Exception thrown while adding 
repository");
+                       //e.printStackTrace();
+                       if(e.getMessage().contains("Exchange structure parsing 
error")) {
+                               logger.error("Throwing 
invalidifcfileexception");
+                               logger.error(e.getMessage());
+                               throw new InvalidIfcFileException("Invalid 
file", e);
+                       } else {
+                               logger.error("Throwing repository exception");
+                               throw new RepositoryExceptionUc("Error adding 
repository", e);
+                       }
+                       
+               } finally {
+                       //super.closeSdaiSession();
                }
        }
        /*

Modified: 
thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImplTest.java
===================================================================
--- thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImplTest.java   
2011-01-21 08:31:36 UTC (rev 6817)
+++ thirdparty/BIM_converter/trunk/src/no/bimfm/ifc/RepositoriesImplTest.java   
2011-01-21 08:32:39 UTC (rev 6818)
@@ -13,6 +13,8 @@
        String testingRepository = "TestRepository";
        String nonExistingRepository = "dummmmmyRepoThatDoesNotExist";
        String testIfcFileName = "sample.ifc";
+       String invalidIfcFileNameMixedCase = "fake1mixedcase.ifc";
+       String invalidIfcFileNameUpperCase = "fake2uppercase.ifc";
        int numberOfIfcElements = 163;
        @Before
        public void setUp() throws Exception {
@@ -82,6 +84,48 @@
                assertFalse(repo.deleteRepository(nonExistingRepository));
        }
        
+       @Test
+       public void testAddIvalidIfcMixedCase() {
+               String ifcFilename = 
Thread.currentThread().getContextClassLoader().getResource(invalidIfcFileNameMixedCase).toString();
+               
+               // OS specific!
+               ifcFilename = ifcFilename.replace("file:/", "");
+               if(repo.checkIfRepositoryExists(testingRepository)) {
+                       repo.deleteRepository(testingRepository);
+               }
+               try {
+                       repo.addRepository(testingRepository, ifcFilename);
+               }  catch (InvalidIfcFileException e) {
+                       assertTrue(true);
+               }       catch (RepositoryExceptionUc e) {
+                       System.out.println(e);
+                       System.out.println("MSG:"+e.getMessage());
+                       System.out.println("Cause:"+e.getCause().getMessage());
+               }
+       }
        
+       @Test
+       public void testAddIvalidIfcUpperCase() {
+               String ifcFilename = 
Thread.currentThread().getContextClassLoader().getResource(invalidIfcFileNameUpperCase).toString();
+               
+               // OS specific!
+               ifcFilename = ifcFilename.replace("file:/", "");
+               if(repo.checkIfRepositoryExists(testingRepository)) {
+                       repo.deleteRepository(testingRepository);
+               }
+               try {
+                       repo.addRepository(testingRepository, ifcFilename);
+               } catch (InvalidIfcFileException e) {
+                       assertTrue(true);
+               } catch (RepositoryExceptionUc e) {
+                       System.out.println(e);
+                       System.out.println("MSG:"+e.getMessage());
+                       System.out.println("Cause:"+e.getCause().getMessage());
+                       
+               }
+               
+               
+       }
+       
 
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]