REPO-4617 Add missing source types for T-engines (#95)

Update missing sourceMediaType -> targetMediaType for alfresco-pdf-renderer
   Update missing sourceMediaType -> targetMediaType for imagemagick
   Update missing sourceMediaType -> targetMediaType for tika libreoffice
   Update missing sourceMediaType -> targetMediaType for tika
   Update missing sourceMediaType -> targetMediaType for misc transformer
   Add T-engine Integration Tests
   Fix JavaDoc warnings
   Add sample files for tested mimetypes
This commit is contained in:
Alexandru-Eusebiu Epure
2019-09-03 13:34:07 +03:00
committed by GitHub
parent cec236355f
commit bcd6fefe4d
83 changed files with 13928 additions and 204 deletions

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2015-2019 Alfresco Software, Ltd. All rights reserved.
*
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
*/
package org.alfresco.transformer;
import static java.util.Collections.emptyMap;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import java.util.Map;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
/**
* @author Cezar Leahu
*/
public class EngineClient
{
private static final RestTemplate REST_TEMPLATE = new RestTemplate();
public static ResponseEntity<Resource> sendTRequest(
final String engineUrl, final String sourceFile,
final String sourceMimetype, final String targetMimetype, final String targetExtension)
{
return sendTRequest(engineUrl, sourceFile, sourceMimetype, targetMimetype, targetExtension,
emptyMap());
}
public static ResponseEntity<Resource> sendTRequest(
final String engineUrl, final String sourceFile,
final String sourceMimetype, final String targetMimetype, final String targetExtension,
final Map<String, String> transformOptions)
{
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MULTIPART_FORM_DATA);
//headers.setAccept(ImmutableList.of(MULTIPART_FORM_DATA));
final MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add("file", new ClassPathResource(sourceFile));
if (sourceMimetype != null && !sourceMimetype.trim().isEmpty())
{
body.add("sourceMimetype", sourceMimetype);
}
if (targetMimetype != null && !targetMimetype.trim().isEmpty())
{
body.add("targetMimetype", targetMimetype);
}
if (targetExtension != null && !targetExtension.trim().isEmpty())
{
body.add("targetExtension", targetExtension);
}
transformOptions.forEach(body::add);
final HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers);
return REST_TEMPLATE.postForEntity(engineUrl + "/transform", entity, Resource.class);
}
}

View File

@@ -0,0 +1,76 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.transformer;
import java.util.Objects;
/**
* @author Cezar Leahu
*/
public class SourceTarget
{
final String source;
final String target;
private SourceTarget(final String source, final String target)
{
this.source = source;
this.target = target;
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SourceTarget that = (SourceTarget) o;
return Objects.equals(source, that.source) &&
Objects.equals(target, that.target);
}
@Override
public int hashCode()
{
return Objects.hash(source, target);
}
@Override
public String toString()
{
return source + '|' + target;
}
public static SourceTarget of(final String source, final String target)
{
return sourceTarget(source, target);
}
public static SourceTarget sourceTarget(final String source, final String target)
{
return new SourceTarget(source, target);
}
}

View File

@@ -0,0 +1,79 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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/>.
* #L%
*/
package org.alfresco.transformer;
/**
* @author Cezar Leahu
*/
public class TestFileInfo
{
private final String mimeType;
private final String extension;
private final String path;
private final boolean exactMimeType;
public TestFileInfo(final String mimeType, final String extension, final String path,
final boolean exactMimeType)
{
this.mimeType = mimeType;
this.extension = extension;
this.path = path;
this.exactMimeType = exactMimeType;
}
public String getMimeType()
{
return mimeType;
}
public String getExtension()
{
return extension;
}
public String getPath()
{
return path;
}
public boolean isExactMimeType()
{
return exactMimeType;
}
public static TestFileInfo testFile(final String mimeType, final String extension,
final String path, final boolean exactMimeType)
{
return new TestFileInfo(mimeType, extension, path, exactMimeType);
}
public static TestFileInfo testFile(final String mimeType, final String extension,
final String path)
{
return new TestFileInfo(mimeType, extension, path, false);
}
}