Merged DEV/3.1_ENTERPRISE_ONLY to HEAD

12465: Supporting changes for enterprise-only monitoring code.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12495 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2008-12-18 15:26:23 +00:00
parent d20db6284c
commit 6b3d327f64
29 changed files with 1123 additions and 83 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -32,6 +32,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.util.exec.RuntimeExec;
import org.alfresco.util.exec.RuntimeExec.ExecutionResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -53,6 +54,12 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
/** the system command executer */
private RuntimeExec executer;
/** the check command executer */
private RuntimeExec checkCommand;
/** the output from the check command */
private String versionString;
/**
* Default constructor
@@ -79,6 +86,29 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
{
this.executer = executer;
}
/**
* Sets the command that must be executed in order to retrieve version information from the converting executable
* and thus test that the executable itself is present.
*
* @param checkCommand
* command executer to retrieve version information
*/
public void setCheckCommand(RuntimeExec checkCommand)
{
this.checkCommand = checkCommand;
}
/**
* Gets the version string captured from the check command.
*
* @return the version string
*/
public String getVersionString()
{
return this.versionString;
}
/**
* Checks for the JMagick and ImageMagick dependencies, using the common
@@ -92,6 +122,30 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
throw new AlfrescoRuntimeException("System runtime executer not set");
}
super.init();
if (isAvailable())
{
try
{
ExecutionResult result = this.checkCommand.execute();
if (result.getSuccess())
{
this.versionString = result.getStdOut().trim();
}
else
{
setAvailable(false);
}
}
catch (Throwable e)
{
setAvailable(false);
logger.error(getClass().getSimpleName() + " not available: "
+ (e.getMessage() != null ? e.getMessage() : ""));
// debug so that we can trace the issue if required
logger.debug(e);
}
}
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -54,6 +54,9 @@ public class PDFToSWFContentTransformer extends AbstractContentTransformer2
/** Used to indicate whether the transformaer in available or not */
private boolean available = false;
/** Stores the output from the check command */
private String versionString;
/** Check and transform command */
private RuntimeExec checkCommand;
private RuntimeExec transformCommand;
@@ -130,15 +133,13 @@ public class PDFToSWFContentTransformer extends AbstractContentTransformer2
{
ExecutionResult result = getCheckCommand().execute();
// check the return code
this.available = result.getSuccess();
if (this.available == false)
if (this.available = result.getSuccess())
{
logger.error("Failed to start SWF2PDF transformer: \n" + result);
this.versionString = result.getStdOut().trim();
}
else
{
// no check - just assume it is available
this.available = true;
logger.error("Failed to start SWF2PDF transformer: \n" + result);
}
// call the base class to make sure that it gets registered
@@ -249,4 +250,24 @@ public class PDFToSWFContentTransformer extends AbstractContentTransformer2
return result;
}
/**
* Signals whether this transformer is available.
*
* @return true, if is available
*/
public boolean isAvailable()
{
return this.available;
}
/**
* Gets the version string captured from the check command.
*
* @return the version string
*/
public String getVersionString()
{
return this.versionString;
}
}