当前位置: 首页>>代码示例>>Java>>正文


Java LogWriter.logBasic方法代码示例

本文整理汇总了Java中org.pentaho.di.core.logging.LogWriter.logBasic方法的典型用法代码示例。如果您正苦于以下问题:Java LogWriter.logBasic方法的具体用法?Java LogWriter.logBasic怎么用?Java LogWriter.logBasic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.logging.LogWriter的用法示例。


在下文中一共展示了LogWriter.logBasic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addOkRemark

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public static void addOkRemark(CheckResultSourceInterface source, String propertyName,
    List<CheckResultInterface> remarks)
{
  final int SUBSTRING_LENGTH = 20;
  LogWriter log = LogWriter.getInstance();
  log.logBasic(JobEntryValidatorUtils.class.getSimpleName(), "attempting to fetch property named '" + propertyName
      + "'");
  String value = ValidatorUtils.getValueAsString(source, propertyName);
  log.logBasic(JobEntryValidatorUtils.class.getSimpleName(), "fetched value [" + value + "]");
  String substr = null;
  if (value != null)
  {
    substr = value.substring(0, Math.min(SUBSTRING_LENGTH, value.length()));
    if (value.length() > SUBSTRING_LENGTH)
    {
      substr += "..."; //$NON-NLS-1$
    }
  }
  remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_OK, ValidatorMessages.getString("messages.passed", //$NON-NLS-1$
      propertyName, substr), source));
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:22,代码来源:JobEntryValidatorUtils.java

示例2: initLogging

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private static void initLogging(CommandLineOption[] options) throws KettleException {
	StringBuffer optionLogfile = getCommandLineOption(options, "logfile").getArgument();
	StringBuffer optionLoglevel = getCommandLineOption(options, "level").getArgument();

	// Set default Locale:
	Locale.setDefault(Const.DEFAULT_LOCALE);

	LogWriter.setConsoleAppenderDebug();
	LogWriter log;
	if (Const.isEmpty(optionLogfile)) {
		log = LogWriter.getInstance(Const.SPOON_LOG_FILE, false, LogWriter.LOG_LEVEL_BASIC);
	} else {
		log = LogWriter.getInstance(optionLogfile.toString(), true, LogWriter.LOG_LEVEL_BASIC);
	}

	if (log.getRealFilename() != null) {
		if (log.isBasic())
			log.logBasic(APP_NAME, Messages.getString("Spoon.Log.LoggingToFile") + log.getRealFilename());// "Logging goes to "
	}

	if (!Const.isEmpty(optionLoglevel)) {
		log.setLogLevel(optionLoglevel.toString());
		if (log.isBasic())
			log.logBasic(APP_NAME, Messages.getString("Spoon.Log.LoggingAtLevel") + log.getLogLevelDesc());// "Logging is at level : "
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:27,代码来源:Spoon.java

示例3: run

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public void run()
{
    LogWriter log = LogWriter.getInstance();
    try
    {
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        while ((line = br.readLine()) != null)
        {
            log.logBasic(type, line);
        }
    }
    catch (IOException ioe)
    {
        log.logError(type, Const.getStackTracker(ioe));
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:19,代码来源:StreamLogger.java

示例4: CreateDestinationFolder

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private boolean CreateDestinationFolder(String foldername,LogWriter log)
{
	FileObject folder=null;
	try
	{
		folder=KettleVFS.getFileObject(foldername);
		
   		if(!folder.exists())	
   		{
   			log.logError(toString(), Messages.getString("JobEntryCopyMoveResultFilenames.Log.FolderNotExists", foldername));
   			if(isCreateDestinationFolder())
   				folder.createFolder();
   			else
   				return false;
   			if(log.isBasic()) log.logBasic(toString(), Messages.getString("JobEntryCopyMoveResultFilenames.Log.FolderCreated",foldername));
   		}else
   		{
   			if(log.isDetailed())
   				log.logDetailed(toString(), Messages.getString("JobEntryCopyMoveResultFilenames.Log.FolderExists",foldername));	
   		}
   		return true;
	}
	catch (Exception e) {
		log.logError(toString(), Messages.getString("JobEntryCopyMoveResultFilenames.Log.CanNotCreatedFolder", foldername,e.toString()));
		
	}
	 finally {
        	if ( folder != null )
        	{
        		try  {
        			folder.close();
        		}
        		catch (Exception ex ) {};
        	}
        }
	 return false;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:38,代码来源:JobEntryCopyMoveResultFilenames.java

示例5: setLog

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private void setLog(LogWriter log, int loglevel, StringBuffer msg)
{
	switch (loglevel) {
	case LogWriter.LOG_LEVEL_ERROR:
		// Output message to log
		// Log level = ERREUR	
		log.logError(toString(), msg.toString());
		break;
	case LogWriter.LOG_LEVEL_MINIMAL:
		// Output message to log
		// Log level = MINIMAL	
		log.logMinimal(toString(), msg.toString());
		break;
	case LogWriter.LOG_LEVEL_BASIC:
		// Output message to log
		// Log level = BASIC	
		log.logBasic(toString(), msg.toString());
		break;
	case LogWriter.LOG_LEVEL_DETAILED:
		// Output message to log
		// Log level = DETAILED	
		log.logDetailed(toString(), msg.toString());
		break;
	case LogWriter.LOG_LEVEL_DEBUG:
		// Output message to log
		// Log level = DEBUG	
		log.logDebug(toString(), msg.toString());
		break;
	case LogWriter.LOG_LEVEL_ROWLEVEL:
		// Output message to log
		// Log level = ROW LEVEL	
		log.logRowlevel(toString(), msg.toString());
		break;
		default:
			// Output message to log
			// Log level = BASIC	
			log.logBasic(toString(), msg.toString());
			break;
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:41,代码来源:WriteToLog.java

示例6: execute

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public Result execute(Result previousResult, int nr, Repository rep, Job parentJob)
{
	LogWriter log = LogWriter.getInstance();
	Result result = previousResult;
	result.setResult( false );
	result.setNrErrors(1);
	
	filescount=0;
	folderscount=0;
	pattern = null;
	
	if (!Const.isEmpty(getWildcard()))  pattern = Pattern.compile(getRealWildcard());
	
	if (foldername!=null)
	{
           String realFoldername = getRealFoldername();
           FileObject FolderObject = null;
		try {
			FolderObject = KettleVFS.getFileObject(realFoldername);

			if ( FolderObject.exists() )
			{
				//Check if it's a folder
				if(FolderObject.getType() == FileType.FOLDER) 
				{
					// File provided is a folder, so we can process ...
					FolderObject.findFiles(new TextFileSelector(FolderObject.toString()));
					if(log.isBasic())	log.logBasic("Total files", "We found : "+filescount + " file(s)");
					if(filescount==0)
					{
						result.setResult(true);
						result.setNrErrors(0);
					}
				}
				else
				{
					// Not a folder, fail
					log.logError("Found files", "[" + realFoldername+"] is not a folder, failing.");
				}	
			}
			else
			{
				//  No Folder found	
				if(log.isBasic()) log.logBasic(toString(), "we can not find ["+realFoldername+"] !");
			}
		} catch (IOException e) {
			log.logError(toString(), "Could not create Folder ["+realFoldername+"], exception: " + e.getMessage());
			result.setResult( false );
			result.setNrErrors(1);					
		}
           finally {
           	if ( FolderObject != null )
           	{
           		try  {
           		     FolderObject.close();
           		}
           		catch ( IOException ex ) {};
           	}
           }			
	}
	else
	{			
		log.logError(toString(), "No Foldername is defined.");
	}
	
	return result;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:68,代码来源:JobEntryFolderIsEmpty.java

示例7: evaluate

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
/**
 * Output message to job log.
 */
public boolean evaluate(Result result)
{
	LogWriter log = LogWriter.getInstance();
	
		
	try
	{
		
				
		loglevel=loglevel+1;
		
		if (loglevel==LogWriter.LOG_LEVEL_ERROR)
		{
			// Output message to log
			// Log level = ERREUR	
			log.logError(Const.CR + getRealLogSubject()+ Const.CR, getRealLogMessage()+ Const.CR);
		}
		else if (loglevel==LogWriter.LOG_LEVEL_MINIMAL)
		{
			// Output message to log
			// Log level = MINIMAL	
			log.logMinimal(Const.CR + getRealLogSubject()+ Const.CR, getRealLogMessage()+ Const.CR);
		}
		else if (loglevel==LogWriter.LOG_LEVEL_BASIC)
		{
			// Output message to log
			// Log level = BASIC	
			log.logBasic(Const.CR + getRealLogSubject()+ Const.CR, getRealLogMessage()+ Const.CR);
		}
		else if (loglevel==LogWriter.LOG_LEVEL_DETAILED)
		{
			// Output message to log
			// Log level = DETAILED	
			log.logDetailed(Const.CR + getRealLogSubject()+ Const.CR, getRealLogMessage()+ Const.CR);
		}
		else if (loglevel==LogWriter.LOG_LEVEL_DEBUG)
		{
			// Output message to log
			// Log level = DEBUG	
			log.logDebug(Const.CR + getRealLogSubject()+ Const.CR, getRealLogMessage()+ Const.CR);
			
		}
		else if (loglevel==LogWriter.LOG_LEVEL_ROWLEVEL)
		{
			// Output message to log
			// Log level = ROWLEVEL	
			log.logRowlevel(Const.CR + getRealLogSubject()+ Const.CR, getRealLogMessage()+ Const.CR);
		}



		return true;
		
		

		
				
	}
	catch(Exception e)
	{
		result.setNrErrors(1);
		log.logError(Messages.getString("WriteToLog.Error.Label"), Messages.getString("WriteToLog.Error.Description") + " : "+e.toString());
		return false;
	}


}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:71,代码来源:JobEntryWriteToLog.java

示例8: execute

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public Result execute(Result previousResult, int nr, Repository rep, Job parentJob)
{
	LogWriter log = LogWriter.getInstance();
	Result result = previousResult;
	result.setResult(false);
	
	if(previousResult!=null)
	{
		try
		{
			int size=previousResult.getResultFiles().size();
			if(log.isBasic())
				log.logBasic(toString(),Messages.getString("JobEntryDeleteResultFilenames.log.FilesFound",""+size));
			if(!specifywildcard)
			{
				// Delete all files
				previousResult.getResultFiles().clear();
				if(log.isDetailed()) log.logDetailed(toString(),Messages.getString("JobEntryDeleteResultFilenames.log.DeletedFiles",""+size));
			}
			else
			{

				 List <ResultFile> resultFiles = result.getResultFilesList();
		        if (resultFiles != null && resultFiles.size() > 0)
		        {
		        	for (Iterator <ResultFile>  it = resultFiles.iterator(); it.hasNext() && !parentJob.isStopped();)
		            {
		        	  ResultFile resultFile = (ResultFile) it.next();
		              FileObject file = resultFile.getFile();
		              if (file != null && file.exists())
		              {
		            	if(CheckFileWildcard(file.getName().getBaseName(), environmentSubstitute(wildcard),true) 
		            			&& !CheckFileWildcard(file.getName().getBaseName(),  environmentSubstitute(wildcardexclude),false))
		  				{
		            		// Remove file from result files list
							result.getResultFiles().remove(resultFile.getFile().toString());
							
		            		if(log.isDetailed()) log.logDetailed(toString(),Messages.getString("JobEntryDeleteResultFilenames.log.DeletedFile",file.toString()));
		  				}  
		            	 
		              }
		            }
		        }     
			}
			result.setResult(true);
		}
		catch(Exception e)
		{
			log.logError(toString(), Messages.getString("JobEntryDeleteResultFilenames.Error",e.toString()));
		}
	}	
	return result;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:54,代码来源:JobEntryDeleteResultFilenames.java

示例9: processOneRow

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private boolean processOneRow(LogWriter log, String sourceFileFolder, String SourceWildcard,
		String Delimiter,String targetDb, String targetTable, Job parentJob,Result result)
{
	boolean retval=false;
	try{
	File sourcefilefolder=new File(sourceFileFolder);
	if(!sourcefilefolder.exists())
	{
		log.logError(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Error.CanNotFindFile",sourceFileFolder));
		return retval;
	}
	if(sourcefilefolder.isFile())
	{
		// source is a file
		retval=importFile(sourceFileFolder, Delimiter, targetDb,targetTable,log,result,parentJob);
	}else if(sourcefilefolder.isDirectory())
	{
		// source is a folder
		File[] listFiles=sourcefilefolder.listFiles();
		int nrFiles=listFiles.length;
		if(nrFiles>0)
		{
			// let's fetch children...
			for(int i=0;i<nrFiles && !parentJob.isStopped() && continueProcessing;i++)
			{
				File child=listFiles[i];
				String childFullName=child.getAbsolutePath();
				if(child.isFile())
				{
					if(Const.isEmpty(SourceWildcard)){
						retval=importFile(childFullName, Delimiter, targetDb,targetTable,log,result,parentJob);
					}else{
						if(GetFileWildcard(childFullName,SourceWildcard)){
							retval=importFile(childFullName, Delimiter, targetDb,targetTable,log,result,parentJob);
						}
					}
				}else {
					// let's run process for this folder
					if(include_subfolders){
						processOneRow(log, childFullName, SourceWildcard,Delimiter, targetDb, 
								targetTable,parentJob,result);
					}
					
				}
			}
		}else
		{
			log.logBasic(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Log.FolderEmpty",sourceFileFolder));
		}
		
	}else
		log.logError(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Log.UnknowType",sourceFileFolder));
	}catch(Exception e){
		log.logError(toString(), e.getMessage());
		incrErrors();
	}
	return retval;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:59,代码来源:JobEntryMSAccessBulkLoad.java

示例10: importFile

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private boolean importFile(String sourceFilename, String delimiter,String targetFilename,
  		String tablename,LogWriter log,Result result,Job parentJob)
  {
  	boolean retval=false;
  	
try{
	
   	incrFilesToProcess();
   	
	File sourceDataFile = new File(sourceFilename);
	File targetDbFile = new File(targetFilename);
	
	// create database if needed
	if(!targetDbFile.exists()) 
	{
		Database.create(targetDbFile);
		log.logBasic(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Log.DbCreated",targetFilename));
	}else
	{
		// Database exists
		Database db=Database.open(targetDbFile);
		log.logBasic(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Log.DbOpened",targetFilename));
		// Let's check table
		if(db.getTable(tablename)!=null)
		{
			log.logBasic(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Log.TableExists",tablename));
		}
		
		// close database
		if(db!=null) db.close();
		log.logBasic(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Log.DbCosed",targetFilename));
	}
	// load data from file
	Database.open(targetDbFile).importFile(tablename, sourceDataFile, delimiter);
	
	log.logBasic(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Log.FileImported",sourceFilename,	tablename,targetFilename));
	
	// add filename to result filename
	if(add_result_filenames)
		addFileToResultFilenames(sourceFilename,log,result,parentJob);

	
	retval=true;
}
catch ( Exception e )
{
	log.logError(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Error.LoadingDataToFile",
			sourceFilename,targetFilename,e.getMessage()));
	
}	
if(retval)
	incrSuccess();
else
	incrErrors();
  	return retval;
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:57,代码来源:JobEntryMSAccessBulkLoad.java

示例11: execute

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public Result execute(Result result, int nr, Repository rep, Job parentJob) throws KettleException {
   LogWriter log = LogWriter.getInstance();
   List<RowMetaAndData> rows = result.getRows();
   RowMetaAndData resultRow = null;

   int nrErrFiles = 0;
   result.setResult(true);


   if(deleteallbefore)
{
   	// clear result filenames
   	int size=result.getResultFiles().size();
   	if(log.isBasic()) log.logBasic(toString(),Messages.getString("JobEntryAddResultFilenames.log.FilesFound",""+size));

	result.getResultFiles().clear();
	if(log.isDetailed()) log.logDetailed(toString(),Messages.getString("JobEntryAddResultFilenames.log.DeletedFiles",""+size));
}
   
   
   if (argFromPrevious) 
   {
   	if(log.isDetailed()) 
   		log.logDetailed(toString(), Messages.getString("JobEntryAddResultFilenames.FoundPreviousRows", String.valueOf((rows != null ? rows.size() : 0)))); //$NON-NLS-1$
   }

   if (argFromPrevious && rows != null) // Copy the input row to the (command line) arguments
   {   	        
     for (int iteration = 0; iteration < rows.size() && !parentJob.isStopped(); iteration++) {
   	  resultRow = rows.get(iteration);

   	 // Get values from previous result 
       String filefolder_previous = resultRow.getString(0,null);
       String fmasks_previous = resultRow.getString(1,null);       

        // ok we can process this file/folder
       if(log.isDetailed()) log.logDetailed(toString(), Messages.getString("JobEntryAddResultFilenames.ProcessingRow", filefolder_previous, fmasks_previous)); //$NON-NLS-1$

         if (!ProcessFile(filefolder_previous, fmasks_previous,parentJob,result, log)) {
       	  nrErrFiles++;
         }
      
     }
   } else if (arguments != null) {

     for (int i = 0; i < arguments.length  && !parentJob.isStopped(); i++) {
       
         // ok we can process this file/folder
   	  if(log.isDetailed()) log.logDetailed(toString(), Messages.getString("JobEntryAddResultFilenames.ProcessingArg", arguments[i], filemasks[i])); //$NON-NLS-1$
         if (!ProcessFile(arguments[i], filemasks[i],parentJob,result, log)) {
       	  nrErrFiles++;
         }
     }
   }
  

   if (nrErrFiles>0)
   {
   	result.setResult(false);
   	result.setNrErrors(nrErrFiles);
   }
   

   return result;
 }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:66,代码来源:JobEntryAddResultFilenames.java

示例12: deleteFolder

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private boolean deleteFolder(String foldername) {
  LogWriter log = LogWriter.getInstance();

  boolean rcode = false;
  FileObject filefolder = null;

  try {
    filefolder = KettleVFS.getFileObject(foldername);

    // Here gc() is explicitly called if e.g. createfile is used in the same
    // job for the same file. The problem is that after creating the file the
    // file object is not properly garbaged collected and thus the file cannot
    // be deleted anymore. This is a known problem in the JVM.

    System.gc();

    if (filefolder.exists()) {
      // the file or folder exists
      if (filefolder.getType() == FileType.FOLDER) {
        // It's a folder
        if (log.isDetailed())
          log.logDetailed(toString(), Messages.getString("JobEntryDeleteFolders.ProcessingFolder", foldername)); //$NON-NLS-1$
        // Delete Files
        int Nr = filefolder.delete(new TextFileSelector());

        if (log.isDetailed())
          log.logDetailed(toString(), Messages.getString("JobEntryDeleteFolders.TotalDeleted", foldername,String.valueOf(Nr))); //$NON-NLS-1$
        rcode = true;
      } else {
      	// Error...This file is not a folder!
      	log.logError(toString(), Messages.getString("JobEntryDeleteFolders.Error.NotFolder"));
      }
    } else {
      // File already deleted, no reason to try to delete it
  	  if(log.isBasic()) log.logBasic(toString(), Messages.getString("JobEntryDeleteFolders.FolderAlreadyDeleted", foldername)); //$NON-NLS-1$
      rcode = true;
    }
  } catch (IOException e) {
    log.logError(toString(), Messages.getString("JobEntryDeleteFolders.CouldNotDelete", foldername, e.getMessage())); //$NON-NLS-1$
  } finally {
    if (filefolder != null) {
      try {
        filefolder.close();
      } catch (IOException ex) {
      };
    }
  }

  return rcode;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:51,代码来源:JobEntryDeleteFolders.java

示例13: execute

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public Result execute(Result previousResult, int nr, Repository rep, Job parentJob)
{
	LogWriter log = LogWriter.getInstance();
	Result result = previousResult;
	result.setResult( false );

	if (filename!=null)
	{
           String realFilename = getRealFilename();

           FileObject fileObject = null;
           try {
           	fileObject = KettleVFS.getFileObject(realFilename);

			if ( ! fileObject.exists() )
			{
				if ( isFailIfFileNotExists() )
				{
					// File doesn't exist and fail flag is on.
				    result.setResult( false );
				    log.logError(toString(), Messages.getString("JobEntryDeleteFile.ERROR_0004_File_Does_Not_Exist", realFilename)); //$NON-NLS-1$
				}
				else
				{
					// File already deleted, no reason to try to delete it
				    result.setResult( true );
				    if(log.isBasic()) log.logBasic(toString(), Messages.getString("JobEntryDeleteFile.File_Already_Deleted", realFilename)); //$NON-NLS-1$
				}
			}
			else
			{
				// Here gc() is explicitly called if e.g. createfile is used in the same
				// job for the same file. The problem is that after creating the file the
				// file object is not properly garbaged collected and thus the file cannot
				// be deleted anymore. This is a known problem in the JVM.
				System.gc();

			    boolean deleted = fileObject.delete();
			    if ( ! deleted )
			    {
					log.logError(toString(), Messages.getString("JobEntryDeleteFile.ERROR_0005_Could_Not_Delete_File", realFilename)); //$NON-NLS-1$
					result.setResult( false );
					result.setNrErrors(1);
			    }
			    if(log.isBasic()) log.logBasic(toString(), Messages.getString("JobEntryDeleteFile.File_Deleted", realFilename)); //$NON-NLS-1$
				result.setResult( true );
			}
		}
           catch (IOException e) {
			log.logError(toString(), Messages.getString("JobEntryDeleteFile.ERROR_0006_Exception_Deleting_File", realFilename, e.getMessage())); //$NON-NLS-1$
			result.setResult( false );
			result.setNrErrors(1);
		}
           finally {
           	if ( fileObject != null )
           	{
           		try  {
           		     fileObject.close();
           		}
           		catch ( IOException ex ) {};
           	}
           }
	}
	else
	{
		log.logError(toString(), Messages.getString("JobEntryDeleteFile.ERROR_0007_No_Filename_Is_Defined")); //$NON-NLS-1$
	}

	return result;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:71,代码来源:JobEntryDeleteFile.java

示例14: ProcessFile

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
private boolean ProcessFile(String filename, String wildcard,Job parentJob) {
  LogWriter log = LogWriter.getInstance();

  boolean rcode = false;
  FileObject filefolder = null;
  String realFilefoldername = environmentSubstitute(filename);
  String realwildcard = environmentSubstitute(wildcard);

  try {
    filefolder = KettleVFS.getFileObject(realFilefoldername);

    // Here gc() is explicitly called if e.g. createfile is used in the same
    // job for the same file. The problem is that after creating the file the
    // file object is not properly garbaged collected and thus the file cannot
    // be deleted anymore. This is a known problem in the JVM.

    System.gc();

    if (filefolder.exists()) {
      // the file or folder exists
      if (filefolder.getType() == FileType.FOLDER) 
      {
        // It's a folder
        if (log.isDetailed())
          log.logDetailed(toString(), Messages.getString("JobEntryDeleteFiles.ProcessingFolder", realFilefoldername)); //$NON-NLS-1$
        // Delete Files
        
        int Nr = filefolder.delete(new TextFileSelector(filefolder.toString(),realwildcard,parentJob));

        if (log.isDetailed())
          log.logDetailed(toString(), Messages.getString("JobEntryDeleteFiles.TotalDeleted", String.valueOf(Nr))); //$NON-NLS-1$
        rcode = true;
      } else {
        // It's a file
        if(log.isDetailed())	
      	  log.logDetailed(toString(), Messages.getString("JobEntryDeleteFiles.ProcessingFile", realFilefoldername)); //$NON-NLS-1$
        boolean deleted = filefolder.delete();
        if (!deleted) {
          log.logError(toString(), Messages.getString("JobEntryDeleteFiles.CouldNotDeleteFile", realFilefoldername)); //$NON-NLS-1$
        } else {
          if(log.isBasic()) log.logBasic(toString(), Messages.getString("JobEntryDeleteFiles.FileDeleted", filename)); //$NON-NLS-1$
          rcode = true;
        }
      }
    } else {
      // File already deleted, no reason to try to delete it
  	  if(log.isBasic()) log.logBasic(toString(), Messages.getString("JobEntryDeleteFiles.FileAlreadyDeleted", realFilefoldername)); //$NON-NLS-1$
      rcode = true;
    }
  } catch (IOException e) {
    log.logError(toString(), Messages.getString("JobEntryDeleteFiles.CouldNotProcess", realFilefoldername, e.getMessage())); //$NON-NLS-1$
  } finally {
    if (filefolder != null) {
      try {
        filefolder.close();
      } catch (IOException ex) {
      }
      ;
    }
  }

  return rcode;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:64,代码来源:JobEntryDeleteFiles.java

示例15: execute

import org.pentaho.di.core.logging.LogWriter; //导入方法依赖的package包/类
public Result execute(Result previousResult, int nr, Repository rep, Job parentJob) throws KettleException
{
  LogWriter log = LogWriter.getInstance();
  Result result = previousResult;
  result.setResult(false);

  if (filename != null)
  {
    String realFilename = getRealFilename();
    FileObject fileObject = null;
    try
    {
      fileObject = KettleVFS.getFileObject(realFilename);

      if (fileObject.exists())
      {
        if (isFailIfFileExists())
        {
          // File exists and fail flag is on.
          result.setResult(false);
          log.logError(toString(), "File [" + realFilename + "] exists, failing.");
        } else
        {
          // File already exists, no reason to try to create it
          result.setResult(true);
          log.logBasic(toString(), "File [" + realFilename + "] already exists, not recreating.");
        }
        // add filename to result filenames if needed
        if(isAddFilenameToResult())
      	  addFilenameToResult(realFilename,log,result, parentJob);
      } else
      {
        //  No file yet, create an empty file.
        fileObject.createFile();
        log.logBasic(toString(), "File [" + realFilename + "] created!");
        // add filename to result filenames if needed
        if(isAddFilenameToResult())
      	  addFilenameToResult(realFilename,log,result, parentJob);
        result.setResult(true);
      }
    } catch (IOException e)
    {
      log.logError(toString(), "Could not create file [" + realFilename + "], exception: " + e.getMessage());
      result.setResult(false);
      result.setNrErrors(1);
    } finally
    {
      if (fileObject != null)
      {
        try
        {
          fileObject.close();
        } catch (IOException ex)
        {
        }
        ;
      }
    }
  } else
  {
    log.logError(toString(), "No filename is defined.");
  }

  return result;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:66,代码来源:JobEntryCreateFile.java


注:本文中的org.pentaho.di.core.logging.LogWriter.logBasic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。