mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
ATS-176 : Log improvements with Slf4j
This commit is contained in:
@@ -27,8 +27,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
|
||||
import org.alfresco.transformer.logging.LogEntry;
|
||||
import org.alfresco.transformer.probes.ProbeTestTransform;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -62,7 +62,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
@Controller
|
||||
public class LibreOfficeController extends AbstractTransformerController
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(LibreOfficeController.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeController.class);
|
||||
|
||||
@Autowired
|
||||
private LibreOfficeJavaExecutor javaExecutor;
|
||||
@@ -92,7 +92,7 @@ public class LibreOfficeController extends AbstractTransformerController
|
||||
public ProbeTestTransform getProbeTestTransform()
|
||||
{
|
||||
// See the Javadoc on this method and Probes.md for the choice of these values.
|
||||
return new ProbeTestTransform(this, logger, "quick.doc", "quick.pdf",
|
||||
return new ProbeTestTransform(this, "quick.doc", "quick.pdf",
|
||||
11817, 1024, 150, 10240, 60*30+1, 60*15+20)
|
||||
{
|
||||
@Override
|
||||
@@ -131,6 +131,9 @@ public class LibreOfficeController extends AbstractTransformerController
|
||||
public void processTransform(File sourceFile, File targetFile,
|
||||
Map<String, String> transformOptions, Long timeout)
|
||||
{
|
||||
logger.debug("Processing request with: sourceFile '{}', targetFile '{}', transformOptions" +
|
||||
" '{}', timeout {} ms", sourceFile, targetFile, transformOptions, timeout);
|
||||
|
||||
javaExecutor.call(sourceFile, targetFile);
|
||||
}
|
||||
}
|
||||
|
@@ -37,11 +37,11 @@ import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
|
||||
import org.artofsolving.jodconverter.office.OfficeException;
|
||||
import org.artofsolving.jodconverter.office.OfficeManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
///////// THIS FILE WAS A COPY OF THE CODE IN alfresco-repository /////////////
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.artofsolving.jodconverter.office.OfficeManager;
|
||||
*/
|
||||
public class JodConverterSharedInstance implements JodConverter
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(JodConverterSharedInstance.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(JodConverterSharedInstance.class);
|
||||
|
||||
private OfficeManager officeManager;
|
||||
private boolean isAvailable = false;
|
||||
@@ -137,10 +137,7 @@ public class JodConverterSharedInstance implements JodConverter
|
||||
{
|
||||
// Logging this as an error as this property would prevent JodConverter & therefore
|
||||
// OOo from starting as specified
|
||||
if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("Unparseable value for property '" + sys + ".portNumbers': " + s);
|
||||
}
|
||||
logger.error("Unparseable value for property '{}.portNumbers': {}", sys, s);
|
||||
// We'll not rethrow the exception, instead allowing the problem to be picked up
|
||||
// when the OOoJodConverter subsystem is started.
|
||||
}
|
||||
@@ -268,10 +265,7 @@ public class JodConverterSharedInstance implements JodConverter
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Cannot parse numerical value from " + string);
|
||||
}
|
||||
logger.debug("Cannot parse numerical value from {}", string);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -300,20 +294,20 @@ public class JodConverterSharedInstance implements JodConverter
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("JodConverter settings (null settings will be replaced by jodconverter defaults):");
|
||||
logger.debug(" officeHome = " + officeHome);
|
||||
logger.debug(" enabled = " + isEnabled());
|
||||
logger.debug(" portNumbers = " + getString(portNumbers));
|
||||
logger.debug(" ooo.exe = " + deprecatedOooExe);
|
||||
logger.debug(" ooo.enabled = " + deprecatedOooEnabled);
|
||||
logger.debug(" ooo.port = " + getString(deprecatedOooPortNumbers));
|
||||
logger.debug(" jodConverter.enabled = " + enabled);
|
||||
logger.debug(" jodconverter.portNumbers = " + getString(this.portNumbers));
|
||||
logger.debug(" jodconverter.officeHome = " + this.officeHome);
|
||||
logger.debug(" jodconverter.maxTasksPerProcess = " + maxTasksPerProcess);
|
||||
logger.debug(" jodconverter.taskExecutionTimeout = " + taskExecutionTimeout);
|
||||
logger.debug(" jodconverter.taskQueueTimeout = " + taskQueueTimeout);
|
||||
logger.debug(" jodconverter.connectTimeout = " + connectTimeout);
|
||||
logger.debug(" jodconverter.url = " + url);
|
||||
logger.debug(" officeHome = {}", officeHome);
|
||||
logger.debug(" enabled = {}", isEnabled());
|
||||
logger.debug(" portNumbers = {}", getString(portNumbers));
|
||||
logger.debug(" ooo.exe = {}", deprecatedOooExe);
|
||||
logger.debug(" ooo.enabled = {}", deprecatedOooEnabled);
|
||||
logger.debug(" ooo.port = {}", getString(deprecatedOooPortNumbers));
|
||||
logger.debug(" jodConverter.enabled = {}", enabled);
|
||||
logger.debug(" jodconverter.portNumbers = {}", getString(this.portNumbers));
|
||||
logger.debug(" jodconverter.officeHome = {}", this.officeHome);
|
||||
logger.debug(" jodconverter.maxTasksPerProcess = {}", maxTasksPerProcess);
|
||||
logger.debug(" jodconverter.taskExecutionTimeout = {}", taskExecutionTimeout);
|
||||
logger.debug(" jodconverter.taskQueueTimeout = {}", taskQueueTimeout);
|
||||
logger.debug(" jodconverter.connectTimeout = {}", connectTimeout);
|
||||
logger.debug(" jodconverter.url = {}", url);
|
||||
}
|
||||
|
||||
// Only start the JodConverter instance(s) if the subsystem is enabled.
|
||||
@@ -362,33 +356,25 @@ public class JodConverterSharedInstance implements JodConverter
|
||||
officeManager = defaultOfficeMgrConfig.buildOfficeManager();
|
||||
officeManager.start();
|
||||
}
|
||||
catch (IllegalStateException isx)
|
||||
catch (IllegalStateException e)
|
||||
{
|
||||
if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("Unable to pre-initialise JodConverter library. "
|
||||
+ "The following error is shown for informational purposes only.", isx);
|
||||
}
|
||||
logger.error("Unable to pre-initialise JodConverter library. " +
|
||||
"The following error is shown for informational purposes only.", e);
|
||||
return;
|
||||
}
|
||||
catch (OfficeException ox)
|
||||
catch (OfficeException e)
|
||||
{
|
||||
if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("Unable to start JodConverter library. "
|
||||
+ "The following error is shown for informational purposes only.", ox);
|
||||
}
|
||||
logger.error("Unable to start JodConverter library. " +
|
||||
"The following error is shown for informational purposes only.", e);
|
||||
|
||||
// We need to let it continue (comment-out return statement) even if an error occurs. See MNT-13706 and associated issues.
|
||||
//return;
|
||||
}
|
||||
catch (Exception x)
|
||||
catch (Exception e)
|
||||
{
|
||||
if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("Unexpected error in configuring or starting the JodConverter library."
|
||||
+ "The following error is shown for informational purposes only.", x);
|
||||
}
|
||||
logger.error(
|
||||
"Unexpected error in configuring or starting the JodConverter library." +
|
||||
"The following error is shown for informational purposes only.", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ import java.io.IOException;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.alfresco.transformer.exceptions.TransformException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDPage;
|
||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
@@ -28,7 +28,7 @@ import com.sun.star.task.ErrorCodeIOException;
|
||||
@Component
|
||||
public class LibreOfficeJavaExecutor implements JavaExecutor
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(LibreOfficeJavaExecutor.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeJavaExecutor.class);
|
||||
|
||||
private static final int JODCONVERTER_TRANSFORMATION_ERROR_CODE = 3088;
|
||||
private static final String OFFICE_HOME = "/opt/libreoffice5.4";
|
||||
|
Reference in New Issue
Block a user