// save profiles
boolean saveAuthor = getBoolean( authorButton.getValue() );
- boolean saveDistributor = hasDistributor ? saveDistributor = getBoolean( distributor2Button.getValue() ) : false;
+ boolean saveDistributor = hasDistributor ? getBoolean( distributor2Button.getValue() ) : false;
if ( saveAuthor ) {
authorItem.setPassword( (char[]) authorText.getValue() );
setValid(true);
setErrorMessage(null);
for (SigningProfile profile : profileList) {
- if (profile == null) continue;
+ if (profile == null)
+ {
+ continue;
+ }
List<SigningProfileItem> profileItemList = profile.getProfileItemList();
for (SigningProfileItem item : profileItemList) {
- if (item == null) continue;
+ if (item == null)
+ {
+ continue;
+ }
checkFile(item.getKeyLocation());
}
SigningProfileItem authorItem = profile.getAuthorItem();
- if (authorItem != null) {
+ if (authorItem != null)
+ {
checkFile(authorItem.getKeyLocation());
}
}
public FontData[] boldFont(Font font) {
FontData[] datas = font.getFontData();
for (FontData data : datas)
+ {
data.setStyle(SWT.BOLD);
+ }
return datas;
}
mappingMap.put( args[0], args[1] );\r
}\r
}\r
- catch (IOException e)\r
+ catch ( final IOException e )\r
{\r
+ logger.error( "Unreachable block" );\r
}\r
}\r
mapper.setMappings( mappingMap );\r
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import org.tizen.common.util.Assert;
import org.tizen.common.util.FreeMarkerUtil;
import org.tizen.common.verrari.IModelProvider;
import org.tizen.common.verrari.ITemplateProvider;
throws Exception
{
final Template freemarkerTemplate = cfg.getTemplate( templateKey );
- if ( null == freemarkerTemplate )
- {
- logger.error( "Template is null for {}", templateKey );
- }
+ Assert.notNull( freemarkerTemplate, "Template is null for " + templateKey );
+
final IModelProvider adapter = new FreemarkerModelManager( modelProvider );
freemarkerTemplate.process( adapter, new OutputStreamWriter( output ) );
}
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
+import org.tizen.common.util.Assert;
import org.tizen.common.verrari.IModelProvider;
import org.tizen.common.verrari.ITemplate;
import org.tizen.common.verrari.engine.AbstractTemplateEngine;
final ITemplate template = getTemplate( templateKey );
logger.debug( "Template :{}", template );
- if ( null == template )
- {
- logger.error( "Template is null for {}", templateKey );
- }
+ Assert.notNull( template, "Template is null for " + templateKey );
String encoding = template.getEncoding();
if (encoding == null) {
package org.tizen.common.verrari.template;
import static org.junit.Assert.assertEquals;
+import static org.tizen.common.util.IOUtil.tryClose;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.InputStream;
import java.io.InputStreamReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.tizen.common.config.Preference;
-import org.tizen.common.config.provider.EnvironmentProvider;
import org.tizen.common.config.provider.SystemPropertiesProvider;
/**
String templateContents;
String fileConents;
+ InputStream in = null;
BufferedReader bufferedReader = null;
InputStreamReader streamReader = null;
// get FileTemplate contents.
try {
- streamReader = new InputStreamReader(fileTemplate.open(), fileTemplate.getEncoding());
+ in = fileTemplate.open();
+ streamReader = new InputStreamReader( in, fileTemplate.getEncoding());
bufferedReader = new BufferedReader(streamReader, 8192);
StringBuilder text = new StringBuilder();
final char[] buffer = new char[8192];
text.append( buffer, 0, nRead );
}
templateContents = text.toString();
- } catch (Exception e) {
- throw e;
} finally {
- if (streamReader != null) { streamReader.close(); }
- if (bufferedReader != null) { bufferedReader.close(); }
+ tryClose( bufferedReader, streamReader, in );
}
// get File contents.
try {
- streamReader = new InputStreamReader(new FileInputStream(file), System.getProperty("file.encoding"));
+ in = new FileInputStream( file );
+ streamReader = new InputStreamReader( in, System.getProperty("file.encoding"));
bufferedReader = new BufferedReader(streamReader, 8192);
StringBuilder text = new StringBuilder();
final char[] buffer = new char[8192];
text.append( buffer, 0, nRead );
}
fileConents = text.toString();
- } catch (Exception e) {
- throw e;
} finally {
- if (streamReader != null) { streamReader.close(); }
- if (bufferedReader != null) { bufferedReader.close(); }
+ tryClose( bufferedReader, streamReader, in );
}
assertEquals(templateContents, fileConents);
{\r
final char[] chars = name.toCharArray();\r
for ( int i=0, n=chars.length ; i<n ; ++i ) {\r
- if ( Character.isJavaIdentifierPart( chars[i] ) ) continue;\r
- if ( '.' == chars[i] ) continue;\r
+ if ( Character.isJavaIdentifierPart( chars[i] ) )\r
+ {\r
+ continue;\r
+ }\r
+ if ( '.' == chars[i] )\r
+ {\r
+ continue;\r
+ }\r
return false;\r
}\r
return true;\r
IDevice device = getDevice();
Assert.notNull( device );
- try
- {
- SyncService service = getSyncService();
- SyncResult syncSuccess =
- service.pullFile( remotePath, localPath, getProgressMonitor() );
- if ( syncSuccess.getCode() != SyncService.RESULT_OK ) {
- // TODO Message fix need
- context.getPrompter().notify( "Error: Failed to Transfer." );
- }
- } catch (Exception e) {
- throw new IllegalStateException( e );
+ SyncService service = getSyncService();
+ SyncResult syncSuccess =
+ service.pullFile( remotePath, localPath, getProgressMonitor() );
+ if ( syncSuccess.getCode() != SyncService.RESULT_OK ) {
+ // TODO Message fix need
+ context.getPrompter().notify( "Error: Failed to Transfer." );
}
}
if ( FilePolicy.OVERWRITE.equals( filePolicy ) )
{
+ logger.debug( "No operation" );
// No op
}
else
output = new DataOutputStream(new SafeFileOutputStream(strLocalFile, strLocalFile + ".temp"));
treeWriter.writeTree(tree, subTreePath, ElementTreeWriter.D_INFINITE, output);
- } catch (Exception e) {
+ } catch ( final IOException e ) {
return "";
} finally {
IOUtil.tryClose(output);
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.channels.FileChannel;
input = new FileReader(filePath);
redirect( input, contents );
return trim( contents.toString() );
- }catch(Exception e) {
+ } catch( final IOException e) {
+ logger.warn( "Exception occurred: ", e );
return null;
}finally{
tryClose( input, contents );
try {
proc= runtime.exec(fullCommand);
i = proc.waitFor();
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (IOException e) {
+ logger.warn( "Exception occurred: ", e );
return false;
+ }
+ catch (InterruptedException e)
+ {
+ logger.warn( "Exception occurred: ", e );
} finally{
logger.info( "HostUtil execute - exit value : {}", i );
if(proc!=null)
StreamGobbler gb2 = new StreamGobbler(p.getErrorStream());
gb1.start();
gb2.start();
- }catch(Exception e){
- e.printStackTrace();
+ }catch(IOException e){
+ logger.warn( "Exception occurred: ", e );
+ return false;
+ } catch (InterruptedException e)
+ {
+ logger.warn( "Exception occurred: ", e );
return false;
}
return i == 0;
gb2 = new StreamGobbler(p.getErrorStream());
gb1.start();
gb2.start();
- }catch(Exception e){
- e.printStackTrace();
+ }catch(IOException e){
+ logger.warn( "Exception occurred: ", e );
return false;
}finally{
logger.debug( "Output Stream :{}", gb1.getResult() );
contents.append(line);
contents.append(LINE_SEPARATOR);
}
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (IOException e) {
+ logger.warn( "Exception occurred: ", e );
return null;
} finally{
tryClose( input );
* Show output messages while executes the command on console view
* @param command - Command to execute.
* @param viewName - View name showing messages while executes the command.
+ *
+ * @throws IOException
+ * @throws InterruptedException
*/
- public static void executeWithConsole(String command, String viewName) throws Exception {
+ public static void executeWithConsole(String command, String viewName) throws IOException, InterruptedException
+ {
BufferedReader input = null;
String line = null;
// abnormal termination
if (proc.exitValue() != 0)
{
- throw new Exception("Failed to execute command: " + command);
+ throw new IllegalStateException("Failed to execute command: " + command);
}
} finally {
tryClose( input );
output = new BufferedWriter(new FileWriter(file));
output.write(contents);
return true;
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (IOException e) {
+ logger.warn( "Exception occurred: ", e );
return false;
}finally{
tryClose( output );
/**
- * @deprecated Use {@link FileUtil#copyTo(String, String)} instead.
+ * @deprecated Use {@link FileUtil#copyTo(String, String)} instead.
+ *
+ * @throws IOException
*/
@Deprecated
- public static boolean copyFile(String src, String des) throws Exception {
+ public static boolean copyFile(String src, String des) throws IOException {
boolean canExecute = false;
File srcFile=new File(src);
File desFile=null;
try
{
return Integer.decode( trimmed );
- } catch ( final Throwable e )
+ } catch ( final NumberFormatException e )
{
return defaultValue;
}
try
{
return Long.decode( trimmed );
- } catch ( final Throwable e )
+ } catch ( final NumberFormatException e )
{
return defaultValue;
}
{
return Double.valueOf( trimmed );
}
- catch( final Throwable e )
+ catch( final NumberFormatException e )
{
return defaultValue;
}
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public abstract class PropertyUtil {
+ protected static final Logger logger = LoggerFactory.getLogger( PropertyUtil.class );
public static Properties loadProperties(String fileName) {
Properties props = new Properties();
BufferedReader reader = null;
props.setProperty(key, value);
}
//props.load(reader);
- } catch (Exception e) {
- e.printStackTrace();
+ }
+ catch ( final IOException e )
+ {
+ logger.info( "Exception Occurred:", e );
} finally {
tryClose( reader );
}
Properties props = new Properties();
try {
props.load(inputStream);
- } catch (Exception e) {
+ } catch (IOException e) {
} finally {
tryClose( inputStream );
}
public static boolean storeProperties(OutputStream outputStream, Properties props) {
try {
props.store(outputStream, null);
- } catch (Exception e) {
+ } catch (IOException e) {
return false;
} finally {
tryClose( outputStream );
public static boolean storeProperties(String fileName, Properties props) {
BufferedWriter writer = null;
- try {
+ try
+ {
writer = new BufferedWriter(new FileWriter(fileName));
props.store(writer, null);
- } catch (Exception e) {
+ }
+ catch ( IOException e )
+ {
return false;
} finally {
tryClose( writer );
private static String getCallerName() {
// Get the stack trace.
- StackTraceElement stack[] = (new Throwable()).getStackTrace();
+ StackTraceElement stack[] = (new IllegalArgumentException()).getStackTrace();
int ix = 0;
// Now search for the first frame before the "Logger" class.
while (ix < stack.length) {
import java.util.Iterator;
import org.junit.Test;
+import org.slf4j.LoggerFactory;
/**
} catch ( ConcurrentModificationException e )
{
// Test Success
+ LoggerFactory.getLogger( getClass() ).info( "Test case successfult" );
}
}
true
};
- Object[] actualData = null;
for ( Object[] input : inputArray ) {
for ( Object arg : inputAddArg ) {
+ Object[] actualData = null;
try {
actualData = ArrayUtil.add(input, arg);
} catch (ArrayStoreException e) {
assertArrayEquals( new String[] { "c" }, ArrayUtil.remove( new String[] { "a", "b", "c" }, -1, 2 ) );
final Object[][] inputArray = new Object[][]{
- null,
new String[]{"hello", "test", "java", "c", "c++", "junit", "time"},
new Integer[]{10, 20, 30, 40, 50, 60, 70, 80, 90},
{10, 20, 30, 40, 50, 60, 70, 80, 90, 100},
new Object[]{null, null, null},
new Object[]{ }
};
- Object[] actualData = null;
-
+
+ try
+ {
+ ArrayUtil.remove( null, 0, 1 );
+ fail();
+ }
+ catch( final IllegalArgumentException e )
+ {
+ LoggerFactory.getLogger( getClass() ).info( "Test case successfult" );
+ }
+
for ( Object[] input : inputArray ) {
for ( int i = -1 ; i < 10 ; i++ ) {
- for( int j = -1 ; j < 10 ; j++ ) {
+ for( int j = i ; j < 10 ; j++ ) {
int deleteCount = 0;
try {
- actualData = ArrayUtil.remove( input, i, j);
+ Object[] actualData = ArrayUtil.remove( input, i, j);
i = Math.max( 0, i );
if( j <= i) {
assertArrayEquals(input , actualData);
fail("Failed remove(Object[], int, int) test");
}
}
- catch ( NullPointerException e ){
- if ( input == null) {
- continue;
- }
- else {
- fail("Failed remove(Object[], int, int) test");
- }
- }
catch (NegativeArraySizeException e) {
if ( input.length < j - i ) {
continue;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Before;
import org.junit.Test;
+import org.slf4j.LoggerFactory;
/**
try {
CollectionUtil.mergeArrayIntoCollection( TEST_CASES[0], null );
fail( "mergeArrayIntoCollection must throw exception" );
- } catch (NullPointerException e) {
+ } catch ( IllegalArgumentException e) {
+ LoggerFactory.getLogger( getClass() ).info( "Test case successful" );
}
for ( final Object[] TEST_CASE : TEST_CASES )
assertEquals( "Tizen"+StringUtil.EMPTY_STRING+"Test",
CollectionUtil.concatenate( iter, StringUtil.EMPTY_STRING ) );
break;
+ default:
+ break;
}
}
CollectionUtil.swap( objectArray, 0, 5 );
fail( "swap must throw exception" );
} catch (Exception e) {
+ LoggerFactory.getLogger( getClass() ).info( "Test case successful" );
}
try {
CollectionUtil.swap( objectArray, -1, 0 );
fail( "swap must throw exception" );
} catch (Exception e) {
+ LoggerFactory.getLogger( getClass() ).info( "Test case successful" );
}
try {
CollectionUtil.swap( null, 0, 1 );
fail( "swap must throw exception" );
} catch (Exception e) {
+ LoggerFactory.getLogger( getClass() ).info( "Test case successful" );
}
}