Merged V4.1-BUG-FIX (4.1.5) to HEAD (4.2)

47769: Merged V4.1.4 (4.1.4) to V4.1-BUG-FIX (4.1.5)
      47768: ALF-17444 transformation of Outlook files (.msg) doesn't work ootb
         - Downgrade ERROR to debug
         - Complex transformer correctly checks all transformations between intermediate mimetypes.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47773 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis 2013-03-07 18:01:39 +00:00
parent 4cf6146ada
commit 6358e05cc9
4 changed files with 63 additions and 8 deletions

View File

@ -41,6 +41,7 @@ import org.alfresco.repo.content.transform.ContentTransformer;
import org.alfresco.repo.content.transform.ContentTransformerRegistry;
import org.alfresco.repo.content.transform.TransformerDebug;
import org.alfresco.repo.content.transform.UnimportantTransformException;
import org.alfresco.repo.content.transform.UnsupportedTransformationException;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.JavaBehaviour;
@ -722,19 +723,21 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
if (done)
{
message = "Transformer succeeded after previous transformer failed"+ (message == null ? "" : ": "+message);
if (rootCause instanceof UnimportantTransformException)
if (rootCause instanceof UnsupportedTransformationException ||
rootCause instanceof UnimportantTransformException)
{
logger.debug(message);
}
else
{
logger.error(message, e);
logger.warn(message, e);
}
}
else if (!first) // The first exception is logged later
{
message = "Transformer exception"+ (message == null ? "" : ": "+message);
if (rootCause instanceof UnimportantTransformException)
if (rootCause instanceof UnsupportedTransformationException ||
rootCause instanceof UnimportantTransformException)
{
logger.debug(message);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@ -121,9 +121,16 @@ public abstract class AbstractContentTransformer2 extends AbstractContentTransfo
boolean transformable = isTransformable(sourceMimetype, sourceSize, targetMimetype, options);
if (transformable == false)
{
AlfrescoRuntimeException e = new AlfrescoRuntimeException("Unsuported transformation attempted: \n" +
" reader: " + reader + "\n" +
" writer: " + writer);
// This method is only called once a transformer has been selected, so it should be able to
// handle the mimetypes but might not be able to handle all the limits as it might be part of
// of a complex (compound) transformer. So report the max size if set.
long maxSourceSizeKBytes = getMaxSourceSizeKBytes(sourceMimetype, targetMimetype, options);
boolean sizeOkay = maxSourceSizeKBytes < 0 || (maxSourceSizeKBytes > 0 && sourceSize <= maxSourceSizeKBytes*1024);
AlfrescoRuntimeException e = new UnsupportedTransformationException("Unsupported transformation: " +
getBeanName()+' '+sourceMimetype+" to "+targetMimetype+' '+
(sizeOkay
? ""
: transformerDebug.fileSize(sourceSize)+" > "+ transformerDebug.fileSize(maxSourceSizeKBytes)));
throw transformerDebug.setCause(e);
}
// it all checks out OK
@ -209,6 +216,12 @@ public abstract class AbstractContentTransformer2 extends AbstractContentTransfo
// We rethrow the exception
throw cste;
}
catch (UnsupportedTransformationException e)
{
// Don't record an error or even the time, as this is normal in compound transformations.
transformerDebug.debug(" Failed", e);
throw e;
}
catch (Throwable e)
{
// Make sure that this transformation gets set back i.t.o. time taken.

View File

@ -760,7 +760,7 @@ public class TransformerDebug
}
if (frame != null)
{
sb.append(spaces(11-sb.length()+lengthOfFirstId)); // Try to pad to level 7
sb.append(spaces(13-sb.length()+lengthOfFirstId)); // Try to pad to level 7
}
return sb.toString();
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.content.transform;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Exception indicates that a transformer is unable to transform a requested
* transformation. Normally the transformer is a component of a complex (compound) transformer
* and has been asked to transform a file that is too large (see transformation limits) as the
* size of the intermediate file is unknown at the start.
*
* @author Alan Davis
*/
public class UnsupportedTransformationException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 9039331287661301086L;
public UnsupportedTransformationException(String msgId)
{
super(msgId);
}
}