diff --git a/.travis.yml b/.travis.yml index c980ceff8e..c40ccc97c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,7 +84,7 @@ jobs: - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300' - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8 - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.6 - script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8090/ -Dimg.url=http://localhost:8090/ -Dtika.url=http://localhost:8090/ -Dtransform.misc.url=http://localhost:8090/ + script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco - name: "Repository - AppContext04TestSuite" before_script: @@ -108,7 +108,7 @@ jobs: - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300' - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8 - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.6 - script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8090/ -Dimg.url=http://localhost:8090/ -Dtika.url=http://localhost:8090/ -Dtransform.misc.url=http://localhost:8090/ + script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco - name: "Repository - AppContextExtraTestSuite" before_script: @@ -122,7 +122,7 @@ jobs: - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300' - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8 - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.6 - script: travis_wait 20 mvn -B test -pl repository -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dalfresco-pdf-renderer.url=http://localhost:8090/ -Djodconverter.url=http://localhost:8090/ -Dimg.url=http://localhost:8090/ -Dtika.url=http://localhost:8090/ -Dtransform.misc.url=http://localhost:8090/ + script: travis_wait 20 mvn -B test -pl repository -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco - name: "Repository - SearchTestSuite" before_script: @@ -182,6 +182,7 @@ jobs: before_script: - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300' - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.15.8 + - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.5 script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco - name: "Remote-api - AppContextExtraTestSuite" diff --git a/data-model/src/main/java/org/alfresco/repo/content/MimetypeMap.java b/data-model/src/main/java/org/alfresco/repo/content/MimetypeMap.java index 2b33e6eb5b..40daca0556 100644 --- a/data-model/src/main/java/org/alfresco/repo/content/MimetypeMap.java +++ b/data-model/src/main/java/org/alfresco/repo/content/MimetypeMap.java @@ -662,7 +662,6 @@ public class MimetypeMap implements MimetypeService boolean successReadingConfig = true; if (jsonConfigFileFinder != null) { - // This should not be "alfresco/mimetype" which is used for the in JVM jodconverter successReadingConfig &= jsonConfigFileFinder.readFiles("alfresco/mimetypes", logger); if (mimetypeJsonConfigDir != null && !mimetypeJsonConfigDir.isBlank()) { @@ -877,11 +876,6 @@ public class MimetypeMap implements MimetypeService */ private MediaType detectType(String filename, ContentReader reader) { -// Metadata metadata = new Metadata(); -// if (filename != null) -// { -// metadata.add(Metadata.RESOURCE_NAME_KEY, filename); -// } TikaInputStream inp = null; try { diff --git a/data-model/src/main/java/org/alfresco/service/cmr/repository/ContentServiceTransientException.java b/data-model/src/main/java/org/alfresco/service/cmr/repository/ContentServiceTransientException.java index e6ced0455b..2e554451b0 100644 --- a/data-model/src/main/java/org/alfresco/service/cmr/repository/ContentServiceTransientException.java +++ b/data-model/src/main/java/org/alfresco/service/cmr/repository/ContentServiceTransientException.java @@ -2,7 +2,7 @@ * #%L * Alfresco Data model classes * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2020 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -33,8 +33,7 @@ import org.alfresco.api.AlfrescoPublicApi; * same action might succeed, all other things not having changed. *

* An example of this would be the case where a request to create a thumbnail - * has failed because the necessary thumbnailing software is not available e.g. because the OpenOffice.org process - * is not currently running. + * has failed because the necessary thumbnailing software is not available. * * @author Neil Mc Erlean * @since 4.0.1 diff --git a/l10n.properties b/l10n.properties index 3ec4175c35..82ff8fc9f0 100644 --- a/l10n.properties +++ b/l10n.properties @@ -2,4 +2,4 @@ MESSAGE_SEARCH_PATH="data-model/src/main/resources/alfresco/messages/dictionary-model*.properties remote-api/src/main/resources/alfresco/messages/admin-console*.properties remote-api/src/main/resources/alfresco/messages/custommodel-restapi-messages*.properties remote-api/src/main/resources/alfresco/messages/rest-framework-messages*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/admin-communitysummary.get*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-repoconsole.get*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-tenantconsole.get*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-workflowconsole.get*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/support-tools/admin-nodebrowser.get*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/audit/entry*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.delete*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links-delete.post*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links.post*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links.put*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/person/user-csv-upload.post*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post*.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put*.properties repository/src/main/resources/alfresco/messages/action-config*.properties repository/src/main/resources/alfresco/messages/action-service*.properties repository/src/main/resources/alfresco/messages/activiti-engine-messages*.properties repository/src/main/resources/alfresco/messages/activities-service*.properties repository/src/main/resources/alfresco/messages/activity-list*.properties repository/src/main/resources/alfresco/messages/application-model*.properties repository/src/main/resources/alfresco/messages/authentication*.properties repository/src/main/resources/alfresco/messages/bootstrap-content-template-examples*.properties repository/src/main/resources/alfresco/messages/bootstrap-example-javascripts*.properties repository/src/main/resources/alfresco/messages/bootstrap-example-smartfoldertemplates*.properties repository/src/main/resources/alfresco/messages/bootstrap-imapScripts*.properties repository/src/main/resources/alfresco/messages/bootstrap-javascripts*.properties repository/src/main/resources/alfresco/messages/bootstrap-messages*.properties repository/src/main/resources/alfresco/messages/bootstrap-readme-template*.properties repository/src/main/resources/alfresco/messages/bootstrap-spaces*.properties repository/src/main/resources/alfresco/messages/bootstrap-templates*.properties repository/src/main/resources/alfresco/messages/bootstrap-tutorial*.properties repository/src/main/resources/alfresco/messages/bootstrap-webScripts*.properties repository/src/main/resources/alfresco/messages/bootstrap-webScriptsExtensions*.properties repository/src/main/resources/alfresco/messages/bpm-messages*.properties repository/src/main/resources/alfresco/messages/categories*.properties repository/src/main/resources/alfresco/messages/coci-service*.properties repository/src/main/resources/alfresco/messages/content-filter-languages*.properties repository/src/main/resources/alfresco/messages/content-model*.properties repository/src/main/resources/alfresco/messages/copy-service*.properties repository/src/main/resources/alfresco/messages/custommodel-service*.properties repository/src/main/resources/alfresco/messages/discussion-messages*.properties repository/src/main/resources/alfresco/messages/distributionpolicies-model*.properties repository/src/main/resources/alfresco/messages/doclink-service*.properties repository/src/main/resources/alfresco/messages/download-model*.properties repository/src/main/resources/alfresco/messages/email-server-model*.properties repository/src/main/resources/alfresco/messages/email-service*.properties repository/src/main/resources/alfresco/messages/file-folder-service*.properties repository/src/main/resources/alfresco/messages/form-service*.properties repository/src/main/resources/alfresco/messages/forum-model*.properties repository/src/main/resources/alfresco/messages/imap-service*.properties repository/src/main/resources/alfresco/messages/initiate-inplace*.properties repository/src/main/resources/alfresco/messages/invitation-service*.properties repository/src/main/resources/alfresco/messages/lock-service*.properties repository/src/main/resources/alfresco/messages/notification-service*.properties repository/src/main/resources/alfresco/messages/period-provider*.properties repository/src/main/resources/alfresco/messages/permissions-service*.properties repository/src/main/resources/alfresco/messages/quickshare-service*.properties repository/src/main/resources/alfresco/messages/rendition-config*.properties repository/src/main/resources/alfresco/messages/replication*.properties repository/src/main/resources/alfresco/messages/repoadmin-service*.properties repository/src/main/resources/alfresco/messages/reset-password-messages*.properties repository/src/main/resources/alfresco/messages/rule-config*.properties repository/src/main/resources/alfresco/messages/site-model*.properties repository/src/main/resources/alfresco/messages/site-service*.properties repository/src/main/resources/alfresco/messages/slingshot*.properties repository/src/main/resources/alfresco/messages/smartfolder-model*.properties repository/src/main/resources/alfresco/messages/subscription-service*.properties repository/src/main/resources/alfresco/messages/system-messages*.properties repository/src/main/resources/alfresco/messages/system-model*.properties repository/src/main/resources/alfresco/messages/template-service*.properties repository/src/main/resources/alfresco/messages/templates-messages*.properties repository/src/main/resources/alfresco/messages/transfer-model*.properties repository/src/main/resources/alfresco/messages/transfer-service*.properties repository/src/main/resources/alfresco/messages/ui-inplace*.properties repository/src/main/resources/alfresco/messages/webdav-messages*.properties repository/src/main/resources/alfresco/messages/workflow-package-messages*.properties repository/src/main/resources/alfresco/workflow/invitation-moderated-workflow-messages*.properties repository/src/main/resources/alfresco/workflow/invitation-nominated-workflow-messages*.properties repository/src/main/resources/alfresco/workflow/workflow-messages*.properties" -EXCLUDED_FILES="data-model/src/main/resources/alfresco/messages/dictionary-messages.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_cs.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_da.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_de.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_el.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_en.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_es.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_fi.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_fr.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_it.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_ja.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_ko.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_nl.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_no.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_pt.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_pt_BR.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_ru.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_sv.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_th.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_zh.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/audit/control.properties repository/src/main/resources/alfresco/messages/content-service.properties repository/src/main/resources/alfresco/messages/module-messages.properties repository/src/main/resources/alfresco/messages/patch-service.properties repository/src/main/resources/alfresco/messages/repoadmin-interpreter-help.properties repository/src/main/resources/alfresco/messages/schema-update.properties repository/src/main/resources/alfresco/messages/tenant-interpreter-help.properties repository/src/main/resources/alfresco/messages/version-service.properties repository/src/main/resources/alfresco/messages/workflow-interpreter-help.properties repository/src/main/resources/alfresco/alfresco-shared.properties repository/src/main/resources/alfresco/caches.properties repository/src/main/resources/alfresco/repository.properties repository/src/main/resources/alfresco/client/config/repo-clients-apps.properties repository/src/main/resources/alfresco/domain/cache-strategies.properties repository/src/main/resources/alfresco/domain/hibernate-cfg.properties repository/src/main/resources/alfresco/domain/quartz.properties repository/src/main/resources/alfresco/domain/transaction.properties repository/src/main/resources/alfresco/keystore/keystore-passwords.properties repository/src/main/resources/alfresco/keystore/ssl-keystore-passwords.properties repository/src/main/resources/alfresco/keystore/ssl-truststore-passwords.properties repository/src/main/resources/alfresco/metadata/RFC822MetadataExtracter.properties repository/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties repository/src/main/resources/alfresco/subsystems/Authentication/alfrescoNtlm/alfresco-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/external/external-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/kerberos/kerberos-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/ldap/ldap-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/ldap-ad/ldap-ad-authentication.properties repository/src/main/resources/alfresco/subsystems/email/InboundSMTP/inboundSMTP.properties repository/src/main/resources/alfresco/subsystems/email/OutboundSMTP/outboundSMTP.properties repository/src/main/resources/alfresco/subsystems/fileServers/default/file-servers.properties repository/src/main/resources/alfresco/subsystems/imap/default/imap-server.properties repository/src/main/resources/alfresco/subsystems/Replication/default/replication.properties repository/src/main/resources/alfresco/subsystems/Search/noindex/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/noindex/noindex-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr/solr-backup.properties repository/src/main/resources/alfresco/subsystems/Search/solr/solr-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr/facet/solr-facets-config.properties repository/src/main/resources/alfresco/subsystems/Search/solr4/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr4/solr-backup.properties repository/src/main/resources/alfresco/subsystems/Search/solr4/solr-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr6/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr6/solr-backup.properties repository/src/main/resources/alfresco/subsystems/Search/solr6/solr-search.properties repository/src/main/resources/alfresco/subsystems/Subscriptions/default/subscription-service.properties repository/src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization.properties repository/src/main/resources/alfresco/subsystems/sysAdmin/default/sysadmin-parameter.properties repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform.properties repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform.properties repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers.properties repository/src/main/resources/org/alfresco/encryption/keystore-parameters.properties repository/src/main/resources/org/alfresco/repo/i18n/testMessages.properties repository/src/main/resources/org/alfresco/repo/module/tool/default-file-mapping.properties repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter.properties" +EXCLUDED_FILES="data-model/src/main/resources/alfresco/messages/dictionary-messages.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_cs.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_da.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_de.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_el.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_en.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_es.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_fi.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_fr.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_it.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_ja.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_ko.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_nl.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_no.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_pt.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_pt_BR.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_ru.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_sv.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_th.properties data-model/src/main/resources/alfresco/model/dataTypeAnalyzers_zh.properties remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/audit/control.properties repository/src/main/resources/alfresco/messages/content-service.properties repository/src/main/resources/alfresco/messages/module-messages.properties repository/src/main/resources/alfresco/messages/patch-service.properties repository/src/main/resources/alfresco/messages/repoadmin-interpreter-help.properties repository/src/main/resources/alfresco/messages/schema-update.properties repository/src/main/resources/alfresco/messages/tenant-interpreter-help.properties repository/src/main/resources/alfresco/messages/version-service.properties repository/src/main/resources/alfresco/messages/workflow-interpreter-help.properties repository/src/main/resources/alfresco/alfresco-shared.properties repository/src/main/resources/alfresco/caches.properties repository/src/main/resources/alfresco/repository.properties repository/src/main/resources/alfresco/client/config/repo-clients-apps.properties repository/src/main/resources/alfresco/domain/cache-strategies.properties repository/src/main/resources/alfresco/domain/hibernate-cfg.properties repository/src/main/resources/alfresco/domain/quartz.properties repository/src/main/resources/alfresco/domain/transaction.properties repository/src/main/resources/alfresco/keystore/keystore-passwords.properties repository/src/main/resources/alfresco/keystore/ssl-keystore-passwords.properties repository/src/main/resources/alfresco/keystore/ssl-truststore-passwords.properties repository/src/main/resources/alfresco/metadata/RFC822MetadataExtracter.properties repository/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties repository/src/main/resources/alfresco/subsystems/Authentication/alfrescoNtlm/alfresco-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/external/external-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/kerberos/kerberos-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/ldap/ldap-authentication.properties repository/src/main/resources/alfresco/subsystems/Authentication/ldap-ad/ldap-ad-authentication.properties repository/src/main/resources/alfresco/subsystems/email/InboundSMTP/inboundSMTP.properties repository/src/main/resources/alfresco/subsystems/email/OutboundSMTP/outboundSMTP.properties repository/src/main/resources/alfresco/subsystems/fileServers/default/file-servers.properties repository/src/main/resources/alfresco/subsystems/imap/default/imap-server.properties repository/src/main/resources/alfresco/subsystems/Replication/default/replication.properties repository/src/main/resources/alfresco/subsystems/Search/noindex/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/noindex/noindex-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr/solr-backup.properties repository/src/main/resources/alfresco/subsystems/Search/solr/solr-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr/facet/solr-facets-config.properties repository/src/main/resources/alfresco/subsystems/Search/solr4/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr4/solr-backup.properties repository/src/main/resources/alfresco/subsystems/Search/solr4/solr-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr6/common-search.properties repository/src/main/resources/alfresco/subsystems/Search/solr6/solr-backup.properties repository/src/main/resources/alfresco/subsystems/Search/solr6/solr-search.properties repository/src/main/resources/alfresco/subsystems/Subscriptions/default/subscription-service.properties repository/src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization.properties repository/src/main/resources/alfresco/subsystems/sysAdmin/default/sysadmin-parameter.properties repository/src/main/resources/org/alfresco/encryption/keystore-parameters.properties repository/src/main/resources/org/alfresco/repo/i18n/testMessages.properties repository/src/main/resources/org/alfresco/repo/module/tool/default-file-mapping.properties" diff --git a/packaging/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt b/packaging/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt deleted file mode 100644 index fac88bf9ef..0000000000 --- a/packaging/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt +++ /dev/null @@ -1,110 +0,0 @@ -The authoritative ImageMagick license can be found at -http://www.imagemagick.org/script/license.php and ImageMagick notices at -http://www.imagemagick.org/www/Notice.html. - -Before we get to the text of the license, lets just review what the license says in simple terms: - -It allows you to: - - * freely download and use ImageMagick software, in whole or in part, for personal, company internal, or commercial purposes; - * use ImageMagick software in packages or distributions that you create; - * link against a library under a different license; - * link code under a different license against a library under this license; - * merge code into a work under a different license; - * extend patent grants to any code using code under this license; - *and extend patent protection. - -It forbids you to: - - * redistribute any piece of ImageMagick-originated software without proper attribution; - * use any marks owned by ImageMagick Studio LLC in any way that might state or imply that ImageMagick Studio LLC endorses your distribution; - * use any marks owned by ImageMagick Studio LLC in any way that might state or imply that you created the ImageMagick software in question. - -It requires you to: - - * include a copy of the license in any redistribution you may make that includes ImageMagick software; - * provide clear attribution to ImageMagick Studio LLC for any distributions that include ImageMagick software. - -It does not require you to: - - * include the source of the ImageMagick software itself, or of any modifications you may have made to it, in any redistribution you may assemble that includes it; - * submit changes that you make to the software back to the ImageMagick Studio LLC (though such feedback is encouraged). - -A few other clarifications include: - * ImageMagick is freely available without charge; - * you may include ImageMagick on any digital media as long as you comply with the terms of the license; - * you can give modified code away for free or sell it under the terms of the ImageMagick license or distribute the result under a different license, but you need to acknowledge the use of the ImageMagick software; - * the license is compatible with the GPL V3. - * when exporting the ImageMagick software, review its export classification. - -Terms and Conditions for Use, Reproduction, and Distribution - -The legally binding and authoritative terms and conditions for use, reproduction, and distribution of ImageMagick follow: - -Copyright © 1999-2018 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available. - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - a. You must give any other recipients of the Work or Derivative Works a copy of this License; and - - b. You must cause any modified files to carry prominent notices stating that You changed the files; and - - c. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - d. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -How to Apply the License to your Work - -To apply the ImageMagick License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information (don't include the brackets). The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the ImageMagick License (the "License"); you may not use - this file except in compliance with the License. You may obtain a copy - of the License at - - https://www.imagemagick.org/script/license.php - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. \ No newline at end of file diff --git a/packaging/distribution/src/main/resources/licenses/3rd-party/libreoffice.txt b/packaging/distribution/src/main/resources/licenses/3rd-party/libreoffice.txt deleted file mode 100644 index a82e6b6292..0000000000 --- a/packaging/distribution/src/main/resources/licenses/3rd-party/libreoffice.txt +++ /dev/null @@ -1,9428 +0,0 @@ - - Licensing and Legal information - - This product is made available subject to the terms of the Mozilla - Public License, v. 2.0. A copy of the MPL Version 2 license can be - found below. - - See MPL Version 2 below - - Third Party Code Additional copyright notices and license terms - applicable to portions of the Software can be found below in this - document. - - All trademarks and registered trademarks mentioned herein are the - property of their respective owners. - - Copyright © 2000, 2014 LibreOffice contributors. All rights reserved. - - This product is based on OpenOffice.org. Portions of this software are - copyright © 2000-2011, Oracle and/or its affiliates. - - This product has been created by The Document Foundation, incorporating - many modifications from different contributors, see - http://www.libreoffice.org/ for more details. - - Note: Do not translate or localize this document. Only English version - is legally binding. - - Contents - - Libraries - - Extensions - - Fonts - - Dictionaries - - Artwork - - Miscellaneous - - GNU Lesser General Public License Version 3 - - GNU Lesser General Public License Version 2.1 - - GNU Library General Public License Version 2 - - GNU General Public License Version 3 - - GNU General Public License Version 2 - - Mozilla Public License Version 1.1 - - Mozilla Public License Version 2.0 - - SIL Open Font License Version 1.1 – 26 February 2007 - - Apache License - - The LaTeX Project Public License - - Creative Commons Attribution-ShareAlike 3.0 Unported - - Third Party Code Additional Copyright Notices and License Terms - - Libraries - -Apache Commons - - The following software may be included in this product: Apache Commons - (codec, httpclient, lang, logging). Use of any of this software is - governed by the terms of the license below: - - See Apache License Version 2.0 below - -beanshell - - The following software may be included in this product: beanshell. Use - of any of this software is governed by the terms of the license below: - - This file is part of the BeanShell Java Scripting distribution. - Documentation and updates may be found at http://www.beanshell.org/ - - Sun Public License Notice: - - The contents of this file are subject to the Sun Public License Version - 1.0 (the "License"); you may not use this file except in compliance - with the License. A copy of the License is available at - http://www.sun.com - - The Original Code is BeanShell. The Initial Developer of the Original - Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright - (C) 2000. All Rights Reserved. - - GNU Public License Notice: - - Alternatively, the contents of this file may be used under the terms of - the GNU Lesser General Public License (the "LGPL"), in which case the - provisions of LGPL are applicable instead of those above. If you wish - to allow use of your version of this file only under the terms of the - LGPL and not to allow others to use your version of this file under the - SPL, indicate your decision by deleting the provisions above and - replace them with the notice and other provisions required by the LGPL. - If you do not delete the provisions above, a recipient may use your - version of this file under either the SPL or the LGPL. - - Patrick Niemeyer (pat@pat.net) Author of Learning Java, O'Reilly & - Associates http://www.pat.net/~pat/ - - See LGPL Version 3 below - -C++ Boost Library - - The following software may be included in this product: C++ Boost - Library. Use of any of this software is governed by the terms of the - license below: - - Boost Software License - Version 1.0 - August 17th, 2003 - - Permission is hereby granted, free of charge, to any person or - organization obtaining a copy of the software and accompanying - documentation covered by this license (the "Software") to use, - reproduce, display, distribute, execute, and transmit the Software, and - to prepare derivative works of the Software, and to permit - third-parties to whom the Software is furnished to do so, all subject - to the following: - - The copyright notices in the Software and this entire statement, - including the above license grant, this restriction and the following - disclaimer, must be included in all copies of the Software, in whole or - in part, and all derivative works of the Software, unless such copies - or derivative works are solely in the form of machine-executable object - code generated by a source language processor. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND - NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE - DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, - WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - -Cairo - - The following software may be included in this product: Cairo. Use of - any of this software is governed by the terms of the license below: - - Cairo is free software. - - Every source file in the implementation[*] of cairo is available to be - redistributed and/or modified under the terms of either the GNU Lesser - General Public License (LGPL) version 2.1 or the Mozilla Public License - (MPL) version 1.1. Some files are available under more liberal terms, - but we believe that in all cases, each file may be used under either - the LGPL or the MPL. - - See the following files in this directory for the precise terms and - conditions of either license: - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Please see each file in the implementation for copyright and licensing - information, (in the opening comment of each file). - - [*] The implementation of cairo is contained entirely within the "src" - and "pixman" directories of the cairo source distribution. There are - other components of the cairo source distribution (such as the "test" - and "perf") that are auxiliary to the library itself. None of the - source code in these directories contributes to a build of the cairo - library itself, (libcairo.so or cairo.dll or similar). - - These auxilary components are also free software, but may be under - different license terms than cairo itself. For example, most of the - test cases in the perf and test directories are made available under a - MIT license to simplify any use of this code for reference purposes in - using cairo itself. Other files might be available under the GNU - General Public License (GPL), for example. Again, please see the - opening comment of each file for copyright and licensing information. - -CLucene - - The following software may be included in this product: CLucene. Use of - any of this software is governed by the terms of the license below: - - CLucene is distributed under the GNU Lesser General Public License - (LGPL) or the Apache License, Version 2.0 - - See LGPL Version 2.1 below - - See Apache License Version 2.0 below - -expat XML Parser Toolkit - - The following software may be included in this product: expat XML - Parser Toolkit. Use of any of this software is governed by the terms of - the license below: - - Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd and - Clark Cooper - - Copyright (c) 2001, 2002, 2003 Expat maintainers. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Flute - - The following software may be included in this product: Flute. Use of - any of this software is governed by the terms of the license below: - - W3C IPR SOFTWARE NOTICE - - Copyright © 2002 World Wide Web Consortium, (Massachusetts Institute of - Technology, Institut National de Recherche en Informatique et en - Automatique, Keio University). All Rights Reserved. - - Note: The original version of the W3C Software Copyright Notice and - License could be found at - http://www.w3.org/Consortium/Legal/copyright-software-19980720 - - Copyright © 1994-2000 World Wide Web Consortium, (Massachusetts - Institute of Technology, Institut National de Recherche en - Informatique et en Automatique, Keio University). All Rights - Reserved. http://www.w3.org/Consortium/Legal/ - - This W3C work (including software, documents, or other related items) - is being provided by the copyright holders under the following license. - By obtaining, using and/or copying this work, you (the licensee) agree - that you have read, understood, and will comply with the following - terms and conditions: - - Permission to use, copy, and modify this software and its - documentation, with or without modification, for any purpose and - without fee or royalty is hereby granted, provided that you include the - following on ALL copies of the software and documentation or portions - thereof, including modifications, that you make: - 1. The full text of this NOTICE in a location viewable to users of the - redistributed or derivative work. - 2. Any pre-existing intellectual property disclaimers, notices, or - terms and conditions. If none exist, a short notice of the - following form (hypertext is preferred, text is permitted) should - be used within the body of any redistributed or derivative code: - "Copyright © 2002 World Wide Web Consortium, (Massachusetts - Institute of Technology, Institut National de Recherche en - Informatique et en Automatique, Keio University). All Rights - Reserved. http://www.w3.org/Consortium/Legal/" - 3. Notice of any changes or modifications to the W3C files, including - the date changes were made. (We recommend you provide URIs to the - location from which the code is derived.) - - THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT - HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, - INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS - FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR - DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, - TRADEMARKS OR OTHER RIGHTS. - - COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL - OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR - DOCUMENTATION. - - The name and trademarks of copyright holders may NOT be used in - advertising or publicity pertaining to the software without specific, - written prior permission. Title to copyright in this software and any - associated documentation will at all times remain with copyright - holders. - - Freetype Library - - The following software may be included in this product: Freetype. Use - of any of this software is governed by the terms of the license below: - - 0. Definitions - - Throughout this license, the terms `package', `FreeType Project', and - `FreeType archive' refer to the set of files originally distributed by - the authors (David Turner, Robert Wilhelm, and Werner Lemberg) as the - `FreeType Project', be they named as alpha, beta or final release. - - `You' refers to the licensee, or person using the project, where - `using' is a generic term including compiling the project's source code - as well as linking it to form a `program' or `executable'. This program - is referred to as `a program using the FreeType engine'. - - This license applies to all files distributed in the original FreeType - Project, including all source code, binaries and documentation, unless - otherwise stated in the file in its original, unmodified form as - distributed in the original archive. If you are unsure whether or not a - particular file is covered by this license, you must contact us to - verify this. - - The FreeType Project is copyright (C) 1996-2000 by David Turner, Robert - Wilhelm, and Werner Lemberg. All rights reserved except as specified - below. - - 1. No Warranty - - THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY KIND, - EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL - ANY OF THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES - CAUSED BY THE USE OR THE INABILITY TO USE, OF THE FREETYPE PROJECT. - - 2. Redistribution - - This license grants a worldwide, royalty-free, perpetual and - irrevocable right and license to use, execute, perform, compile, - display, copy, create derivative works of, distribute and sublicense - the FreeType Project (in both source and object code forms) and - derivative works thereof for any purpose; and to authorize others to - exercise some or all of the rights granted herein, subject to the - following conditions: - * Redistribution of source code must retain this license file - ('FTL.TXT') unaltered; any additions, deletions or changes to the - original files must be clearly indicated in accompanying - documentation. The copyright notices of the unaltered, original - files must be preserved in all copies of source files. - * Redistribution in binary form must provide a disclaimer that states - that the software is based in part of the work of the FreeType - Team, in the distribution documentation. We also encourage you to - put an URL to the FreeType web page in your documentation, though - this isn't mandatory. - - These conditions apply to any software derived from or based on the - FreeType Project, not just the unmodified files. If you use our work, - you must acknowledge us. However, no fee need be paid to us. - - 3. Advertising - - Neither the FreeType authors and contributors nor you shall use the - name of the other for commercial, advertising, or promotional purposes - without specific prior written permission. - - We suggest, but do not require, that you use one or more of the - following phrases to refer to this software in your documentation or - advertising materials: `FreeType Project', `FreeType Engine', `FreeType - library', or `FreeType Distribution'. - - As you have not signed this license, you are not required to accept it. - However, as the FreeType Project is copyrighted material, only this - license, or another one contracted with the authors, grants you the - right to use, distribute, and modify it. Therefore, by using, - distributing, or modifying the FreeType Project, you indicate that you - understand and accept all the terms of this license. - - 4. Contacts - - There are two mailing lists related to FreeType: - * freetype@freetype.org - - Discusses general use and applications of FreeType, as well as future - and wanted additions to the library and distribution. If you are - looking for support, start in this list if you haven't found anything - to help you in the documentation. - * devel@freetype.org - - Discusses bugs, as well as engine internals, design issues, specific - licenses, porting, etc. - * http://www.freetype.org - - Holds the current FreeType web page, which will allow you to download - our latest development version and read online documentation. - - You can also contact us individually at: - - David Turner - Robert Wilhelm - Werner Lemberg - -GNU ISO C++ Library - - The following software may be included in this product: GNU ISO C++ - Library. Use of any of this software is governed by the terms of the - license below: - - © Free Software Foundation, Inc. - - See GPL Version 2 below - - Additional License(s) - -libstdc++: -// Explicit instantiation file. - -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 -// Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free -software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you -compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be -covered by -// the GNU General Public License. - -libgcc: -// -// ISO C++ 14882: -// - -/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. - Contributed by Jakub Jelinek . - - This file is part of GNU CC. - - GNU CC is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU CC 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU CC; see the file COPYING. If not, write to - the Free Software Foundation, 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with other files, - some of which are compiled with GCC, to produce an executable, - this library does not by itself cause the resulting executable - to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public -License. */ - -/* Locate the FDE entry for a given address, using PT_GNU_EH_FRAME ELF - segment and dl_iterate_phdr to avoid register/deregister calls at - DSO load/unload. */ - -Firebird - - The applicable and approved licenses for the source files of the - Firebird RDBMS project are: - - 1) InterBase Public License (IPL), version 1.0 - - 2) Initial Developer's Public License (IDPL), version 1.0 - - The IPL is copyright of Borland Corp., the other licenses are copyright - by the source code authors and contributors. Both are variants of the - Mozilla Public License V.1.1 (MPL). See - http://www.firebirdsql.org/en/licensing/ - -fontconfig - - The following software may be included in this product: fontconfig. Use - of any of this software is governed by the terms of the license below: - - Copyright © 2002 Keith Packard - - Permission to use, copy, modify, distribute, and sell this software and - its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appear in all copies and that - both that copyright notice and this permission notice appear in - supporting documentation, and that the name of the author(s) not be - used in advertising or publicity pertaining to distribution of the - software without specific, written prior permission. The authors make - no representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied warranty. - - THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR - CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - -Graphite2 - - The following software may be included in this product: Graphite2. Use - of any of this software is governed by the terms of the license below: - - Copyright 2010, SIL International All rights reserved. - - This library 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 2.1 of License, or (at - your option) any later version. - - This program 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 also have received a copy of the GNU Lesser General Public - License along with this library in the file named "LICENSE". If not, - write to the Free Software Foundation, Inc., 59 Temple Place, Suite - 330, Boston, MA 02111-1307, USA or visit their web page on the internet - at http://www.fsf.org/licenses/lgpl.html. - - Alternatively, you may use this library under the terms of the Mozilla - Public License (http://mozilla.org/MPL) or under the GNU General - Public License, as published by the Free Sofware Foundation; either - version 2 of the license or (at your option) any later version. - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - -HarfBuzz - - HarfBuzz is licensed under the so-called "Old MIT" license. Details - follow. For parts of HarfBuzz that are licensed under different - licenses see individual files names COPYING in subdirectories where - applicable. - - Copyright © 2010,2011,2012 Google, Inc. - Copyright © 2012 Mozilla Foundation - Copyright © 2011 Codethink Limited - Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies) - Copyright © 2009 Keith Stribley - Copyright © 2009 Martin Hosken and SIL International - Copyright © 2007 Chris Wilson - Copyright © 2006 Behdad Esfahbod - Copyright © 2005 David Turner - Copyright © 2004,2007,2008,2009,2010 Red Hat, Inc. - Copyright © 1998-2004 David Turner and Werner Lemberg - - For full copyright notices consult the individual files in the package. - - Permission is hereby granted, without written agreement and without - license or royalty fees, to use, copy, modify, and distribute this - software and its documentation for any purpose, provided that the above - copyright notice and the following two paragraphs appear in all copies - of this software. - - IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING - OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE - COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON - AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE - MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - -HSQLDB - - The following software may be included in this product: HSQLDB. Use of - any of this software is governed by the terms of the license below: - - ORIGINAL LICENSE (a.k.a. "hypersonic_lic.txt") - - For content, code, and products originally developed by Thomas Mueller - and the Hypersonic SQL Group: - - Copyright (c) 1995-2000 by the Hypersonic SQL Group. All rights - reserved. Redistribution and use in source and binary forms, with or - without modification, are permitted provided that the following - conditions are met: - - Redistribution of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of the Hypersonic SQL Group nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL - GROUP, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - This software consists of voluntary contributions made by many - individuals on behalf of the Hypersonic SQL Group. - - For work added by the HSQL Development Group (a.k.a. hsqldb_lic.txt) - - Copyright (c) 2001-2004, The HSQL Development Group All rights - reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - Redistribution of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of the HSQL Development Group nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT - GROUP, HSQLDB.ORG, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. - -Hunspell - - The following software may be included in this product: Hunspell. Use - of any of this software is governed by the terms of the license below: - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - The contents of this software may be used under the terms of the GNU - General Public License Version 2 or later (the "GPL"), or the GNU - Lesser General Public License Version 2.1 or later (the "LGPL") or - (excepting the LGPLed GNU gettext library in the intl/ directory) the - Mozilla Public License Version 1.1 or later (the "MPL"). - - Software distributed under these licenses is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - licenses for the specific language governing rights and limitations - under the licenses. - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - -Hyphen - - The following software may be included in this product: Hyphen. Use of - any of this software is governed by the terms of the license below: - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - The contents of this software may be used under the terms of the GNU - General Public License Version 2 or later (the "GPL"), or the GNU - Lesser General Public License Version 2.1 or later (the "LGPL") or - (excepting the LGPLed GNU gettext library in the intl/ directory) the - Mozilla Public License Version 1.1 or later (the "MPL"). - - The Plain TeX hyphenation tables "hyphen.tex" by Donald E. Knuth has a - non MPL/LGPL compatible license, but freely redistributable: "Unlimited - copying and redistribution of this file are permitted as long as this - file is not modified. Modifications are permitted, but only if the - resulting file is not named hyphen.tex." - - Software distributed under these licenses is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - licenses for the specific language governing rights and limitations - under the licenses. - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - -IAccessible2 - - The following software may be included in this product: IAccessible2 - API. - - IAccessible2 IDL Specification - - Copyright (c) 2007, 2013 Linux Foundation - Copyright (c) 2006 IBM Corporation - Copyright (c) 2000, 2006 Sun Microsystems, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 1. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - - 1. Neither the name of the Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This BSD License conforms to the Open Source Initiative "Simplified BSD - License" as published at: - http://www.opensource.org/licenses/bsd-license.php - - IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 - mark may be used in accordance with the Linux Foundation Trademark - Policy to indicate compliance with the IAccessible2 specification. - - Find out more about IAccessible2 at - http://accessibility.linuxfoundation.org/. - -ICU - - The following software may be included in this product: ICU. Use of any - of this software is governed by the terms of the license below: - - ICU License - ICU 1.8.1 and later - - COPYRIGHT AND PERMISSION NOTICE - - Copyright (c) 1995-2002 International Business Machines Corporation and - others All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, and/or sell copies of the Software, and to permit persons - to whom the Software is furnished to do so, provided that the above - copyright notice(s) and this permission notice appear in all copies of - the Software and that both the above copyright notice(s) and this - permission notice appear in supporting documentation. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL - INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - Except as contained in this notice, the name of a copyright holder - shall not be used in advertising or otherwise to promote the sale, use - or other dealings in this Software without prior written authorization - of the copyright holder. - - All trademarks and registered trademarks mentioned herein are the - property of their respective owners. - -IJG JPEG Library - - The following software may be included in this product: IJG JPEG - Library. Use of any of this software is governed by the terms of the - license below: - - In plain English: - 1. We don't promise that this software works. (But if you find any - bugs, please let us know!) - 2. You can use this software for whatever you want. You don't have to - pay us. - 3. You may not pretend that you wrote this software. If you use it in - a program, you must acknowledge somewhere in your documentation - that you've used the IJG code. - - In legalese: - - The authors make NO WARRANTY or representation, either express or - implied, with respect to this software, its quality, accuracy, - merchantability, or fitness for a particular purpose. This software is - provided "AS IS", and you, its user, assume the entire risk as to its - quality and accuracy. - - This software is copyright (C) 1991-1998, Thomas G. Lane. All Rights - Reserved except as specified below. - - Permission is hereby granted to use, copy, modify, and distribute this - software (or portions thereof) for any purpose, without fee, subject to - these conditions: (1) If any part of the source code for this software - is distributed, then this README file must be included, with this - copyright and no-warranty notice unaltered; and any additions, - deletions, or changes to the original files must be clearly indicated - in accompanying documentation. (2) If only executable code is - distributed, then the accompanying documentation must state that "this - software is based in part on the work of the Independent JPEG Group". - (3) Permission for use of this software is granted only if the user - accepts full responsibility for any undesirable consequences; the - authors accept NO LIABILITY for damages of any kind. - - These conditions apply to any software derived from or based on the IJG - code, not just to the unmodified library. If you use our work, you - ought to acknowledge us. - - Permission is NOT granted for the use of any IJG author's name or - company name in advertising or publicity relating to this software or - products derived from it. This software may be referred to only as "the - Independent JPEG Group's software". - - We specifically permit and encourage the use of this software as the - basis of commercial products, provided that all warranty or liability - claims are assumed by the product vendor. - - ansi2knr.c is included in this distribution by permission of L. Peter - Deutsch, sole proprietor of its copyright holder, Aladdin Enterprises - of Menlo Park, CA. ansi2knr.c is NOT covered by the above copyright and - conditions, but instead by the usual distribution terms of the Free - Software Foundation; principally, that you must include source code if - you redistribute it. (See the file ansi2knr.c for full details.) - However, since ansi2knr.c is not needed as part of any program - generated from the IJG code, this does not limit you more than the - foregoing paragraphs do. - - The Unix configuration script "configure" was produced with GNU - Autoconf. It is copyright by the Free Software Foundation but is freely - distributable. The same holds for its supporting scripts (config.guess, - config.sub, ltconfig, ltmain.sh). Another support script, install-sh, - is copyright by M.I.T. but is also freely distributable. - - It appears that the arithmetic coding option of the JPEG spec is - covered by patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic - coding cannot legally be used without obtaining one or more licenses. - For this reason, support for arithmetic coding has been removed from - the free JPEG software. (Since arithmetic coding provides only a - marginal gain over the unpatented Huffman mode, it is unlikely that - very many implementations will support it.) So far as we are aware, - there are no patent restrictions on the remaining code. - - The IJG distribution formerly included code to read and write GIF - files. To avoid entanglement with the Unisys LZW patent, GIF reading - support has been removed altogether, and the GIF writer has been - simplified to produce "uncompressed GIFs". This technique does not use - the LZW algorithm; the resulting GIF files are larger than usual, but - are readable by all standard GIF decoders. - - We are required to state that - - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - -JDOM - - The following software may be included in this product: JDOM. Use of - any of this software is governed by the terms of the license below: - - Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. All rights - reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistribution of source code must retain the above copyright - notice, this list of conditions, and the following disclaimer. - - 2. Redistribution in binary form must reproduce the above copyright - notice, this list of conditions, and the disclaimer that follows these - conditions in the documentation and/or other materials provided with - the distribution. - - 3. The name "JDOM" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact . - - 4. Products derived from this software may not be called "JDOM", nor - may "JDOM" appear in their name, without prior written permission from - the JDOM Project Management . - - In addition, we request (but do not require) that you include in the - end-user documentation provided with the redistribution and/or in the - software itself an acknowledgement equivalent to the following: - - "This product includes software developed by the JDOM Project - (http://www.jdom.org/)." - - Alternatively, the acknowledgment may be graphical using the logos - available at http://www.jdom.org/images/logos. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many - individuals on behalf of the JDOM Project and was originally created by - Jason Hunter and Brett McLaughlin - . For more information on the JDOM Project, - please see http://www.jdom.org/. - -libatomic-ops - - The following software may be included in this product: libatomic-ops. - Use of any of this software is governed by the terms of the license - below: - - See GPL Version 2 below - -libcdr - - The following software may be included in this product: libcdr. Use of - any of this software is governed by the terms of the license below: - - MPL 1.1 / LGPL v2+ / GPL v2+ - - See GPL Version 2 below - - See LGPL Version 2 below - - See MPL Version 1.1 below - -libcmis - - The following software may be included in this product: libcmis. Use of - any of this software is governed by the terms of the license below: - - MPL 1.1 / LGPL v2+ / GPL v2+ - - See GPL Version 2 below - - See LGPL Version 2 below - - See MPL Version 1.1 below - -libcurl - - The following software may be included in this product: libcurl. Use of - any of this software is governed by the terms of the license below: - - Copyright (c) 1996 - 2009, Daniel Stenberg, . - - All rights reserved. - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - Except as contained in this notice, the name of a copyright holder - shall not be used in advertising or otherwise to promote the sale, use - or other dealings in this Software without prior written authorization - of the copyright holder. - -libeot - - The following software may be included in this product: libeot. Use of - any of this software is governed by the terms of the license below: - - See MPL Version 2 below - -libe-book - - The following software may be included in this product: libe-book. Use - of any of this software is governed by the terms of the license below: - - LGPL v2.1+ / MPL 2+ - - See LGPL Version 2.1 below - - See MPL Version 2 below - -libetonyek - - The following software may be included in this product: libetonyek. Use - of any of this software is governed by the terms of the license below: - - See MPL Version 2 below - -libexttextcat - - The following software may be included in this product: libexttextcat. - Use of any of this software is governed by the terms of the license - below: - - Copyright (c) 2003, WiseGuys Internet B.V. - - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - - Redistribution of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - - Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the WiseGuys Internet B.V. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -libfreehand - - The following software may be included in this product: libfreehand. - Use of any of this software is governed by the terms of the license - below: - - See MPL Version 2 below - -liblangtag - - The following software may be included in this product: liblangtag. Use - of any of this software is governed by the terms of the license below: - - See LGPL Version 3 below - -libmspub - - The following software may be included in this product: libmspub. Use - of any of this software is governed by the terms of the license below: - - MPL 1.1 / LGPL v2+ / GPL v2+ - - See GPL Version 2 below - - See LGPL Version 2 below - - See MPL Version 1.1 below - -libmwaw - - The following software may be included in this product: libmwaw. Use of - any of this software is governed by the terms of the license below: - - LGPL v2.1+ / MPL 2 - - See LGPL Version 2.1 below - - See MPL Version 2 below - -libodfgen - - The following software may be included in this product: libodfgen. Use - of any of this software is governed by the terms of the license below: - - LGPL v2.1+ / MPL 2 - - See LGPL Version 2.1 below - - See MPL Version 2 below - -liborcus - - The following software may be included in this product: liborcus. Use - of any of this software is governed by the terms of the license below: - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -libpng - - The following software may be included in this product: libpng. Use of - any of this software is governed by the terms of the license below: - - This copy of the libpng notices is provided for your convenience. In - case of - any discrepancy between this copy and the notices in the file png.h - that is - included in the libpng distribution, the latter shall prevail. - COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - If you modify libpng you may insert additional notices immediately - following - this sentence. - This code is released under the libpng license. - libpng versions 1.2.6, August 15, 2004, through 1.5.1, February 3, - 2011, are - Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are - distributed according to the same disclaimer and license as - libpng-1.2.5 - with the following individual added to the list of Contributing Authors - Cosmin Truta - libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, - are - Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are - distributed according to the same disclaimer and license as - libpng-1.0.6 - with the following individuals added to the list of Contributing - Authors - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant - and with the following additions to the disclaimer: - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. - libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are - distributed according to the same disclaimer and license as - libpng-0.96, - with the following individuals added to the list of Contributing - Authors: - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - libpng versions 0.89, June 1996, through 0.96, May 1997, are - Copyright (c) 1996, 1997 Andreas Dilger - Distributed according to the same disclaimer and license as - libpng-0.88, - with the following individuals added to the list of Contributing - Authors: - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - libpng versions 0.5, May 1995, through 0.88, January 1996, are - Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. - For the purposes of this copyright and license, "Contributing Authors" - is defined as the following set of individuals: - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - The PNG Reference Library is supplied "AS IS". The Contributing Authors - and Group 42, Inc. disclaim all warranties, expressed or implied, - including, without limitation, the warranties of merchantability and of - fitness for any purpose. The Contributing Authors and Group 42, Inc. - assume no liability for direct, indirect, incidental, special, - exemplary, - or consequential damages, which may result from the use of the PNG - Reference Library, even if advised of the possibility of such damage. - Permission is hereby granted to use, copy, modify, and distribute this - source code, or portions hereof, for any purpose, without fee, subject - to the following restrictions: - 1. The origin of this source code must not be misrepresented. - 2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. - 3. This Copyright notice may not be removed or altered from any - source or altered source distribution. - The Contributing Authors and Group 42, Inc. specifically permit, - without - fee, and encourage the use of this source code as a component to - supporting the PNG file format in commercial products. If you use this - source code in a product, acknowledgment is not required but would be - appreciated. - A "png_get_copyright" function is available, for convenient use in - "about" - boxes and the like: - printf("%s",png_get_copyright(NULL)); - Also, the PNG logo (in PNG format, of course) is supplied in the - files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - Libpng is OSI Certified Open Source Software. OSI Certified Open Source - is a - certification mark of the Open Source Initiative. - Glenn Randers-Pehrson - glennrp at users.sourceforge.net - February 3, 2011 - -libvisio - - The following software may be included in this product: libvisio. Use - of any of this software is governed by the terms of the license below: - - MPL 1.1+ / LGPL v2.1+ / GPL v2+ - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - -libwpd - - The following software may be included in this product: libwpd. Use of - any of this software is governed by the terms of the license below: - - LGPL v2.1+ / MPL 2 - - See LGPL Version 2.1 below - - See MPL Version 2 below - -libwpg - - The following software may be included in this product: libwpg. Use of - any of this software is governed by the terms of the license below: - - LGPL v2.1+ / MPL 2 - - See LGPL Version 2.1 below - - See MPL Version 2 below - -libwps - - The following software may be included in this product: libwps. Use of - any of this software is governed by the terms of the license below: - - LGPL v2.1+ / MPL 2 - - See LGPL Version 2.1 below - - See MPL Version 2 below - -libxml2 - - The following software may be included in this product: libxml2. Use of - any of this software is governed by the terms of the license below: - - Except where otherwise noted in the source code (e.g. the files hash.c, - list.c and the trio files, which are covered by a similar license but - with different Copyright notices) all the files are: - - Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FIT- NESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE DANIEL VEILLARD BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- NECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of Daniel Veillard shall - not be used in advertising or otherwise to promote the sale, use or - other dealings in this Software without prior written authorization - from him. - -libxslt - - The following software may be included in this product: libxslt. Use of - any of this software is governed by the terms of the license below: - - License for libxslt except libexslt - - Copyright (C) 2001-2002 Daniel Veillard. All Rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FIT- NESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE DANIEL VEILLARD BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- NECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of Daniel Veillard shall - not be used in advertising or otherwise to promote the sale, use or - other dealings in this Software without prior written authorization - from him. - - License for libexslt - - Copyright (C) 2001-2002 Thomas Broyer, Charlie Bozeman and Daniel - Veillard. All Rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FIT- NESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF OR IN CON- NECTION WITH THE SOFTWARE OR - THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of the authors shall not - be used in advertising or otherwise to promote the sale, use or other - dealings in this Software without prior written authorization from him. - -Little CMS (lcms2) - - The following software may be included in this product: Little CMS - (lcms2). Use of any of this software is governed by the terms of the - license below: - - Copyright (c) 1998-2011 Marti Maria Saguer - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -lpsolve - - The following software may be included in this product: lpsolve. Use of - any of this software is governed by the terms of the license below: - - See LGPL Version 2.1 below - -mdds - - The following software may be included in this product: mdds. Use of - any of this software is governed by the terms of the license below: - - Copyright (c) 2010 Kohei Yoshida - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Mesa - - The following software may be included in this product: The Mesa 3D - Graphics Library. The default Mesa license is as follows: - - Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - Ext headers - - Copyright (c) 2007 The Khronos Group Inc. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and/or associated documentation files (the - "Materials"), to deal in the Materials without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Materials, and to - permit persons to whom the Materials are furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Materials. - - THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - -Microsoft Visual C++ 2010 Runtime Libraries - - The following software may be included in this product: Microsoft - Visual C++ 2010 Runtime Libraries. Use of any of this software is - governed by the terms of the license below: - - MICROSOFT SOFTWARE LICENSE TERMS - - MICROSOFT VISUAL C++ 2010 RUNTIME LIBRARIES WITH SERVICE PACK 1 - - These license terms are an agreement between Microsoft Corporation (or - based on where you live, one of its affiliates) and you. Please read - them. They apply to the software named above, which includes the media - on which you received it, if any. The terms also apply to any Microsoft - * updates, - * supplements, - * Internet-based services, and - * support services - - for this software, unless other terms accompany those items. If so, - those terms apply. - - BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT - THEM, DO NOT USE THE SOFTWARE. - - If you comply with these license terms, you have the rights below. - 1. INSTALLATION AND USE RIGHTS. You may install and use any number of - copies of the software on your devices. - 2. SCOPE OF LICENSE. The software is licensed, not sold. This - agreement only gives you some rights to use the software. Microsoft - reserves all other rights. Unless applicable law gives you more - rights despite this limitation, you may use the software only as - expressly permitted in this agreement. In doing so, you must comply - with any technical limitations in the software that only allow you - to use it in certain ways. You may not - - * disclose the results of any benchmark tests of the software to any - third party without Microsoft’s prior written approval; - * work around any technical limitations in the software; - * reverse engineer, decompile or disassemble the software, except and - only to the extent that applicable law expressly permits, despite - this limitation; - * make more copies of the software than specified in this agreement - or allowed by applicable law, despite this limitation; - * publish the software for others to copy; - * rent, lease or lend the software; - * transfer the software or this agreement to any third party; or - * use the software for commercial software hosting services. - - 3. BACKUP COPY. You may make one backup copy of the software. You may - use it only to reinstall the software. - 4. DOCUMENTATION. Any person that has valid access to your computer or - internal network may copy and use the documentation for your - internal, reference purposes. - 5. EXPORT RESTRICTIONS. The software is subject to United States - export laws and regulations. You must comply with all domestic and - international export laws and regulations that apply to the - software. These laws include restrictions on destinations, end - users and end use. For additional information, see - www.microsoft.com/exporting. - 6. SUPPORT SERVICES. Because this software is “as is,” we may not - provide support services for it. - 7. ENTIRE AGREEMENT. This agreement, and the terms for supplements, - updates, Internet-based services and support services that you use, - are the entire agreement for the software and support services. - 8. APPLICABLE LAW. - - a. United States. If you acquired the software in the United States, - Washington state law governs the interpretation of this agreement - and applies to claims for breach of it, regardless of conflict of - laws principles. The laws of the state where you live govern all - other claims, including claims under state consumer protection - laws, unfair competition laws, and in tort. - b. Outside the United States. If you acquired the software in any - other country, the laws of that country apply. - - 9. LEGAL EFFECT. This agreement describes certain legal rights. You - may have other rights under the laws of your country. You may also - have rights with respect to the party from whom you acquired the - software. This agreement does not change your rights under the laws - of your country if the laws of your country do not permit it to do - so. - 10. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR - THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, - GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS - UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE - EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE - IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE AND NON-INFRINGEMENT. - 11. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN - RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO - U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING - CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL - DAMAGES. - - This limitation applies to - * anything related to the software, services, content (including - code) on third party Internet sites, or third party programs; and - * claims for breach of contract, breach of warranty, guarantee or - condition, strict liability, negligence, or other tort to the - extent permitted by applicable law. - - It also applies even if Microsoft knew or should have known about the - possibility of the damages. The above limitation or exclusion may not - apply to you because your country may not allow the exclusion or - limitation of incidental, consequential or other damages. - -Mozilla - - The following software may be included in this product: Mozilla, - Mozilla Address Book, NP SDK. Use of any of this software is governed - by the terms of the license below: - - See MPL 1.1 below - -MySQL Connector/C++ - - The following software may be included in this product: - MySQL Connector/C++. Use of any of this software is governed by the - terms of the license below: - - Copyright 2007-2008 MySQL AB, 2008-2009 Sun Microsystems Inc. - - See GPL Version 2 below - -MyThes - - The following software may be included in this product: MyThes. Use of - any of this software is governed by the terms of the license below: - - Copyright 2003 Kevin B. Hendricks, Stratford, Ontario, Canada And - Contributors. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistribution of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. All modifications to the source code must be clearly marked as such. - Binary redistribution based on modified source code must be clearly - marked as modified versions in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS ``AS - IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEVIN B. HENDRICKS - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -neon - - The following software may be included in this product: neon. Use of - any of this software is governed by the terms of the license below: - - neon is Copyright (C) 1999-2007 Joe Orton - Portions are: - Copyright (C) 1999-2000 Tommi Komulainen - Copyright (C) 1999-2000 Peter Boos - Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. - Copyright (C) 2004 Aleix Conchillo Flaque - Copyright (C) 2004 Jiang Lei - Copyright (C) 2004-2005 Vladimir Berezniker @ - http://public.xdi.org/=vmpn - - See LGPL Version 2.1 below - -Network Security Services (NSS) - - The following software may be included in this product: Network - Security Services (NSS). Use of any of this software is governed by the - terms of the license below: - - See MPL 1.1 below - -OpenLDAP - - The following software may be included in this product: OpenLDAP. Use - of any of this software is governed by the terms of the license below: - - The OpenLDAP Public License - - Version 2.8, 17 August 2003 - - Redistribution and use of this software and associated documentation - ("Software"), with or without modification, are permitted provided that - the following conditions are met: - 1. Redistributions in source form must retain copyright statements and - notices, - 2. Redistributions in binary form must reproduce applicable copyright - statements and notices, this list of conditions, and the following - disclaimer in the documentation and/or other materials provided - with the distribution, and - 3. Redistributions must contain a verbatim copy of this document. - - The OpenLDAP Foundation may revise this license from time to time. Each - revision is distinguished by a version number. You may use this - Software under terms of this license revision or under the terms of any - subsequent revision of the license. - - THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS - CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - NO EVENT SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE - AUTHOR(S) OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - The names of the authors and copyright holders must not be used in - advertising or otherwise to promote the sale, use or other dealing in - this Software without specific, written prior permission. Title to - copyright in this Software shall at all times remain with copyright - holders. - - OpenLDAP is a registered trademark of the OpenLDAP Foundation. - - Copyright 1999-2003 The OpenLDAP Foundation, Redwood City, California, - USA. All Rights Reserved. Permission to copy and distribute verbatim - copies of this document is granted. - -OpenSSL - - The following software may be included in this product: OpenSSL. Use of - any of this software is governed by the terms of the license below: - - The OpenSSL toolkit stays under a dual license, i.e. both the - conditions of the OpenSSL License and the original SSLeay license apply - to the toolkit. - - See below for the actual license texts. Actually both licenses are - BSD-style Open Source licenses. In case of any license issues related - to OpenSSL please contact openssl-core@openssl.org. - - OpenSSL License - - Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - 1. Redistribution of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: "This product - includes software developed by the OpenSSL Project for use in the - OpenSSL Toolkit. (http://www.openssl.org/)" - 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used - to endorse or promote products derived from this software without - prior written permission. For written permission, please contact - openssl-core@openssl.org. - 5. Products derived from this software may not be called "OpenSSL" nor - may "OpenSSL" appear in their names without prior written - permission of the OpenSSL Project. - 6. Redistribution of any form whatsoever must retain the following - acknowledgment: "This product includes software developed by the - OpenSSL Project for use in the OpenSSL Toolkit - (http://www.openssl.org/)" - - THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This product includes cryptographic software written by Eric Young - (eay@cryptsoft.com). This product includes software written by Tim - Hudson (tjh@cryptsoft.com). - - Original SSLeay License - - Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights - reserved. - - This package is an SSL implementation written by Eric Young - (eay@cryptsoft.com). - The implementation was written so as to conform with Netscapes SSL. - - This library is free for commercial and non-commercial use as long as - the following conditions are aheared to. The following conditions apply - to all code found in this distribution, be it the RC4, RSA, lhash, DES, - etc., code; not just the SSL code. The SSL documentation included with - this distribution is covered by the same copyright terms except that - the holder is Tim Hudson (tjh@cryptsoft.com). - - Copyright remains Eric Young's, and as such any Copyright notices in - the code are not to be removed. If this package is used in a product, - Eric Young should be given attribution as the author of the parts of - the library used. This can be in the form of a textual message at - program startup or in documentation (online or textual) provided with - the package. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - 1. Redistribution of source code must retain the copyright notice, - this list of conditions and the following disclaimer. - 2. Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgment: "This product - includes cryptographic software written by Eric Young - (eay@cryptsoft.com)" The word 'cryptographic' can be left out if - the routines from the library being used are not cryptographic - related :-). - 4. If you include any Windows specific code (or a derivative thereof) - from the apps directory (application code) you must include an - acknowledgment: "This product includes software written by Tim - Hudson (tjh@cryptsoft.com)" - - THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - The license and distribution terms for any publicly available version - or derivative of this code cannot be changed. i.e. this code cannot - simply be copied and put under another distribution license [including - the GNU Public License.] - -Pentaho Reporting Flow Engine - - The following software may be included in this product: Pentaho - Reporting Flow Engine (including core, flow-engine, libbase, libfonts, - libformula, liblayout, libloader, librepository, libserializer, and - libxml). Use of any of this software is governed by the terms of the - license below: - - See LGPL Version 2.1 below - -Pixman - - The following software may be included in this product: Pixman - (libpixman). Use of any of this software is governed by the terms of - the license below: - - The following is the MIT license, agreed upon by most contributors. - - Copyright holders of new code should use this license statement where - possible. They may also add themselves to the list below. - - Copyright 1987, 1988, 1989, 1998 The Open Group - Copyright 1987, 1988, 1989 Digital Equipment Corporation - Copyright 1999, 2004, 2008 Keith Packard - Copyright 2000 SuSE, Inc. - Copyright 2000 Keith Packard, member of The XFree86 Project, Inc. - Copyright 2004, 2005, 2007, 2008, 2009, 2010 Red Hat, Inc. - Copyright 2004 Nicholas Miell - Copyright 2005 Lars Knoll & Zack Rusin, Trolltech - Copyright 2005 Trolltech AS - Copyright 2007 Luca Barbato - Copyright 2008 Aaron Plattner, NVIDIA Corporation - Copyright 2008 Rodrigo Kumpera - Copyright 2008 André Tupinambá - Copyright 2008 Mozilla Corporation - Copyright 2008 Frederic Plourde - Copyright 2009, Oracle and/or its affiliates. All rights reserved. - Copyright 2009, 2010 Nokia Corporation - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: The above copyright notice and this - permission notice (including the next paragraph) shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -poppler - - The following software may be included in this product: poppler. Use of - any of this software is governed by the terms of the license below: - - See GPL Version 2 below - -PostgreSQL - - The following software may be included in this product: PostgreSQL. Use - of any of this software is governed by the terms of the license below: - - PostgreSQL is released under the PostgreSQL License, a liberal Open - Source license, similar to the BSD or MIT licenses. - - PostgreSQL Database Management System - (formerly known as Postgres, then as Postgres95) - - Portions Copyright (c) 1996-2012, The PostgreSQL Global Development - Group - - Portions Copyright (c) 1994, The Regents of the University of - California - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose, without fee, and without a written - agreement is hereby granted, provided that the above copyright notice - and this paragraph and the following two paragraphs appear in all - copies. - - IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY - FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, - INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS - DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. - - THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE - PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF - CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, - ENHANCEMENTS, OR MODIFICATIONS. - -Python - - The following software may be included in this product: Python. Use of - any of this software is governed by the terms of the license below: - - PSF LICENSE AGREEMENT FOR PYTHON 2.3 - - 1. This LICENSE AGREEMENT is between the Python Software Foundation - ("PSF"), and the Individual or Organization ("Licensee") accessing and - otherwise using Python 2.3 software in source or binary form and its - associated documentation. - - 2. Subject to the terms and conditions of this License Agreement, PSF - hereby grants Licensee a nonexclusive, royalty-free, world-wide license - to reproduce, analyze, test, perform and/or display publicly, prepare - derivative works, distribute, and otherwise use Python 2.3 alone or in - any derivative version, provided, however, that PSF's License Agreement - and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, - 2004 Python Software Foundation; All Rights Reserved" are retained in - Python 2.3 alone or in any derivative version prepared by Licensee. - - 3. In the event Licensee prepares a derivative work that is based on or - incorporates Python 2.3 or any part thereof, and wants to make the - derivative work available to others as provided herein, then Licensee - hereby agrees to include in any such work a brief summary of the - changes made to Python 2.3. - - 4. PSF is making Python 2.3 available to Licensee on an "AS IS" basis. - PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY - OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY - REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY - PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT INFRINGE ANY - THIRD PARTY RIGHTS. - - 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 2.3 - FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A - RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, OR - ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - - 6. This License Agreement will automatically terminate upon a material - breach of its terms and conditions. - - 7. Nothing in this License Agreement shall be deemed to create any - relationship of agency, partnership, or joint venture between PSF and - Licensee. This License Agreement does not grant permission to use PSF - trademarks or trade name in a trademark sense to endorse or promote - products or services of Licensee, or any third party. - - 8. By copying, installing or otherwise using Python 2.3, Licensee - agrees to be bound by the terms and conditions of this License - Agreement. - - BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 - - BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 - - 1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an - office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the - Individual or Organization ("Licensee") accessing and otherwise using - this software in source or binary form and its associated documentation - ("the Software"). - - 2. Subject to the terms and conditions of this BeOpen Python License - Agreement, BeOpen hereby grants Licensee a non-exclusive, royalty-free, - world-wide license to reproduce, analyze, test, perform and/or display - publicly, prepare derivative works, distribute, and otherwise use the - Software alone or in any derivative version, provided, however, that - the BeOpen Python License is retained in the Software, alone or in any - derivative version prepared by Licensee. - - 3. BeOpen is making the Software available to Licensee on an "AS IS" - basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR - IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND - DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS - FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT - INFRINGE ANY THIRD PARTY RIGHTS. - - 4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE - SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS - AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY - DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - - 5. This License Agreement will automatically terminate upon a material - breach of its terms and conditions. - - 6. This License Agreement shall be governed by and interpreted in all - respects by the law of the State of California, excluding conflict of - law provisions. Nothing in this License Agreement shall be deemed to - create any relationship of agency, partnership, or joint venture - between BeOpen and Licensee. This License Agreement does not grant - permission to use BeOpen trademarks or trade names in a trademark sense - to endorse or promote products or services of Licensee, or any third - party. As an exception, the "BeOpen Python" logos available at - http://www.pythonlabs.com/logos.html may be used according to the - permissions granted on that web page. - - 7. By copying, installing or otherwise using the software, Licensee - agrees to be bound by the terms and conditions of this License - Agreement. - - CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 - - 1. This LICENSE AGREEMENT is between the Corporation for National - Research Initiatives, having an office at 1895 Preston White Drive, - Reston, VA 20191 ("CNRI"), and the Individual or Organization - ("Licensee") accessing and otherwise using Python 1.6.1 software in - source or binary form and its associated documentation. - - 2. Subject to the terms and conditions of this License Agreement, CNRI - hereby grants Licensee a nonexclusive, royalty-free, world-wide license - to reproduce, analyze, test, perform and/or display publicly, prepare - derivative works, distribute, and otherwise use Python 1.6.1 alone or - in any derivative version, provided, however, that CNRI's License - Agreement and CNRI's notice of copyright, i.e., "Copyright (c) - 1995-2001 Corporation for National Research Initiatives; All Rights - Reserved" are retained in Python 1.6.1 alone or in any derivative - version prepared by Licensee. Alternately, in lieu of CNRI's License - Agreement, Licensee may substitute the following text (omitting the - quotes): "Python 1.6.1 is made available subject to the terms and - conditions in CNRI's License Agreement. This Agreement together with - Python 1.6.1 may be located on the Internet using the following unique, - persistent identifier (known as a handle): 1895.22/1013. This Agreement - may also be obtained from a proxy server on the Internet using the - following URL: http://hdl.handle.net/1895.22/1013". - - 3. In the event Licensee prepares a derivative work that is based on or - incorporates Python 1.6.1 or any part thereof, and wants to make the - derivative work available to others as provided herein, then Licensee - hereby agrees to include in any such work a brief summary of the - changes made to Python 1.6.1. - - 4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" - basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. - BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND DISCLAIMS ANY - REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY - PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT INFRINGE - ANY THIRD PARTY RIGHTS. - - 5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON - 1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS - A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, - OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - - 6. This License Agreement will automatically terminate upon a material - breach of its terms and conditions. - - 7. This License Agreement shall be governed by the federal intellectual - property law of the United States, including without limitation the - federal copyright law, and, to the extent such U.S. federal law does - not apply, by the law of the Commonwealth of Virginia, excluding - Virginia's conflict of law provisions. Notwithstanding the foregoing, - with regard to derivative works based on Python 1.6.1 that incorporate - non-separable material that was previously distributed under the GNU - General Public License (GPL), the law of the Commonwealth of Virginia - shall govern this License Agreement only as to issues arising under or - with respect to Paragraphs 4, 5, and 7 of this License Agreement. - Nothing in this License Agreement shall be deemed to create any - relationship of agency, partnership, or joint venture between CNRI and - Licensee. This License Agreement does not grant permission to use CNRI - trademarks or trade name in a trademark sense to endorse or promote - products or services of Licensee, or any third party. - - 8. By clicking on the "ACCEPT" button where indicated, or by copying, - installing or otherwise using Python 1.6.1, Licensee agrees to be bound - by the terms and conditions of this License Agreement. - - ACCEPT - - CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 - - Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, - The Netherlands. All rights reserved. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose and without fee is hereby granted, - provided that the above copyright notice appear in all copies and that - both that copyright notice and this permission notice appear in - supporting documentation, and that the name of Stichting Mathematisch - Centrum or CWI not be used in advertising or publicity pertaining to - distribution of the software without specific, written prior - permission. - - STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO - THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR - ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Raptor RDF Parser Library - - The following software may be included in this product: Raptor RDF - Parser Library. Use of any of this software is governed by the terms of - the license below: - - Copyright (C) 2000-2008 David Beckett - Copyright (C) 2000-2005 University of Bristol. All Rights - Reserved. - - All the licenses below are alternatives and if you select one license, - that one alone applies. - - See LGPL Version 2.1 below - - See Apache License Version 2.0 below - -Rasqal RDF Query Library - - The following software may be included in this product: Rasqal RDF - Query Library. Use of any of this software is governed by the terms of - the license below: - - Copyright (C) 2000-2008 David Beckett - Copyright (C) 2000-2005 University of Bristol. All Rights - Reserved. - - All the licenses below are alternatives and if you select one license, - that one alone applies. - - See LGPL Version 2.1 below - - See Apache License Version 2.0 below - -Redland RDF Application Framework - - The following software may be included in this product: Redland RDF - Application Framework. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2000-2008 David Beckett - Copyright (C) 2000-2005 University of Bristol. All Rights - Reserved. - - All the licenses below are alternatives and if you select one license, - that one alone applies. - - See LGPL Version 2.1 below - - See Apache License Version 2.0 below - -Remote Control Wrapper - - The following software may be included in this product: Remote Control - Wrapper. Use of any of this software is governed by the terms of the - license below: - - Created by Martin Kahr under a MIT-style license. Copyright (c) - 2006/2007 martinkahr.com. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Rhino - - The following software may be included in this product: Rhino. Use of - any of this software is governed by the terms of the license below: - - See MPL Version 1.1 below - -SANE - - The following software may be included in this product: SANE. Use of - any of this software is governed by the terms of the license below: - - sane - Scanner Access Now Easy. Copyright (C) 1997-1999 David - Mosberger-Tang and Andreas Beck - - This file is part of the SANE package. - - This file is in the public domain. You may use and modify it as you see - fit, as long as this copyright message is included and that there is an - indication as to what modifications have been made (if any). - - SANE 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. - - This file declares SANE application interface. See the SANE standard - for a detailed explanation of the interface. - -STLPort - - The following software may be included in this product:STLport. Use of - any of this software is governed by the terms of the license below: - - License Agreement - - Boris Fomitchev grants Licensee a non-exclusive, non-transferable, - royalty-free license to use STLport and its documentation without fee. - - By downloading, using, or copying STLport or any portion thereof, - Licensee agrees to abide by the intellectual property laws and all - other applicable laws of the United States of America, and to all of - the terms and conditions of this Agreement. - - Licensee shall maintain the following copyright and permission notices - on STLport sources and its documentation unchanged: - - Copyright 1999,2000 Boris Fomitchev - - This material is provided "as is", with absolutely no warranty - expressed or implied. Any use is at your own risk. - - Permission to use or copy this software for any purpose is hereby - granted without fee, provided the above notices are retained on all - copies. Permission to modify the code and to distribute modified code - is granted, provided the above notices are retained, and a notice that - the code was modified is included with the above copyright notice. - - The Licensee may distribute binaries compiled with STLport (whether - original or modified) without any royalties or restrictions. - - The Licensee may distribute original or modified STLport sources, - provided that: - * The conditions indicated in the above permission notice are met; - * The following copyright notices are retained when present, and - conditions provided in accompanying permission notices are met: - - Copyright 1994 Hewlett-Packard Company - - Copyright 1996,97 Silicon Graphics Computer Systems, Inc. - - Copyright 1997 Moscow Center for SPARC Technology. - - Permission to use, copy, modify, distribute and sell this software - and its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appear in all copies and - that both that copyright notice and this permission notice appear in - supporting documentation. Hewlett-Packard Company makes no - representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied warranty. - - Permission to use, copy, modify, distribute and sell this software - and its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appear in all copies and - that both that copyright notice and this permission notice appear in - supporting documentation. Silicon Graphics makes no representations - about the suitability of this software for any purpose. It is - provided "as is" without express or implied warranty. - - Permission to use, copy, modify, distribute and sell this software - and its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appear in all copies and - that both that copyright notice and this permission notice appear in - supporting documentation. Moscow Center for SPARC Technology makes - no representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied warranty. - -TWAIN - - The following software may be included in this product: TWAIN. Use of - any of this software is governed by the terms of the license below: - - The TWAIN License - - The TWAIN Working Group grants customer ("Customer") the worldwide, - royalty-free, non-exclusive license to reproduce and distribute the - software and documentation of the TWAIN toolkit ("TWAIN Toolkit"). The - TWAIN Toolkit was designed to be used by third parties to assist them - in becoming compliant with the TWAIN standard, but it has not been - developed to the standards of a commercial product. Consequently, the - TWAIN toolkit is provided AS IS without any warranty. THE TWAIN Working - Group disclaims all warranties in the TWAIN toolkit whether implied, - express or statutory, including, without limitation, the implied - warranties of merchantability, non infringement of third party rights - and fitness for a particular purpose. The TWAIN Working Group disclaims - all liability for damages, whether direct, indirect, special, - incidental, or consequential, arising from the reproduction, - distribution, modification, or other use of the TWAIN Toolkit. - - As a condition of this license, Customer agrees to include in software - programs based in whole or in part on the TWAIN Toolkit the following - provisions in (i) the header or similar file in such software and (ii) - prominently in its documentation and to require its sublicensees to - include these provisions in similar locations: The TWAIN Toolkit is - distributed as is. The developer and distributors of the TWAIN Toolkit - expressly disclaim all implied, express or statutory warranties - including, without limitation, the implied warranties of - merchantability, non infringement of third party rights and fitness for - a particular purpose. Neither the developers nor the distributors will - be liable for damages, whether direct, indirect, special, incidental, - or consequential, as a result of the reproduction, modification, - distribution or other use of the TWAIN Toolkit. - -Unicode CLDR data repository - - The following software may be included in this product: Unicode's CLDR - data repository. Use of any of this software is governed by the terms - of the license below: - - Copyright 1991-2005 Unicode, Inc. All rights reserved. Distributed - under the Terms of Use in http://www.unicode.org/copyright.html. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of the Unicode data files and any associated documentation (the - "Data Files") or Unicode software and any associated documentation (the - "Software") to deal in the Data Files or Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, and/or sell copies of the Data Files or Software, - and to permit persons to whom the Data Files or Software are furnished - to do so, provided that (a) the above copyright notice(s) and this - permission notice appear with all copies of the Data Files or Software, - (b) both the above copyright notice(s) and this permission notice - appear in associated documentation, and (c) there is clear notice in - each modified Data File or in the Software as well as in the - documentation associated with the Data File(s) or Software that the - data or software has been modified. - - THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF - ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR - ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR - SOFTWARE. - - Except as contained in this notice, the name of a copyright holder - shall not be used in advertising or otherwise to promote the sale, use - or other dealings in these Data Files or Software without prior written - authorization of the copyright holder. - -UnixODBC - - The following software may be included in this product: unixODBC. Use - of any of this software is governed by the terms of the license below: - - See LGPL Version 2.1 below - -vigra - - The following software may be included in this product: vigra. Use of - any of this software is governed by the terms of the license below: - - The VIGRA Artistic License - - (modeled after the Perl Artistic License) - - Preamble - - The intent of this document is to state the conditions under which - VIGRA may be copied, such that the author maintains some semblance of - artistic control over the development of the library, while giving the - users of the library the right to use and distribute VIGRA in a - more-or-less customary fashion, plus the right to make reasonable - modifications. - - Definitions - - "Copyright Holder" of the VIGRA library is Ullrich Koethe, Cognitive - Systems Group, University of Hamburg, Germany. - - "Library" refers to the collection of files distributed by the - Copyright Holder under the name "VIGRA" (including this LICENSE file - and all accompanying documentation), and derivatives of that collection - of files created through textual modification. - - "Standard Version" refers to the Library if it has not been modified, - or has been modified in accordance with the wishes of the Copyright - Holder as specified below. - - "You" is you, if you're thinking about using, copying, modifying or - distributing this Library. - - "Freely Available" means that no fee is charged for the item. It also - means that recipients of the item may redistribute it under the same - conditions they received it. - - "Reasonable copying fee" is whatever you can justify on the basis of - media cost, duplication charges, time of people involved, and so on. - (You will not be required to justify it to the Copyright Holder, but - only to the computing community at large as a market that must bear the - fee.) - - License terms - - 1. You may make and give away verbatim copies of the Standard Version - of this Library without restriction, provided that you duplicate all of - the original copyright notices, this license, and associated - disclaimers. - - 2. The Standard Version of the Library may be distributed as part of a - collection of software, provided no more than a reasonable copying fee - is charged for the software collection. - - 3. You may apply bug fixes and portability fixes derived from the - Public Domain or from the Copyright Holder. A Library modified in such - a way shall still be considered the Standard Version. - - 4. You may otherwise modify your copy of this Library in any way, - provided that you insert a prominent notice in each changed file - stating how and when you changed that file, and provided that you do at - least ONE of the following: - - a. place your modifications in the Public Domain or otherwise make them - Freely Available, for example by allowing the Copyright Holder to - include your modifications in the Standard Version of the Library. - - b. use the modified Library only within your corporation or - organization. - - c. make other distribution arrangements with the Copyright Holder. - - 5. You may distribute programs which use this Library in object code or - executable form without restriction. - - 6. Any object code generated as a result of using this Library does not - fall under the copyright of this Library, but belongs to whomever - generated it, and may be sold commercially. - - 7. The name of the Copyright Holder or the Library may not be used to - endorse or promote products derived from this software without specific - prior written permission. - - 8. THIS LIBRARY IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR IMPLIED - WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, - INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND OR ANY - DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER - OR NOT ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR ON ANY THEORY OF - LIABILITY ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - OF THIS LIBRARY. - -W3C Simple API for CSS (SAC) - - The following software may be included in this product: W3C Simple API - for CSS (SAC). Use of any of this software is governed by the terms of - the license below: - - W3C IPR SOFTWARE NOTICE - - Copyright © 2002 World Wide Web Consortium, (Massachusetts Institute of - Technology, Institut National de Recherche en Informatique et en - Automatique, Keio University). All Rights Reserved. - - Note: The original version of the W3C Software Copyright Notice and - License could be found at - http://www.w3.org/Consortium/Legal/copyright-software-19980720 - - Copyright © 1994-2002 World Wide Web Consortium, - (Massachusetts Institute of Technology, Institut National de - Recherche en Informatique et en Automatique, Keio University). All - Rights Reserved. http://www.w3.org/Consortium/Legal/ - - This W3C work (including software, documents, or other related items) - is being provided by the copyright holders under the following license. - By obtaining, using and/or copying this work, you (the licensee) agree - that you have read, understood, and will comply with the following - terms and conditions: - - Permission to use, copy, and modify this software and its - documentation, with or without modification, for any purpose and - without fee or royalty is hereby granted, provided that you include the - following on ALL copies of the software and documentation or portions - thereof, including modifications, that you make: - 1. The full text of this NOTICE in a location viewable to users of the - redistributed or derivative work. - 2. Any pre-existing intellectual property disclaimers, notices, or - terms and conditions. If none exist, a short notice of the - following form (hypertext is preferred, text is permitted) should - be used within the body of any redistributed or derivative code: - "Copyright © 2002 World Wide Web Consortium, - (Massachusetts Institute of Technology, Institut National - de Recherche en Informatique et en Automatique, Keio - University). All Rights Reserved. - http://www.w3.org/Consortium/Legal/" - 3. Notice of any changes or modifications to the W3C files, including - the date changes were made. (We recommend you provide URIs to the - location from which the code is derived.) - - THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT - HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, - INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS - FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR - DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, - TRADEMARKS OR OTHER RIGHTS. - - COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL - OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR - DOCUMENTATION. - - The name and trademarks of copyright holders may NOT be used in - advertising or publicity pertaining to the software without specific, - written prior permission. Title to copyright in this software and any - associated documentation will at all times remain with copyright - holders. - - X11 XRender Extension - - The following software may be included in this product: X11 XRender - Extension. Use of any of this software is governed by the terms of the - license below: - - Copyright © 2000 SuSE, Inc. - - Permission to use, copy, modify, distribute, and sell this software and - its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appear in all copies and that - both that copyright notice and this permission notice appear in - supporting documentation, and that the name of SuSE not be used in - advertising or publicity pertaining to distribution of the software - without specific, written prior permission. SuSE makes no - representations about the suitability of this software for any purpose. - It is provided "as is" without express or implied warranty. - - SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT - SHALL SuSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES - OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - SOFTWARE. - -Xalan - - The following software may be included in this product: Xalan. Use of - any of this software is governed by the terms of the license below: - - See Apache License Version 2.0 below - -XML Security Library (xmlsec) - - The following software may be included in this product: XML Security - Library (xmlsec). Use of any of this software is governed by the terms - of the license below: - - xmlsec, xmlsec-openssl, xmlsec-gnutls libraries - - Copyright (C) 2002-2003 Aleksey Sanin. All Rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FIT- NESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE ALEKSEY SANIN BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- NECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of Aleksey Sanin shall not - be used in advertising or otherwise to promote the sale, use or other - dealings in this Software without prior written authorization from him. - - xmlsec-nss library - - Copyright (C) 2002-2003 Aleksey Sanin. All Rights Reserved. - - Copyright (c) 2003 America Online, Inc. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - Portions of the Software were created using source code and/or APIs - governed by the Mozilla Public License (MPL). The MPL is available at - http://www.mozilla.org/MPL/MPL-1.1.html. The MPL permits such - portions to be distributed with code not governed by MPL, as long as - the requirements of MPL are fulfilled for such portions. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FIT- NESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE ALEKSEY SANIN BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- NECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of Aleksey Sanin shall not - be used in advertising or otherwise to promote the sale, use or other - dealings in this Software without prior written authorization from him. - -XSLT MathML Library - - The following software may be included in this product: XSLT MathML - Library. Use of any of this software is governed by the terms of the - license below: - - Copyright - - Copyright (C) 2001-2003 Vasil Yaroshevich - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - Except as contained in this notice, the names of individuals credited - with contribution to this software shall not be used in advertising or - otherwise to promote the sale, use or other dealings in this Software - without prior written authorization from the individuals in question. - - Any stylesheet derived from this Software that is publicly distributed - will be identified with a different name and the version strings in any - derived Software will be changed so that no possibility of confusion - between the derived package and this Software will exist. - - Warranty - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER CONTRIBUTOR BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH - THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -zlib - - The following software may be included in this product: zlib. Use of - any of this software is governed by the terms of the license below: - - (C) 1995-2002 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software in - a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - - Extensions - - Only third party extensions are listed here whose source code is not in - the LibreOffice tree. - -Barcode - - The following software may be included in this product: Barcode. Use of - any of this software is governed by the terms of the license below: - - Copyright (C) Dániel Darabos and Kálmán Szalai - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - This program 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 - General Public License for more details. - - See GPL Version 3 below - -Convert Text to Number - - The following software may be included in this product: Convert Text to - Number. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2008/2009 - Cor Nouws - - See LGPL Version 3 below - -OpenOffice.org2GoogleDocs - export & import to Google Docs, Zoho, WebDAV - - The following software may be included in this product: - OpenOffice.org2GoogleDocs - export & import to Google Docs, Zoho, - WebDAV. Use of any of this software is governed by the terms of the - license below: - - Copyright © Przemyslaw Rumik - - See LGPL Version 3 below - -Hungarian cross-reference toolbar - - The following software may be included in this product: Hungarian - cross-reference toolbar. Use of any of this software is governed by the - terms of the license below: - - 2009-2010 (c) László Németh, license: GNU LGPL - - See LGPL Version 3 below - -LanguageTool Grammar Checker - - The following software may be included in this product: LanguageTool - Grammar Checker. Use of any of this software is governed by the terms - of the license below: - - See LGPL Version 3 below - -Numbertext - - The following software may be included in this product: Numbertext. Use - of any of this software is governed by the terms of the license below: - - License: LGPL/BSD dual-license, 2009-2010 (C) László Németh (nemeth at - openoffice dot org) - - Numbertext language data (Soros programs): - - LGPL/BSD dual-license, 2009-2010 (C) László Németh et al. (see AUTHORS) - - Serbian modules: - - CC/LGPL/BSD tri-license, 2009 (C) Goran Rakić (grakic at devbase dot - net) - - Note: for full distribution with specifications, IDE and JavaScript - implementation, see http://NUMBERTEXT.org - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - - See LGPL Version 3 below - -SmART Gallery (Diagram) - - The following software may be included in this product: SmART Gallery - (Diagram). Use of any of this software is governed by the terms of the - license below: - - Copyright © Tibor Hornyák and OxygenOffice Professional Team - - http://ooop.sf.net/ - - See LGPL Version 3 below - -Solver for Nonlinear Programming - - The following software may be included in this product: Solver for - Nonlinear Programming. Use of any of this software is governed by the - terms of the license below: - - Copyright 2009 by Sun Microsystems, Inc. - - See LGPL Version 3 below - -Typography Toolbar - - The following software may be included in this product: Typography - Toolbar. Use of any of this software is governed by the terms of the - license below: - - 2009-2010 (c) László Németh, license: GNU LGPL - - See LGPL Version 3 below - -Validator - - The following software may be included in this product: Validator. Use - of any of this software is governed by the terms of the license below: - - Copyright © Tibor Hornyák and OxygenOffice Professional Team - - http://ooop.sf.net/ - - See LGPL Version 3 below - -WatchWindow - - The following software may be included in this product: WatchWindow. - Use of any of this software is governed by the terms of the license - below: - - Copyright © Tibor Hornyák and OxygenOffice Professional Team - - http://ooop.sf.net/ - - See LGPL Version 3 below - - Fonts - -Adobe PostScript® AFM files - - The following software may be included in this product: PostScript® AFM - Files. Use of any of this software is governed by the terms of the - license below: - - Adobe Core 35 AFM Files with 314 Glyph Entries - - This file and the 35 PostScript® AFM files it accompanies may be used, - copied, and distributed for any purpose and without charge, with or - without modification, provided that all copyright notices are retained; - that the AFM files are not distributed without this file; that all - modifications to this file or any of the AFM files are prominently - noted in the modified file(s); and that this paragraph is not modified. - Adobe Systems has no responsibility or obligation to support the use of - the AFM files. - -Caladea - - Copyright (c) 2012 Huerta Tipografia - - This Font Software is licensed under the Apache License, Version 2.0 as - shown below. - - See Apache License Version 2.0 below - -Carlito - - Copyright (c) 2010-2013 by tyPoland Lukasz Dziedzic with Reserved Font - Name "Carlito". - - This Font Software is licensed under the SIL Open Font License, Version - 1.1 as shown below. - - See SIL Open Font License, Version 1.1 below - -Deja Vu - - The following software may be included in this product: Deja Vu fonts. - Use of any of this software is governed by the terms of the license - below: - - Fonts are (c) Bitstream (see below). DejaVu changes are in public - domain. Glyphs imported from Arev fonts are (c) Tavmjong Bah (see - below) - - Bitstream Vera Fonts Copyright - - Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream - Vera is a trademark of Bitstream, Inc. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of the fonts accompanying this license ("Fonts") and associated - documentation files (the "Font Software"), to reproduce and distribute - the Font Software, including without limitation the rights to use, - copy, merge, publish, distribute, and/or sell copies of the Font - Software, and to permit persons to whom the Font Software is furnished - to do so, subject to the following conditions: - - The above copyright and trademark notices and this permission notice - shall be included in all copies of one or more of the Font Software - typefaces. - - The Font Software may be modified, altered, or added to, and in - particular the designs of glyphs or characters in the Fonts may be - modified and additional glyphs or characters may be added to the Fonts, - only if the fonts are renamed to names not containing either the words - "Bitstream" or the word "Vera". - - This License becomes null and void to the extent applicable to Fonts or - Font Software that has been modified and is distributed under the - "Bitstream Vera" names. - - The Font Software may be sold as part of a larger software package but - no copy of one or more of the Font Software typefaces may be sold by - itself. - - THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL - BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, - OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT - SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. - - Except as contained in this notice, the names of Gnome, the Gnome - Foundation, and Bitstream Inc., shall not be used in advertising or - otherwise to promote the sale, use or other dealings in this Font - Software without prior written authorization from the Gnome Foundation - or Bitstream Inc., respectively. For further information, contact: - fonts at gnome dot org. - - Arev Fonts Copyright - - Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a - copy of the fonts accompanying this license ("Fonts") and associated - documentation files (the "Font Software"), to reproduce and distribute - the modifications to the Bitstream Vera Font Software, including - without limitation the rights to use, copy, merge, publish, distribute, - and/or sell copies of the Font Software, and to permit persons to whom - the Font Software is furnished to do so, subject to the following - conditions: - - The above copyright and trademark notices and this permission notice - shall be included in all copies of one or more of the Font Software - typefaces. - - The Font Software may be modified, altered, or added to, and in - particular the designs of glyphs or characters in the Fonts may be - modified and additional glyphs or characters may be added to the Fonts, - only if the fonts are renamed to names not containing either the words - "Tavmjong Bah" or the word "Arev". - - This License becomes null and void to the extent applicable to Fonts or - Font Software that has been modified and is distributed under the - "Tavmjong Bah Arev" names. - - The Font Software may be sold as part of a larger software package but - no copy of one or more of the Font Software typefaces may be sold by - itself. - - THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL - TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL - DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM - OTHER DEALINGS IN THE FONT SOFTWARE. - - Except as contained in this notice, the name of Tavmjong Bah shall not - be used in advertising or otherwise to promote the sale, use or other - dealings in this Font Software without prior written authorization from - Tavmjong Bah. For further information, contact: tavmjong @ free . fr. - -Gentium - - The following software may be included in this product: Gentium fonts. - Use of any of this software is governed by the terms of the license - below: - - Copyright (c) 2003-2008 SIL International (http://www.sil.org/), - with Reserved Font Names "Gentium" and "SIL". - - This Font Software is licensed under the SIL Open Font License, Version - 1.1. This license is copied below, and is also available with a - FAQ at: http://scripts.sil.org/OFL - - See SIL Open Font License, Version 1.1 below - -Liberation - - The following software may be included in this product: Liberation - fonts. Use of any of this software is governed by the terms of the - license below: - - This Font Software is licensed under the SIL Open Font License, Version - 1.1. This license is copied below, and is also available with a - FAQ at: http://scripts.sil.org/OFL - - See SIL Open Font License, Version 1.1 below - - LICENSE AGREEMENT AND LIMITED PRODUCT WARRANTY - LIBERATION FONT SOFTWARE - - This agreement governs the use of the Software and any updates to the - Software, regardless of the delivery mechanism. Subject to the - following terms, Red Hat, Inc. ("Red Hat") grants to the user - ("Client") a license to this work pursuant to the GNU General Public - License v.2 with the exceptions set forth below and such other terms as - are set forth in this End User License Agreement. - - 1. The Software and License Exception. LIBERATION font software (the - "Software") consists of TrueType-OpenType formatted font software for - rendering LIBERATION typefaces in sans-serif, serif, and monospaced - character styles. You are licensed to use, modify, copy, and distribute - the Software pursuant to the GNU General Public License v.2 with the - following exceptions: - - (a) As a special exception, if you create a document which uses this - font, and embed this font or unaltered portions of this font into the - document, this font does not by itself cause the resulting document to - be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the document might be covered - by the GNU General Public License. If you modify this font, you may - extend this exception to your version of the font, but you are not - obligated to do so. If you do not wish to do so, delete this exception - statement from your version. - - (b) As a further exception, any distribution of the object code of the - Software in a physical product must provide you the right to access and - modify the source code for the Software and to reinstall that modified - version of the Software in object code form on the same physical - product on which you received it. - - 2. Intellectual Property Rights. The Software and each of its - components, including the source code, documentation, appearance, - structure and organization are owned by Red Hat and others and are - protected under copyright and other laws. Title to the Software and any - component, or to any copy, modification, or merged portion shall remain - with the aforementioned, subject to the applicable license. The - "LIBERATION" trademark is a trademark of Red Hat, Inc. in the U.S. and - other countries. This agreement does not permit Client to distribute - modified versions of the Software using Red Hat's trademarks. If Client - makes a redistribution of a modified version of the Software, then - Client must modify the files names to remove any reference to the Red - Hat trademarks and must not use the Red Hat trademarks in any way to - reference or promote the modified Software. - - 3. Limited Warranty. To the maximum extent permitted under applicable - law, the Software is provided and licensed "as is" without warranty of - any kind, expressed or implied, including the implied warranties of - merchantability, non-infringement or fitness for a particular purpose. - Red Hat does not warrant that the functions contained in the Software - will meet Client's requirements or that the operation of the Software - will be entirely error free or appear precisely as described in the - accompanying documentation. - - 4. Limitation of Remedies and Liability. To the maximum extent - permitted by applicable law, Red Hat or any Red Hat authorized dealer - will not be liable to Client for any incidental or consequential - damages, including lost profits or lost savings arising out of the use - or inability to use the Software, even if Red Hat or such dealer has - been advised of the possibility of such damages. - - 5. General. If any provision of this agreement is held to be - unenforceable, that shall not affect the enforceability of the - remaining provisions. This agreement shall be governed by the laws of - the State of North Carolina and of the United States, without regard to - any conflict of laws provisions, except that the United Nations - Convention on the International Sale of Goods shall not apply. - - Copyright © 2007 Red Hat, Inc. All rights reserved. LIBERATION is a - trademark of Red Hat, Inc. - -Linux Libertine G and Linux Biolinum G - - This Font Software is Copyright (c) 2003-2006, Philipp H. Poll - (http://linuxlibertine.sf.net/). - All Rights Reserved. - "Linux Libertine" is a Reserved Font Name for this Font Software. - - Graphite extension of the original Linux Libertine font was made by - Laszlo Nemeth under the same license. - Our fonts are free in the sense of the GPL. In short: Changing the font - is allowed as long as the derivative work is published under the same - license again. Pedantics keep claiming that the embedded use of - GPL-fonts in i.e. PDFs requires the free publication of the PDF as - well. This is why our GPL contains the so called "font exception". - - See GPL version 2 below - - As a special exception, if you create a document which uses this font, - and embed this font or unaltered portions of this font into the - document, this font does not by itself cause the resulting document to - be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the document might be covered - by the GNU General Public License. If you modify this font, you may - extend this exception to your version of the font, but you are not - obligated to do so. If you do not wish to do so, delete this exception - statement from your version. - - Additionally our fonts are licensed under the Open Fonts License (see - below). - - This Font Software is licensed under the SIL Open Font License, Version - 1.0. No modification of the license is permitted, only verbatim copy is - allowed. This license is copied below, and is also available with a FAQ - at: http://scripts.sil.org/OFL - - SIL OPEN FONT LICENSE Version 1.0 - 22 November 2005 - - PREAMBLE The goals of the Open Font License (OFL) are to stimulate - worldwide development of cooperative font projects, to support the font - creation efforts of academic and linguistic communities, and to provide - an open framework in which fonts may be shared and improved in - partnership with others. - - The OFL allows the licensed fonts to be used, studied, modified and - redistributed freely as long as they are not sold by themselves. The - fonts, including any derivative works, can be bundled, embedded, - redistributed and sold with any software provided that the font names - of derivative works are changed. The fonts and derivatives, however, - cannot be released under any other type of license. - - DEFINITIONS "Font Software" refers to any and all of the following: - - font files - data files - source code - build scripts - documentation - - "Reserved Font Name" refers to the Font Software name as seen by users - and any other names as specified after the copyright statement. - - "Standard Version" refers to the collection of Font Software components - as distributed by the Copyright Holder. - - "Modified Version" refers to any derivative font software made by - adding to, deleting, or substituting -- in part or in whole -- any of - the components of the Standard Version, by changing formats or by - porting the Font Software to a new environment. - - "Author" refers to any designer, engineer, programmer, technical writer - or other person who contributed to the Font Software. - - PERMISSION & CONDITIONS Permission is hereby granted, free of charge, - to any person obtaining a copy of the Font Software, to use, study, - copy, merge, embed, modify, redistribute, and sell modified and - unmodified copies of the Font Software, subject to the following - conditions: - - 1) Neither the Font Software nor any of its individual components, in - Standard or Modified Versions, may be sold by itself. - - 2) Standard or Modified Versions of the Font Software may be bundled, - redistributed and sold with any software, provided that each copy - contains the above copyright notice and this license. These can be - included either as stand-alone text files, human-readable headers or in - the appropriate machine-readable metadata fields within text or binary - files as long as those fields can be easily viewed by the user. - - 3) No Modified Version of the Font Software may use the Reserved Font - Name(s), in part or in whole, unless explicit written permission is - granted by the Copyright Holder. This restriction applies to all - references stored in the Font Software, such as the font menu name and - other font description fields, which are used to differentiate the font - from others. - - 4) The name(s) of the Copyright Holder or the Author(s) of the Font - Software shall not be used to promote, endorse or advertise any - Modified Version, except to acknowledge the contribution(s) of the - Copyright Holder and the Author(s) or with their explicit written - permission. - - 5) The Font Software, modified or unmodified, in part or in whole, must - be distributed using this license, and may not be distributed under any - other license. - - TERMINATION This license becomes null and void if any of the above - conditions are not met. - - DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF - ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY - WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO - EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, - OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT - SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. - -Open Sans - - The following software may be included in this product: Open Sans - fonts. Use of any of this software is governed by the terms of the - license below: - - See Apache License Version 2.0 below - -PT Serif - - The following software may be included in this product: PT Serif fonts. - Use of any of this software is governed by the terms of the license - below: - - Copyright (c) 2010, ParaType Ltd. - (http://www.paratype.com/public), with Reserved Font Names "PT - Sans", "PT Serif" and "ParaType". - - This Font Software is licensed under the SIL Open Font License, Version - 1.1. This license is copied below, and is also available with a - FAQ at: http://scripts.sil.org/OFL - - See SIL Open Font License, Version 1.1 below - -Source Code Pro - - The following software may be included in this product: Source Code Pro - fonts. Use of any of this software is governed by the terms of the - license below: - - Copyright 2010, 2012 Adobe Systems Incorporated - (http://www.adobe.com/), with Reserved Font Name 'Source'. All - Rights Reserved. Source is a trademark of Adobe Systems Incorporated in - the United States and/or other countries. - - This Font Software is licensed under the SIL Open Font License, Version - 1.1. This license is copied below, and is also available with a - FAQ at: http://scripts.sil.org/OFL - - See SIL Open Font License, Version 1.1 below - -Source Sans Pro - - The following software may be included in this product: Source Sans Pro - fonts. Use of any of this software is governed by the terms of the - license below: - - Copyright 2010, 2012 Adobe Systems Incorporated - (http://www.adobe.com/), with Reserved Font Name 'Source'. All - Rights Reserved. Source is a trademark of Adobe Systems Incorporated in - the United States and/or other countries. - - This Font Software is licensed under the SIL Open Font License, Version - 1.1. This license is copied below, and is also available with a - FAQ at: http://scripts.sil.org/OFL - - See SIL Open Font License, Version 1.1 below - - Dictionaries - -Afrikaans - - Spelling dictionary - - The following software may be included in this product: Afrikaans - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Afrikaans Wordlist - - The Afrikaans wordlist used by MySpell is made up of multiple - wordlists. These are wither in the public domain, are used with the - authors permission or are licensed under the LGPL. The majority of - the words are derived from the Nieuwoudt and Viljoen list. - - The Nieuwoudt list was first published in this form in 1993 by Bernard - A Nieuwoudt. Contact details: origen at icon co za or bnieuwoudt at acm - org - - Copyright (C) 1993, 2003 Bernard A Nieuwoudt relicensed under the - LGPL. - - The Viljoen list is derived from the original Nieuwoudt list and is - used with permission of the author and relicensed under the LGPL. - - Copyright (C) 1998 Danie Viljoen - - MySpell Affix File - - Copyright (C) 2003 Dwayne Bailey under the LGPL based on the - original ispell list by Renier de Vos which was released under the BSD - license. - - Hyphenation patterns - - The following software may be included in this product: Afrikaans - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2005 Friedel Wolff - - This library 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 2.1 of the - License, or (at your option) any later version. - -Arabic - - Spelling dictionary - - The following software may be included in this product: Arabic spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Author of Hunspell-ar, the arabic dictionary for Hunspell - (spellchecker): 2006-2008, Mohamed Kebdani, med.kebdani (at) gmail.com - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - The contents of this software may be used under the terms of the GNU - General Public License Version 2 or later (the "GPL"), or the GNU - Lesser General Public License Version 2.1 or later (the "LGPL") the - Mozilla Public License Version 1.1 or later (the "MPL"). - - Software distributed under these licenses is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - licenses for the specific language governing rights and limitations - under the licenses. - - Thesaurus - - The following software may be included in this product: Arabic - thesaurus. Use of any of this software is governed by the terms of the - license below: - - 2006-2009, Taha Zerrouki, taha_zerrouki at gawab.com - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - The contents of this software may be used under the terms of the GNU - General Public License Version 2 or later (the "GPL"), or the GNU - Lesser General Public License Version 2.1 or later (the "LGPL") the - Mozilla Public License Version 1.1 or later (the "MPL"). - - Software distributed under these licenses is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - licenses for the specific language governing rights and limitations - under the licenses. - -Aragonese - - Spelling dictionary - - The following software may be included in this product: Aragonese - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (c) 2011 Santiago Paricio (spariciogmailcom) - Copyright (c) 2011 Juan Pablo Martínez (jpmartunizares) - - MPL1.1/GPLv3+/LGPLv3+ Tri-licence - - Version 0.2 of the wordlist (an_ES.dic) has been built using free - corpuses have been used as Wikipedia in Aragonese - (http://an.wikipedia.org) and wordlists obtained from Apertium - dictionaries - (http://apertium.svn.sourceforge.net/viewvc/apertium/tags/apertium - -es-an/release-2.0/). - -Belarusian - - Spelling dictionary - - The following software may be included in this product: Belarusian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Creative Commons CC-BY-SA - - Author: Mikalai Udodau - Origin: Словазбор аўтарскі; арфаграфія паводле ТСБМ-2005 - -Bengali - - Spelling dictionary - - The following software may be included in this product: Bengali - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See GNU GPL version 2.0 below - -Breton - - Spelling dictionary - - The following software may be included in this product: Breton spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - LICENSE: "An Drouizig" spelling dictionary: LGPL - -Bulgarian - - Spelling dictionary - - The following software may be included in this product: Bulgarian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See GNU GPL version 2.0 below - - Hyphenation patterns - - The following software may be included in this product: Bulgarian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2001 Anton Zinoviev and Borislav Mitev - Maintained by Radostin Radnev - - See GNU GPL version 2.0 below - - Thesaurus - - The following software may be included in this product: Bulgarian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2001 Radostin Radnev - - See GNU GPL version 2.0 below - -Catalan - - Spelling dictionary - - The following software may be included in this product: Catalan - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2002-2008 Joan Moratinos - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. This program 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 General Public License for more details. You should have - received a copy of the GNU General Public License along with this - program; if not, write to the Free Software Foundation, Inc., 59 Temple - Place - Suite 330, Boston, MA 02111-1307, USA. - - See GPL version 3 below - - Hyphenation patterns - - The following software may be included in this product: Catalan - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - See GPL version 3 below - - Thesaurus - - The following software may be included in this product: Catalan - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2009 Joan Montané --- Softcatalà - - License: GPL/LGPL - - See GPL version 3 below - - See LGPL version 3 below - -Czech - - Thesaurus - - The following software may be included in this product: Czech - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (c) 2002 Pavel Rychly, Pavel Smrz, {pary,smrz}@fi.muni.cz, - NLPlab, Faculty of Informatics, Masaryk University - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this data (the "Data"), to deal in the Data without - restriction, including without limitation the rights to use, copy, - modify, merge, publish, distribute, sublicense, and/or sell copies of - the Data, and to permit persons to whom the Data is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Data. - - THE DATA ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA - OR THE USE OR OTHER DEALINGS IN THE DATA. - -Croatian - - Spelling dictionary - - The following software may be included in this product: Croatian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See LGPL Version 2.1 below - - Hyphenation patterns - - The following software may be included in this product: Croatian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - These patterns were manually converted from TeX hyphenation patterns - using the guide at - http://wiki.services.openoffice.org/wiki/Documentation/SL/Using_Te - X_hyphenation_patterns_in_OpenOffice.org - - Original version: - http://tug.org/svn/texhyphen/trunk/hyph-utf8/tex/generic/hyph-utf8 - /patterns/txt/hyph-hr.pat.txt?revision=416 - - License: OpenOffice.org adaption of this file is licensed under the GNU - LGPL license. - - See LGPL Version 2.1 below - - Original license text: This file is part of hyph-utf8 package and - resulted from semi-manual conversions of hyphenation patterns into - UTF-8 in June 2008. - - Source: hrhyph.tex (1996-04-10) Author: Marinović Igor - - The above mentioned file should become obsolete, and the author of the - original file should preferably modify this file instead. - - Modifications were needed in order to support native UTF-8 engines, but - functionality (hopefully) didn't change in any way, at least not - intentionally. This file is no longer stand-alone; at least for 8-bit - engines you probably want to use loadhyph-foo.tex (which will load this - file) instead. - - Modifications were done by Jonathan Kew, Mojca Miklavec & Arthur - Reutenauer with help & support from: - Karl Berry, who gave us free - hands and all resources - Taco Hoekwater, with useful macros - Hans - Hagen, who did the unicodifisation of patterns already long before and - helped with testing, suggestions and bug reports - Norbert Preining, - who tested & integrated patterns into TeX Live - - However, the "copyright/copyleft" owner of patterns remains the - original author. - - The copyright statement of this file is thus: - - Do with this file whatever needs to be done in future for the sake of - "a better world" as long as you respect the copyright of original file. - If you're the original author of patterns or taking over a new - revolution, please remove all of the TUG comments & credits that we - added here - you are the Queen / the King, we are only the servants. - - If you want to change this file, rather than uploading directly to - CTAN, we would be grateful if you could send it to us - (http://tug.org/tex-hyphen) or ask for credentials for SVN - repository and commit it yourself; we will then upload the whole - "package" to CTAN. - - Before a new "pattern-revolution" starts, please try to follow some - guidelines if possible: - - - \lccode is *forbidden*, and I really mean it - all the patterns - should be in UTF-8 - the only "allowed" TeX commands in this file are: - \patterns, \hyphenation, and if you really cannot do without, also - \input and \message - in particular, please no \catcode or \lccode - changes, they belong to loadhyph-foo.tex, and no \lefthyphenmin and - \righthyphenmin, they have no influence here and belong elsewhere - - \begingroup and/or \endinput is not needed - feel free to do whatever - you want inside comments - - We know that TeX is extremely powerful, but give a stupid parser at - least a chance to read your patterns. - - For more information see http://tug.org/tex-hyphen - -Danish - - Spelling dictionary - - The following software may be included in this product: Danish spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Stavekontrolden - Danish dictionary files for Hunspell - - Version 1.6 - 2010-09-19 - - da_DK.dic, da_DK.aff: © 2010 Foreningen for frit tilgængelige - sprogværktøjer - - http://www.stavekontrolden.dk - - These files are published under the following open source licenses: - * GNU GPL version 2.0 - * GNU LGPL version 2.1 - * Mozilla MPL version 1.1 - - This dictionary is based on data from Det Danske Sprog- og - Litteraturselskab - - (The Danish Society for Language and Literature), - http://www.dsl.dk. - - Hyphenation patterns - - The following software may be included in this product: Danish - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Thesaurus - - The following software may be included in this product: Danish - thesaurus. Use of any of this software is governed by the terms of the - license below: - * GNU GPL version 2.0 - * GNU LGPL version 2.1 - * Mozilla MPL version 1.1 - - Stavekontrolden - Danish thesaurus files for OpenOffice.org 3.0. - - Den Danske Ordbog - Synonymer - - DanNet - leksikalsk-semantisk ordnet fra Det Danske Sprog- og - Litteraturselskab og Center for Sprogteknologi, Københavns Universitet - - © 2007 Foreningen for frit tilgængelige sprogværktøjer - -Dutch - - Spelling dictionary and hyphenation patterns - - The following software may be included in this product: Dutch spelling - dictionary and hyphenation patterns. Use of any of this software is - governed by the terms of the license below: - - 1. Name: Dutch word list for spell checking - OpenTaal - - 2. Version of words list: 2.10G; version of spell checking: 2.10G. - - 3. Requirements: Hunspell 1.2.8 and higher - - 4. Spelling Seal of Dutch Language Union: The OpenTaal list of lemmas - has received the Spelling Seal of Approval from the Dutch Language - Union, the formal Dutch language institute. For more information please - see: http://www.taalunieversum.org/keurmerk/ - - 5. Copyrights: © 2006-2010 OpenTaal, © 2001-2005 Simon Brouwer e.a., © - 1996 Nederlandstalige Tex Gebruikersgroep - - 6. Licenses: OpenTaal aims to create and publish free Dutch language - files. To enable the broadest (re)use the language files are freely - available under the below, liberal licenses at the discretion of the - user. We strongly recommend to read the applicable license before - usage. - - A. BSD (revised version): - - - Full license text: - http://creativecommons.org/licenses/BSD/legalcode - - - Summary: http://creativecommons.org/licenses/BSD/deed.en - - B. Creative Commons, Attribution 3.0 (unported) - - - Full license text: - http://creativecommons.org/licenses/by/3.0/legalcode - - - Summary: http://creativecommons.org/licenses/by/3.0/deed.en - - 7. Support OpenTaal: OpenTaal is a non-profit volunteer project. With - your (small) financial support OpenTaal will further expand its - activities and enhance its professionalism. Your donation is welcome at - account number: 15.62.32.782, BIC: RABONL2U, IBAN: NL88RABO0156232782 - of Stichting OpenTaal / OpenTaal Foundation. In the Netherlands your - donations are tax deductible. OpenTaal Foundation has been designated - by the Dutch Tax Administration as an Institution for General Benefit - (algemeen nut beogende instelling or ANBI). Please see: - http://belastingdienst.nl/anbi/ - - 8. Participate: Everyone is welcome to participate. Please give - feedback, discuss on the mailing list or run Harvester. By contributing - to the project you agree that your contribution is available under free - or/open source licenses. In case you wish, your name will be mentioned - on the website. Your are invited to send us your written request. - - 9. Rights of third parties: OpenTaal respects the rights of third - parties and aims to keep its data freely available. Therefore you may - no use protected sources of third parties, i.e. dictionaries, without - their permission when you contribute to the project. It is permitted to - use the materials of the Dutch Language Union, i.e. their spelling - instruction and word list. In case you believe OpenTaal is violating - your rights, we ask you to send us a written notice as soon as - possible. - - 10.Contact: OpenTaal Foundation, http://www.opentaal.org, - bestuur@opentaal.org - -German - - Spelling dictionary - - The following software may be included in this product: German spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Author: Franz Michael Baumann - - License: GNU GPL Version 2 or GPL Version 3 or OASIS 0.1 - - The "frami"-dictionary contains the complete word list of Björn Jacke's - "igerman98" - - (Version: 2011-03-21) and numerous supplements by Franz Michael Baumann - according to the reform of 2006-08-01. - - OASIS distribution license agreement 0.1 from 2005-11-10 - - Without any modifications this dictionary may be distributed with - programs that support the OASIS Open Document Format for Office - Applications and whose PRIMARY format for saving documents is the Open - Document Format. - - This requires that all licenses and copyright files are also - distributed together with the package the dictionary is shipped with. - - Any modifications of the dictionary files are not allowed for this - agreement, modifications require the use of the GNU GENERAL PUBLIC - LICENSE. - - If you have questions or don't get along with this, send me your - comments/questions/ideas to Bjoern Jacke - - See GPL version 3 below - - See GPL version 2 below - - Hyphenation patterns - - The following software may be included in this product: German - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Authors: Marco Huggenberger / Daniel Naber - - Version: 2011-05-05 (author and license information in source file - added) - - License: GNU LGPL - - See LGPL Version 2.1 below - - Thesaurus - - The following software may be included in this product: German - thesaurus. Use of any of this software is governed by the terms of the - license below: - - OpenThesaurus - Deutscher Thesaurus - Synonyme und Assoziationen - - Version: 2011-05-04 AT - - License: GNU LGPL - - See LGPL Version 2.1 below - -Greek - - Spelling dictionary - - The following software may be included in this product: Greek spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - Hyphenation patterns - - The following software may be included in this product: Greek - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - See LGPL Version 2.1 below - -English (Australia) - - Spelling dictionary - - The following software may be included in this product: English - (Australia) spelling dictionary. Use of any of this software is - governed by the terms of the license below: - - Copyright (C) 2006 Cameron Roy - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - See GPL version 2 below - -English (Canada) - - Spelling dictionary - - The following software may be included in this product: English - (Canada) spelling dictionary. Use of any of this software is governed - by the terms of the license below: -Wordlist en_CA spelling and morphological dictionary for OpenOffice.org -Version 2008-12-18 - -Based on Wordlist Hunspell dictionaries version 2008-12-05 -and Wordlist POS and AGID data created by Kevin Atkinson -and released on http://wordlist.sourceforge.net. - -Other fixes: - -OOo Issue 48060 - add numbers with affixes by COMPOUNDRULE (1st, 111th, 1990s et -c.) -New REP items (better suggestions for accented words and a few mistakes) -OOo Issue 63541 - remove *dessicated, *dessication - -László Németh - -Original license: - -2008-12-05 Release - -README file for en_US and en_CA Hunspell dictionaries - -These dictionaries are created using the speller/make-hunspell-dict -dictionary in SCOWL, SVN revision 74. - -The NOSUGGEST flag was added to certain taboo words. While I made an -honest attempt to flag the strongest taboo words with the NOSUGGEST -flag, I MAKE NO GUARANTEE THAT I FLAGGED EVERY POSSIBLE TABOO WORD. -The list was originally derived from Németh László, however I removed -some words which, while being considered taboo by some dictionaries, -are not really considered swear words in today's society. - -You can find SCOWL and friend at http://wordlist.sourceforge.net/. -Bug reports should go to the Issue Tracker found on the previously -mentioned web site. General discussion should go to the -wordlist-devel at sourceforge net mailing list. - -COPYRIGHT, SOURCES, and CREDITS: - -The en_US and en_CA dictionaries come directly from SCOWL (up to level -60) and is thus under the same copyright of SCOWL. The affix file is -a heavily modified version of the original english.aff file which was -released as part of Geoff Kuenning's Ispell and as such is covered by -his BSD license. Part of SCOWL is also based on Ispell thus the -Ispell copyright is included with the SCOWL copyright. - -The collective work is Copyright 2000-2007 by Kevin Atkinson as well -as any of the copyrights mentioned below: - - Copyright 2000-2007 by Kevin Atkinson - - Permission to use, copy, modify, distribute and sell these word - lists, the associated scripts, the output created from the scripts, - and its documentation for any purpose is hereby granted without fee, - provided that the above copyright notice appears in all copies and - that both that copyright notice and this permission notice appear in - supporting documentation. Kevin Atkinson makes no representations - about the suitability of this array for any purpose. It is provided - "as is" without express or implied warranty. - -Alan Beale also deserves special credit as he has, -in addition to providing the 12Dicts package and being a major -contributor to the ENABLE word list, given me an incredible amount of -feedback and created a number of special lists (those found in the -Supplement) in order to help improve the overall quality of SCOWL. - -The 10 level includes the 1000 most common English words (according to -the Moby (TM) Words II [MWords] package), a subset of the 1000 most -common words on the Internet (again, according to Moby Words II), and -frequently class 16 from Brian Kelk's "UK English Wordlist -with Frequency Classification". - -The MWords package was explicitly placed in the public domain: - - The Moby lexicon project is complete and has - been place into the public domain. Use, sell, - rework, excerpt and use in any way on any platform. - - Placing this material on internal or public servers is - also encouraged. The compiler is not aware of any - export restrictions so freely distribute world-wide. - - You can verify the public domain status by contacting - - Grady Ward - 3449 Martha Ct. - Arcata, CA 95521-4884 - - grady@netcom.com - grady@northcoast.com - -The "UK English Wordlist With Frequency Classification" is also in the -Public Domain: - - Date: Sat, 08 Jul 2000 20:27:21 +0100 - From: Brian Kelk - - > I was wondering what the copyright status of your "UK English - > Wordlist With Frequency Classification" word list as it seems to - > be lacking any copyright notice. - - There were many many sources in total, but any text marked - "copyright" was avoided. Locally-written documentation was one - source. An earlier version of the list resided in a filespace called - PUBLIC on the University mainframe, because it was considered public - domain. - - Date: Tue, 11 Jul 2000 19:31:34 +0100 - - > So are you saying your word list is also in the public domain? - - That is the intention. - -The 20 level includes frequency classes 7-15 from Brian's word list. - -The 35 level includes frequency classes 2-6 and words appearing in at -least 11 of 12 dictionaries as indicated in the 12Dicts package. All -words from the 12Dicts package have had likely inflections added via -my inflection database. - -The 12Dicts package and Supplement is in the Public Domain. - -The WordNet database, which was used in the creation of the -Inflections database, is under the following copyright: - - This software and database is being provided to you, the LICENSEE, - by Princeton University under the following license. By obtaining, - using and/or copying this software and database, you agree that you - have read, understood, and will comply with these terms and - conditions.: - - Permission to use, copy, modify and distribute this software and - database and its documentation for any purpose and without fee or - royalty is hereby granted, provided that you agree to comply with - the following copyright notice and statements, including the - disclaimer, and that the same appear on ALL copies of the software, - database and documentation, including modifications that you make - for internal use or for distribution. - - WordNet 1.6 Copyright 1997 by Princeton University. All rights - reserved. - - THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON - UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR - IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON - UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT- - ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE - LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT INFRINGE ANY - THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. - - The name of Princeton University or Princeton may not be used in - advertising or publicity pertaining to distribution of the software - and/or database. Title to copyright in this software, database and - any associated documentation shall at all times remain with - Princeton University and LICENSEE agrees to preserve same. - -The 40 level includes words from Alan's 3esl list found in version 4.0 -of his 12dicts package. Like his other stuff the 3esl list is also in the -public domain. - -The 50 level includes Brian's frequency class 1, words words appearing -in at least 5 of 12 of the dictionaries as indicated in the 12Dicts -package, and uppercase words in at least 4 of the previous 12 -dictionaries. A decent number of proper names is also included: The -top 1000 male, female, and Last names from the 1990 Census report; a -list of names sent to me by Alan Beale; and a few names that I added -myself. Finally a small list of abbreviations not commonly found in -other word lists is included. - -The name files form the Census report is a government document which I -don't think can be copyrighted. - -The file special-jargon.50 uses common.lst and word.lst from the -"Unofficial Jargon File Word Lists" which is derived from "The Jargon -File". All of which is in the Public Domain. This file also contain -a few extra UNIX terms which are found in the file "unix-terms" in the -special/ directory. - -The 55 level includes words from Alan's 2of4brif list found in version -4.0 of his 12dicts package. Like his other stuff the 2of4brif is also -in the public domain. - -The 60 level includes Brian's frequency class 0 and all words -appearing in at least 2 of the 12 dictionaries as indicated by the -12Dicts package. A large number of names are also included: The 4,946 -female names and the 3,897 male names from the MWords package. - -The 70 level includes the 74,550 common dictionary words and the -21,986 names list from the MWords package The common dictionary words, -like those from the 12Dicts package, have had all likely inflections -added. The 70 level also included the 5desk list from version 4.0 of -the 12Dics package which is the public domain - -The 80 level includes the ENABLE word list, all the lists in the -ENABLE supplement package (except for ABLE), the "UK Advanced Cryptics -Dictionary" (UKACD), the list of signature words in from YAWL package, -and the 10,196 places list from the MWords package. - -The ENABLE package, mainted by M\Cooper , -is in the Public Domain: - - The ENABLE master word list, WORD.LST, is herewith formally released - into the Public Domain. Anyone is free to use it or distribute it in - any manner they see fit. No fee or registration is required for its - use nor are "contributions" solicited (if you feel you absolutely - must contribute something for your own peace of mind, the authors of - the ENABLE list ask that you make a donation on their behalf to your - favorite charity). This word list is our gift to the Scrabble - community, as an alternate to "official" word lists. Game designers - may feel free to incorporate the WORD.LST into their games. Please - mention the source and credit us as originators of the list. Note - that if you, as a game designer, use the WORD.LST in your product, - you may still copyright and protect your product, but you may *not* - legally copyright or in any way restrict redistribution of the - WORD.LST portion of your product. This *may* under law restrict your - rights to restrict your users' rights, but that is only fair. - -UKACD, by J Ross Beresford , is under the -following copyright: - - Copyright (c) J Ross Beresford 1993-1999. All Rights Reserved. - - The following restriction is placed on the use of this publication: - if The UK Advanced Cryptics Dictionary is used in a software package - or redistributed in any form, the copyright notice must be - prominently displayed and the text of this document must be included - verbatim. - - There are no other restrictions: I would like to see the list - distributed as widely as possible. - -The 95 level includes the 354,984 single words and 256,772 compound -words from the MWords package, ABLE.LST from the ENABLE Supplement, -and some additional words found in my part-of-speech database that -were not found anywhere else. - -Accent information was taken from UKACD. - -My VARCON package was used to create the American, British, and -Canadian word list. - -Since the original word lists used used in the VARCON package came -from the Ispell distribution they are under the Ispell copyright: - - Copyright 1993, Geoff Kuenning, Granada Hills, CA - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistribution of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. All modifications to the source code must be clearly marked as - such. Binary redistribution based on modified source code - must be clearly marked as modified versions in the documentation - and/or other materials provided with the distribution. - (clause 4 removed with permission from Geoff Kuenning) - 5. The name of Geoff Kuenning may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS - IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEOFF - KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -English (South Africa) - - Spelling dictionary - - The following software may be included in this product: English (South - Africa) spelling dictionary. Use of any of this software is governed by - the terms of the license below: - - See LGPL Version 2.1 below - -English (United Kingdom) - - Spelling dictionary - - The following software may be included in this product: English (United - Kingdom) spelling dictionary. Use of any of this software is governed - by the terms of the license below: - - See LGPL Version 2.1 below - - Hyphenation patterns - - The following software may be included in this product: English (United - Kingdom) hyphenation patterns. Use of any of this software is governed - by the terms of the license below: - - BSD-style. Unlimited copying, redistribution and modification of this - file is permitted with this copyright and license information. - -English (USA) - - Spelling dictionary - - The following software may be included in this product: English (USA) - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See English (Canada). - - Hyphenation patterns - - The following software may be included in this product: English (USA) - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - BSD-style. Unlimited copying, redistribution and modification of this - file - is permitted with this copyright and license information. - - Thesaurus - - The following software may be included in this product: English (USA) - thesaurus. Use of any of this software is governed by the terms of the - license below: - - WordNet Release 2.1 - - This software and database is being provided to you, the LICENSEE, by - Princeton University under the following license. By obtaining, using - and/or copying this software and database, you agree that you have - read, understood, and will comply with these terms and conditions.: - - Permission to use, copy, modify and distribute this software and - database and its documentation for any purpose and without fee or - royalty is hereby granted, provided that you agree to comply with the - following copyright notice and statements, including the disclaimer, - and that the same appear on ALL copies of the software, database and - documentation, including modifications that you make for internal use - or for distribution. - - WordNet 2.1 Copyright 2005 by Princeton University. All rights - reserved. - - THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON UNIVERSITY - MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF - EXAMPLE, BUT NOT LIMITATION, PRINCETON UNIVERSITY MAKES NO - REPRESENTATIONS OR WARRANTIES OF MERCHANT- ABILITY OR FITNESS FOR ANY - PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE, DATABASE - OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, - TRADEMARKS OR OTHER RIGHTS. - - The name of Princeton University or Princeton may not be used in - advertising or publicity pertaining to distribution of the software - and/or database. Title to copyright in this software, database and any - associated documentation shall at all times remain with Princeton - University and LICENSEE agrees to preserve same. - - English sentence checker for LibreOffice - - The following software may be included in this product: English - sentence checker. Use of any of this software is governed by the terms - of the license below: - - 2011-2012 (c) László Németh, license: MPL 1.1 / GPLv3+ / LGPLv3+ - - See GPL Version 3 below - - See LGPL Version 3 below - - See MPL Version 1.1 below - -Estonian - - Spelling dictionary - - The following software may be included in this product: Estonian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Dictionary is adapted to myspell by Jaak Pruulmann (jjpp@meso.ee, - http://www.meso.ee/~jjpp/speller/ ) on the base of word list - created and shared by IEL (Institute of the Estonian Language, - tarkvara@eki.ee). The original of EKI software license is available at - http://www.eki.ee/eki/licence.html. The work of Jaak Pruulmann is - licensed under LGPL (GNU Lesser General Public License). The copies of - licenses are added to current file. IEL is informed about the use of - this word list. - - Software License Agreement - - Institute of the Estonian Language - - Copyright © Institute of the Estonian Language - - E-mail: tarkvara@eki.ee - - URL: http://www.eki.ee/tarkvara/ - - The present License Agreement gives the user of this Software Product - (hereinafter: Product) the right to use the Product for whatever - purpose (incl. distribution, copying, altering, inclusion in other - software, and selling) on the following conditions: - - The present License Agreement should belong unaltered to each copy ever - made of this Product; - - Neither the Institute of the Estonian Language (hereinafter: IEL) nor - the author(s) of the Product will take responsibility for any - detriment, direct or indirect, possibly ensuing from the application of - the Product; - - The IEL is ready to share the Product with other users as we wish to - advance research on the Estonian language and to promote the use of - Estonian in IT-technology now rapidly developing, yet we refuse to bind - ourselves to any further obligation, which means that the IEL is not - obliged either to warrant the suitability of the Product for a concrete - use, to improve the program, or to provide a more detailed description - of the underlying algorithms. (Which does not mean, though, that we may - not do it.) - - Whenever you use the Product, we request that you inform us by writing - to the e-mail address tarkvara@eki.ee or to street address listed - below. - - Institute of the Estonian Language - - Roosikrantsi 6 - EE-10119 Tallinn - ESTONIA - - E-mail: eki@eki.ee - Phone & Fax: +372-6411443 - - See LGPL Version 2.1 below - - Hyphenation patterns - - The following software may be included in this product: Estonian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Hyphenation file is adapted to OpenOffice.org by Jaak Pruulmann - (jjpp@meso.ee, http://www.meso.ee/~jjpp/speller/) on the base of - the LaTeX hyphenation file created by Enn Saar (saar@aai.ee), who has - signed the JCA (Joint Copyright Agreement) allowing to use his work for - OpenOffice.org. The original file is available at address - http://www.cs.ut.ee/~tqnu/eehyph.tex and in the heading of the - file it is written that this file is licensed under LPPL. The work of - Jaak Pruulmann is licensed under LGPL (GNU Lesser General Public - License). - - See LPPL below - - See LGPL Version 2.1 below - -French - - Spelling dictionary - - The following software may be included in this product: French spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Olivier R. - dicollectefreefr - - Dicollecte: http://www.dicollecte.org/ - - Licenses: - * MPL: Mozilla Public License version 1.1 or higher - * GPL: GNU General Public License version 2.0 or higher - * LGPL: GNU Lesser General Public License version 2.1 or higher - - Hyphenation patterns - - The following software may be included in this product: French - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Origin: Based on the TeX hyphenation tables frhyph.tex (V2.12) - <2002/12/11> - http://mirror.ctan.org/language/hyphenation/frhyph.tex - - The TeX hyphenation tables are released under the LaTeX Project Public - License (LPPL) - - See LPPL below - - License: OpenOffice.org adaptions of this package are licensed under - the GNU Lesser General Public License (LGPL) version 2.1 or higher. - - See LGPL Version 2.1 below - - Author: Conversion author is Paul Pichaureau - - - Based on a previous conversion by Blaise Drayer - - Thesaurus - - The following software may be included in this product: French - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Licence: LGPL: GNU Lesser General Public License version 2.1 or higher. - - See LGPL Version 2.1 below - -Galician - - Spelling dictionary - - The following software may be included in this product: Galician - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - This extension was made by Frco. Javier Rial Rodríguez for Mancomún, - Centro de Referencia e Servizos de Software Libre 2008 - - Spellchecker files (gl_ES.aff, gl_ES.dic) from Mar Castro Pereiro also - developed for Mancomún. - - Distributed under the GPL License. - - See GPL Version 3 below - -Gujarati - - Spelling dictionary - - The following software may be included in this product: Gujarati - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See GPL Version 3 below - -Hebrew - - Spelling dictionary - - The following software may be included in this product: Hebrew spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - This dictionary is Copyright (C) 2000-2009, Nadav Har'El - (nyh@math.technion.ac.il) and Dan Kenigsberg - (danken@cs.technion.ac.il). - - It is licensed under the GNU General Public License (GPL). - - See GPL Version 3 below - -Hindi - - The following software may be included in this product: Hindi spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - GNU Aspell Hindi Word List Package - Copyright © 2005 Swapnil {Hajare, Sant} - - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - Conversion made by Laszlo Nemeth, for demonstration of Hunspell Unicode - support. - - See GPL Version 2 below - -Hungarian - - Spelling dictionary - - The following software may be included in this product: Hungarian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - The contents of this software may be used under the terms of the GNU - General Public License Version 2 or later (the "GPL"), or the GNU - Lesser General Public License Version 2.1 or later (the "LGPL", see - COPYING.LGPL) or (excepting the LGPLed GNU gettext library in the intl/ - directory) the Mozilla Public License Version 1.1 or later (the "MPL", - see COPYING.MPL). - - Software distributed under these licenses is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - licences for the specific language governing rights and limitations - under the licenses. - - 2010 (c) László Németh & Ferenc Godó - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Hungarian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright © Bence Nagy , 2006 - - Original license: GPL v2 - - Patch author: László Németh - - Patch license: MPL/GPL/LGPL - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Thesaurus - - The following software may be included in this product: Hungarian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2009, László Németh - - See GPL Version 2 below - - Hungarian sentence checker for LibreOffice - - The following software may be included in this product: Hungarian - sentence checker. Use of any of this software is governed by the terms - of the license below: - - 2009-2012 (c) László Németh, license: MPL 1.1 / GPLv3+ / LGPLv3+ - - See GPL Version 3 below - - See LGPL Version 3 below - - See MPL Version 1.1 below - -Icelandic - - Spelling dictionary and thesaurus - - The wordlist was developed by Orðabók Háskólans in cooperation with - Reiknistofnun Háskóla Íslands in the early nineties and was released - into the public domain. Further modifications to the wordlist are also - released into the public domain. - The thesaurus and words in the spell checker with additional - morphological information are from the Icelandic Wiktionary Project, - http://is.wiktionary.org. Works released by the Wiktionary project are - under the Creative Commons Attribution-ShareAlike 3.0 Unported license. - You are free: - to Share — to copy, distribute and transmit the work - to Remix — to adapt the work - to make commercial use of the work - Under the following conditions: - Attribution — You must attribute the work in the manner specified by - the author or licensor (but not in any way that suggests that they - endorse you or your use of the work). - Share Alike — If you alter, transform, or build upon this work, you may - distribute the resulting work only under the same or similar license to - this one. - - See CC-BY-SA 3.0 below - -Italian - - Spelling dictionary - - The following software may be included in this product: Italian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2001, 2002 Gianluca Turconi - Copyright (C) 2002, 2003, 2004 Gianluca Turconi and Davide Prina - Copyright (C) 2004, 2005, 2006, 2007 Davide Prina - Copyright (C) 2010 Andrea Pescetti - - See GPL Version 3 below - - Hyphenation patterns - - The following software may be included in this product: Italian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Origin: Based on the TeX hyphenation tables by Claudio Beccari - - Author: conversion author is Giuseppe Bilotta - - - See LGPL Version 3 below - - Thesaurus - - The following software may be included in this product: Italian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2004,2005,2006,2007,2008 Daniela Volta - Copyright (C) 2008 Giovanni Zuliani - Copyright (C) 2006,2007,2008 Davide Prina - Copyright (C) 2010 Andrea Pescetti - - See GPL Version 3 below - -Kurdish - - Spelling dictionary - - The following software may be included in this product: Kurdish - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - (C) Copyright Reimar Heider - - With contributions from Kevin P. Scannell and Rêzan - Tovjîn - - The original word list used for this package was augmented using Kevin - Scannell's web crawling software "An Crúbadán" and then hand-checked by - Ronahi and Tovjîn. - - Originally GPL, relicensed on 04-07-2007 to GPLv3, LGPLv3, MPL 1.1 - - See GPL Version 3 below - - See LGPL Version 3 below - - See MPL Version 1.1 below - -Lao - - Spelling dictionary - - The following software may be included in this product: Lao spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2013 by Brian Eugene Wilson, Robert Martin Campbell - - See LGPL Version 2.1 below - -Latvian - - Spelling dictionary - - The following software may be included in this product: Latvian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2002-2010 Janis Eisaks, jancs@dv.lv, - http://dict.dv.lv - - See LGPL Version 2.1 below - - Hyphenation patterns - - The following software may be included in this product: Latvian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2004-2005 Jânis Vilims, jvilims@apollo.lv - - See LGPL Version 2.1 below - - Thesaurus - - The following software may be included in this product: Latvian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2002-2010 Janis Eisaks, jancs@dv.lv, - http://dict.dv.lv - - See LGPL Version 2.1 below - -Lithuanian - - Spelling dictionary - - The following software may be included in this product: Lithuanian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (c) Albertas Agejevas , 2000, 2001. All - rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - 1. Redistribution of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - 3. Neither the name of the Albertas Agejevas nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY ALBERTAS AGEJEVAS AND CONTRIBUTORS ``AS - IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALBERTAS AGEJEVAS - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Hyphenation patterns - - The following software may be included in this product: Lithuanian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Origin: TeX hyphenation tables by Sigitas Tolusis and Vytas - Statulevicius. The original tables can be found at - http://www.vtex.lt/tex/download/zip/texmf.zip as lthyphen.tex. - - Author: Converted to OOo format by Albertas Agejevas - - License: LaTeX Project Public Licence - - See LPPL below - -Nepali - - Spelling dictionary - - The following software may be included in this product: Nepali spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Compiled by Madan Puraskar Pustakalaya - - See LGPL Version 2.1 below - - Thesaurus - - The following software may be included in this product: Nepali - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Compiled by Madan Puraskar Pustakalaya - - See LGPL Version 2.1 below - -Norwegian - - Spelling dictionary - - The following software may be included in this product: Norwegian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See GPL Version 2 below - - Hyphenation patterns - - The following software may be included in this product: Norwegian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - See GPL Version 2 below - - Thesaurus - - The following software may be included in this product: Norwegian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - See GPL Version 2 below - -Occitan - - Spelling dictionary - - The following software may be included in this product: Occitan - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2006 Bruno GALLART - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - See GPL Version 2 below - -Polish - - Spelling dictionary - - The following software may be included in this product: Polish spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - This dictionary for spell-checking Polish texts is licensed under GPL, - LGPL, MPL (Mozilla Public License) and Creative Commons ShareAlike - licenses (see http://creativecommons.org/licenses/sa/1.0). - - Hyphenation patterns - - The following software may be included in this product: Polish - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Origin: Based on the TeX hyphenation patterns plhyph.tex, version 3.0a, - Wednesday, May 17th, 1995. The original file is in CTAN archives, for - example - here:http://ctan.binkerton.com/ctan.readme.php?filename=language/p - olish/plhyph.tex and is licensed under LPPL. - - License: OpenOffice.org Adaptions of this package are licensed under - the GNU LGPL license. - - Author: conversion and corrects author is Artur Polaczyński - - - See LGPL Version 3 below - - Thesaurus - - The following software may be included in this product: Polish - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (C) 2004-2008 Marcin Miłkowski - - - This product is made available subject to the terms of GNU Lesser - General Public License Version 2.1. - - See LGPL Version 2.1 below - -Portuguese - - Spelling dictionary - - The following software may be included in this product: Portuguese - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2006 Jose Joao de Almeida, Rui Vilela, Alberto Simões - - Dep. Informatica, Universidade do Minho, Portugal - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Portuguese - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Based on the TeX hyphenation tables by Pedro J. de Rezende (Brazilian) - and tuned up by J.Joao Dias Almeida - - Author: conversion author is Paulo Morgado - - See GPL Version 2 below - - Thesaurus - - The following software may be included in this product: Portuguese - thesaurus. Use of any of this software is governed by the terms of the - license below: - - See GPL Version 2 below - -Portuguese (Brazilian) - - Spelling dictionary - - The following software may be included in this product: Portuguese - (Brazilian) spelling dictionary. Use of any of this software is - governed by the terms of the license below: - - This dictionary is under continuous development by Raimundo Moura and - his team. It is icensed under the terms of the GNU Lesser General - Public License version 3 (LGPLv3), as published by the Free Software - Foundation, and Mozilla Public License as published by The Mozilla - Foundation. The credits are available at - http://pt-br.libreoffice.org/projetos/projeto-vero-verificador-ort - ografico/ and you can find new releases at - http://extensions.libreoffice.org - - Copyright (C) 2006 - 2013 by Raimundo Santos Moura - - - See LGPL Version 3 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Portuguese - (Brazilian) hyphenation patterns. Use of any of this software is - governed by the terms of the license below: - - These hyphenation patterns are under continuous development by Raimundo - Moura and his team. It is icensed under the terms of the GNU Lesser - General Public License version 3 (LGPLv3), as published by the Free - Software Foundation, and Mozilla Public License as published by The - Mozilla Foundation. The credits are available at - http://pt-br.libreoffice.org/projetos/projeto-vero-verificador-ort - ografico/ and you can find new releases at - http://extensions.libreoffice.org - - Copyright (C) 2006 - 2013 by Raimundo Santos Moura - - - See LGPL Version 3 below - - See MPL Version 1.1 below - - Portuguese Brazilian sentence checker for LibreOffice - - The following software may be included in this product: Portuguese - (Brazilian) sentence checker. Use of any of this software is governed - by the terms of the license below: - - MPL 1.1 / GPLv3+ / LGPLv3+ - - 2013 © Raimundo Santos Moura - - See GPL Version 3 below - - See LGPL Version 3 below - - See MPL Version 1.1 below - -Romanian - - Spelling dictionary - - The following software may be included in this product: Romanian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - GPL 2.0/LGPL 2.1/MPL 1.1 tri-license. - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Romanian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - GNU General Public License Version 2 - - See GPL Version 2 below - - Thesaurus - - The following software may be included in this product: Romanian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - GNU General Public License Version 2 or later - - See GPL Version 2 below - -Russian - - Spelling dictionary - - The following software may be included in this product: Russian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (c) 1997-2008, Alexander I. Lebedev - - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - * Redistribution of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistribution in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - * Modified versions must be clearly marked as such. - * The name of Alexander I. Lebedev may not be used to endorse or - promote products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Hyphenation patterns - - The following software may be included in this product: Russian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - unknown - - Thesaurus - - The following software may be included in this product: Russian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - License: GNU LGPL - - Author: Mikhail Korolyov - - Origin: Абрамовъ, Н. Словарь русскихъ синонимовъ и сходныхъ по смыслу - выраженiй. Изд. 3-е, доп., Пг., 1911 - - Russian grammar checker - - The following software may be included in this product: Russian grammar - checker. Use of any of this software is governed by the terms of the - license below: - - 2009, 2011, 2012 (c) Yakov Reztsov , license: MPL - 1.1 / GPL / LGPL - -Scottish Gaelic - - Spelling dictionary - - The following software may be included in this product: Scottish Gaelic - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See GPL Version 3 below - -Serbian - - Spelling dictionary - - The following software may be included in this product: Serbian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Serbian spellcheck dictionary (files sr.dic, sr.aff, sh.dic, sh.aff) is - released under disjunctive tri-licence GNU LGPL version 2.1 or later / - MPL version 1.1 or later / GNU GPL version 2 or later giving you the - choice of one of the three sets of free software licensing terms. You - can also use the dictionary under the terms of the Creative Commons - BY-SA 3.0 Unpored licence. - - Hyphenation patterns - - The following software may be included in this product: Serbian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Serbian hyphenation patterns (files hyph_sr.dic and hyph_sh.dic) are - derived from the official TeX patterns for Serbocroatian language - (Cyrillic and Latin) created by Dejan Muhamedagić - version 2.02 released on 22 June 2008. The - format is adopted for usage with Hyphen hyphenation library and is - released again as hyphen-sr under the compatible GNU LGPL version 2.1 - or later. - - See LGPL Version 2.1 below - -Sinhala - - Spelling dictionary - - The following software may be included in this product: Sinhala - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) <2010> Laknath Semage - - See GPL Version 3 below - -Slovak - - Spelling dictionary - - The following software may be included in this product: Slovak spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - Data are released under these licenses (you can select one): - * The GNU General Public License (GPL) Version 2, June 1991 - * GNU Lesser General Public License Version 2.1, February 1999 - * Mozilla Public License 1.1 (MPL 1.1) - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Slovak - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Dictionary is created by converting TeX hyphenation patterns for Slovak - (Author: Jana Chlebíková) with lingucomponent-tools - (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/oo-cs/lingucompone - nt-tools/). - - Original license: LPPL - - See LPPL below - - Thesaurus - - The following software may be included in this product: Slovak - thesaurus. Use of any of this software is governed by the terms of the - license below: - - Copyright (c) 2004-2010 Tibor Bako, yorik (at) szm.sk, Zdenko Podobný, - zposter (at) gmail.com - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this data (the "Data"), to deal in the Data without - restriction, including without limitation the rights to use, copy, - modify, merge, publish, distribute, sublicense, and/or sell copies of - the Data, and to permit persons to whom the Data is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Data. - - THE DATA ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA - OR THE USE OR OTHER DEALINGS IN THE DATA. - -Slovenian - - Spelling dictionary - - The following software may be included in this product: Slovenian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - See GPL Version 2 below - - See LGPL Version 2.1 below - - Hyphenation patterns - - The following software may be included in this product: Slovenian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - See GPL Version 2 below - - See LGPL Version 2.1 below - - Thesaurus - - The following software may be included in this product: Slovenian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - See LGPL Version 2.1 below - -Spanish - - Spelling dictionary - - The following software may be included in this product: Spanish - spelling dictionary. Use of any of this software is governed by the - terms of the licenses (or any later versions) below: - - See GPL version 3 below - - See LGPL Version 3 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Spanish - hyphenation patterns. Use of any of this software is governed by the - terms of the licenses (or any later versions) below: - - See GPL version 3 below - - See LGPL Version 3 below - - See MPL Version 1.1 below - - Thesaurus - - The following software may be included in this product: Spanish - thesaurus. Use of any of this software is governed by the terms of the - license below: - - See LGPL Version 2.1 below - -Swahili - - Spelling dictionary - - The following software may be included in this product: Swahili - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2004 Jason M Githeko - - See LGPL Version 2.1 below - -Swedish - - Spelling dictionary - - The following software may be included in this product: Swedish - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright © 2003-12 Göran Andersson . - - This dictionary is made available subject to the terms of GNU Lesser - General Public License Version 3. - - See LGPL Version 3 below - - Thesaurus - - The following software may be included in this product: Swedish - thesaurus. Use of any of this software is governed by the terms of the - license below: - - This thesaurus was directly converted from Synlex. The synonyms will be - displayed sorted by their voted synonym level. - - The synlex file license, You are free to use this file - with the same license - - Copyright (c) Viggo Kann KTH 2009 - - THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED - OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - - Permission is hereby granted to use or copy this program for any - purpose, provided the above notices are retained on all copies. - Permission to modify the code and to distribute modified code is - granted, provided the above notices are retained, and a notice that the - code was modified is included with the above copyright notice. - -Telugu - - Spelling dictionary - - The following software may be included in this product: Telugu spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - GNU Hunspell Telugu Word List Package adaptation - - Copyright © 2010 adaptation to Hunspell, Arjuna Rao Chavala - Copyright © 2005 Aspell Telugu word list released by IndLinux, Khadir - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - See GPL Version 2 below - - Hyphenation patterns - - The following software may be included in this product: Telugu - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright © 2009 Santhosh Thottingal - - The Telugu Hyphenation Dictionary may be used under the terms of either - the GNU General Public License Version 3 or later (the "GPL"), or the - GNU Lesser General Public License Version 3 or later (the "LGPL") - - See GPL Version 3 below - - See LGPL Version 3 below - -Thai - - Spelling dictionary - - The following software may be included in this product: Thai spelling - dictionary. Use of any of this software is governed by the terms of the - license below: - - See LGPL Version 2.1 below - -Ukrainian - - Spelling dictionary - - The following software may be included in this product: Ukrainian - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 1999 Vladimir Yakovchuk, Oleg Podgurniy - Copyright (C) 2001 Dmytro Kovalyov, Maksym Polyakov, Andriy Rysin - Copyright (C) 2002 Valentyn Solomko, Volodymyr M. Lisivka - Copyright (C) 2005 Andriy Rysin, Eugeniy Meshcheryakov, Dmytro Kovalyov - Copyright (C) 2006-2009 Andriy Rysin - - This dictionary is licensed under GPL 2.0 or above, LGPL 2.1 or above - and MPL (Mozilla Public License) 1.1 licenses. - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - - Hyphenation patterns - - The following software may be included in this product: Ukrainian - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright 1998-2002 Maksym Polyakov. - - License: GNU General Public License version 2 or any later version - - See GPL Version 2 below - - Thesaurus - - The following software may be included in this product: Ukrainian - thesaurus. Use of any of this software is governed by the terms of the - license below: - - This thesaurus is based on: П. М. Деркач, Короткий словник синонімів - української мови, Радянська школа, Київ, 1960 С. Караванський, Пошук - українського слова - - Copyright (C) 2009 Andriy Rysin - - This thesaurus is licensed under GPL, LGPL and MPL (Mozilla Public - License) licenses. - - See GPL Version 2 below - - See LGPL Version 2.1 below - - See MPL Version 1.1 below - -Vietnamese - - Spelling dictionary - - The following software may be included in this product: Vietnamese - spelling dictionary. Use of any of this software is governed by the - terms of the license below: - - Authors: - Ivan Garcia - Nguyễn Xuân Minh - - This spellchecker for OpenOffice was based on the Vietnamese Dictionary - list from Proffessor Hồ Ngọc Đức - - This spellchecker is released with GPLv2 license. - - See GPL Version 2 below - -Zulu - - Hyphenation patterns - - The following software may be included in this product: Zulu - hyphenation patterns. Use of any of this software is governed by the - terms of the license below: - - Copyright (C) 2005, 2007 Friedel Wolff - - See LGPL Version 2.1 below - - Artwork - -KDE Crystal theme icons - - The following software may be included in this product: KDE Crystal - theme icons. Use of any of this software is governed by the terms of - the license below: - - KDE Crystal theme icons. - Copyright (C) 2002 and following years KDE Artists This library 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, version 2.1 of the License. - - See LGPL Version 2.1 below - -Tango theme - - Portions of the Tango theme contain work licenced under the Creative - Commons Attribution-Share Alike 3.0 United States License. To view a - copy of this licence, visit - http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to - Creative Commons, 171 Second Street, Suite 300, San Francisco, - California 94105, USA. - - This artwork is attributed to the "GNOME Project": - http://www.gnome.org - - See CC-BY-SA 3.0 below - - Miscellaneous - -Adobe Printer Description Files - - The following software may be included in this product: Adobe Printer - Description Files. Use of any of this software is governed by the terms - of the license below: - - Copyright 1987-1995 Adobe Systems Incorporated. - - All Rights Reserved. - - Permission is granted for redistribution of this file as long as this - copyright notice is intact and the contents of the file is not altered - in any way from its original form. - - End of Copyright statement - -International Color Consortium sRGB Profiles - - The following software may be included in this product: ICC sRGB - Profiles. Use of any of this software is governed by the terms of the - license below: - - To anyone who acknowledges that the files "sRGB_IEC61966-2-1_noBPC.icc" - and "sRGB_IEC61966-2-1_withBPC.icc" are provided "AS IS" WITH NO - EXPRESS OR IMPLIED WARRANTY, permission to use, copy and distribute - these file for any purpose is hereby granted without fee, provided that - the files are not changed including the HP copyright notice tag, and - that the name of Hewlett-Packard Company shall not be used in - advertising or publicity pertaining to distribution of the software - without specific, written prior permission. Hewlett-Packard Company - makes no representations about the suitability of this software for any - purpose. - - GNU Lesser General Public License Version 3 - - Copyright © 2007 Free Software Foundation, Inc. - - Everyone is permitted to copy and distribute verbatim copies of this - license document, but changing it is not allowed. - - This version of the GNU Lesser General Public License incorporates the - terms and conditions of version 3 of the GNU General Public License, - supplemented by the additional permissions listed below. - -0. Additional Definitions. - - As used herein, “this License” refers to version 3 of the GNU Lesser - General Public License, and the “GNU GPL” refers to version 3 of the - GNU General Public License. - - “The Library” refers to a covered work governed by this License, other - than an Application or a Combined Work as defined below. - - An “Application” is any work that makes use of an interface provided by - the Library, but which is not otherwise based on the Library. Defining - a subclass of a class defined by the Library is deemed a mode of using - an interface provided by the Library. - - A “Combined Work” is a work produced by combining or linking an - Application with the Library. The particular version of the Library - with which the Combined Work was made is also called the “Linked - Version”. - - The “Minimal Corresponding Source” for a Combined Work means the - Corresponding Source for the Combined Work, excluding any source code - for portions of the Combined Work that, considered in isolation, are - based on the Application, and not on the Linked Version. - - The “Corresponding Application Code” for a Combined Work means the - object code and/or source code for the Application, including any data - and utility programs needed for reproducing the Combined Work from the - Application, but excluding the System Libraries of the Combined Work. - -1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License - without being bound by section 3 of the GNU GPL. - -2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a - facility refers to a function or data to be supplied by an Application - that uses the facility (other than as an argument passed when the - facility is invoked), then you may convey a copy of the modified - version: - * a) under this License, provided that you make a good faith effort - to ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - * b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - -3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from a - header file that is part of the Library. You may convey such object - code under terms of your choice, provided that, if the incorporated - material is not limited to numerical parameters, data structure layouts - and accessors, or small macros, inline functions and templates (ten or - fewer lines in length), you do both of the following: - * a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are covered - by this License. - * b) Accompany the object code with a copy of the GNU GPL and this - license document. - -4. Combined Works. - - You may convey a Combined Work under terms of your choice that, taken - together, effectively do not restrict modification of the portions of - the Library contained in the Combined Work and reverse engineering for - debugging such modifications, if you also do each of the following: - * a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - * b) Accompany the Combined Work with a copy of the GNU GPL and this - license document. - * c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among these - notices, as well as a reference directing the user to the copies of - the GNU GPL and this license document. - * d) Do one of the following: - + 0) Convey the Minimal Corresponding Source under the terms of - this License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - + 1) Use a suitable shared library mechanism for linking with - the Library. A suitable mechanism is one that (a) uses at run - time a copy of the Library already present on the user's - computer system, and (b) will operate properly with a modified - version of the Library that is interface-compatible with the - Linked Version. - * e) Provide Installation Information, but only if you would - otherwise be required to provide such information under section 6 - of the GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the Combined - Work produced by recombining or relinking the Application with a - modified version of the Linked Version. (If you use option 4d0, the - Installation Information must accompany the Minimal Corresponding - Source and Corresponding Application Code. If you use option 4d1, - you must provide the Installation Information in the manner - specified by section 6 of the GNU GPL for conveying Corresponding - Source.) - -5. Combined Libraries. - - You may place library facilities that are a work based on the Library - side by side in a single library together with other library facilities - that are not Applications and are not covered by this License, and - convey such a combined library under terms of your choice, if you do - both of the following: - * a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - * b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - -6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions of - the GNU Lesser General Public License from time to time. Such new - versions will be similar in spirit to the present version, but may - differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the Library - as you received it specifies that a certain numbered version of the GNU - Lesser General Public License “or any later version” applies to it, you - have the option of following the terms and conditions either of that - published version or of any later version published by the Free - Software Foundation. If the Library as you received it does not specify - a version number of the GNU Lesser General Public License, you may - choose any version of the GNU Lesser General Public License ever - published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide - whether future versions of the GNU Lesser General Public License shall - apply, that proxy's public statement of acceptance of any version is - permanent authorization for you to choose that version for the Library. - - GNU Lesser General Public License Version 2.1 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the suc -cessor of the GNU Library Public License, version 2, hence the version number 2. -1.] - -Preamble - - The licenses for most software are designed to take away your freedom - to share and change it. By contrast, the GNU General Public Licenses - are intended to guarantee your freedom to share and change free - software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some - specially designated software packages--typically libraries--of the - Free Software Foundation and other authors who decide to use it. You - can use it too, but we suggest you first think carefully about whether - this license or the ordinary General Public License is the better - strategy to use in any particular case, based on the explanations - below. - - When we speak of free software, we are referring to freedom of use, not - price. Our General Public Licenses are designed to make sure that you - have the freedom to distribute copies of free software (and charge for - this service if you wish); that you receive source code or can get it - if you want it; that you can change the software and use pieces of it - in new free programs; and that you are informed that you can do these - things. - - To protect your rights, we need to make restrictions that forbid - distributors to deny you these rights or to ask you to surrender these - rights. These restrictions translate to certain responsibilities for - you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis or - for a fee, you must give the recipients all the rights that we gave - you. You must make sure that they, too, receive or can get the source - code. If you link other code with the library, you must provide - complete object files to the recipients, so that they can relink them - with the library after making changes to the library and recompiling - it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the - library, and (2) we offer you this license, which gives you legal - permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that there - is no warranty for the free library. Also, if the library is modified - by someone else and passed on, the recipients should know that what - they have is not the original version, so that the original author's - reputation will not be affected by problems that might be introduced by - others. - - Finally, software patents pose a constant threat to the existence of - any free program. We wish to make sure that a company cannot - effectively restrict the users of a free program by obtaining a - restrictive license from a patent holder. Therefore, we insist that any - patent license obtained for a version of the library must be consistent - with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the ordinary - GNU General Public License. This license, the GNU Lesser General Public - License, applies to certain designated libraries, and is quite - different from the ordinary General Public License. We use this license - for certain libraries in order to permit linking those libraries into - non-free programs. - - When a program is linked with a library, whether statically or using a - shared library, the combination of the two is legally speaking a - combined work, a derivative of the original library. The ordinary - General Public License therefore permits such linking only if the - entire combination fits its criteria of freedom. The Lesser General - Public License permits more lax criteria for linking other code with - the library. - - We call this license the "Lesser" General Public License because it - does Less to protect the user's freedom than the ordinary General - Public License. It also provides other free software developers Less of - an advantage over competing non-free programs. These disadvantages are - the reason we use the ordinary General Public License for many - libraries. However, the Lesser license provides advantages in certain - special circumstances. - - For example, on rare occasions, there may be a special need to - encourage the widest possible use of a certain library, so that it - becomes a de-facto standard. To achieve this, non-free programs must be - allowed to use the library. A more frequent case is that a free library - does the same job as widely used non-free libraries. In this case, - there is little to gain by limiting the free library to free software - only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free - programs enables a greater number of people to use a large body of free - software. For example, permission to use the GNU C Library in non-free - programs enables many more people to use the whole GNU operating - system, as well as its variant, the GNU/Linux operating system. - - Although the Lesser General Public License is Less protective of the - users' freedom, it does ensure that the user of a program that is - linked with the Library has the freedom and the wherewithal to run that - program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and - modification follow. Pay close attention to the difference between a - "work based on the library" and a "work that uses the library". The - former contains code derived from the library, whereas the latter must - be combined with the library in order to run. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other - program which contains a notice placed by the copyright holder or other - authorized party saying it may be distributed under the terms of this - Lesser General Public License (also called "this License"). Each - licensee is addressed as "you". - - A "library" means a collection of software functions and/or data - prepared so as to be conveniently linked with application programs - (which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work which - has been distributed under these terms. A "work based on the Library" - means either the Library or any derivative work under copyright law: - that is to say, a work containing the Library or a portion of it, - either verbatim or with modifications and/or translated - straightforwardly into another language. (Hereinafter, translation is - included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for - making modifications to it. For a library, complete source code means - all the source code for all modules it contains, plus any associated - interface definition files, plus the scripts used to control - compilation and installation of the library. - - Activities other than copying, distribution and modification are not - covered by this License; they are outside its scope. The act of running - a program using the Library is not restricted, and output from such a - program is covered only if its contents constitute a work based on the - Library (independent of the use of the Library in a tool for writing - it). Whether that is true depends on what the Library does and what the - program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's - complete source code as you receive it, in any medium, provided that - you conspicuously and appropriately publish on each copy an appropriate - copyright notice and disclaimer of warranty; keep intact all the - notices that refer to this License and to the absence of any warranty; - and distribute a copy of this License along with the Library. - - You may charge a fee for the physical act of transferring a copy, and - you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Library or any portion of - it, thus forming a work based on the Library, and copy and distribute - such modifications or work under the terms of Section 1 above, provided - that you also meet all of these conditions: - * a) The modified work must itself be a software library. - * b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - * c) You must cause the whole of the work to be licensed at no charge - to all third parties under the terms of this License. - * d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility is - invoked, then you must make a good faith effort to ensure that, in - the event an application does not supply such function or table, - the facility still operates, and performs whatever part of its - purpose remains meaningful. - (For example, a function in a library to compute square roots has a - purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square root - function must still compute square roots.) - - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the Library, - and can be reasonably considered independent and separate works in - themselves, then this License, and its terms, do not apply to those - sections when you distribute them as separate works. But when you - distribute the same sections as part of a whole which is a work based - on the Library, the distribution of the whole must be on the terms of - this License, whose permissions for other licensees extend to the - entire whole, and thus to each and every part regardless of who wrote - it. - - Thus, it is not the intent of this section to claim rights or contest - your rights to work written entirely by you; rather, the intent is to - exercise the right to control the distribution of derivative or - collective works based on the Library. - - In addition, mere aggregation of another work not based on the Library - with the Library (or with a work based on the Library) on a volume of a - storage or distribution medium does not bring the other work under the - scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public - License instead of this License to a given copy of the Library. To do - this, you must alter all the notices that refer to this License, so - that they refer to the ordinary GNU General Public License, version 2, - instead of to this License. (If a newer version than version 2 of the - ordinary GNU General Public License has appeared, then you can specify - that version instead if you wish.) Do not make any other change in - these notices. - - Once this change is made in a given copy, it is irreversible for that - copy, so the ordinary GNU General Public License applies to all - subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of the - Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or derivative - of it, under Section 2) in object code or executable form under the - terms of Sections 1 and 2 above provided that you accompany it with the - complete corresponding machine-readable source code, which must be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange. - - If distribution of object code is made by offering access to copy from - a designated place, then offering equivalent access to copy the source - code from the same place satisfies the requirement to distribute the - source code, even though third parties are not compelled to copy the - source along with the object code. - - 5. A program that contains no derivative of any portion of the Library, - but is designed to work with the Library by being compiled or linked - with it, is called a "work that uses the Library". Such a work, in - isolation, is not a derivative work of the Library, and therefore falls - outside the scope of this License. - - However, linking a "work that uses the Library" with the Library - creates an executable that is a derivative of the Library (because it - contains portions of the Library), rather than a "work that uses the - library". The executable is therefore covered by this License. Section - 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file - that is part of the Library, the object code for the work may be a - derivative work of the Library even though the source code is not. - Whether this is true is especially significant if the work can be - linked without the Library, or if the work is itself a library. The - threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data structure - layouts and accessors, and small macros and small inline functions (ten - lines or less in length), then the use of the object file is - unrestricted, regardless of whether it is legally a derivative work. - (Executables containing this object code plus portions of the Library - will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may - distribute the object code for the work under the terms of Section 6. - Any executables containing that work also fall under Section 6, whether - or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or link - a "work that uses the Library" with the Library to produce a work - containing portions of the Library, and distribute that work under - terms of your choice, provided that the terms permit modification of - the work for the customer's own use and reverse engineering for - debugging such modifications. - - You must give prominent notice with each copy of the work that the - Library is used in it and that the Library and its use are covered by - this License. You must supply a copy of this License. If the work - during execution displays copyright notices, you must include the - copyright notice for the Library among them, as well as a reference - directing the user to the copy of this License. Also, you must do one - of these things: - * a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood that - the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - * b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - * c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - * d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - * e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the - Library" must include any data and utility programs needed for - reproducing the executable from it. However, as a special exception, - the materials to be distributed need not include anything that is - normally distributed (in either source or binary form) with the major - components (compiler, kernel, and so on) of the operating system on - which the executable runs, unless that component itself accompanies the - executable. - - It may happen that this requirement contradicts the license - restrictions of other proprietary libraries that do not normally - accompany the operating system. Such a contradiction means you cannot - use both them and the Library together in an executable that you - distribute. - - 7. You may place library facilities that are a work based on the - Library side-by-side in a single library together with other library - facilities not covered by this License, and distribute such a combined - library, provided that the separate distribution of the work based on - the Library and of the other library facilities is otherwise permitted, - and provided that you do these two things: - * a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library facilities. - This must be distributed under the terms of the Sections above. - * b) Give prominent notice with the combined library of the fact that - part of it is a work based on the Library, and explaining where to - find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute the - Library except as expressly provided under this License. Any attempt - otherwise to copy, modify, sublicense, link with, or distribute the - Library is void, and will automatically terminate your rights under - this License. However, parties who have received copies, or rights, - from you under this License will not have their licenses terminated so - long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not - signed it. However, nothing else grants you permission to modify or - distribute the Library or its derivative works. These actions are - prohibited by law if you do not accept this License. Therefore, by - modifying or distributing the Library (or any work based on the - Library), you indicate your acceptance of this License to do so, and - all its terms and conditions for copying, distributing or modifying the - Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the - Library), the recipient automatically receives a license from the - original licensor to copy, distribute, link with or modify the Library - subject to these terms and conditions. You may not impose any further - restrictions on the recipients' exercise of the rights granted herein. - You are not responsible for enforcing compliance by third parties with - this License. - - 11. If, as a consequence of a court judgment or allegation of patent - infringement or for any other reason (not limited to patent issues), - conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot - distribute so as to satisfy simultaneously your obligations under this - License and any other pertinent obligations, then as a consequence you - may not distribute the Library at all. For example, if a patent license - would not permit royalty-free redistribution of the Library by all - those who receive copies directly or indirectly through you, then the - only way you could satisfy both it and this License would be to refrain - entirely from distribution of the Library. - - If any portion of this section is held invalid or unenforceable under - any particular circumstance, the balance of the section is intended to - apply, and the section as a whole is intended to apply in other - circumstances. - - It is not the purpose of this section to induce you to infringe any - patents or other property right claims or to contest validity of any - such claims; this section has the sole purpose of protecting the - integrity of the free software distribution system which is implemented - by public license practices. Many people have made generous - contributions to the wide range of software distributed through that - system in reliance on consistent application of that system; it is up - to the author/donor to decide if he or she is willing to distribute - software through any other system and a licensee cannot impose that - choice. - - This section is intended to make thoroughly clear what is believed to - be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in - certain countries either by patents or by copyrighted interfaces, the - original copyright holder who places the Library under this License may - add an explicit geographical distribution limitation excluding those - countries, so that distribution is permitted only in or among countries - not thus excluded. In such case, this License incorporates the - limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new - versions of the Lesser General Public License from time to time. Such - new versions will be similar in spirit to the present version, but may - differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the Library - specifies a version number of this License which applies to it and "any - later version", you have the option of following the terms and - conditions either of that version or of any later version published by - the Free Software Foundation. If the Library does not specify a license - version number, you may choose any version ever published by the Free - Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free - programs whose distribution conditions are incompatible with these, - write to the author to ask for permission. For software which is - copyrighted by the Free Software Foundation, write to the Free Software - Foundation; we sometimes make exceptions for this. Our decision will be - guided by the two goals of preserving the free status of all - derivatives of our free software and of promoting the sharing and reuse - of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO - WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. - EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR - OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, - EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH - YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL - NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY - AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU - FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR - CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF - SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - DAMAGES. - - END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest - possible use to the public, we recommend making it free software that - everyone can redistribute and change. You can do so by permitting - redistribution under these terms (or, alternatively, under the terms of - the ordinary General Public License). - - To apply these terms, attach the following notices to the library. It - is safest to attach them to the start of each source file to most - effectively convey the exclusion of warranty; and each file should have - at least the "copyright" line and a pointer to where the full notice is - found. -one line to give the library's name and an idea of what it does. -Copyright (C) year name of author - -This library 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 2.1 of the License, or (at your option) any later version. - -This library 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 this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - Also add information on how to contact you by electronic and paper - mail. - - You should also get your employer (if you work as a programmer) or your - school, if any, to sign a "copyright disclaimer" for the library, if - necessary. Here is a sample; alter the names: -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice - - That's all there is to it! - - GNU Library General Public License Version 2 - - Version 2, June 1991 -Copyright (C) 1991 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is -numbered 2 because it goes with version 2 of the ordinary GPL.] - -Preamble - - The licenses for most software are designed to take away your freedom - to share and change it. By contrast, the GNU General Public Licenses - are intended to guarantee your freedom to share and change free - software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some - specially designated Free Software Foundation software, and to any - other libraries whose authors decide to use it. You can use it for your - libraries, too. - - When we speak of free software, we are referring to freedom, not price. - Our General Public Licenses are designed to make sure that you have the - freedom to distribute copies of free software (and charge for this - service if you wish), that you receive source code or can get it if you - want it, that you can change the software or use pieces of it in new - free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid anyone - to deny you these rights or to ask you to surrender the rights. These - restrictions translate to certain responsibilities for you if you - distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis or - for a fee, you must give the recipients all the rights that we gave - you. You must make sure that they, too, receive or can get the source - code. If you link a program with the library, you must provide complete - object files to the recipients so that they can relink them with the - library, after making changes to the library and recompiling it. And - you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright the - library, and (2) offer you this license which gives you legal - permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain that - everyone understands that there is no warranty for this free library. - If the library is modified by someone else and passed on, we want its - recipients to know that what they have is not the original version, so - that any problems introduced by others will not reflect on the original - authors' reputations. - - Finally, any free program is threatened constantly by software patents. - We wish to avoid the danger that companies distributing free software - will individually obtain patent licenses, thus in effect transforming - the program into proprietary software. To prevent this, we have made it - clear that any patent must be licensed for everyone's free use or not - licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary - GNU General Public License, which was designed for utility programs. - This license, the GNU Library General Public License, applies to - certain designated libraries. This license is quite different from the - ordinary one; be sure to read it in full, and don't assume that - anything in it is the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that - they blur the distinction we usually make between modifying or adding - to a program and simply using it. Linking a program with a library, - without changing the library, is in some sense simply using the - library, and is analogous to running a utility program or application - program. However, in a textual and legal sense, the linked executable - is a combined work, a derivative of the original library, and the - ordinary General Public License treats it as such. - - Because of this blurred distinction, using the ordinary General Public - License for libraries did not effectively promote software sharing, - because most developers did not use the libraries. We concluded that - weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the - users of those programs of all benefit from the free status of the - libraries themselves. This Library General Public License is intended - to permit developers of non-free programs to use free libraries, while - preserving your freedom as a user of such programs to change the free - libraries that are incorporated in them. (We have not seen how to - achieve this as regards changes in header files, but we have achieved - it as regards changes in the actual functions of the Library.) The hope - is that this will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and - modification follow. Pay close attention to the difference between a - "work based on the library" and a "work that uses the library". The - former contains code derived from the library, while the latter only - works together with the library. - - Note that it is possible for a library to be covered by the ordinary - General Public License rather than by this special one. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which - contains a notice placed by the copyright holder or other authorized - party saying it may be distributed under the terms of this Library - General Public License (also called "this License"). Each licensee is - addressed as "you". - - A "library" means a collection of software functions and/or data - prepared so as to be conveniently linked with application programs - (which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work which - has been distributed under these terms. A "work based on the Library" - means either the Library or any derivative work under copyright law: - that is to say, a work containing the Library or a portion of it, - either verbatim or with modifications and/or translated - straightforwardly into another language. (Hereinafter, translation is - included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for - making modifications to it. For a library, complete source code means - all the source code for all modules it contains, plus any associated - interface definition files, plus the scripts used to control - compilation and installation of the library. - - Activities other than copying, distribution and modification are not - covered by this License; they are outside its scope. The act of running - a program using the Library is not restricted, and output from such a - program is covered only if its contents constitute a work based on the - Library (independent of the use of the Library in a tool for writing - it). Whether that is true depends on what the Library does and what the - program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's - complete source code as you receive it, in any medium, provided that - you conspicuously and appropriately publish on each copy an appropriate - copyright notice and disclaimer of warranty; keep intact all the - notices that refer to this License and to the absence of any warranty; - and distribute a copy of this License along with the Library. - - You may charge a fee for the physical act of transferring a copy, and - you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Library or any portion of - it, thus forming a work based on the Library, and copy and distribute - such modifications or work under the terms of Section 1 above, provided - that you also meet all of these conditions: - * a) The modified work must itself be a software library. - * b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - * c) You must cause the whole of the work to be licensed at no charge - to all third parties under the terms of this License. - * d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility is - invoked, then you must make a good faith effort to ensure that, in - the event an application does not supply such function or table, - the facility still operates, and performs whatever part of its - purpose remains meaningful. - (For example, a function in a library to compute square roots has a - purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square root - function must still compute square roots.) - - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the Library, - and can be reasonably considered independent and separate works in - themselves, then this License, and its terms, do not apply to those - sections when you distribute them as separate works. But when you - distribute the same sections as part of a whole which is a work based - on the Library, the distribution of the whole must be on the terms of - this License, whose permissions for other licensees extend to the - entire whole, and thus to each and every part regardless of who wrote - it. - - Thus, it is not the intent of this section to claim rights or contest - your rights to work written entirely by you; rather, the intent is to - exercise the right to control the distribution of derivative or - collective works based on the Library. - - In addition, mere aggregation of another work not based on the Library - with the Library (or with a work based on the Library) on a volume of a - storage or distribution medium does not bring the other work under the - scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public - License instead of this License to a given copy of the Library. To do - this, you must alter all the notices that refer to this License, so - that they refer to the ordinary GNU General Public License, version 2, - instead of to this License. (If a newer version than version 2 of the - ordinary GNU General Public License has appeared, then you can specify - that version instead if you wish.) Do not make any other change in - these notices. - - Once this change is made in a given copy, it is irreversible for that - copy, so the ordinary GNU General Public License applies to all - subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of the - Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or derivative - of it, under Section 2) in object code or executable form under the - terms of Sections 1 and 2 above provided that you accompany it with the - complete corresponding machine-readable source code, which must be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange. - - If distribution of object code is made by offering access to copy from - a designated place, then offering equivalent access to copy the source - code from the same place satisfies the requirement to distribute the - source code, even though third parties are not compelled to copy the - source along with the object code. - - 5. A program that contains no derivative of any portion of the Library, - but is designed to work with the Library by being compiled or linked - with it, is called a "work that uses the Library". Such a work, in - isolation, is not a derivative work of the Library, and therefore falls - outside the scope of this License. - - However, linking a "work that uses the Library" with the Library - creates an executable that is a derivative of the Library (because it - contains portions of the Library), rather than a "work that uses the - library". The executable is therefore covered by this License. Section - 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file - that is part of the Library, the object code for the work may be a - derivative work of the Library even though the source code is not. - Whether this is true is especially significant if the work can be - linked without the Library, or if the work is itself a library. The - threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data structure - layouts and accessors, and small macros and small inline functions (ten - lines or less in length), then the use of the object file is - unrestricted, regardless of whether it is legally a derivative work. - (Executables containing this object code plus portions of the Library - will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may - distribute the object code for the work under the terms of Section 6. - Any executables containing that work also fall under Section 6, whether - or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or link - a "work that uses the Library" with the Library to produce a work - containing portions of the Library, and distribute that work under - terms of your choice, provided that the terms permit modification of - the work for the customer's own use and reverse engineering for - debugging such modifications. - - You must give prominent notice with each copy of the work that the - Library is used in it and that the Library and its use are covered by - this License. You must supply a copy of this License. If the work - during execution displays copyright notices, you must include the - copyright notice for the Library among them, as well as a reference - directing the user to the copy of this License. Also, you must do one - of these things: - * a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood that - the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - * b) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - * c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - * d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the - Library" must include any data and utility programs needed for - reproducing the executable from it. However, as a special exception, - the source code distributed need not include anything that is normally - distributed (in either source or binary form) with the major components - (compiler, kernel, and so on) of the operating system on which the - executable runs, unless that component itself accompanies the - executable. - - It may happen that this requirement contradicts the license - restrictions of other proprietary libraries that do not normally - accompany the operating system. Such a contradiction means you cannot - use both them and the Library together in an executable that you - distribute. - - 7. You may place library facilities that are a work based on the - Library side-by-side in a single library together with other library - facilities not covered by this License, and distribute such a combined - library, provided that the separate distribution of the work based on - the Library and of the other library facilities is otherwise permitted, - and provided that you do these two things: - * a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library facilities. - This must be distributed under the terms of the Sections above. - * b) Give prominent notice with the combined library of the fact that - part of it is a work based on the Library, and explaining where to - find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute the - Library except as expressly provided under this License. Any attempt - otherwise to copy, modify, sublicense, link with, or distribute the - Library is void, and will automatically terminate your rights under - this License. However, parties who have received copies, or rights, - from you under this License will not have their licenses terminated so - long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not - signed it. However, nothing else grants you permission to modify or - distribute the Library or its derivative works. These actions are - prohibited by law if you do not accept this License. Therefore, by - modifying or distributing the Library (or any work based on the - Library), you indicate your acceptance of this License to do so, and - all its terms and conditions for copying, distributing or modifying the - Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the - Library), the recipient automatically receives a license from the - original licensor to copy, distribute, link with or modify the Library - subject to these terms and conditions. You may not impose any further - restrictions on the recipients' exercise of the rights granted herein. - You are not responsible for enforcing compliance by third parties to - this License. - - 11. If, as a consequence of a court judgment or allegation of patent - infringement or for any other reason (not limited to patent issues), - conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot - distribute so as to satisfy simultaneously your obligations under this - License and any other pertinent obligations, then as a consequence you - may not distribute the Library at all. For example, if a patent license - would not permit royalty-free redistribution of the Library by all - those who receive copies directly or indirectly through you, then the - only way you could satisfy both it and this License would be to refrain - entirely from distribution of the Library. - - If any portion of this section is held invalid or unenforceable under - any particular circumstance, the balance of the section is intended to - apply, and the section as a whole is intended to apply in other - circumstances. - - It is not the purpose of this section to induce you to infringe any - patents or other property right claims or to contest validity of any - such claims; this section has the sole purpose of protecting the - integrity of the free software distribution system which is implemented - by public license practices. Many people have made generous - contributions to the wide range of software distributed through that - system in reliance on consistent application of that system; it is up - to the author/donor to decide if he or she is willing to distribute - software through any other system and a licensee cannot impose that - choice. - - This section is intended to make thoroughly clear what is believed to - be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in - certain countries either by patents or by copyrighted interfaces, the - original copyright holder who places the Library under this License may - add an explicit geographical distribution limitation excluding those - countries, so that distribution is permitted only in or among countries - not thus excluded. In such case, this License incorporates the - limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new - versions of the Library General Public License from time to time. Such - new versions will be similar in spirit to the present version, but may - differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the Library - specifies a version number of this License which applies to it and "any - later version", you have the option of following the terms and - conditions either of that version or of any later version published by - the Free Software Foundation. If the Library does not specify a license - version number, you may choose any version ever published by the Free - Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free - programs whose distribution conditions are incompatible with these, - write to the author to ask for permission. For software which is - copyrighted by the Free Software Foundation, write to the Free Software - Foundation; we sometimes make exceptions for this. Our decision will be - guided by the two goals of preserving the free status of all - derivatives of our free software and of promoting the sharing and reuse - of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO - WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. - EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR - OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, - EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH - YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL - NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY - AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU - FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR - CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF - SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - DAMAGES. - - END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest - possible use to the public, we recommend making it free software that - everyone can redistribute and change. You can do so by permitting - redistribution under these terms (or, alternatively, under the terms of - the ordinary General Public License). - - To apply these terms, attach the following notices to the library. It - is safest to attach them to the start of each source file to most - effectively convey the exclusion of warranty; and each file should have - at least the "copyright" line and a pointer to where the full notice is - found. -one line to give the library's name and an idea of what it does. -Copyright (C) year name of author - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -This library 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the -Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -Boston, MA 02110-1301, USA. - - Also add information on how to contact you by electronic and paper - mail. - - You should also get your employer (if you work as a programmer) or your - school, if any, to sign a "copyright disclaimer" for the library, if - necessary. Here is a sample; alter the names: -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice - - That's all there is to it! - - GNU General Public License Version 3 - - Copyright © 2007 Free Software Foundation, Inc. - - Everyone is permitted to copy and distribute verbatim copies of this - license document, but changing it is not allowed. - -Preamble - - The GNU General Public License is a free, copyleft license for software - and other kinds of works. - - The licenses for most software and other practical works are designed - to take away your freedom to share and change the works. By contrast, - the GNU General Public License is intended to guarantee your freedom to - share and change all versions of a program--to make sure it remains - free software for all its users. We, the Free Software Foundation, use - the GNU General Public License for most of our software; it applies - also to any other work released this way by its authors. You can apply - it to your programs, too. - - When we speak of free software, we are referring to freedom, not price. - Our General Public Licenses are designed to make sure that you have the - freedom to distribute copies of free software (and charge for them if - you wish), that you receive source code or can get it if you want it, - that you can change the software or use pieces of it in new free - programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you - these rights or asking you to surrender the rights. Therefore, you have - certain responsibilities if you distribute copies of the software, or - if you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether gratis - or for a fee, you must pass on to the recipients the same freedoms that - you received. You must make sure that they, too, receive or can get the - source code. And you must show them these terms so they know their - rights. - - Developers that use the GNU GPL protect your rights with two steps: (1) - assert copyright on the software, and (2) offer you this License giving - you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains - that there is no warranty for this free software. For both users' and - authors' sake, the GPL requires that modified versions be marked as - changed, so that their problems will not be attributed erroneously to - authors of previous versions. - - Some devices are designed to deny users access to install or run - modified versions of the software inside them, although the - manufacturer can do so. This is fundamentally incompatible with the aim - of protecting users' freedom to change the software. The systematic - pattern of such abuse occurs in the area of products for individuals to - use, which is precisely where it is most unacceptable. Therefore, we - have designed this version of the GPL to prohibit the practice for - those products. If such problems arise substantially in other domains, - we stand ready to extend this provision to those domains in future - versions of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. - States should not allow patents to restrict development and use of - software on general-purpose computers, but in those that do, we wish to - avoid the special danger that patents applied to a free program could - make it effectively proprietary. To prevent this, the GPL assures that - patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and - modification follow. - -TERMS AND CONDITIONS - - 0. Definitions. - - “This License” refers to version 3 of the GNU General Public License. - - “Copyright” also means copyright-like laws that apply to other kinds of - works, such as semiconductor masks. - - “The Program” refers to any copyrightable work licensed under this - License. Each licensee is addressed as “you”. “Licensees” and - “recipients” may be individuals or organizations. - - To “modify” a work means to copy from or adapt all or part of the work - in a fashion requiring copyright permission, other than the making of - an exact copy. The resulting work is called a “modified version” of the - earlier work or a work “based on” the earlier work. - - A “covered work” means either the unmodified Program or a work based on - the Program. - - To “propagate” a work means to do anything with it that, without - permission, would make you directly or secondarily liable for - infringement under applicable copyright law, except executing it on a - computer or modifying a private copy. Propagation includes copying, - distribution (with or without modification), making available to the - public, and in some countries other activities as well. - - To “convey” a work means any kind of propagation that enables other - parties to make or receive copies. Mere interaction with a user through - a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays “Appropriate Legal Notices” to - the extent that it includes a convenient and prominently visible - feature that (1) displays an appropriate copyright notice, and (2) - tells the user that there is no warranty for the work (except to the - extent that warranties are provided), that licensees may convey the - work under this License, and how to view a copy of this License. If the - interface presents a list of user commands or options, such as a menu, - a prominent item in the list meets this criterion. - - 1. Source Code. - - The “source code” for a work means the preferred form of the work for - making modifications to it. “Object code” means any non-source form of - a work. - - A “Standard Interface” means an interface that either is an official - standard defined by a recognized standards body, or, in the case of - interfaces specified for a particular programming language, one that is - widely used among developers working in that language. - - The “System Libraries” of an executable work include anything, other - than the work as a whole, that (a) is included in the normal form of - packaging a Major Component, but which is not part of that Major - Component, and (b) serves only to enable use of the work with that - Major Component, or to implement a Standard Interface for which an - implementation is available to the public in source code form. A “Major - Component”, in this context, means a major essential component (kernel, - window system, and so on) of the specific operating system (if any) on - which the executable work runs, or a compiler used to produce the work, - or an object code interpreter used to run it. - - The “Corresponding Source” for a work in object code form means all the - source code needed to generate, install, and (for an executable work) - run the object code and to modify the work, including scripts to - control those activities. However, it does not include the work's - System Libraries, or general-purpose tools or generally available free - programs which are used unmodified in performing those activities but - which are not part of the work. For example, Corresponding Source - includes interface definition files associated with source files for - the work, and the source code for shared libraries and dynamically - linked subprograms that the work is specifically designed to require, - such as by intimate data communication or control flow between those - subprograms and other parts of the work. - - The Corresponding Source need not include anything that users can - regenerate automatically from other parts of the Corresponding Source. - - The Corresponding Source for a work in source code form is that same - work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of - copyright on the Program, and are irrevocable provided the stated - conditions are met. This License explicitly affirms your unlimited - permission to run the unmodified Program. The output from running a - covered work is covered by this License only if the output, given its - content, constitutes a covered work. This License acknowledges your - rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not convey, - without conditions so long as your license otherwise remains in force. - You may convey covered works to others for the sole purpose of having - them make modifications exclusively for you, or provide you with - facilities for running those works, provided that you comply with the - terms of this License in conveying all material for which you do not - control copyright. Those thus making or running the covered works for - you must do so exclusively on your behalf, under your direction and - control, on terms that prohibit them from making any copies of your - copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under the - conditions stated below. Sublicensing is not allowed; section 10 makes - it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological - measure under any applicable law fulfilling obligations under article - 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar - laws prohibiting or restricting circumvention of such measures. - - When you convey a covered work, you waive any legal power to forbid - circumvention of technological measures to the extent such - circumvention is effected by exercising rights under this License with - respect to the covered work, and you disclaim any intention to limit - operation or modification of the work as a means of enforcing, against - the work's users, your or third parties' legal rights to forbid - circumvention of technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you - receive it, in any medium, provided that you conspicuously and - appropriately publish on each copy an appropriate copyright notice; - keep intact all notices stating that this License and any - non-permissive terms added in accord with section 7 apply to the code; - keep intact all notices of the absence of any warranty; and give all - recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, and - you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to - produce it from the Program, in the form of source code under the terms - of section 4, provided that you also meet all of these conditions: - * a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - * b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to “keep - intact all notices”. - * c) You must license the entire work, as a whole, under this License - to anyone who comes into possession of a copy. This License will - therefore apply, along with any applicable section 7 additional - terms, to the whole of the work, and all its parts, regardless of - how they are packaged. This License gives no permission to license - the work in any other way, but it does not invalidate such - permission if you have separately received it. - * d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your work - need not make them do so. - - A compilation of a covered work with other separate and independent - works, which are not by their nature extensions of the covered work, - and which are not combined with it such as to form a larger program, in - or on a volume of a storage or distribution medium, is called an - “aggregate” if the compilation and its resulting copyright are not used - to limit the access or legal rights of the compilation's users beyond - what the individual works permit. Inclusion of a covered work in an - aggregate does not cause this License to apply to the other parts of - the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms of - sections 4 and 5, provided that you also convey the machine-readable - Corresponding Source under the terms of this License, in one of these - ways: - * a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium customarily - used for software interchange. - * b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as long - as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the Corresponding Source - from a network server at no charge. - * c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This alternative - is allowed only occasionally and noncommercially, and only if you - received the object code with such an offer, in accord with - subsection 6b. - * d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - * e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded - from the Corresponding Source as a System Library, need not be included - in conveying the object code work. - - A “User Product” is either (1) a “consumer product”, which means any - tangible personal property which is normally used for personal, family, - or household purposes, or (2) anything designed or sold for - incorporation into a dwelling. In determining whether a product is a - consumer product, doubtful cases shall be resolved in favor of - coverage. For a particular product received by a particular user, - “normally used” refers to a typical or common use of that class of - product, regardless of the status of the particular user or of the way - in which the particular user actually uses, or expects or is expected - to use, the product. A product is a consumer product regardless of - whether the product has substantial commercial, industrial or - non-consumer uses, unless such uses represent the only significant mode - of use of the product. - - “Installation Information” for a User Product means any methods, - procedures, authorization keys, or other information required to - install and execute modified versions of a covered work in that User - Product from a modified version of its Corresponding Source. The - information must suffice to ensure that the continued functioning of - the modified object code is in no case prevented or interfered with - solely because modification has been made. - - If you convey an object code work under this section in, or with, or - specifically for use in, a User Product, and the conveying occurs as - part of a transaction in which the right of possession and use of the - User Product is transferred to the recipient in perpetuity or for a - fixed term (regardless of how the transaction is characterized), the - Corresponding Source conveyed under this section must be accompanied by - the Installation Information. But this requirement does not apply if - neither you nor any third party retains the ability to install modified - object code on the User Product (for example, the work has been - installed in ROM). - - The requirement to provide Installation Information does not include a - requirement to continue to provide support service, warranty, or - updates for a work that has been modified or installed by the - recipient, or for the User Product in which it has been modified or - installed. Access to a network may be denied when the modification - itself materially and adversely affects the operation of the network or - violates the rules and protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, - in accord with this section must be in a format that is publicly - documented (and with an implementation available to the public in - source code form), and must require no special password or key for - unpacking, reading or copying. - - 7. Additional Terms. - - “Additional permissions” are terms that supplement the terms of this - License by making exceptions from one or more of its conditions. - Additional permissions that are applicable to the entire Program shall - be treated as though they were included in this License, to the extent - that they are valid under applicable law. If additional permissions - apply only to part of the Program, that part may be used separately - under those permissions, but the entire Program remains governed by - this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option remove - any additional permissions from that copy, or from any part of it. - (Additional permissions may be written to require their own removal in - certain cases when you modify the work.) You may place additional - permissions on material, added by you to a covered work, for which you - have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you - add to a covered work, you may (if authorized by the copyright holders - of that material) supplement the terms of this License with terms: - * a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - * b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - * c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - * d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - * e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - * f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions - of it) with contractual assumptions of liability to the recipient, - for any liability that these contractual assumptions directly - impose on those licensors and authors. - - All other non-permissive additional terms are considered “further - restrictions” within the meaning of section 10. If the Program as you - received it, or any part of it, contains a notice stating that it is - governed by this License along with a term that is a further - restriction, you may remove that term. If a license document contains a - further restriction but permits relicensing or conveying under this - License, you may add to a covered work material governed by the terms - of that license document, provided that the further restriction does - not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you - must place, in the relevant source files, a statement of the additional - terms that apply to those files, or a notice indicating where to find - the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the - form of a separately written license, or stated as exceptions; the - above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly - provided under this License. Any attempt otherwise to propagate or - modify it is void, and will automatically terminate your rights under - this License (including any patent licenses granted under the third - paragraph of section 11). - - However, if you cease all violation of this License, then your license - from a particular copyright holder is reinstated (a) provisionally, - unless and until the copyright holder explicitly and finally terminates - your license, and (b) permanently, if the copyright holder fails to - notify you of the violation by some reasonable means prior to 60 days - after the cessation. - - Moreover, your license from a particular copyright holder is reinstated - permanently if the copyright holder notifies you of the violation by - some reasonable means, this is the first time you have received notice - of violation of this License (for any work) from that copyright holder, - and you cure the violation prior to 30 days after your receipt of the - notice. - - Termination of your rights under this section does not terminate the - licenses of parties who have received copies or rights from you under - this License. If your rights have been terminated and not permanently - reinstated, you do not qualify to receive new licenses for the same - material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or run - a copy of the Program. Ancillary propagation of a covered work - occurring solely as a consequence of using peer-to-peer transmission to - receive a copy likewise does not require acceptance. However, nothing - other than this License grants you permission to propagate or modify - any covered work. These actions infringe copyright if you do not accept - this License. Therefore, by modifying or propagating a covered work, - you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically - receives a license from the original licensors, to run, modify and - propagate that work, subject to this License. You are not responsible - for enforcing compliance by third parties with this License. - - An “entity transaction” is a transaction transferring control of an - organization, or substantially all assets of one, or subdividing an - organization, or merging organizations. If propagation of a covered - work results from an entity transaction, each party to that transaction - who receives a copy of the work also receives whatever licenses to the - work the party's predecessor in interest had or could give under the - previous paragraph, plus a right to possession of the Corresponding - Source of the work from the predecessor in interest, if the predecessor - has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the - rights granted or affirmed under this License. For example, you may not - impose a license fee, royalty, or other charge for exercise of rights - granted under this License, and you may not initiate litigation - (including a cross-claim or counterclaim in a lawsuit) alleging that - any patent claim is infringed by making, using, selling, offering for - sale, or importing the Program or any portion of it. - - 11. Patents. - - A “contributor” is a copyright holder who authorizes use under this - License of the Program or a work on which the Program is based. The - work thus licensed is called the contributor's “contributor version”. - - A contributor's “essential patent claims” are all patent claims owned - or controlled by the contributor, whether already acquired or hereafter - acquired, that would be infringed by some manner, permitted by this - License, of making, using, or selling its contributor version, but do - not include claims that would be infringed only as a consequence of - further modification of the contributor version. For purposes of this - definition, “control” includes the right to grant patent sublicenses in - a manner consistent with the requirements of this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free - patent license under the contributor's essential patent claims, to - make, use, sell, offer for sale, import and otherwise run, modify and - propagate the contents of its contributor version. - - In the following three paragraphs, a “patent license” is any express - agreement or commitment, however denominated, not to enforce a patent - (such as an express permission to practice a patent or covenant not to - sue for patent infringement). To “grant” such a patent license to a - party means to make such an agreement or commitment not to enforce a - patent against the party. - - If you convey a covered work, knowingly relying on a patent license, - and the Corresponding Source of the work is not available for anyone to - copy, free of charge and under the terms of this License, through a - publicly available network server or other readily accessible means, - then you must either (1) cause the Corresponding Source to be so - available, or (2) arrange to deprive yourself of the benefit of the - patent license for this particular work, or (3) arrange, in a manner - consistent with the requirements of this License, to extend the patent - license to downstream recipients. “Knowingly relying” means you have - actual knowledge that, but for the patent license, your conveying the - covered work in a country, or your recipient's use of the covered work - in a country, would infringe one or more identifiable patents in that - country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or - arrangement, you convey, or propagate by procuring conveyance of, a - covered work, and grant a patent license to some of the parties - receiving the covered work authorizing them to use, propagate, modify - or convey a specific copy of the covered work, then the patent license - you grant is automatically extended to all recipients of the covered - work and works based on it. - - A patent license is “discriminatory” if it does not include within the - scope of its coverage, prohibits the exercise of, or is conditioned on - the non-exercise of one or more of the rights that are specifically - granted under this License. You may not convey a covered work if you - are a party to an arrangement with a third party that is in the - business of distributing software, under which you make payment to the - third party based on the extent of your activity of conveying the work, - and under which the third party grants, to any of the parties who would - receive the covered work from you, a discriminatory patent license (a) - in connection with copies of the covered work conveyed by you (or - copies made from those copies), or (b) primarily for and in connection - with specific products or compilations that contain the covered work, - unless you entered into that arrangement, or that patent license was - granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting any - implied license or other defenses to infringement that may otherwise be - available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot convey a - covered work so as to satisfy simultaneously your obligations under - this License and any other pertinent obligations, then as a consequence - you may not convey it at all. For example, if you agree to terms that - obligate you to collect a royalty for further conveying from those to - whom you convey the Program, the only way you could satisfy both those - terms and this License would be to refrain entirely from conveying the - Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have - permission to link or combine any covered work with a work licensed - under version 3 of the GNU Affero General Public License into a single - combined work, and to convey the resulting work. The terms of this - License will continue to apply to the part which is the covered work, - but the special requirements of the GNU Affero General Public License, - section 13, concerning interaction through a network will apply to the - combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of - the GNU General Public License from time to time. Such new versions - will be similar in spirit to the present version, but may differ in - detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the Program - specifies that a certain numbered version of the GNU General Public - License “or any later version” applies to it, you have the option of - following the terms and conditions either of that numbered version or - of any later version published by the Free Software Foundation. If the - Program does not specify a version number of the GNU General Public - License, you may choose any version ever published by the Free Software - Foundation. - - If the Program specifies that a proxy can decide which future versions - of the GNU General Public License can be used, that proxy's public - statement of acceptance of a version permanently authorizes you to - choose that version for the Program. - - Later license versions may give you additional or different - permissions. However, no additional obligations are imposed on any - author or copyright holder as a result of your choosing to follow a - later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY - APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT - HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT - WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE - OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU - ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING - WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR - CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, - INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES - ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT - NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES - SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO - OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided - above cannot be given local legal effect according to their terms, - reviewing courts shall apply local law that most closely approximates - an absolute waiver of all civil liability in connection with the - Program, unless a warranty or assumption of liability accompanies a - copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest - possible use to the public, the best way to achieve this is to make it - free software which everyone can redistribute and change under these - terms. - - To do so, attach the following notices to the program. It is safest to - attach them to the start of each source file to most effectively state - the exclusion of warranty; and each file should have at least the - “copyright” line and a pointer to where the full notice is found. - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - Also add information on how to contact you by electronic and paper - mail. - - If the program does terminal interaction, make it output a short notice - like this when it starts in an interactive mode: - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - - The hypothetical commands `show w' and `show c' should show the - appropriate parts of the General Public License. Of course, your - program's commands might be different; for a GUI interface, you would - use an “about box”. - - You should also get your employer (if you work as a programmer) or - school, if any, to sign a “copyright disclaimer” for the program, if - necessary. For more information on this, and how to apply and follow - the GNU GPL, see . - - The GNU General Public License does not permit incorporating your - program into proprietary programs. If your program is a subroutine - library, you may consider it more useful to permit linking proprietary - applications with the library. If this is what you want to do, use the - GNU Lesser General Public License instead of this License. But first, - please read . - - GNU General Public License Version 2 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -Preamble - - The licenses for most software are designed to take away your freedom - to share and change it. By contrast, the GNU General Public License is - intended to guarantee your freedom to share and change free - software--to make sure the software is free for all its users. This - General Public License applies to most of the Free Software - Foundation's software and to any other program whose authors commit to - using it. (Some other Free Software Foundation software is covered by - the GNU Lesser General Public License instead.) You can apply it to - your programs, too. - - When we speak of free software, we are referring to freedom, not price. - Our General Public Licenses are designed to make sure that you have the - freedom to distribute copies of free software (and charge for this - service if you wish), that you receive source code or can get it if you - want it, that you can change the software or use pieces of it in new - free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid anyone - to deny you these rights or to ask you to surrender the rights. These - restrictions translate to certain responsibilities for you if you - distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether gratis - or for a fee, you must give the recipients all the rights that you - have. You must make sure that they, too, receive or can get the source - code. And you must show them these terms so they know their rights. - - We protect your rights with two steps: (1) copyright the software, and - (2) offer you this license which gives you legal permission to copy, - distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain - that everyone understands that there is no warranty for this free - software. If the software is modified by someone else and passed on, we - want its recipients to know that what they have is not the original, so - that any problems introduced by others will not reflect on the original - authors' reputations. - - Finally, any free program is threatened constantly by software patents. - We wish to avoid the danger that redistributors of a free program will - individually obtain patent licenses, in effect making the program - proprietary. To prevent this, we have made it clear that any patent - must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and - modification follow. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains a - notice placed by the copyright holder saying it may be distributed - under the terms of this General Public License. The "Program", below, - refers to any such program or work, and a "work based on the Program" - means either the Program or any derivative work under copyright law: - that is to say, a work containing the Program or a portion of it, - either verbatim or with modifications and/or translated into another - language. (Hereinafter, translation is included without limitation in - the term "modification".) Each licensee is addressed as "you". - - Activities other than copying, distribution and modification are not - covered by this License; they are outside its scope. The act of running - the Program is not restricted, and the output from the Program is - covered only if its contents constitute a work based on the Program - (independent of having been made by running the Program). Whether that - is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's source - code as you receive it, in any medium, provided that you conspicuously - and appropriately publish on each copy an appropriate copyright notice - and disclaimer of warranty; keep intact all the notices that refer to - this License and to the absence of any warranty; and give any other - recipients of the Program a copy of this License along with the - Program. - - You may charge a fee for the physical act of transferring a copy, and - you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion of - it, thus forming a work based on the Program, and copy and distribute - such modifications or work under the terms of Section 1 above, provided - that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - b) You must cause any work that you distribute or publish, that - in whole or in part contains or is derived from the Program or - any part thereof, to be licensed as a whole at no charge to all - third parties under the terms of this License. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you - provide a warranty) and that users may redistribute the program - under these conditions, and telling the user how to view a copy - of this License. (Exception: if the Program itself is - interactive but does not normally print such an announcement, - your work based on the Program is not required to print an - announcement.) - - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the Program, - and can be reasonably considered independent and separate works in - themselves, then this License, and its terms, do not apply to those - sections when you distribute them as separate works. But when you - distribute the same sections as part of a whole which is a work based - on the Program, the distribution of the whole must be on the terms of - this License, whose permissions for other licensees extend to the - entire whole, and thus to each and every part regardless of who wrote - it. - - Thus, it is not the intent of this section to claim rights or contest - your rights to work written entirely by you; rather, the intent is to - exercise the right to control the distribution of derivative or - collective works based on the Program. - - In addition, mere aggregation of another work not based on the Program - with the Program (or with a work based on the Program) on a volume of a - storage or distribution medium does not bring the other work under the - scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, - under Section 2) in object code or executable form under the terms of - Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Sections 1 and 2 above on a medium customarily used for software - interchange; or, - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a - medium customarily used for software interchange; or, - c) Accompany it with the information you received as to the - offer to distribute corresponding source code. (This alternative - is allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - - The source code for a work means the preferred form of the work for - making modifications to it. For an executable work, complete source - code means all the source code for all modules it contains, plus any - associated interface definition files, plus the scripts used to control - compilation and installation of the executable. However, as a special - exception, the source code distributed need not include anything that - is normally distributed (in either source or binary form) with the - major components (compiler, kernel, and so on) of the operating system - on which the executable runs, unless that component itself accompanies - the executable. - - If distribution of executable or object code is made by offering access - to copy from a designated place, then offering equivalent access to - copy the source code from the same place counts as distribution of the - source code, even though third parties are not compelled to copy the - source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program - except as expressly provided under this License. Any attempt otherwise - to copy, modify, sublicense or distribute the Program is void, and will - automatically terminate your rights under this License. However, - parties who have received copies, or rights, from you under this - License will not have their licenses terminated so long as such parties - remain in full compliance. - - 5. You are not required to accept this License, since you have not - signed it. However, nothing else grants you permission to modify or - distribute the Program or its derivative works. These actions are - prohibited by law if you do not accept this License. Therefore, by - modifying or distributing the Program (or any work based on the - Program), you indicate your acceptance of this License to do so, and - all its terms and conditions for copying, distributing or modifying the - Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the - Program), the recipient automatically receives a license from the - original licensor to copy, distribute or modify the Program subject to - these terms and conditions. You may not impose any further restrictions - on the recipients' exercise of the rights granted herein. You are not - responsible for enforcing compliance by third parties to this License. - - 7. If, as a consequence of a court judgment or allegation of patent - infringement or for any other reason (not limited to patent issues), - conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot - distribute so as to satisfy simultaneously your obligations under this - License and any other pertinent obligations, then as a consequence you - may not distribute the Program at all. For example, if a patent license - would not permit royalty-free redistribution of the Program by all - those who receive copies directly or indirectly through you, then the - only way you could satisfy both it and this License would be to refrain - entirely from distribution of the Program. - - If any portion of this section is held invalid or unenforceable under - any particular circumstance, the balance of the section is intended to - apply and the section as a whole is intended to apply in other - circumstances. - - It is not the purpose of this section to induce you to infringe any - patents or other property right claims or to contest validity of any - such claims; this section has the sole purpose of protecting the - integrity of the free software distribution system, which is - implemented by public license practices. Many people have made generous - contributions to the wide range of software distributed through that - system in reliance on consistent application of that system; it is up - to the author/donor to decide if he or she is willing to distribute - software through any other system and a licensee cannot impose that - choice. - - This section is intended to make thoroughly clear what is believed to - be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in - certain countries either by patents or by copyrighted interfaces, the - original copyright holder who places the Program under this License may - add an explicit geographical distribution limitation excluding those - countries, so that distribution is permitted only in or among countries - not thus excluded. In such case, this License incorporates the - limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions - of the General Public License from time to time. Such new versions will - be similar in spirit to the present version, but may differ in detail - to address new problems or concerns. - - Each version is given a distinguishing version number. If the Program - specifies a version number of this License which applies to it and "any - later version", you have the option of following the terms and - conditions either of that version or of any later version published by - the Free Software Foundation. If the Program does not specify a version - number of this License, you may choose any version ever published by - the Free Software Foundation. - - 10. If you wish to incorporate parts of the Program into other free - programs whose distribution conditions are different, write to the - author to ask for permission. For software which is copyrighted by the - Free Software Foundation, write to the Free Software Foundation; we - sometimes make exceptions for this. Our decision will be guided by the - two goals of preserving the free status of all derivatives of our free - software and of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO - WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. - EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR - OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, - EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH - YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL - NECESSARY SERVICING, REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY - AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU - FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR - CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF - SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - DAMAGES. - - END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest - possible use to the public, the best way to achieve this is to make it - free software which everyone can redistribute and change under these - terms. - - To do so, attach the following notices to the program. It is safest to - attach them to the start of each source file to most effectively convey - the exclusion of warranty; and each file should have at least the - "copyright" line and a pointer to where the full notice is found. -one line to give the program's name and an idea of what it does. -Copyright (C) yyyy name of author - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Also add information on how to contact you by electronic and paper - mail. - - If the program is interactive, make it output a short notice like this - when it starts in an interactive mode: -Gnomovision version 69, Copyright (C) year name of author -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. - - The hypothetical commands `show w' and `show c' should show the - appropriate parts of the General Public License. Of course, the - commands you use may be called something other than `show w' and `show - c'; they could even be mouse-clicks or menu items--whatever suits your - program. - - You should also get your employer (if you work as a programmer) or your - school, if any, to sign a "copyright disclaimer" for the program, if - necessary. Here is a sample; alter the names: -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -signature of Ty Coon, 1 April 1989 -Ty Coon, President of Vice - - This General Public License does not permit incorporating your program - into proprietary programs. If your program is a subroutine library, you - may consider it more useful to permit linking proprietary applications - with the library. If this is what you want to do, use the GNU - Lesser General Public License instead of this License. - - Mozilla Public License Version 1.1 - -1. Definitions. - - 1.0.1. "Commercial Use" - means distribution or otherwise making the Covered Code - available to a third party. - - 1.1. "Contributor" - means each entity that creates or contributes to the creation of - Modifications. - - 1.2. "Contributor Version" - means the combination of the Original Code, prior Modifications - used by a Contributor, and the Modifications made by that - particular Contributor. - - 1.3. "Covered Code" - means the Original Code or Modifications or the combination of - the Original Code and Modifications, in each case including - portions thereof. - - 1.4. "Electronic Distribution Mechanism" - means a mechanism generally accepted in the software development - community for the electronic transfer of data. - - 1.5. "Executable" - means Covered Code in any form other than Source Code. - - 1.6. "Initial Developer" - means the individual or entity identified as the Initial - Developer in the Source Code notice required by Exhibit A. - - 1.7. "Larger Work" - means a work which combines Covered Code or portions thereof - with code not governed by the terms of this License. - - 1.8. "License" - means this document. - - 1.8.1. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently - acquired, any and all of the rights conveyed herein. - - 1.9. "Modifications" - means any addition to or deletion from the substance or - structure of either the Original Code or any previous - Modifications. When Covered Code is released as a series of - files, a Modification is: - - a. - Any addition to or deletion from the contents of a file containing - Original Code or previous Modifications. - b. - Any new file that contains any part of the Original Code or - previous Modifications. - - 1.10. "Original Code" - means Source Code of computer software code which is described - in the Source Code notice required by Exhibit A as Original - Code, and which, at the time of its release under this License - is not already Covered Code governed by this License. - - 1.10.1. "Patent Claims" - means any patent claim(s), now owned or hereafter acquired, - including without limitation, method, process, and apparatus - claims, in any patent Licensable by grantor. - - 1.11. "Source Code" - means the preferred form of the Covered Code for making - modifications to it, including all modules it contains, plus any - associated interface definition files, scripts used to control - compilation and installation of an Executable, or source code - differential comparisons against either the Original Code or - another well known, available Covered Code of the Contributor's - choice. The Source Code can be in a compressed or archival form, - provided the appropriate decompression or de-archiving software - is widely available for no charge. - - 1.12. "You" (or "Your") - means an individual or a legal entity exercising rights under, - and complying with all of the terms of, this License or a future - version of this License issued under Section 6.1. For legal - entities, "You" includes any entity which controls, is - controlled by, or is under common control with You. For purposes - of this definition, "control" means (a) the power, direct or - indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. Source Code License. - - 2.1. The Initial Developer Grant. - - The Initial Developer hereby grants You a world-wide, royalty-free, - non-exclusive license, subject to third party intellectual property - claims: - a. under intellectual property rights (other than patent or trademark) - Licensable by Initial Developer to use, reproduce, modify, display, - perform, sublicense and distribute the Original Code (or portions - thereof) with or without Modifications, and/or as part of a Larger - Work; and - b. under Patents Claims infringed by the making, using or selling of - Original Code, to make, have made, use, practice, sell, and offer - for sale, and/or otherwise dispose of the Original Code (or - portions thereof). - c. the licenses granted in this Section 2.1 (a) and (b) are effective - on the date Initial Developer first distributes Original Code under - the terms of this License. - d. Notwithstanding Section 2.1 (b) above, no patent license is - granted: 1) for code that You delete from the Original Code; 2) - separate from the Original Code; or 3) for infringements caused by: - i) the modification of the Original Code or ii) the combination of - the Original Code with other software or devices. - - 2.2. Contributor Grant. - - Subject to third party intellectual property claims, each Contributor - hereby grants You a world-wide, royalty-free, non-exclusive license - a. under intellectual property rights (other than patent or trademark) - Licensable by Contributor, to use, reproduce, modify, display, - perform, sublicense and distribute the Modifications created by - such Contributor (or portions thereof) either on an unmodified - basis, with other Modifications, as Covered Code and/or as part of - a Larger Work; and - b. under Patent Claims infringed by the making, using, or selling of - Modifications made by that Contributor either alone and/or in - combination with its Contributor Version (or portions of such - combination), to make, use, sell, offer for sale, have made, and/or - otherwise dispose of: 1) Modifications made by that Contributor (or - portions thereof); and 2) the combination of Modifications made by - that Contributor with its Contributor Version (or portions of such - combination). - c. the licenses granted in Sections 2.2 (a) and 2.2 (b) are effective - on the date Contributor first makes Commercial Use of the Covered - Code. - d. Notwithstanding Section 2.2 (b) above, no patent license is - granted: 1) for any code that Contributor has deleted from the - Contributor Version; 2) separate from the Contributor Version; 3) - for infringements caused by: i) third party modifications of - Contributor Version or ii) the combination of Modifications made by - that Contributor with other software (except as part of the - Contributor Version) or other devices; or 4) under Patent Claims - infringed by Covered Code in the absence of Modifications made by - that Contributor. - -3. Distribution Obligations. - - 3.1. Application of License. - - The Modifications which You create or to which You contribute are - governed by the terms of this License, including without limitation - Section 2.2. The Source Code version of Covered Code may be distributed - only under the terms of this License or a future version of this - License released under Section 6.1, and You must include a copy of this - License with every copy of the Source Code You distribute. You may not - offer or impose any terms on any Source Code version that alters or - restricts the applicable version of this License or the recipients' - rights hereunder. However, You may include an additional document - offering the additional rights described in Section 3.5. - - 3.2. Availability of Source Code. - - Any Modification which You create or to which You contribute must be - made available in Source Code form under the terms of this License - either on the same media as an Executable version or via an accepted - Electronic Distribution Mechanism to anyone to whom you made an - Executable version available; and if made available via Electronic - Distribution Mechanism, must remain available for at least twelve (12) - months after the date it initially became available, or at least six - (6) months after a subsequent version of that particular Modification - has been made available to such recipients. You are responsible for - ensuring that the Source Code version remains available even if the - Electronic Distribution Mechanism is maintained by a third party. - - 3.3. Description of Modifications. - - You must cause all Covered Code to which You contribute to contain a - file documenting the changes You made to create that Covered Code and - the date of any change. You must include a prominent statement that the - Modification is derived, directly or indirectly, from Original Code - provided by the Initial Developer and including the name of the Initial - Developer in (a) the Source Code, and (b) in any notice in an - Executable version or related documentation in which You describe the - origin or ownership of the Covered Code. - - 3.4. Intellectual Property Matters - - (a) Third Party Claims - - If Contributor has knowledge that a license under a third party's - intellectual property rights is required to exercise the rights granted - by such Contributor under Sections 2.1 or 2.2, Contributor must include - a text file with the Source Code distribution titled "LEGAL" which - describes the claim and the party making the claim in sufficient detail - that a recipient will know whom to contact. If Contributor obtains such - knowledge after the Modification is made available as described in - Section 3.2, Contributor shall promptly modify the LEGAL file in all - copies Contributor makes available thereafter and shall take other - steps (such as notifying appropriate mailing lists or newsgroups) - reasonably calculated to inform those who received the Covered Code - that new knowledge has been obtained. - - (b) Contributor APIs - - If Contributor's Modifications include an application programming - interface and Contributor has knowledge of patent licenses which are - reasonably necessary to implement that API, Contributor must also - include this information in the legal file. - - (c) Representations. - - Contributor represents that, except as disclosed pursuant to Section - 3.4 (a) above, Contributor believes that Contributor's Modifications - are Contributor's original creation(s) and/or Contributor has - sufficient rights to grant the rights conveyed by this License. - - 3.5. Required Notices. - - You must duplicate the notice in Exhibit A in each file of the Source - Code. If it is not possible to put such notice in a particular Source - Code file due to its structure, then You must include such notice in a - location (such as a relevant directory) where a user would be likely to - look for such a notice. If You created one or more Modification(s) You - may add your name as a Contributor to the notice described in Exhibit - A. You must also duplicate this License in any documentation for the - Source Code where You describe recipients' rights or ownership rights - relating to Covered Code. You may choose to offer, and to charge a fee - for, warranty, support, indemnity or liability obligations to one or - more recipients of Covered Code. However, You may do so only on Your - own behalf, and not on behalf of the Initial Developer or any - Contributor. You must make it absolutely clear than any such warranty, - support, indemnity or liability obligation is offered by You alone, and - You hereby agree to indemnify the Initial Developer and every - Contributor for any liability incurred by the Initial Developer or such - Contributor as a result of warranty, support, indemnity or liability - terms You offer. - - 3.6. Distribution of Executable Versions. - - You may distribute Covered Code in Executable form only if the - requirements of Sections 3.1, 3.2, 3.3, 3.4 and 3.5 have been met for - that Covered Code, and if You include a notice stating that the Source - Code version of the Covered Code is available under the terms of this - License, including a description of how and where You have fulfilled - the obligations of Section 3.2. The notice must be conspicuously - included in any notice in an Executable version, related documentation - or collateral in which You describe recipients' rights relating to the - Covered Code. You may distribute the Executable version of Covered Code - or ownership rights under a license of Your choice, which may contain - terms different from this License, provided that You are in compliance - with the terms of this License and that the license for the Executable - version does not attempt to limit or alter the recipient's rights in - the Source Code version from the rights set forth in this License. If - You distribute the Executable version under a different license You - must make it absolutely clear that any terms which differ from this - License are offered by You alone, not by the Initial Developer or any - Contributor. You hereby agree to indemnify the Initial Developer and - every Contributor for any liability incurred by the Initial Developer - or such Contributor as a result of any such terms You offer. - - 3.7. Larger Works. - - You may create a Larger Work by combining Covered Code with other code - not governed by the terms of this License and distribute the Larger - Work as a single product. In such a case, You must make sure the - requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Code due to statute, - judicial order, or regulation then You must: (a) comply with the terms - of this License to the maximum extent possible; and (b) describe the - limitations and the code they affect. Such description must be included - in the legal file described in Section 3.4 and must be included with - all distributions of the Source Code. Except to the extent prohibited - by statute or regulation, such description must be sufficiently - detailed for a recipient of ordinary skill to be able to understand it. - -5. Application of this License. - - This License applies to code to which the Initial Developer has - attached the notice in Exhibit A and to related Covered Code. - -6. Versions of the License. - - 6.1. New Versions - - Netscape Communications Corporation ("Netscape") may publish revised - and/or new versions of the License from time to time. Each version will - be given a distinguishing version number. - - 6.2. Effect of New Versions - - Once Covered Code has been published under a particular version of the - License, You may always continue to use it under the terms of that - version. You may also choose to use such Covered Code under the terms - of any subsequent version of the License published by Netscape. No one - other than Netscape has the right to modify the terms applicable to - Covered Code created under this License. - - 6.3. Derivative Works - - If You create or use a modified version of this License (which you may - only do in order to apply it to code which is not already Covered Code - governed by this License), You must (a) rename Your license so that the - phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or - any confusingly similar phrase do not appear in your license (except to - note that your license differs from this License) and (b) otherwise - make it clear that Your version of the license contains terms which - differ from the Mozilla Public License and Netscape Public License. - (Filling in the name of the Initial Developer, Original Code or - Contributor in the notice described in Exhibit A shall not of - themselves be deemed to be modifications of this License.) - -7. Disclaimer of warranty - - Covered code is provided under this license on an "as is" basis, - without warranty of any kind, either expressed or implied, including, - without limitation, warranties that the covered code is free of - defects, merchantable, fit for a particular purpose or non-infringing. - The entire risk as to the quality and performance of the covered code - is with you. Should any covered code prove defective in any respect, - you (not the initial developer or any other contributor) assume the - cost of any necessary servicing, repair or correction. This disclaimer - of warranty constitutes an essential part of this license. No use of - any covered code is authorized hereunder except under this disclaimer. - -8. Termination - - 8.1. This License and the rights granted hereunder will terminate - automatically if You fail to comply with terms herein and fail to cure - such breach within 30 days of becoming aware of the breach. All - sublicenses to the Covered Code which are properly granted shall - survive any termination of this License. Provisions which, by their - nature, must remain in effect beyond the termination of this License - shall survive. - - 8.2. If You initiate litigation by asserting a patent infringement - claim (excluding declaratory judgment actions) against Initial - Developer or a Contributor (the Initial Developer or Contributor - against whom You file such action is referred to as "Participant") - alleging that: - a. such Participant's Contributor Version directly or indirectly - infringes any patent, then any and all rights granted by such - Participant to You under Sections 2.1 and/or 2.2 of this License - shall, upon 60 days notice from Participant terminate - prospectively, unless if within 60 days after receipt of notice You - either: (i) agree in writing to pay Participant a mutually - agreeable reasonable royalty for Your past and future use of - Modifications made by such Participant, or (ii) withdraw Your - litigation claim with respect to the Contributor Version against - such Participant. If within 60 days of notice, a reasonable royalty - and payment arrangement are not mutually agreed upon in writing by - the parties or the litigation claim is not withdrawn, the rights - granted by Participant to You under Sections 2.1 and/or 2.2 - automatically terminate at the expiration of the 60 day notice - period specified above. - b. any software, hardware, or device, other than such Participant's - Contributor Version, directly or indirectly infringes any patent, - then any rights granted to You by such Participant under Sections - 2.1(b) and 2.2(b) are revoked effective as of the date You first - made, used, sold, distributed, or had made, Modifications made by - that Participant. - - 8.3. If You assert a patent infringement claim against Participant - alleging that such Participant's Contributor Version directly or - indirectly infringes any patent where such claim is resolved (such as - by license or settlement) prior to the initiation of patent - infringement litigation, then the reasonable value of the licenses - granted by such Participant under Sections 2.1 or 2.2 shall be taken - into account in determining the amount or value of any payment or - license. - - 8.4. In the event of termination under Sections 8.1 or 8.2 above, all - end user license agreements (excluding distributors and resellers) - which have been validly granted by You or any distributor hereunder - prior to termination shall survive termination. - -9. Limitation of liability - - Under no circumstances and under no legal theory, whether tort - (including negligence), contract, or otherwise, shall you, the initial - developer, any other contributor, or any distributor of covered code, - or any supplier of any of such parties, be liable to any person for any - indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all other - commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of - liability shall not apply to liability for death or personal injury - resulting from such party's negligence to the extent applicable law - prohibits such limitation. Some jurisdictions do not allow the - exclusion or limitation of incidental or consequential damages, so this - exclusion and limitation may not apply to you. - -10. U.S. government end users - - The Covered Code is a "commercial item," as that term is defined in 48 - C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" - and "commercial computer software documentation," as such terms are - used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 - and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. - Government End Users acquire Covered Code with only those rights set - forth herein. - -11. Miscellaneous - - This License represents the complete agreement concerning subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. This License shall be governed by - California law provisions (except to the extent applicable law, if any, - provides otherwise), excluding its conflict-of-law provisions. With - respect to disputes in which at least one party is a citizen of, or an - entity chartered or registered to do business in the United States of - America, any litigation relating to this License shall be subject to - the jurisdiction of the Federal Courts of the Northern District of - California, with venue lying in Santa Clara County, California, with - the losing party responsible for costs, including without limitation, - court costs and reasonable attorneys' fees and expenses. The - application of the United Nations Convention on Contracts for the - International Sale of Goods is expressly excluded. Any law or - regulation which provides that the language of a contract shall be - construed against the drafter shall not apply to this License. - -12. Responsibility for claims - - As between Initial Developer and the Contributors, each party is - responsible for claims and damages arising, directly or indirectly, out - of its utilization of rights under this License and You agree to work - with Initial Developer and Contributors to distribute such - responsibility on an equitable basis. Nothing herein is intended or - shall be deemed to constitute any admission of liability. - -13. Multiple-licensed code - - Initial Developer may designate portions of the Covered Code as - "Multiple-Licensed". "Multiple-Licensed" means that the Initial - Developer permits you to utilize portions of the Covered Code under - Your choice of the MPL or the alternative licenses, if any, specified - by the Initial Developer in the file described in Exhibit A. - -Exhibit A - Mozilla Public License. - -"The contents of this file are subject to the Mozilla Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is ______________________________________. - -The Initial Developer of the Original Code is ________________________. -Portions created by ______________________ are Copyright (C) ______ -_______________________. All Rights Reserved. - -Contributor(s): ______________________________________. - -Alternatively, the contents of this file may be used under the terms -of the _____ license (the "[___] License"), in which case the -provisions of [______] License are applicable instead of those -above. If you wish to allow use of your version of this file only -under the terms of the [____] License and not to allow others to use -your version of this file under the MPL, indicate your decision by -deleting the provisions above and replace them with the notice and -other provisions required by the [___] License. If you do not delete -the provisions above, a recipient may use your version of this file -under either the MPL or the [___] License." - - NOTE: The text of this Exhibit A may differ slightly from the text of - the notices in the Source Code files of the Original Code. You should - use the text of this Exhibit A rather than the text found in the - Original Code Source Code for Your Modifications. - - Mozilla Public License Version 2.0 - -1. Definitions - - 1.1. “Contributor” - means each individual or legal entity that creates, contributes - to the creation of, or owns Covered Software. - - 1.2. “Contributor Version” - means the combination of the Contributions of others (if any) - used by a Contributor and that particular Contributor’s - Contribution. - - 1.3. “Contribution” - means Covered Software of a particular Contributor. - - 1.4. “Covered Software” - means Source Code Form to which the initial Contributor has - attached the notice in Exhibit A, the Executable Form of such - Source Code Form, and Modifications of such Source Code Form, in - each case including portions thereof. - - 1.5. “Incompatible With Secondary Licenses” - means - - a. - that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - b. - that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the terms - of a Secondary License. - - 1.6. “Executable Form” - means any form of the work other than Source Code Form. - - 1.7. “Larger Work” - means a work that combines Covered Software with other material, - in a separate file or files, that is not Covered Software. - - 1.8. “License” - means this document. - - 1.9. “Licensable” - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any - and all of the rights conveyed by this License. - - 1.10. “Modifications” - means any of the following: - - a. - any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered Software; - or - b. - any new file in Source Code Form that contains any Covered - Software. - - 1.11. “Patent Claims” of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, - having made, import, or transfer of either its Contributions or - its Contributor Version. - - 1.12. “Secondary License” - means either the GNU General Public License, Version 2.0, the - GNU Lesser General Public License, Version 2.1, the GNU Affero - General Public License, Version 3.0, or any later versions of - those licenses. - - 1.13. “Source Code Form” - means the form of the work preferred for making modifications. - - 1.14. “You” (or “Your”) - means an individual or a legal entity exercising rights under - this License. For legal entities, “You” includes any entity that - controls, is controlled by, or is under common control with You. - For purposes of this definition, “control” means (a) the power, - direct or indirect, to cause the direction or management of such - entity, whether by contract or otherwise, or (b) ownership of - more than fifty percent (50%) of the outstanding shares or - beneficial ownership of such entity. - -2. License Grants and Conditions - - 2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, - or as part of a Larger Work; and - b. under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - - 2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor - first distributes such Contribution. - - 2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted - under this License. No additional rights or licenses will be implied - from the distribution or licensing of Covered Software under this - License. Notwithstanding Section 2.1(b) above, no patent license is - granted by a Contributor: - a. for any code that a Contributor has removed from Covered Software; - or - b. for infringements caused by: (i) Your and any other third party’s - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its - Contributor Version); or - c. under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service - marks, or logos of any Contributor (except as may be necessary to - comply with the notice requirements in Section 3.4). - - 2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License - (if permitted under the terms of Section 3.3). - - 2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights - to grant the rights to its Contributions conveyed by this License. - - 2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - - 2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted - in Section 2.1. - -3. Responsibilities - - 3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients’ rights in the Source Code - Form. - - 3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - a. such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients - of the Executable Form how they can obtain a copy of such Source - Code Form by reasonable means in a timely manner, at a charge no - more than the cost of distribution to the recipient; and - b. You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients’ rights in the Source Code Form under this License. - - 3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and - the Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - - 3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, - or limitations of liability) contained within the Source Code Form of - the Covered Software, except that You may alter any license notices to - the extent required to remedy known factual inaccuracies. - - 3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered - by You alone, and You hereby agree to indemnify every Contributor for - any liability incurred by such Contributor as a result of warranty, - support, indemnity or liability terms You offer. You may include - additional disclaimers of warranty and limitations of liability - specific to any jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Software due to - statute, judicial order, or regulation then You must: (a) comply with - the terms of this License to the maximum extent possible; and (b) - describe the limitations and the code they affect. Such description - must be placed in a text file included with all distributions of the - Covered Software under this License. Except to the extent prohibited by - statute or regulation, such description must be sufficiently detailed - for a recipient of ordinary skill to be able to understand it. - -5. Termination - - 5.1. The rights granted under this License will terminate automatically - if You fail to comply with any of its terms. However, if You become - compliant, then the rights granted under this License from a particular - Contributor are reinstated (a) provisionally, unless and until such - Contributor explicitly and finally terminates Your grants, and (b) on - an ongoing basis, if such Contributor fails to notify You of the - non-compliance by some reasonable means prior to 60 days after You have - come back into compliance. Moreover, Your grants from a particular - Contributor are reinstated on an ongoing basis if such Contributor - notifies You of the non-compliance by some reasonable means, this is - the first time You have received notice of non-compliance with this - License from such Contributor, and You become compliant prior to 30 - days after Your receipt of the notice. - - 5.2. If You initiate litigation against any entity by asserting a - patent infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under - Section 2.1 of this License shall terminate. - - 5.3. In the event of termination under Sections 5.1 or 5.2 above, all - end user license agreements (excluding distributors and resellers) - which have been validly granted by You or Your distributors under this - License prior to termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an “as is” basis, - without warranty of any kind, either expressed, implied, or statutory, - including, without limitation, warranties that the Covered Software is - free of defects, merchantable, fit for a particular purpose or - non-infringing. The entire risk as to the quality and performance of - the Covered Software is with You. Should any Covered Software prove - defective in any respect, You (not any Contributor) assume the cost of - any necessary servicing, repair, or correction. This disclaimer of - warranty constitutes an essential part of this License. No use of any - Covered Software is authorized under this License except under this - disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort - (including negligence), contract, or otherwise, shall any Contributor, - or anyone who distributes Covered Software as permitted above, be - liable to You for any direct, indirect, special, incidental, or - consequential damages of any character including, without limitation, - damages for lost profits, loss of goodwill, work stoppage, computer - failure or malfunction, or any and all other commercial damages or - losses, even if such party shall have been informed of the possibility - of such damages. This limitation of liability shall not apply to - liability for death or personal injury resulting from such party’s - negligence to the extent applicable law prohibits such limitation. Some - jurisdictions do not allow the exclusion or limitation of incidental or - consequential damages, so this exclusion and limitation may not apply - to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the - courts of a jurisdiction where the defendant maintains its principal - place of business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. - Nothing in this Section shall prevent a party’s ability to bring - cross-claims or counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides - that the language of a contract shall be construed against the drafter - shall not be used to construe this License against a Contributor. - -10. Versions of the License - - 10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in - Section 10.3, no one other than the license steward has the right to - modify or publish new versions of this License. Each version will be - given a distinguishing version number. - - 10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered - Software, or under the terms of any subsequent version published by the - license steward. - - 10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - - 10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses - - If You choose to distribute Source Code Form that is Incompatible With - Secondary Licenses under the terms of this version of the License, the - notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - - If it is not possible or desirable to put the notice in a particular - file, then You may include the notice in a location (such as a LICENSE - file in a relevant directory) where a recipient would be likely to look - for such a notice. - - You may add additional accurate notices of copyright ownership. - -Exhibit B - “Incompatible With Secondary Licenses” Notice - - This Source Code Form is “Incompatible With Secondary Licenses”, as - defined by the Mozilla Public License, v. 2.0. - - SIL Open Font License Version 1.1 – 26 February 2007 - - PREAMBLE The goals of the Open Font License (OFL) are to stimulate - worldwide development of collaborative font projects, to support the - font creation efforts of academic and linguistic communities, and to - provide a free and open framework in which fonts may be shared and - improved in partnership with others. - - The OFL allows the licensed fonts to be used, studied, modified and - redistributed freely as long as they are not sold by themselves. The - fonts, including any derivative works, can be bundled, embedded, - redistributed and/or sold with any software provided that the font - names of derivative works are changed. The fonts and derivatives, - however, cannot be released under any other type of license. The - requirement for fonts to remain under this license does not apply to - any document created using the fonts or their derivatives. - - DEFINITIONS "Font Software" refers to the set of files released by the - Copyright Holder(s) under this license and clearly marked as such. This - may include source files, build scripts and documentation. - - "Reserved Font Name" refers to any names specified as such after the - copyright statement(s). - - "Original Version" refers to the collection of Font Software components - as distributed by the Copyright Holder(s). - - "Modified Version" refers to any derivative made by adding to, - deleting, or substituting – in part or in whole -- any of the - components of the Original Version, by changing formats or by porting - the Font Software to a new environment. - - "Author" refers to any designer, engineer, programmer, technical writer - or other person who contributed to the Font Software. - - PERMISSION & CONDITIONS Permission is hereby granted, free of charge, - to any person obtaining a copy of the Font Software, to use, study, - copy, merge, embed, modify, redistribute, and sell modified and - unmodified copies of the Font Software, subject to the following - conditions: - - 1) Neither the Font Software nor any of its individual components, in - Original or Modified Versions, may be sold by itself. - - 2) Original or Modified Versions of the Font Software may be bundled, - redistributed and/or sold with any software, provided that each copy - contains the above copyright notice and this license. These can be - included either as stand-alone text files, human-readable headers or in - the appropriate machine-readable metadata fields within text or binary - files as long as those fields can be easily viewed by the user. - - 3) No Modified Version of the Font Software may use the Reserved Font - Name(s) unless explicit written permission is granted by the - corresponding Copyright Holder. This restriction only applies to the - primary font name as presented to the users. - - 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font - Software shall not be used to promote, endorse or advertise any - Modified Version, except to acknowledge the contribution(s) of the - Copyright Holder(s) and the Author(s) or with their explicit written - permission. - - 5) The Font Software, modified or unmodified, in part or in whole, must - be distributed entirely under this license, and must not be distributed - under any other license. The requirement for fonts to remain under this - license does not apply to any document created using the Font Software. - - TERMINATION This license becomes null and void if any of the above - conditions are not met. - - DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF - ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY - WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO - EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, - OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT - SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. - - Apache License - - Version 2.0, January 2004 - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by the - copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all other - entities that control, are controlled by, or are under common control - with that entity. For the purposes of this definition, "control" means - (i) the power, direct or indirect, to cause the direction or management - of such entity, whether by contract or otherwise, or (ii) ownership of - fifty percent (50%) or more of the outstanding shares, or (iii) - beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity exercising - permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but not - limited to compiled object code, generated documentation, and - conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or Object - form, made available under the License, as indicated by a copyright - notice that is included in or attached to the work (an example is - provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including the - original version of the Work and any modifications or additions to that - Work or Derivative Works thereof, that is intentionally submitted to - Licensor for inclusion in the Work by the copyright owner or by an - individual or Legal Entity authorized to submit on behalf of the - copyright owner. For the purposes of this definition, "submitted" means - any form of electronic, verbal, or written communication sent to the - Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity on - behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, publicly - display, publicly perform, sublicense, and distribute the Work and such - Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of this - License, each Contributor hereby grants to You a perpetual, worldwide, - non-exclusive, no-charge, royalty-free, irrevocable (except as stated - in this section) patent license to make, have made, use, offer to sell, - sell, import, and otherwise transfer the Work, where such license - applies only to those patent claims licensable by such Contributor that - are necessarily infringed by their Contribution(s) alone or by - combination of their Contribution(s) with the Work to which such - Contribution(s) was submitted. If You institute patent litigation - against any entity (including a cross-claim or counterclaim in a - lawsuit) alleging that the Work or a Contribution incorporated within - the Work constitutes direct or contributory patent infringement, then - any patent licenses granted to You under this License for that Work - shall terminate as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the Work - or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You meet the - following conditions: - 1. You must give any other recipients of the Work or Derivative Works - a copy of this License; and - 2. You must cause any modified files to carry prominent notices - stating that You changed the files; and - 3. You must retain, in the Source form of any Derivative Works that - You distribute, all copyright, patent, trademark, and attribution - notices from the Source form of the Work, excluding those notices - that do not pertain to any part of the Derivative Works; and - 4. If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained within - such NOTICE file, excluding those notices that do not pertain to - any part of the Derivative Works, in at least one of the following - places: within a NOTICE text file distributed as part of the - Derivative Works; within the Source form or documentation, if - provided along with the Derivative Works; or, within a display - generated by the Derivative Works, if and wherever such third-party - notices normally appear. The contents of the NOTICE file are for - informational purposes only and do not modify the License. You may - add Your own attribution notices within Derivative Works that You - distribute, alongside or as an addendum to the NOTICE text from the - Work, provided that such additional attribution notices cannot be - construed as modifying the License. You may add Your own copyright - statement to Your modifications and may provide additional or - different license terms and conditions for use, reproduction, or - distribution of Your modifications, or for any such Derivative - Works as a whole, provided Your use, reproduction, and distribution - of the Work otherwise complies with the conditions stated in this - License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work by - You to the Licensor shall be under the terms and conditions of this - License, without any additional terms or conditions. Notwithstanding - the above, nothing herein shall supersede or modify the terms of any - separate license agreement you may have executed with Licensor - regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or agreed - to in writing, Licensor provides the Work (and each Contributor - provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied, including, without - limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, - MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely - responsible for determining the appropriateness of using or - redistributing the Work and assume any risks associated with Your - exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, unless - required by applicable law (such as deliberate and grossly negligent - acts) or agreed to in writing, shall any Contributor be liable to You - for damages, including any direct, indirect, special, incidental, or - consequential damages of any character arising as a result of this - License or out of the use or inability to use the Work (including but - not limited to damages for loss of goodwill, work stoppage, computer - failure or malfunction, or any and all other commercial damages or - losses), even if such Contributor has been advised of the possibility - of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing the - Work or Derivative Works thereof, You may choose to offer, and charge a - fee for, acceptance of support, warranty, indemnity, or other liability - obligations and/or rights consistent with this License. However, in - accepting such obligations, You may act only on Your own behalf and on - Your sole responsibility, not on behalf of any other Contributor, and - only if You agree to indemnify, defend, and hold each Contributor - harmless for any liability incurred by, or claims asserted against, - such Contributor by reason of your accepting any such warranty or - additional liability. - - END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "" replaced - with your own identifying information. (Don't include the brackets!) - The text should be enclosed in the appropriate comment syntax for the - file format. We also recommend that a file or class name and - description of purpose be included on the same "printed page" as the - copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - The LaTeX Project Public License - -LPPL Version 1.3c 2008-05-04 - -Copyright 1999 2002-2008 LaTeX3 Project - Everyone is allowed to distribute verbatim copies of this - license document, but modification of it is not allowed. - - -PREAMBLE -======== - -The LaTeX Project Public License (LPPL) is the primary license under -which the LaTeX kernel and the base LaTeX packages are distributed. - -You may use this license for any work of which you hold the copyright -and which you wish to distribute. This license may be particularly -suitable if your work is TeX-related (such as a LaTeX package), but -it is written in such a way that you can use it even if your work is -unrelated to TeX. - -The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', -below, gives instructions, examples, and recommendations for authors -who are considering distributing their works under this license. - -This license gives conditions under which a work may be distributed -and modified, as well as conditions under which modified versions of -that work may be distributed. - -We, the LaTeX3 Project, believe that the conditions below give you -the freedom to make and distribute modified versions of your work -that conform with whatever technical specifications you wish while -maintaining the availability, integrity, and reliability of -that work. If you do not see how to achieve your goal while -meeting these conditions, then read the document `cfgguide.tex' -and `modguide.tex' in the base LaTeX distribution for suggestions. - - -DEFINITIONS -=========== - -In this license document the following terms are used: - - `Work' - Any work being distributed under this License. - - `Derived Work' - Any work that under any applicable law is derived from the Work. - - `Modification' - Any procedure that produces a Derived Work under any applicable - law -- for example, the production of a file containing an - original file associated with the Work or a significant portion of - such a file, either verbatim or with modifications and/or - translated into another language. - - `Modify' - To apply any procedure that produces a Derived Work under any - applicable law. - - `Distribution' - Making copies of the Work available from one person to another, in - whole or in part. Distribution includes (but is not limited to) - making any electronic components of the Work accessible by - file transfer protocols such as FTP or HTTP or by shared file - systems such as Sun's Network File System (NFS). - - `Compiled Work' - A version of the Work that has been processed into a form where it - is directly usable on a computer system. This processing may - include using installation facilities provided by the Work, - transformations of the Work, copying of components of the Work, or - other activities. Note that modification of any installation - facilities provided by the Work constitutes modification of the Work. - - `Current Maintainer' - A person or persons nominated as such within the Work. If there is - no such explicit nomination then it is the `Copyright Holder' under - any applicable law. - - `Base Interpreter' - A program or process that is normally needed for running or - interpreting a part or the whole of the Work. - - A Base Interpreter may depend on external components but these - are not considered part of the Base Interpreter provided that each - external component clearly identifies itself whenever it is used - interactively. Unless explicitly specified when applying the - license to the Work, the only applicable Base Interpreter is a - `LaTeX-Format' or in the case of files belonging to the - `LaTeX-format' a program implementing the `TeX language'. - - - -CONDITIONS ON DISTRIBUTION AND MODIFICATION -=========================================== - -1. Activities other than distribution and/or modification of the Work -are not covered by this license; they are outside its scope. In -particular, the act of running the Work is not restricted and no -requirements are made concerning any offers of support for the Work. - -2. You may distribute a complete, unmodified copy of the Work as you -received it. Distribution of only part of the Work is considered -modification of the Work, and no right to distribute such a Derived -Work may be assumed under the terms of this clause. - -3. You may distribute a Compiled Work that has been generated from a -complete, unmodified copy of the Work as distributed under Clause 2 -above, as long as that Compiled Work is distributed in such a way that -the recipients may install the Compiled Work on their system exactly -as it would have been installed if they generated a Compiled Work -directly from the Work. - -4. If you are the Current Maintainer of the Work, you may, without -restriction, modify the Work, thus creating a Derived Work. You may -also distribute the Derived Work without restriction, including -Compiled Works generated from the Derived Work. Derived Works -distributed in this manner by the Current Maintainer are considered to -be updated versions of the Work. - -5. If you are not the Current Maintainer of the Work, you may modify -your copy of the Work, thus creating a Derived Work based on the Work, -and compile this Derived Work, thus creating a Compiled Work based on -the Derived Work. - -6. If you are not the Current Maintainer of the Work, you may -distribute a Derived Work provided the following conditions are met -for every component of the Work unless that component clearly states -in the copyright notice that it is exempt from that condition. Only -the Current Maintainer is allowed to add such statements of exemption -to a component of the Work. - - a. If a component of this Derived Work can be a direct replacement - for a component of the Work when that component is used with the - Base Interpreter, then, wherever this component of the Work - identifies itself to the user when used interactively with that - Base Interpreter, the replacement component of this Derived Work - clearly and unambiguously identifies itself as a modified version - of this component to the user when used interactively with that - Base Interpreter. - - b. Every component of the Derived Work contains prominent notices - detailing the nature of the changes to that component, or a - prominent reference to another file that is distributed as part - of the Derived Work and that contains a complete and accurate log - of the changes. - - c. No information in the Derived Work implies that any persons, - including (but not limited to) the authors of the original version - of the Work, provide any support, including (but not limited to) - the reporting and handling of errors, to recipients of the - Derived Work unless those persons have stated explicitly that - they do provide such support for the Derived Work. - - d. You distribute at least one of the following with the Derived Work: - - 1. A complete, unmodified copy of the Work; - if your distribution of a modified component is made by - offering access to copy the modified component from a - designated place, then offering equivalent access to copy - the Work from the same or some similar place meets this - condition, even though third parties are not compelled to - copy the Work along with the modified component; - - 2. Information that is sufficient to obtain a complete, - unmodified copy of the Work. - -7. If you are not the Current Maintainer of the Work, you may -distribute a Compiled Work generated from a Derived Work, as long as -the Derived Work is distributed to all recipients of the Compiled -Work, and as long as the conditions of Clause 6, above, are met with -regard to the Derived Work. - -8. The conditions above are not intended to prohibit, and hence do not -apply to, the modification, by any method, of any component so that it -becomes identical to an updated version of that component of the Work as -it is distributed by the Current Maintainer under Clause 4, above. - -9. Distribution of the Work or any Derived Work in an alternative -format, where the Work or that Derived Work (in whole or in part) is -then produced by applying some process to that format, does not relax or -nullify any sections of this license as they pertain to the results of -applying that process. - -10. a. A Derived Work may be distributed under a different license - provided that license itself honors the conditions listed in - Clause 6 above, in regard to the Work, though it does not have - to honor the rest of the conditions in this license. - - b. If a Derived Work is distributed under a different license, that - Derived Work must provide sufficient documentation as part of - itself to allow each recipient of that Derived Work to honor the - restrictions in Clause 6 above, concerning changes from the Work. - -11. This license places no restrictions on works that are unrelated to -the Work, nor does this license place any restrictions on aggregating -such works with the Work by any means. - -12. Nothing in this license is intended to, or may be used to, prevent -complete compliance by all parties with all applicable laws. - - -NO WARRANTY -=========== - -There is no warranty for the Work. Except when otherwise stated in -writing, the Copyright Holder provides the Work `as is', without -warranty of any kind, either expressed or implied, including, but not -limited to, the implied warranties of merchantability and fitness for a -particular purpose. The entire risk as to the quality and performance -of the Work is with you. Should the Work prove defective, you assume -the cost of all necessary servicing, repair, or correction. - -In no event unless required by applicable law or agreed to in writing -will The Copyright Holder, or any author named in the components of the -Work, or any other party who may distribute and/or modify the Work as -permitted above, be liable to you for damages, including any general, -special, incidental or consequential damages arising out of any use of -the Work or out of inability to use the Work (including, but not limited -to, loss of data, data being rendered inaccurate, or losses sustained by -anyone as a result of any failure of the Work to operate with any other -programs), even if the Copyright Holder or said author or said other -party has been advised of the possibility of such damages. - - -MAINTENANCE OF THE WORK -======================= - -The Work has the status `author-maintained' if the Copyright Holder -explicitly and prominently states near the primary copyright notice in -the Work that the Work can only be maintained by the Copyright Holder -or simply that it is `author-maintained'. - -The Work has the status `maintained' if there is a Current Maintainer -who has indicated in the Work that they are willing to receive error -reports for the Work (for example, by supplying a valid e-mail -address). It is not required for the Current Maintainer to acknowledge -or act upon these error reports. - -The Work changes from status `maintained' to `unmaintained' if there -is no Current Maintainer, or the person stated to be Current -Maintainer of the work cannot be reached through the indicated means -of communication for a period of six months, and there are no other -significant signs of active maintenance. - -You can become the Current Maintainer of the Work by agreement with -any existing Current Maintainer to take over this role. - -If the Work is unmaintained, you can become the Current Maintainer of -the Work through the following steps: - - 1. Make a reasonable attempt to trace the Current Maintainer (and - the Copyright Holder, if the two differ) through the means of - an Internet or similar search. - - 2. If this search is successful, then enquire whether the Work - is still maintained. - - a. If it is being maintained, then ask the Current Maintainer - to update their communication data within one month. - - b. If the search is unsuccessful or no action to resume active - maintenance is taken by the Current Maintainer, then announce - within the pertinent community your intention to take over - maintenance. (If the Work is a LaTeX work, this could be - done, for example, by posting to comp.text.tex.) - - 3a. If the Current Maintainer is reachable and agrees to pass - maintenance of the Work to you, then this takes effect - immediately upon announcement. - - b. If the Current Maintainer is not reachable and the Copyright - Holder agrees that maintenance of the Work be passed to you, - then this takes effect immediately upon announcement. - - 4. If you make an `intention announcement' as described in 2b. above - and after three months your intention is challenged neither by - the Current Maintainer nor by the Copyright Holder nor by other - people, then you may arrange for the Work to be changed so as - to name you as the (new) Current Maintainer. - - 5. If the previously unreachable Current Maintainer becomes - reachable once more within three months of a change completed - under the terms of 3b) or 4), then that Current Maintainer must - become or remain the Current Maintainer upon request provided - they then update their communication data within one month. - -A change in the Current Maintainer does not, of itself, alter the fact -that the Work is distributed under the LPPL license. - -If you become the Current Maintainer of the Work, you should -immediately provide, within the Work, a prominent and unambiguous -statement of your status as Current Maintainer. You should also -announce your new status to the same pertinent community as -in 2b) above. - - -WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE -====================================================== - -This section contains important instructions, examples, and -recommendations for authors who are considering distributing their -works under this license. These authors are addressed as `you' in -this section. - -Choosing This License or Another License ----------------------------------------- - -If for any part of your work you want or need to use *distribution* -conditions that differ significantly from those in this license, then -do not refer to this license anywhere in your work but, instead, -distribute your work under a different license. You may use the text -of this license as a model for your own license, but your license -should not refer to the LPPL or otherwise give the impression that -your work is distributed under the LPPL. - -The document `modguide.tex' in the base LaTeX distribution explains -the motivation behind the conditions of this license. It explains, -for example, why distributing LaTeX under the GNU General Public -License (GPL) was considered inappropriate. Even if your work is -unrelated to LaTeX, the discussion in `modguide.tex' may still be -relevant, and authors intending to distribute their works under any -license are encouraged to read it. - -A Recommendation on Modification Without Distribution ------------------------------------------------------ - -It is wise never to modify a component of the Work, even for your own -personal use, without also meeting the above conditions for -distributing the modified component. While you might intend that such -modifications will never be distributed, often this will happen by -accident -- you may forget that you have modified that component; or -it may not occur to you when allowing others to access the modified -version that you are thus distributing it and violating the conditions -of this license in ways that could have legal implications and, worse, -cause problems for the community. It is therefore usually in your -best interest to keep your copy of the Work identical with the public -one. Many works provide ways to control the behavior of that work -without altering any of its licensed components. - -How to Use This License ------------------------ - -To use this license, place in each of the components of your work both -an explicit copyright notice including your name and the year the work -was authored and/or last substantially modified. Include also a -statement that the distribution and/or modification of that -component is constrained by the conditions in this license. - -Here is an example of such a notice and statement: - - %% pig.dtx - %% Copyright 2005 M. Y. Name - % - % This work may be distributed and/or modified under the - % conditions of the LaTeX Project Public License, either version 1.3 - % of this license or (at your option) any later version. - % The latest version of this license is in - % http://www.latex-project.org/lppl.txt - % and version 1.3 or later is part of all distributions of LaTeX - % version 2005/12/01 or later. - % - % This work has the LPPL maintenance status `maintained'. - % - % The Current Maintainer of this work is M. Y. Name. - % - % This work consists of the files pig.dtx and pig.ins - % and the derived file pig.sty. - -Given such a notice and statement in a file, the conditions -given in this license document would apply, with the `Work' referring -to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being -generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' -referring to any `LaTeX-Format', and both `Copyright Holder' and -`Current Maintainer' referring to the person `M. Y. Name'. - -If you do not want the Maintenance section of LPPL to apply to your -Work, change `maintained' above into `author-maintained'. -However, we recommend that you use `maintained', as the Maintenance -section was added in order to ensure that your Work remains useful to -the community even when you can no longer maintain and support it -yourself. - -Derived Works That Are Not Replacements ---------------------------------------- - -Several clauses of the LPPL specify means to provide reliability and -stability for the user community. They therefore concern themselves -with the case that a Derived Work is intended to be used as a -(compatible or incompatible) replacement of the original Work. If -this is not the case (e.g., if a few lines of code are reused for a -completely different task), then clauses 6b and 6d shall not apply. - - -Important Recommendations -------------------------- - - Defining What Constitutes the Work - - The LPPL requires that distributions of the Work contain all the - files of the Work. It is therefore important that you provide a - way for the licensee to determine which files constitute the Work. - This could, for example, be achieved by explicitly listing all the - files of the Work near the copyright notice of each file or by - using a line such as: - - % This work consists of all files listed in manifest.txt. - - in that place. In the absence of an unequivocal list it might be - impossible for the licensee to determine what is considered by you - to comprise the Work and, in such a case, the licensee would be - entitled to make reasonable conjectures as to which files comprise - the Work. - - Creative Commons Attribution-ShareAlike 3.0 Unported - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES - RESULTING FROM ITS USE. - -License - - THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS - CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS - PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK - OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS - PROHIBITED. - - BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND - AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS - LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE - RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS - AND CONDITIONS. - - 1. Definitions - a. "Adaptation" means a work based upon the Work, or upon the Work and - other pre-existing works, such as a translation, adaptation, - derivative work, arrangement of music or other alterations of a - literary or artistic work, or phonogram or performance and includes - cinematographic adaptations or any other form in which the Work may - be recast, transformed, or adapted including in any form - recognizably derived from the original, except that a work that - constitutes a Collection will not be considered an Adaptation for - the purpose of this License. For the avoidance of doubt, where the - Work is a musical work, performance or phonogram, the - synchronization of the Work in timed-relation with a moving image - ("synching") will be considered an Adaptation for the purpose of - this License. - b. "Collection" means a collection of literary or artistic works, such - as encyclopedias and anthologies, or performances, phonograms or - broadcasts, or other works or subject matter other than works - listed in Section 1(f) below, which, by reason of the selection and - arrangement of their contents, constitute intellectual creations, - in which the Work is included in its entirety in unmodified form - along with one or more other contributions, each constituting - separate and independent works in themselves, which together are - assembled into a collective whole. A work that constitutes a - Collection will not be considered an Adaptation (as defined below) - for the purposes of this License. - c. "Creative Commons Compatible License" means a license that is - listed at http://creativecommons.org/compatiblelicenses that has - been approved by Creative Commons as being essentially equivalent - to this License, including, at a minimum, because that license: (i) - contains terms that have the same purpose, meaning and effect as - the License Elements of this License; and, (ii) explicitly permits - the relicensing of adaptations of works made available under that - license under this License or a Creative Commons jurisdiction - license with the same License Elements as this License. - d. "Distribute" means to make available to the public the original and - copies of the Work or Adaptation, as appropriate, through sale or - other transfer of ownership. - e. "License Elements" means the following high-level license - attributes as selected by Licensor and indicated in the title of - this License: Attribution, ShareAlike. - f. "Licensor" means the individual, individuals, entity or entities - that offer(s) the Work under the terms of this License. - g. "Original Author" means, in the case of a literary or artistic - work, the individual, individuals, entity or entities who created - the Work or if no individual or entity can be identified, the - publisher; and in addition (i) in the case of a performance the - actors, singers, musicians, dancers, and other persons who act, - sing, deliver, declaim, play in, interpret or otherwise perform - literary or artistic works or expressions of folklore; (ii) in the - case of a phonogram the producer being the person or legal entity - who first fixes the sounds of a performance or other sounds; and, - (iii) in the case of broadcasts, the organization that transmits - the broadcast. - h. "Work" means the literary and/or artistic work offered under the - terms of this License including without limitation any production - in the literary, scientific and artistic domain, whatever may be - the mode or form of its expression including digital form, such as - a book, pamphlet and other writing; a lecture, address, sermon or - other work of the same nature; a dramatic or dramatico-musical - work; a choreographic work or entertainment in dumb show; a musical - composition with or without words; a cinematographic work to which - are assimilated works expressed by a process analogous to - cinematography; a work of drawing, painting, architecture, - sculpture, engraving or lithography; a photographic work to which - are assimilated works expressed by a process analogous to - photography; a work of applied art; an illustration, map, plan, - sketch or three-dimensional work relative to geography, topography, - architecture or science; a performance; a broadcast; a phonogram; a - compilation of data to the extent it is protected as a - copyrightable work; or a work performed by a variety or circus - performer to the extent it is not otherwise considered a literary - or artistic work. - i. "You" means an individual or entity exercising rights under this - License who has not previously violated the terms of this License - with respect to the Work, or who has received express permission - from the Licensor to exercise rights under this License despite a - previous violation. - j. "Publicly Perform" means to perform public recitations of the Work - and to communicate to the public those public recitations, by any - means or process, including by wire or wireless means or public - digital performances; to make available to the public Works in such - a way that members of the public may access these Works from a - place and at a place individually chosen by them; to perform the - Work to the public by any means or process and the communication to - the public of the performances of the Work, including by public - digital performance; to broadcast and rebroadcast the Work by any - means including signs, sounds or images. - k. "Reproduce" means to make copies of the Work by any means including - without limitation by sound or visual recordings and the right of - fixation and reproducing fixations of the Work, including storage - of a protected performance or phonogram in digital form or other - electronic medium. - - 2. Fair Dealing Rights. Nothing in this License is intended to reduce, - limit, or restrict any uses free from copyright or rights arising from - limitations or exceptions that are provided for in connection with the - copyright protection under copyright law or other applicable laws. - - 3. License Grant. Subject to the terms and conditions of this License, - Licensor hereby grants You a worldwide, royalty-free, non-exclusive, - perpetual (for the duration of the applicable copyright) license to - exercise the rights in the Work as stated below: - a. to Reproduce the Work, to incorporate the Work into one or more - Collections, and to Reproduce the Work as incorporated in the - Collections; - b. to create and Reproduce Adaptations provided that any such - Adaptation, including any translation in any medium, takes - reasonable steps to clearly label, demarcate or otherwise identify - that changes were made to the original Work. For example, a - translation could be marked "The original work was translated from - English to Spanish," or a modification could indicate "The original - work has been modified."; - c. to Distribute and Publicly Perform the Work including as - incorporated in Collections; and, - d. to Distribute and Publicly Perform Adaptations. - e. For the avoidance of doubt: - i. Non-waivable Compulsory License Schemes. In those - jurisdictions in which the right to collect royalties through - any statutory or compulsory licensing scheme cannot be waived, - the Licensor reserves the exclusive right to collect such - royalties for any exercise by You of the rights granted under - this License; - ii. Waivable Compulsory License Schemes. In those jurisdictions in - which the right to collect royalties through any statutory or - compulsory licensing scheme can be waived, the Licensor waives - the exclusive right to collect such royalties for any exercise - by You of the rights granted under this License; and, - iii. Voluntary License Schemes. The Licensor waives the right to - collect royalties, whether individually or, in the event that - the Licensor is a member of a collecting society that - administers voluntary licensing schemes, via that society, - from any exercise by You of the rights granted under this - License. - - The above rights may be exercised in all media and formats whether now - known or hereafter devised. The above rights include the right to make - such modifications as are technically necessary to exercise the rights - in other media and formats. Subject to Section 8(f), all rights not - expressly granted by Licensor are hereby reserved. - - 4. Restrictions. The license granted in Section 3 above is expressly - made subject to and limited by the following restrictions: - a. You may Distribute or Publicly Perform the Work only under the - terms of this License. You must include a copy of, or the Uniform - Resource Identifier (URI) for, this License with every copy of the - Work You Distribute or Publicly Perform. You may not offer or - impose any terms on the Work that restrict the terms of this - License or the ability of the recipient of the Work to exercise the - rights granted to that recipient under the terms of the License. - You may not sublicense the Work. You must keep intact all notices - that refer to this License and to the disclaimer of warranties with - every copy of the Work You Distribute or Publicly Perform. When You - Distribute or Publicly Perform the Work, You may not impose any - effective technological measures on the Work that restrict the - ability of a recipient of the Work from You to exercise the rights - granted to that recipient under the terms of the License. This - Section 4(a) applies to the Work as incorporated in a Collection, - but this does not require the Collection apart from the Work itself - to be made subject to the terms of this License. If You create a - Collection, upon notice from any Licensor You must, to the extent - practicable, remove from the Collection any credit as required by - Section 4(c), as requested. If You create an Adaptation, upon - notice from any Licensor You must, to the extent practicable, - remove from the Adaptation any credit as required by Section 4(c), - as requested. - b. You may Distribute or Publicly Perform an Adaptation only under the - terms of: (i) this License; (ii) a later version of this License - with the same License Elements as this License; (iii) a Creative - Commons jurisdiction license (either this or a later license - version) that contains the same License Elements as this License - (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons - Compatible License. If you license the Adaptation under one of the - licenses mentioned in (iv), you must comply with the terms of that - license. If you license the Adaptation under the terms of any of - the licenses mentioned in (i), (ii) or (iii) (the "Applicable - License"), you must comply with the terms of the Applicable License - generally and the following provisions: (I) You must include a copy - of, or the URI for, the Applicable License with every copy of each - Adaptation You Distribute or Publicly Perform; (II) You may not - offer or impose any terms on the Adaptation that restrict the terms - of the Applicable License or the ability of the recipient of the - Adaptation to exercise the rights granted to that recipient under - the terms of the Applicable License; (III) You must keep intact all - notices that refer to the Applicable License and to the disclaimer - of warranties with every copy of the Work as included in the - Adaptation You Distribute or Publicly Perform; (IV) when You - Distribute or Publicly Perform the Adaptation, You may not impose - any effective technological measures on the Adaptation that - restrict the ability of a recipient of the Adaptation from You to - exercise the rights granted to that recipient under the terms of - the Applicable License. This Section 4(b) applies to the Adaptation - as incorporated in a Collection, but this does not require the - Collection apart from the Adaptation itself to be made subject to - the terms of the Applicable License. - c. If You Distribute, or Publicly Perform the Work or any Adaptations - or Collections, You must, unless a request has been made pursuant - to Section 4(a), keep intact all copyright notices for the Work and - provide, reasonable to the medium or means You are utilizing: (i) - the name of the Original Author (or pseudonym, if applicable) if - supplied, and/or if the Original Author and/or Licensor designate - another party or parties (e.g., a sponsor institute, publishing - entity, journal) for attribution ("Attribution Parties") in - Licensor's copyright notice, terms of service or by other - reasonable means, the name of such party or parties; (ii) the title - of the Work if supplied; (iii) to the extent reasonably - practicable, the URI, if any, that Licensor specifies to be - associated with the Work, unless such URI does not refer to the - copyright notice or licensing information for the Work; and (iv) , - consistent with Ssection 3(b), in the case of an Adaptation, a - credit identifying the use of the Work in the Adaptation (e.g., - "French translation of the Work by Original Author," or "Screenplay - based on original Work by Original Author"). The credit required by - this Section 4(c) may be implemented in any reasonable manner; - provided, however, that in the case of a Adaptation or Collection, - at a minimum such credit will appear, if a credit for all - contributing authors of the Adaptation or Collection appears, then - as part of these credits and in a manner at least as prominent as - the credits for the other contributing authors. For the avoidance - of doubt, You may only use the credit required by this Section for - the purpose of attribution in the manner set out above and, by - exercising Your rights under this License, You may not implicitly - or explicitly assert or imply any connection with, sponsorship or - endorsement by the Original Author, Licensor and/or Attribution - Parties, as appropriate, of You or Your use of the Work, without - the separate, express prior written permission of the Original - Author, Licensor and/or Attribution Parties. - d. Except as otherwise agreed in writing by the Licensor or as may be - otherwise permitted by applicable law, if You Reproduce, Distribute - or Publicly Perform the Work either by itself or as part of any - Adaptations or Collections, You must not distort, mutilate, modify - or take other derogatory action in relation to the Work which would - be prejudicial to the Original Author's honor or reputation. - Licensor agrees that in those jurisdictions (e.g. Japan), in which - any exercise of the right granted in Section 3(b) of this License - (the right to make Adaptations) would be deemed to be a distortion, - mutilation, modification or other derogatory action prejudicial to - the Original Author's honor and reputation, the Licensor will waive - or not assert, as appropriate, this Section, to the fullest extent - permitted by the applicable national law, to enable You to - reasonably exercise Your right under Section 3(b) of this License - (right to make Adaptations) but not otherwise. - - 5. Representations, Warranties and Disclaimer - - UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR - OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY - KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, - INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, - FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF - LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF - ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW - THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO - YOU. - - 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE - LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR - ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES - ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - 7. Termination - a. This License and the rights granted hereunder will terminate - automatically upon any breach by You of the terms of this License. - Individuals or entities who have received Adaptations or - Collections from You under this License, however, will not have - their licenses terminated provided such individuals or entities - remain in full compliance with those licenses. Sections 1, 2, 5, 6, - 7, and 8 will survive any termination of this License. - b. Subject to the above terms and conditions, the license granted here - is perpetual (for the duration of the applicable copyright in the - Work). Notwithstanding the above, Licensor reserves the right to - release the Work under different license terms or to stop - distributing the Work at any time; provided, however that any such - election will not serve to withdraw this License (or any other - license that has been, or is required to be, granted under the - terms of this License), and this License will continue in full - force and effect unless terminated as stated above. - - 8. Miscellaneous - a. Each time You Distribute or Publicly Perform the Work or a - Collection, the Licensor offers to the recipient a license to the - Work on the same terms and conditions as the license granted to You - under this License. - b. Each time You Distribute or Publicly Perform an Adaptation, - Licensor offers to the recipient a license to the original Work on - the same terms and conditions as the license granted to You under - this License. - c. If any provision of this License is invalid or unenforceable under - applicable law, it shall not affect the validity or enforceability - of the remainder of the terms of this License, and without further - action by the parties to this agreement, such provision shall be - reformed to the minimum extent necessary to make such provision - valid and enforceable. - d. No term or provision of this License shall be deemed waived and no - breach consented to unless such waiver or consent shall be in - writing and signed by the party to be charged with such waiver or - consent. - e. This License constitutes the entire agreement between the parties - with respect to the Work licensed here. There are no - understandings, agreements or representations with respect to the - Work not specified here. Licensor shall not be bound by any - additional provisions that may appear in any communication from - You. This License may not be modified without the mutual written - agreement of the Licensor and You. - f. The rights granted under, and the subject matter referenced, in - this License were drafted utilizing the terminology of the Berne - Convention for the Protection of Literary and Artistic Works (as - amended on September 28, 1979), the Rome Convention of 1961, the - WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms - Treaty of 1996 and the Universal Copyright Convention (as revised - on July 24, 1971). These rights and subject matter take effect in - the relevant jurisdiction in which the License terms are sought to - be enforced according to the corresponding provisions of the - implementation of those treaty provisions in the applicable - national law. If the standard suite of rights granted under - applicable copyright law includes additional rights not granted - under this License, such additional rights are deemed to be - included in the License; this License is not intended to restrict - the license of any rights under applicable law. - -Creative Commons Notice - - Creative Commons is not a party to this License, and makes no warranty - whatsoever in connection with the Work. Creative Commons will not be - liable to You or any party on any legal theory for any damages - whatsoever, including without limitation any general, special, - incidental or consequential damages arising in connection to this - license. Notwithstanding the foregoing two (2) sentences, if Creative - Commons has expressly identified itself as the Licensor hereunder, it - shall have all rights and obligations of Licensor. - - Except for the limited purpose of indicating to the public that the - Work is licensed under the CCPL, Creative Commons does not authorize - the use by either party of the trademark "Creative Commons" or any - related trademark or logo of Creative Commons without the prior written - consent of Creative Commons. Any permitted use will be in compliance - with Creative Commons' then-current trademark usage guidelines, as may - be published on its website or otherwise made available upon request - from time to time. For the avoidance of doubt, this trademark - restriction does not form part of the License. - - Creative Commons may be contacted at http://creativecommons.org/. - diff --git a/packaging/distribution/src/main/resources/licenses/notice.txt b/packaging/distribution/src/main/resources/licenses/notice.txt index b066847e1d..d76401367c 100644 --- a/packaging/distribution/src/main/resources/licenses/notice.txt +++ b/packaging/distribution/src/main/resources/licenses/notice.txt @@ -45,7 +45,6 @@ commons-pool http://jakarta.apache.org/commons/ commons-validator http://jakarta.apache.org/commons/ ConcurrentLinkedHashMap http://code.google.com/p/concurrentlinkedhashmap/ Fast Infoset Project http://fi.java.net/ -PDFBox http://pdfbox.apache.org/ Google Data Java Client Library http://code.google.com/p/gdata-java-client/ Geronimo Activation http://geronimo.apache.org/ Geronimo Annotation http://geronimo.apache.org/ @@ -191,10 +190,6 @@ truezip http://truezip.java.net/ icu4j http://icu-project.org/ -=== Imagemagick === -Imagemagick http://www.imagemagick.org/script/license.php - - === JSON license === JSon http://www.json.org/java/ @@ -211,16 +206,11 @@ libwmf http://wvware.sourceforge.net/libwmf.html === LGPL 2.1 === Hibernate http://www.hibernate.org/ jid3lib http://javamusictag.sourceforge.net/ -JMagick http://sourceforge.net/projects/jmagick/ -JODConverter http://jodconverter.sourceforge.net/ -PDF Renderer http://java.net/projects/pdf-renderer TinyMCE http://www.tinymce.com/ === LGPL 3.0 === Gytheio https://github.com/Alfresco/gytheio -Jut.jar http://www.openoffice.org/licenses/lgpl_license.html -OpenOffice SDK http://www.openoffice.org/licenses/lgpl_license.html === MIT License === @@ -243,7 +233,6 @@ juniversalchardet http://code.google.com/p/juniversalchardet/ === Mozilla Public License 2.0 === CCC2 http://www.webdetails.pt/ctools/ccc/ rhino-js http://www.mozilla.org/rhino/ -LibreOffice http://www.libreoffice.org/ === Oracle Binary Code License === @@ -279,7 +268,6 @@ The svn diff files with the details of the changes can be found in the following === Apache 2.0 License ==== acegi http://sourceforge.net/projects/acegisecurity/ commons-dbcp http://jakarta.apache.org/commons/ -PDFBox http://pdfbox.apache.org/ Greenmail http://www.icegreen.com/greenmail/ POI http://poi.apache.org/ quartz http://quartz-scheduler.org/ @@ -297,12 +285,9 @@ TrueLicense http://truelicense.java.net/ === LGPL 2.1 === Hibernate http://www.hibernate.org/ -JODConverter http://jodconverter.sourceforge.net/ -PDF Renderer http://java.net/projects/pdf-renderer TinyMCE http://www.tinymce.com/ === LGPL 3.0 === -Jut.jar http://www.openoffice.org/licenses/lgpl_license.html === Mozilla Public License 2.0 === rhino-js http://www.mozilla.org/rhino/ diff --git a/packaging/tests/environment/docker-compose-minimal+transforms.yml b/packaging/tests/environment/docker-compose-minimal+transforms.yml index 1f49de4b8b..17281c9512 100644 --- a/packaging/tests/environment/docker-compose-minimal+transforms.yml +++ b/packaging/tests/environment/docker-compose-minimal+transforms.yml @@ -40,11 +40,6 @@ services: -Daos.baseUrlOverwrite=http://localhost:8082/alfresco/aos -Dmessaging.broker.url=\"failover:(tcp://activemq:61616)?timeout=3000&jms.useCompression=true\" -DlocalTransform.core-aio.url=http://transform-core-aio:8090/ - -Dalfresco-pdf-renderer.url=http://transform-core-aio:8090/ - -Djodconverter.url=http://transform-core-aio:8090/ - -Dimg.url=http://transform-core-aio:8090/ - -Dtika.url=http://transform-core-aio:8090/ - -Dtransform.misc.url=http://transform-core-aio:8090/ -Dimap.server.port=1143 -Dftp.port=1221 -Dcors.enabled=true diff --git a/packaging/war/src/main/resources/log4j.properties b/packaging/war/src/main/resources/log4j.properties index 75817dd16b..d2395ab8e8 100644 --- a/packaging/war/src/main/resources/log4j.properties +++ b/packaging/war/src/main/resources/log4j.properties @@ -239,11 +239,6 @@ log4j.logger.freemarker.runtime= # Metadata extraction log4j.logger.org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter=warn -# Reduces PDFont error level due to ALF-7105 -log4j.logger.org.apache.pdfbox.pdmodel.font.PDSimpleFont=fatal -log4j.logger.org.apache.pdfbox.pdmodel.font.PDFont=fatal -log4j.logger.org.apache.pdfbox.pdmodel.font.PDCIDFont=fatal - # no index support log4j.logger.org.alfresco.repo.search.impl.noindex.NoIndexIndexer=fatal log4j.logger.org.alfresco.repo.search.impl.noindex.NoIndexSearchService=fatal @@ -264,10 +259,7 @@ log4j.logger.org.alfresco.enterprise.repo.authorization.AuthorizationsConsistenc log4j.logger.org.alfresco.heartbeat=info # Transformations -log4j.logger.org.alfresco.repo.content.transform.JodContentTransformer=info -log4j.logger.org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerWorker=info -log4j.logger.org.alfresco.repo.content.transform.pdfrenderer.AlfrescoPdfRendererContentTransformerWorker=info -log4j.logger.org.alfresco.repo.content.transform.TikaPoweredContentTransformer=info +#log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug log4j.logger.org.alfresco.repo.content.transform=info diff --git a/packaging/war/src/main/webapp/images/logo/libreoffice.png b/packaging/war/src/main/webapp/images/logo/libreoffice.png deleted file mode 100644 index c08e6b16cb..0000000000 Binary files a/packaging/war/src/main/webapp/images/logo/libreoffice.png and /dev/null differ diff --git a/packaging/war/src/main/webapp/images/logo/myfaces.png b/packaging/war/src/main/webapp/images/logo/myfaces.png deleted file mode 100644 index 52c42a8128..0000000000 Binary files a/packaging/war/src/main/webapp/images/logo/myfaces.png and /dev/null differ diff --git a/packaging/war/src/main/webapp/images/logo/pdfbox.gif b/packaging/war/src/main/webapp/images/logo/pdfbox.gif deleted file mode 100644 index 36d6a66fbf..0000000000 Binary files a/packaging/war/src/main/webapp/images/logo/pdfbox.gif and /dev/null differ diff --git a/pom.xml b/pom.xml index 173e10b2fa..d9b4420a4c 100644 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,9 @@ 11 ${project.build.directory}/alf_data - convert 1.0.12 6.0 - 1.1 2.3 7.1 6.0.1 @@ -61,7 +59,6 @@ 2.11.2 3.4.2 1.0.0 - 2.0.21 8.15 1.68 3.6.0 @@ -82,8 +79,6 @@ 1.25 5.4.1 7.7.10 - 4.1.2 - 1.4 11.0.0-alfresco-001 3.4.1.Final 2.24.2 @@ -165,20 +160,6 @@ alfresco-mmt ${dependency.alfresco-mmt.version} - - org.alfresco - alfresco-pdf-renderer - ${dependency.alfresco-pdf-renderer.version} - linux - tgz - - - org.alfresco - alfresco-pdf-renderer - ${dependency.alfresco-pdf-renderer.version} - win64 - tgz - org.alfresco alfresco-server-root @@ -534,12 +515,6 @@ commons-compress 1.20 - - - org.apache.pdfbox - pdfbox - ${dependency.pdfbox.version} - org.apache.commons commons-csv diff --git a/remote-api/pom.xml b/remote-api/pom.xml index eaea048447..b1d8a9e7cd 100644 --- a/remote-api/pom.xml +++ b/remote-api/pom.xml @@ -208,100 +208,6 @@ - - - - win-alfresco-pdf-renderer-test - - - windows - - - - - org.alfresco - alfresco-pdf-renderer - win64 - tgz - - - - - - false - maven-antrun-plugin - - - extract-alfresco-pdf-renderer-test - generate-test-resources - - run - - - ${skipTests} - - - - - - - - - - - - - ${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer - - - - linux-alfresco-pdf-renderer-test - - - linux - - - - - org.alfresco - alfresco-pdf-renderer - linux - tgz - - - - - - false - maven-antrun-plugin - - - extract-alfresco-pdf-renderer-test - generate-test-resources - - run - - - ${skipTests} - - - - - - - - - - - - - - - - ${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer - - - @@ -335,8 +241,6 @@ ${project.build.directory} - ${alfresco-pdf-renderer.exe} - ${db.url} ${db.driver} @@ -344,7 +248,6 @@ ${db.username} ${db.password} ${dir.root} - ${img.exe} 30 2000 diff --git a/remote-api/src/main/java/org/alfresco/repo/webdav/UnlockMethod.java b/remote-api/src/main/java/org/alfresco/repo/webdav/UnlockMethod.java index 837afdfeac..b68a5f5aa4 100644 --- a/remote-api/src/main/java/org/alfresco/repo/webdav/UnlockMethod.java +++ b/remote-api/src/main/java/org/alfresco/repo/webdav/UnlockMethod.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 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 . + * #L% + */ package org.alfresco.repo.webdav; import java.util.Set; @@ -82,8 +82,6 @@ public class UnlockMethod extends WebDAVMethod { if (!(strLockTokenHeader.startsWith("<") && strLockTokenHeader.endsWith(">"))) { - // ALF-13904: Header isn't correctly enclosed in < and > characters. Try correcting this - // to allow for Windows 7 + OpenOffice.org bug. strLockTokenHeader = "<" + strLockTokenHeader + ">"; } if (strLockTokenHeader.startsWith("<" + WebDAV.OPAQUE_LOCK_TOKEN) && strLockTokenHeader.endsWith(">")) diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console.properties b/remote-api/src/main/resources/alfresco/messages/admin-console.properties index b5f2a8469e..c8afd58a28 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console.properties @@ -20,7 +20,6 @@ admin-console.close=Close admin-console.password.show=Show Password admin-console.password.hide=Hide Password admin-console.unavailable=Information is currently unavailable -admin-console.not.installed=Not Installed admin-console.requesterror=We couldn't complete your request. Try again. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_cs.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_cs.properties index c25789f47a..bb38b90ebb 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_cs.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_cs.properties @@ -20,7 +20,6 @@ admin-console.close=Zav\u0159\u00edt admin-console.password.show=Zobrazit heslo admin-console.password.hide=Skr\u00fdt heslo admin-console.unavailable=Informace nejsou moment\u00e1ln\u011b k\u00a0dispozici -admin-console.not.installed=Nen\u00ed nainstalov\u00e1no admin-console.requesterror=V\u00e1\u0161 po\u017eadavek nebylo mo\u017en\u00e9 dokon\u010dit. Zkuste to znovu. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_da.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_da.properties index 56ef65033d..957cdf8ff2 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_da.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_da.properties @@ -20,7 +20,6 @@ admin-console.close=Luk admin-console.password.show=Vis adgangskode admin-console.password.hide=Skjul adgangskode admin-console.unavailable=Oplysningerne er i \u00f8jeblikket ikke tilg\u00e6ngelige -admin-console.not.installed=Ikke installeret admin-console.requesterror=Vi kunne ikke fuldf\u00f8re anmodningen. Pr\u00f8v igen. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_de.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_de.properties index d881bcca99..97ac247fa3 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_de.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_de.properties @@ -20,7 +20,6 @@ admin-console.close=Schlie\u00dfen admin-console.password.show=Passwort anzeigen admin-console.password.hide=Passwort ausblenden admin-console.unavailable=Information ist derzeit nicht verf\u00fcgbar -admin-console.not.installed=Nicht installiert admin-console.requesterror=Die Anfrage konnte nicht durchgef\u00fchrt werden. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_es.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_es.properties index 6614ea9123..f86a00548a 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_es.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_es.properties @@ -20,7 +20,6 @@ admin-console.close=Cerrar admin-console.password.show=Mostrar contrase\u00f1a admin-console.password.hide=Ocultar contrase\u00f1a admin-console.unavailable=La informaci\u00f3n no est\u00e1 disponible en este momento -admin-console.not.installed=No instalado admin-console.requesterror=No se ha podido realizar la solicitud. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_fi.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_fi.properties index 4643904772..3930429b47 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_fi.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_fi.properties @@ -20,7 +20,6 @@ admin-console.close=Sulje admin-console.password.show=N\u00e4yt\u00e4 salasana admin-console.password.hide=Piilota salasana admin-console.unavailable=Tiedot eiv\u00e4t ole juuri nyt saatavilla -admin-console.not.installed=Ei asennettu admin-console.requesterror=Pyynn\u00f6n suorittaminen ei onnistu. Yrit\u00e4 uudelleen. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_fr.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_fr.properties index b3f44ff2dd..33381012a9 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_fr.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_fr.properties @@ -20,7 +20,6 @@ admin-console.close=Fermer admin-console.password.show=Afficher le mot de passe admin-console.password.hide=Masquer le mot de passe admin-console.unavailable=Informations actuellement indisponibles -admin-console.not.installed=Pas install\u00e9 admin-console.requesterror=Echec de la requ\u00eate. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_it.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_it.properties index dd914cc813..d15abc4749 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_it.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_it.properties @@ -20,7 +20,6 @@ admin-console.close=Chiudi admin-console.password.show=Mostra password admin-console.password.hide=Nascondi password admin-console.unavailable=Le informazioni non sono al momento disponibili -admin-console.not.installed=Non installato admin-console.requesterror=Impossibile completare la richiesta. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_ja.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_ja.properties index 7fed11a6f7..4fc41c89e3 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_ja.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_ja.properties @@ -20,7 +20,6 @@ admin-console.close=\u9589\u3058\u308b admin-console.password.show=\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8868\u793a\u3059\u308b admin-console.password.hide=\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u975e\u8868\u793a\u306b\u3059\u308b admin-console.unavailable=\u73fe\u5728\u3001\u60c5\u5831\u306f\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093 -admin-console.not.installed=\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u305b\u3093 admin-console.requesterror=\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u5b8c\u4e86\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002 diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_nb.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_nb.properties index 40de4e6daf..041779bc8c 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_nb.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_nb.properties @@ -20,7 +20,6 @@ admin-console.close=Lukk admin-console.password.show=Vis passord admin-console.password.hide=Skjul passord admin-console.unavailable=Informasjon er for tiden ikke tilgjengelig -admin-console.not.installed=Ikke installert admin-console.requesterror=Vi kunne ikke fullf\u00f8re foresp\u00f8rselen. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_nl.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_nl.properties index e0fcb37a88..54f7e7de10 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_nl.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_nl.properties @@ -20,7 +20,6 @@ admin-console.close=Sluiten admin-console.password.show=Wachtwoord weergeven admin-console.password.hide=Wachtwoord verbergen admin-console.unavailable=Informatie is momenteel niet beschikbaar -admin-console.not.installed=Niet ge\u00efnstalleerd admin-console.requesterror=Kan de aanvraag niet uitvoeren. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_pl.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_pl.properties index f4a949780e..50a2e6790d 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_pl.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_pl.properties @@ -20,7 +20,6 @@ admin-console.close=Zamknij admin-console.password.show=Poka\u017c has\u0142o admin-console.password.hide=Ukryj has\u0142o admin-console.unavailable=Informacja nie jest aktualnie dost\u0119pna -admin-console.not.installed=Niezainstalowane admin-console.requesterror=Nie mo\u017cna wykona\u0107 Twojego zapytania. Spr\u00f3buj ponownie. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_pt_BR.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_pt_BR.properties index b27905f074..8f701815c8 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_pt_BR.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_pt_BR.properties @@ -20,7 +20,6 @@ admin-console.close=Fechar admin-console.password.show=Mostrar senha admin-console.password.hide=Ocultar senha admin-console.unavailable=Informa\u00e7\u00e3o indispon\u00edvel no momento -admin-console.not.installed=N\u00e3o instalado admin-console.requesterror=N\u00e3o conseguimos concluir a solicita\u00e7\u00e3o. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_ru.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_ru.properties index e1f6ce4cd1..ba9094bd4d 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_ru.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_ru.properties @@ -20,7 +20,6 @@ admin-console.close=\u0417\u0430\u043a\u0440\u044b\u0442\u044c admin-console.password.show=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c admin-console.password.hide=\u0421\u043a\u0440\u044b\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c admin-console.unavailable=\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 -admin-console.not.installed=\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e admin-console.requesterror=\u041d\u0430\u043c \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_sv.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_sv.properties index bff497bb1a..ce852e2c5b 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_sv.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_sv.properties @@ -20,7 +20,6 @@ admin-console.close=St\u00e4ng admin-console.password.show=Visa l\u00f6senord admin-console.password.hide=D\u00f6lj l\u00f6senord admin-console.unavailable=Informationen \u00e4r f\u00f6r n\u00e4rvarande otillg\u00e4nglig -admin-console.not.installed=Inte installerad admin-console.requesterror=Vi kunde inte slutf\u00f6ra din beg\u00e4ran. F\u00f6rs\u00f6k igen. diff --git a/remote-api/src/main/resources/alfresco/messages/admin-console_zh_CN.properties b/remote-api/src/main/resources/alfresco/messages/admin-console_zh_CN.properties index 4b51ba51ae..1cc63a0de3 100644 --- a/remote-api/src/main/resources/alfresco/messages/admin-console_zh_CN.properties +++ b/remote-api/src/main/resources/alfresco/messages/admin-console_zh_CN.properties @@ -20,7 +20,6 @@ admin-console.close=\u5173\u95ed admin-console.password.show=\u663e\u793a\u5bc6\u7801 admin-console.password.hide=\u9690\u85cf\u5bc6\u7801 admin-console.unavailable=\u4fe1\u606f\u5f53\u524d\u4e0d\u53ef\u7528 -admin-console.not.installed=\u672a\u5b89\u88c5 admin-console.requesterror=\u6211\u4eec\u65e0\u6cd5\u5b8c\u6210\u8bf7\u6c42\u3002 diff --git a/remote-api/src/test/java/org/alfresco/repo/webdav/UnlockMethodTest.java b/remote-api/src/test/java/org/alfresco/repo/webdav/UnlockMethodTest.java index 0683106193..60b30c58e2 100644 --- a/remote-api/src/test/java/org/alfresco/repo/webdav/UnlockMethodTest.java +++ b/remote-api/src/test/java/org/alfresco/repo/webdav/UnlockMethodTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 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 . + * #L% + */ package org.alfresco.repo.webdav; import static org.junit.Assert.assertEquals; @@ -223,25 +223,6 @@ public class UnlockMethodTest } } - /** - * OpenOffice.org on Windows 7 results in a lock token header that is NOT enclosed in - * the required < and > characters. Whilst technically an invalid header, we treat - * this case specially for reasons of interoperability (ALF-13904) - * - * @throws WebDAVServerException - */ - @Test - public void parseLockTokenHeaderFromOOoOnWindows7() throws WebDAVServerException - { - String lockToken = "976e2f82-40ab-4852-a867-986e9ce11f82:admin"; - // Note the missing enclosing < and > characters - String lockHeaderValue = WebDAV.OPAQUE_LOCK_TOKEN + lockToken; - request.addHeader(WebDAV.HEADER_LOCK_TOKEN, lockHeaderValue); - unlockMethod.parseRequestHeaders(); - - assertEquals(lockToken, unlockMethod.getLockToken()); - } - /** * Test MNT-9680: Working copies are open in read-only mode when using Webdav online edit * diff --git a/remote-api/src/test/java/org/alfresco/rest/api/tests/RenditionsTest.java b/remote-api/src/test/java/org/alfresco/rest/api/tests/RenditionsTest.java index 02ca59812c..16b6089751 100644 --- a/remote-api/src/test/java/org/alfresco/rest/api/tests/RenditionsTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/api/tests/RenditionsTest.java @@ -321,8 +321,7 @@ public class RenditionsTest extends AbstractBaseApiTest // renditionId in the path parameter is not registered/available getSingle(getNodeRenditionsUrl(contentNodeId), ("renditionId" + System.currentTimeMillis()), 404); - // Create a node without any content. Test only if OpenOffice is available - if(isOpenOfficeAvailable()) + if (areLocalTransformsAvailable()) { String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", TYPE_CM_CONTENT, userOneN1.getId()); getSingle(getNodeRenditionsUrl(emptyContentNodeId), "doclib", 200); @@ -410,8 +409,7 @@ public class RenditionsTest extends AbstractBaseApiTest // Create 'doclib' rendition request Rendition renditionRequest = new Rendition().setId("doclib"); - // Test only if OpenOffice is available - if (isOpenOfficeAvailable()) + if (areLocalTransformsAvailable()) { // Create a node without any content String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", TYPE_CM_CONTENT, userOneN1.getId()); @@ -557,7 +555,7 @@ public class RenditionsTest extends AbstractBaseApiTest response = getSingle(getNodeRenditionsUrl(contentNodeId), ("doclib/content"), params, 200); assertNotNull(response.getResponseAsBytes()); - if(isOpenOfficeAvailable()) + if (areLocalTransformsAvailable()) { // Create multipart request - Word doc file renditionName = "doclib"; @@ -963,10 +961,9 @@ public class RenditionsTest extends AbstractBaseApiTest } /** - * Returns true if OpenOffice-based transformations are currently known to - * be available, else false. + * Returns true if doc to pdf transformations available, indicating Local transforms ar available. */ - protected boolean isOpenOfficeAvailable() + protected boolean areLocalTransformsAvailable() { return synchronousTransformClient.isSupported(MimetypeMap.MIMETYPE_WORD, -1, null, MimetypeMap.MIMETYPE_PDF, Collections.emptyMap(), null, null); diff --git a/remote-api/src/test/resources/log4j.properties b/remote-api/src/test/resources/log4j.properties index 8df8259224..e8b1b86823 100644 --- a/remote-api/src/test/resources/log4j.properties +++ b/remote-api/src/test/resources/log4j.properties @@ -13,7 +13,6 @@ log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug log4j.logger.org.alfresco.repo.rendition2=debug #log4j.logger.org.alfresco.repo.rendition2.LocalTransformClient=debug -#log4j.logger.org.alfresco.repo.rendition2.LegacyTransformClient=debug #log4j.logger.org.alfresco.repo.rendition.RenditionServiceImpl=debug #log4j.logger.org.alfresco.enterprise.repo.rendition2.RemoteTransformClient=debug log4j.logger.org.alfresco.repo.thumbnail.ThumbnailServiceImplTest=DEBUG diff --git a/repository/pom.xml b/repository/pom.xml index a727a4ff78..a94e6823a0 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -264,21 +264,6 @@ org.apache.xmlbeans xmlbeans - - org.apache.pdfbox - pdfbox - - - org.apache.pdfbox - fontbox - ${dependency.pdfbox.version} - - - - org.apache.pdfbox - pdfbox-tools - ${dependency.pdfbox.version} - org.bouncycastle bcprov-jdk15on @@ -311,16 +296,6 @@ FastInfoset 1.2.18 - - org.alfresco - alfresco-jodconverter-core - 3.0.1.1 - - - jmagick - jmagick - 6.6.9 - org.htmlparser htmlparser @@ -335,33 +310,6 @@ jaxen 1.2.0 - - - org.apache.poi - poi - ${dependency.poi.version} - - - org.apache.poi - poi-ooxml - ${dependency.poi.version} - - - org.apache.poi - poi-ooxml-schemas - - - - - org.apache.poi - ooxml-schemas - ${dependency.ooxml-schemas.version} - - - org.apache.poi - poi-scratchpad - ${dependency.poi.version} - javax.servlet javax.servlet-api @@ -1048,102 +996,6 @@ - - - - win-alfresco-pdf-renderer-test - - - windows - - - - - org.alfresco - alfresco-pdf-renderer - win64 - tgz - - - - - - false - maven-antrun-plugin - - - extract-alfresco-pdf-renderer-test - generate-test-resources - - run - - - ${skipTests} - - - - - - - - - - - - - ${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer - - - - linux-alfresco-pdf-renderer-test - - - linux - - - - - org.alfresco - alfresco-pdf-renderer - linux - tgz - - - - - - false - maven-antrun-plugin - - - extract-alfresco-pdf-renderer-test - generate-test-resources - - run - - - ${skipTests} - - - - - - - - - - - - - - - - ${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer - - - - - @@ -1169,8 +1021,6 @@ ${project.build.directory} - ${alfresco-pdf-renderer.exe} - ${db.url} ${db.driver} @@ -1178,7 +1028,6 @@ ${db.username} ${db.password} ${dir.root} - ${img.exe} 30 2000 diff --git a/repository/src/main/java/org/alfresco/repo/content/ContentServiceImpl.java b/repository/src/main/java/org/alfresco/repo/content/ContentServiceImpl.java index be7bf64f3c..86e58e6527 100644 --- a/repository/src/main/java/org/alfresco/repo/content/ContentServiceImpl.java +++ b/repository/src/main/java/org/alfresco/repo/content/ContentServiceImpl.java @@ -80,7 +80,7 @@ import java.util.Set; * @author Derek Hulley * @since 3.2 */ -public class ContentServiceImpl extends ContentTransformServiceAdaptor implements ContentService, ApplicationContextAware +public class ContentServiceImpl implements ContentService, ApplicationContextAware { private static Log logger = LogFactory.getLog(ContentServiceImpl.class); diff --git a/repository/src/main/java/org/alfresco/repo/content/ContentTransformServiceAdaptor.java b/repository/src/main/java/org/alfresco/repo/content/ContentTransformServiceAdaptor.java deleted file mode 100644 index 8a06611f10..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/ContentTransformServiceAdaptor.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.repo.content; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.transform.AbstractContentTransformer2; -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.content.transform.LocalTransform; -import org.alfresco.repo.content.transform.LocalTransformServiceRegistry; -import org.alfresco.repo.content.transform.UnsupportedTransformationException; -import org.alfresco.repo.rendition2.LegacySynchronousTransformClient; -import org.alfresco.repo.rendition2.SynchronousTransformClient; -import org.alfresco.repo.rendition2.TransformationOptionsConverter; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentTransformService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NoTransformerException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.transform.client.registry.TransformServiceRegistry; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * Contains deprecated methods originally from {@link org.alfresco.repo.content.ContentServiceImpl} that is used to - * perform Legacy transforms. - * - * @author adavis - */ -@Deprecated -public class ContentTransformServiceAdaptor implements ContentTransformService -{ - private ContentTransformer imageMagickContentTransformer; - private LegacySynchronousTransformClient legacySynchronousTransformClient; - private LocalTransformServiceRegistry localTransformServiceRegistryImpl; - private SynchronousTransformClient synchronousTransformClient; - private TransformServiceRegistry localTransformServiceRegistry; - private TransformationOptionsConverter converter; - - @Deprecated - public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer) - { - this.imageMagickContentTransformer = imageMagickContentTransformer; - } - - public void setLegacySynchronousTransformClient(LegacySynchronousTransformClient legacySynchronousTransformClient) - { - this.legacySynchronousTransformClient = legacySynchronousTransformClient; - } - - public void setLocalTransformServiceRegistryImpl(LocalTransformServiceRegistry localTransformServiceRegistryImpl) - { - this.localTransformServiceRegistryImpl = localTransformServiceRegistryImpl; - } - - public void setSynchronousTransformClient(SynchronousTransformClient synchronousTransformClient) - { - this.synchronousTransformClient = synchronousTransformClient; - } - - public void setLocalTransformServiceRegistry(TransformServiceRegistry localTransformServiceRegistry) - { - this.localTransformServiceRegistry = localTransformServiceRegistry; - } - - public void setConverter(TransformationOptionsConverter converter) - { - this.converter = converter; - } - - @Deprecated - @Override - public void transform(ContentReader reader, ContentWriter writer) - { - synchronousTransformClient.transform(reader, writer, Collections.emptyMap(), null, null); - } - - @Deprecated - @Override - public void transform(ContentReader reader, ContentWriter writer, Map legacyOptionsMap) - throws NoTransformerException, ContentIOException - { - TransformationOptions transformationOptions = new TransformationOptions(legacyOptionsMap); - Map options = converter.getOptions(transformationOptions, null, null); - synchronousTransformClient.transform(reader, writer, options, null, null); - } - - @Deprecated - @Override - public void transform(ContentReader reader, ContentWriter writer, TransformationOptions transformationOptions) - throws NoTransformerException, ContentIOException - { - try - { - Map options = converter.getOptions(transformationOptions, null, null); - synchronousTransformClient.transform(reader, writer, options, null, null); - } - catch (UnsupportedTransformationException ute) - { - throw newNoTransformerException(reader, writer); - } - catch (IllegalArgumentException iae) - { - if (iae.getMessage().contains("sourceNodeRef null has no content")) - { - throw newNoTransformerException(reader, writer); - } - throw new AlfrescoRuntimeException(iae.getMessage(), iae); - } - } - - private NoTransformerException newNoTransformerException(ContentReader reader, ContentWriter writer) - { - String sourceMimetype = reader == null ? "null" : reader.getMimetype(); - String targetMimetype = writer == null ? "null" : writer.getMimetype(); - return new NoTransformerException(sourceMimetype, targetMimetype); - } - - @Deprecated - @Override - public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return getTransformer(sourceMimetype, targetMimetype, new TransformationOptions()); - } - - @Deprecated - @Override - public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return getTransformer(null, sourceMimetype, -1, targetMimetype, new TransformationOptions()); - } - - @Deprecated - @Override - public ContentTransformer getTransformer(String sourceUrl, String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - ContentTransformer localTransformer = wrapLocalTransformer(sourceUrl, sourceMimetype, sourceSize, targetMimetype, options); - return localTransformer == null - ? legacySynchronousTransformClient.getTransformer(sourceUrl, sourceMimetype, sourceSize, targetMimetype, options) - : localTransformer; - } - - @Deprecated - @Override - // Same as getActiveTransformers, but with debug - public List getTransformers(String sourceUrl, String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - ContentTransformer localTransformer = wrapLocalTransformer(sourceUrl, sourceMimetype, sourceSize, targetMimetype, options); - return localTransformer == null - ? legacySynchronousTransformClient.getTransformers(sourceUrl, sourceMimetype, sourceSize, targetMimetype, options) - : Collections.singletonList(localTransformer); - } - - @Deprecated - @Override - // Same as getTransformers, but without debug - public List getActiveTransformers(String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - return getActiveTransformers(sourceMimetype, -1, targetMimetype, options); - } - - @Deprecated - @Override - // Same as getTransformers, but without debug - public List getActiveTransformers(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - ContentTransformer localTransformer = wrapLocalTransformer(null, sourceMimetype, sourceSize, targetMimetype, options); - return localTransformer == null - ? legacySynchronousTransformClient.getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options) - : Collections.singletonList(localTransformer); - } - - private ContentTransformer wrapLocalTransformer(String sourceUrl, String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions transformationOptions) - { - AbstractContentTransformer2 transformer = null; - Map options = converter.getOptions(transformationOptions, null, null); - LocalTransform localTransform = localTransformServiceRegistryImpl.getLocalTransform(sourceMimetype, - sourceSize, targetMimetype, options, null); - if (localTransform != null) - { - transformer = new AbstractContentTransformer2() { - - @Override - public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws ContentIOException - { - try - { - transformInternal(reader, writer, transformationOptions); - } - catch (Exception e) - { - throw new ContentIOException(e.getMessage(), e); - } - } - - - @Override - protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions transformationOptions) throws Exception - { - localTransform.transform(reader, writer, options, null, null); - } - - @Override - public void register() - { - } - - @Override - public boolean isSupportedTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return true; - } - - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - return true; - } - - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return true; - } - - @Override - public boolean isTransformableSize(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - return true; - } - - @Override - public String getName() - { - return "Wrapped<"+localTransformServiceRegistryImpl.findTransformerName(sourceMimetype, sourceSize, - targetMimetype, options, null)+">"; - } - }; - } - return transformer; - } - - @Deprecated - @Override - public long getMaxSourceSizeBytes(String sourceMimetype, - String targetMimetype, TransformationOptions transformationOptions) - { - Map options = converter.getOptions(transformationOptions, null, null); - return localTransformServiceRegistry.findMaxSize(sourceMimetype, targetMimetype, options, null); - } - - @Deprecated - @Override - public ContentTransformer getImageTransformer() - { - return imageMagickContentTransformer; - } - - @Deprecated - @Override - public boolean isTransformable(ContentReader reader, ContentWriter writer) - { - return isTransformable(reader, writer, null); - } - - @Deprecated - @Override - public boolean isTransformable(ContentReader reader, ContentWriter writer, TransformationOptions transformationOptions) - { - String sourceMimetype = reader.getMimetype(); - long sourceSizeInBytes = reader.getSize(); - String contentUrl = reader.getContentUrl(); - String targetMimetype = writer.getMimetype(); - NodeRef sourceNodeRef = transformationOptions.getSourceNodeRef(); - Map options = converter.getOptions(transformationOptions, null, null); - return synchronousTransformClient.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, - options, null, sourceNodeRef); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/JodConverter.java b/repository/src/main/java/org/alfresco/repo/content/JodConverter.java deleted file mode 100644 index 4db177f508..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/JodConverter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content; - -import org.artofsolving.jodconverter.office.OfficeManager; - -///////// THIS FILE IS A COPY OF THE CODE IN alfresco-docker-libreoffice ///////////// - -public interface JodConverter -{ - /** - * Gets the JodConverter OfficeManager. - * @return - */ - public abstract OfficeManager getOfficeManager(); - - /** - * This method returns a boolean indicating whether the JodConverter connection to OOo is available. - * @return true if available, else false - */ - public abstract boolean isAvailable(); -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/JodConverterSharedInstance.java b/repository/src/main/java/org/alfresco/repo/content/JodConverterSharedInstance.java deleted file mode 100644 index 518da49910..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/JodConverterSharedInstance.java +++ /dev/null @@ -1,537 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.content; - -import java.io.File; -import java.io.FileFilter; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -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.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; - -///////// THIS FILE IS A COPY OF THE CODE IN alfresco-docker-libreoffice ///////////// - -/** - * Makes use of the JodConverter library and an installed - * OpenOffice application to perform OpenOffice-driven conversions. - * - * @author Neil McErlean - */ -public class JodConverterSharedInstance implements InitializingBean, DisposableBean, JodConverter -{ - private static Log logger = LogFactory.getLog(JodConverterSharedInstance.class); - - private OfficeManager officeManager; - boolean isAvailable = false; - - // JodConverter's built-in configuration settings. - // - // These properties are set by Spring dependency injection at system startup in the usual way. - // If the values are changed via the JMX console at runtime, then the subsystem will be stopped - // and can be restarted with the new values - meaning that JodConverter will also be stopped and restarted. - // Therefore there is no special handling required for changes to e.g. portNumbers which determines - // the number of OOo instances there should be in the pool. - // - // Numeric parameters have to be handled as Strings, as that is what Spring gives us for missing values - // e.g. if jodconverter.maxTasksPerProcess is not specified in the properties file, the value - // "${jodconverter.maxTasksPerProcess}" will be injected. - - private Integer maxTasksPerProcess; - private String url; - private String officeHome; - private int[] portNumbers; - private Long taskExecutionTimeout; - private Long taskQueueTimeout; - private File templateProfileDir; - private Boolean enabled; - private Long connectTimeout; - - private String deprecatedOooExe; - private Boolean deprecatedOooEnabled; - private int[] deprecatedOooPortNumbers; - - public void setMaxTasksPerProcess(String maxTasksPerProcess) - { - Long l = parseStringForLong(maxTasksPerProcess.trim()); - if (l != null) - { - this.maxTasksPerProcess = l.intValue(); - } - } - - public void setUrl(String url) - { - this.url = url == null ? null : url.trim(); - } - - public void setOfficeHome(String officeHome) - { - this.officeHome = officeHome == null ? "" : officeHome.trim(); - } - - public void setDeprecatedOooExe(String deprecatedOooExe) - { - this.deprecatedOooExe = deprecatedOooExe == null ? "" : deprecatedOooExe.trim(); - } - - public void setPortNumbers(String s) - { - portNumbers = parsePortNumbers(s, "jodconverter"); - } - - public void setDeprecatedOooPort(String s) - { - deprecatedOooPortNumbers = parsePortNumbers(s, "ooo"); - } - - private int[] parsePortNumbers(String s, String sys) - { - int[] portNumbers = null; - s = s == null ? null : s.trim(); - if (s != null && !s.isEmpty()) - { - StringTokenizer tokenizer = new StringTokenizer(s, ","); - int tokenCount = tokenizer.countTokens(); - portNumbers = new int[tokenCount]; - for (int i = 0;tokenizer.hasMoreTokens();i++) - { - try - { - portNumbers[i] = Integer.parseInt(tokenizer.nextToken().trim()); - } - catch (NumberFormatException e) - { - // 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); - } - // We'll not rethrow the exception, instead allowing the problem to be picked up - // when the OOoJodConverter subsystem is started. - } - } - } - return portNumbers; - } - - public void setTaskExecutionTimeout(String taskExecutionTimeout) - { - this.taskExecutionTimeout = parseStringForLong(taskExecutionTimeout.trim()); - } - - public void setTemplateProfileDir(String templateProfileDir) - { - if (templateProfileDir == null || templateProfileDir.trim().length() == 0) - { - this.templateProfileDir = null; - } - else - { - File tmp = new File(templateProfileDir); - if (!tmp.isDirectory()) - { - throw new AlfrescoRuntimeException("OpenOffice template profile directory "+templateProfileDir+" does not exist."); - } - this.templateProfileDir = tmp; - } - } - - public void setTaskQueueTimeout(String taskQueueTimeout) - { - this.taskQueueTimeout = parseStringForLong(taskQueueTimeout.trim()); - } - - public void setConnectTimeout(String connectTimeout) - { - this.connectTimeout = parseStringForLong(connectTimeout.trim()); - } - - public void setEnabled(String enabled) - { - this.enabled = parseEnabled(enabled); - - // If this is a request from the Enterprise Admin console to disable the JodConverter. - if (this.enabled == false && (deprecatedOooEnabled == null || deprecatedOooEnabled == false)) - { - // We need to change isAvailable to false so we don't make calls to a previously started OfficeManger. - // In the case of Enterprise it is very unlikely that ooo.enabled will have been set to true. - this.isAvailable = false; - } - } - - public void setDeprecatedOooEnabled(String deprecatedOooEnabled) - { - this.deprecatedOooEnabled = parseEnabled(deprecatedOooEnabled); - // No need to worry about isAvailable as this setting cannot be changed via the Admin console. - } - - private Boolean parseEnabled(String enabled) - { - enabled = enabled == null ? "" : enabled.trim(); - return Boolean.parseBoolean(enabled); - } - - // So that Community systems <= Alfresco 6.0.1-ea keep working on upgrade, we may need to use the deprecated - // ooo.exe setting rather than the jodconverter.officeHome setting if we don't have the jod setting as - // oooDirect was replaced by jodconverter after this release. - String getOfficeHome() - { - String officeHome = this.officeHome; - if ((officeHome == null || officeHome.isEmpty()) && (deprecatedOooExe != null && !deprecatedOooExe.isEmpty())) - { - // It will only be possible to use the ooo.exe value if it includes a path, which itself has the officeHome - // value in it. - - // jodconverter.officeHome=/opt/libreoffice5.4/ - // ooo.exe=/opt/libreoffice5.4/program/soffice.bin - - // jodconverter.officeHome=C:/noscan/installs/521~1.1/LIBREO~1/App/libreoffice - // ooo.exe=C:/noscan/installs/COMMUN~1.0-E/LIBREO~1/App/libreoffice/program/soffice.exe - - File oooExe = new File(deprecatedOooExe); - File parent = oooExe.getParentFile(); - if (parent != null && "program".equals(parent.getName())) - { - File grandparent = parent.getParentFile(); - if (grandparent != null) - { - officeHome = grandparent.getPath(); - } - } - } - return officeHome; - } - - // So that Community systems <= Alfresco 6.0.1-ea keep working on upgrade, we may need to use the deprecated - // ooo.enabled setting if true rather than the jodconverter.enabled setting as oooDirect was replaced by - // jodconverter after this release. - // If ooo.enabled is true the JodConverter will be enabled. - // If ooo.enabled is false or unset the jodconverter.enabled value is used. - // Community set properties via alfresco-global.properties. - // Enterprise may do the same but may also reset jodconverter.enabled them via the Admin console. - // In the case of Enterprise it is very unlikely that ooo.enabled will be set to true. - boolean isEnabled() - { - return (deprecatedOooEnabled != null && deprecatedOooEnabled) || (enabled != null && enabled); - } - - // So that Community systems <= Alfresco 6.0.1-ea keep working on upgrade, we may need to use the deprecated - // ooo.port setting rather than the jodconverter.portNumbers if ooo.enabled is true and jodconverter.enabled - // is false. - int[] getPortNumbers() - { - return (enabled == null || !enabled) && deprecatedOooEnabled != null && deprecatedOooEnabled - ? deprecatedOooPortNumbers - : portNumbers; - } - - private Long parseStringForLong(String string) - { - Long result = null; - try - { - long l = Long.parseLong(string); - result = new Long(l); - } - catch (NumberFormatException nfe) - { - if (logger.isDebugEnabled()) - { - logger.debug("Cannot parse numerical value from " + string); - } - // else intentionally empty - } - return result; - } - - /* - * (non-Javadoc) - * @see org.alfresco.repo.content.JodConverter#isAvailable() - */ - public boolean isAvailable() - { - final boolean result = isAvailable && (officeManager != null || (url != null && !url.isEmpty())); - return result; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - public void afterPropertiesSet() throws Exception - { - // isAvailable defaults to false afterPropertiesSet. It only becomes true on successful completion of this method. - this.isAvailable = false; - - int[] portNumbers = getPortNumbers(); - String officeHome = getOfficeHome(); - 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); - } - - // Only start the JodConverter instance(s) if the subsystem is enabled. - if (isEnabled() == false) - { - return; - } - - if (url == null || url.isEmpty()) - { - - logAllSofficeFilesUnderOfficeHome(); - - try - { - DefaultOfficeManagerConfiguration defaultOfficeMgrConfig = new DefaultOfficeManagerConfiguration(); - if (maxTasksPerProcess != null && maxTasksPerProcess > 0) - { - defaultOfficeMgrConfig.setMaxTasksPerProcess(maxTasksPerProcess); - } - if (officeHome != null && officeHome.length() != 0) - { - defaultOfficeMgrConfig.setOfficeHome(officeHome); - } - if (portNumbers != null && portNumbers.length != 0) - { - defaultOfficeMgrConfig.setPortNumbers(portNumbers); - } - if (taskExecutionTimeout != null && taskExecutionTimeout > 0) - { - defaultOfficeMgrConfig.setTaskExecutionTimeout(taskExecutionTimeout); - } - if (taskQueueTimeout != null && taskQueueTimeout > 0) - { - defaultOfficeMgrConfig.setTaskQueueTimeout(taskQueueTimeout); - } - if (templateProfileDir != null) - { - defaultOfficeMgrConfig.setTemplateProfileDir(templateProfileDir); - } - if (connectTimeout != null) - { - defaultOfficeMgrConfig.setConnectTimeout(connectTimeout); - } - // Try to configure and start the JodConverter library. - officeManager = defaultOfficeMgrConfig.buildOfficeManager(); - officeManager.start(); - } - catch (IllegalStateException isx) - { - if (logger.isErrorEnabled()) - { - logger.error("Unable to pre-initialise JodConverter library. " - + "The following error is shown for informational purposes only.", isx); - } - return; - } - catch (OfficeException ox) - { - if (logger.isErrorEnabled()) - { - logger.error("Unable to start JodConverter library. " - + "The following error is shown for informational purposes only.", ox); - } - - // 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) - { - if (logger.isErrorEnabled()) - { - logger.error("Unexpected error in configuring or starting the JodConverter library." - + "The following error is shown for informational purposes only.", x); - } - return; - } - } - - // If any exceptions are thrown in the above code, then isAvailable - // should remain false, hence the return statements. - this.isAvailable = true; - } - - private String getString(int[] portNumbers) - { - StringBuilder portInfo = new StringBuilder(); - if (portNumbers != null) - { - for (int i = 0;i < portNumbers.length;i++) - { - portInfo.append(portNumbers[i]); - if (i < portNumbers.length - 1) - { - portInfo.append(", "); - } - } - } - return portInfo.toString(); - } - - private void logAllSofficeFilesUnderOfficeHome() - { - if (logger.isDebugEnabled() == false) - { - return; - } - - String officeHome = getOfficeHome(); - File requestedOfficeHome = new File(officeHome); - - logger.debug("Some information on soffice* files and their permissions"); - - logFileInfo(requestedOfficeHome); - - for (File f : findSofficePrograms(requestedOfficeHome, new ArrayList(), 2)) - { - logFileInfo(f); - } - } - - private List findSofficePrograms(File searchRoot, List results, int maxRecursionDepth) - { - return this.findSofficePrograms(searchRoot, results, 0, maxRecursionDepth); - } - - private List findSofficePrograms(File searchRoot, List results, - int currentRecursionDepth, int maxRecursionDepth) - { - if (currentRecursionDepth >= maxRecursionDepth) - { - return results; - } - - File[] matchingFiles = searchRoot.listFiles(new FilenameFilter() - { - @Override - public boolean accept(File dir, String name) - { - return name.startsWith("soffice"); - } - }); - for (File f : matchingFiles) - { - results.add(f); - } - - for (File dir : searchRoot.listFiles(new FileFilter() - { - @Override - public boolean accept(File f) { - return f.isDirectory(); - } - })) - { - findSofficePrograms(dir, results, currentRecursionDepth + 1, maxRecursionDepth); - } - - return results; - } - - /** - * Logs some information on the specified file, including name and r/w/x permissions. - * @param f the file to log. - */ - private void logFileInfo(File f) - { - if (logger.isDebugEnabled() == false) - { - return; - } - - StringBuilder msg = new StringBuilder(); - msg.append(f).append(" "); - if (f.exists()) - { - if (f.canRead()) - { - msg.append("(") - .append(f.isDirectory() ? "d" : "-") - .append(f.canRead() ? "r" : "-") - .append(f.canWrite() ? "w" : "-") - .append(f.canExecute() ? "x" : "-") - .append(")"); - } - } - else - { - msg.append("does not exist"); - } - logger.debug(msg.toString()); - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.DisposableBean#destroy() - */ - public void destroy() throws Exception { - this.isAvailable = false; - if (officeManager != null) - { - // If there is an OfficeException when stopping the officeManager below, then there is - // little that can be done other than logging the exception and carrying on. The JodConverter-based - // libraries will not be used in any case, as isAvailable is false. - // - // Any exception thrown out of this method will be logged and swallowed by Spring - // (see javadoc for method declaration). Therefore there is no handling here for - // exceptions from jodConverter. - officeManager.stop(); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.content.JodConverterWorker#getOfficeManager() - */ - public OfficeManager getOfficeManager() - { - return officeManager; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/TikaOfficeDetectParser.java b/repository/src/main/java/org/alfresco/repo/content/TikaOfficeDetectParser.java deleted file mode 100644 index 62a7bb8959..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/TikaOfficeDetectParser.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content; - -import java.io.IOException; -import java.io.InputStream; -import java.io.PushbackInputStream; -import java.util.HashSet; -import java.util.Set; - -import org.apache.poi.poifs.common.POIFSConstants; -import org.apache.poi.util.IOUtils; -import org.apache.tika.exception.TikaException; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; -import org.apache.tika.parser.ParseContext; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.microsoft.OfficeParser; -import org.apache.tika.parser.microsoft.ooxml.OOXMLParser; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -///////// THIS FILE IS A COPY OF THE CODE IN alfresco-docker-tika ///////////// - -/** - * Apache Tika assumes that - * you either know exactly what your content is, or that - * you'll leave it to auto-detection. - * Within Alfresco, we usually do know. However, from time - * to time, we don't know if we have one of the old or one - * of the new office files (eg .xls and .xlsx). - * This class allows automatically selects the appropriate - * old (OLE2) or new (OOXML) Tika parser as required. - * - * @author Nick Burch - */ -public class TikaOfficeDetectParser implements Parser { - private Parser ole2Parser = new OfficeParser(); - private Parser ooxmlParser = new OOXMLParser(); - - public Set getSupportedTypes(ParseContext parseContext) { - Set types = new HashSet(); - types.addAll(ole2Parser.getSupportedTypes(parseContext)); - types.addAll(ooxmlParser.getSupportedTypes(parseContext)); - return types; - } - - public void parse(InputStream stream, - ContentHandler handler, Metadata metadata, - ParseContext parseContext) throws IOException, SAXException, - TikaException - { - byte[] initial4 = new byte[4]; - InputStream wrapped; - // Preserve TikaInputStreams as TikaInputStreams as they require less memory to process - if (stream.markSupported()) - { - stream.mark(initial4.length); - IOUtils.readFully(stream, initial4); - stream.reset(); - wrapped = stream; - } - else - { - PushbackInputStream inp = new PushbackInputStream(stream, 4); - IOUtils.readFully(inp, initial4); - inp.unread(initial4); - wrapped = inp; - } - - // Which is it? - if(initial4[0] == POIFSConstants.OOXML_FILE_HEADER[0] && - initial4[1] == POIFSConstants.OOXML_FILE_HEADER[1] && - initial4[2] == POIFSConstants.OOXML_FILE_HEADER[2] && - initial4[3] == POIFSConstants.OOXML_FILE_HEADER[3]) - { - ooxmlParser.parse(wrapped, handler, metadata, parseContext); - } - else - { - ole2Parser.parse(wrapped, handler, metadata, parseContext); - } - } - - /** - * @deprecated This method will be removed in Apache Tika 1.0. - */ - public void parse(InputStream stream, - ContentHandler handler, Metadata metadata) - throws IOException, SAXException, TikaException - { - parse(stream, handler, metadata, new ParseContext()); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/metadata/MediaTypeDisablingDocumentSelector.java b/repository/src/main/java/org/alfresco/repo/content/metadata/MediaTypeDisablingDocumentSelector.java deleted file mode 100644 index 294ffb66b4..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/metadata/MediaTypeDisablingDocumentSelector.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2020 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 . - * #L% - */ -package org.alfresco.repo.content.metadata; - -import java.util.List; - -import org.apache.tika.extractor.DocumentSelector; -import org.apache.tika.metadata.Metadata; - -/** - * @deprecated OOTB extractors are being moved to T-Engines. - * - * Tika 1.6 has the ability to parse embedded artifacts, such as images in a PDF, - * but this can be very resource intensive so adding this selector - * to parsers and transformers that handle formats with embedded artifacts - * will disable parsing of the specified content types. - */ -@Deprecated -public class MediaTypeDisablingDocumentSelector implements DocumentSelector -{ - private List disabledMediaTypes; - - public void setDisabledMediaTypes(List disabledMediaTypes) - { - this.disabledMediaTypes = disabledMediaTypes; - } - - @Override - public boolean select(Metadata metadata) - { - String contentType = metadata.get(Metadata.CONTENT_TYPE); - if (contentType == null || contentType.equals("") || disabledMediaTypes == null) - { - return true; - } - return !disabledMediaTypes.contains(contentType); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformer.java deleted file mode 100644 index 80f5b4f6ea..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformer.java +++ /dev/null @@ -1,506 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.ContentAccessor; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.extensions.surf.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Provides basic services for {@link org.alfresco.repo.content.transform.ContentTransformer} - * implementations. - *

- * This class maintains the performance measures for the transformers as well, making sure that - * there is an extra penalty for transformers that fail regularly. - * - * @deprecated - * Deprecated since 3.0. The abstract base class org.alfresco.repo.content.transform.AbstractContentTransformer2 should now be used instead. - * - * @author Derek Hulley - */ -@Deprecated -public abstract class AbstractContentTransformer implements ContentTransformer, BeanNameAware -{ - private static final Log logger = LogFactory.getLog(AbstractContentTransformer.class); - - private MimetypeService mimetypeService; - private ContentTransformerRegistry registry; - @SuppressWarnings("deprecation") - private List explicitTransformations; - private double averageTime = 0.0; - private long count = 0L; - - /** The bean name. */ - private String beanName; - - /** - * All transformers start with an average transformation time of 0.0ms. - */ - @SuppressWarnings("deprecation") - protected AbstractContentTransformer() - { - averageTime = 0.0; - explicitTransformations = new ArrayList(0); - } - - /** - * The registry to auto-register with - * - * @param registry the transformer registry - */ - public void setRegistry(ContentTransformerRegistry registry) - { - this.registry = registry; - } - - /** - * Helper setter of the mimetype service. This is not always required. - * - * @param mimetypeService MimetypeService - */ - public void setMimetypeService(MimetypeService mimetypeService) - { - this.mimetypeService = mimetypeService; - } - - /** - * @return Returns the mimetype helper - */ - protected MimetypeService getMimetypeService() - { - return mimetypeService; - } - - /** - * @return Returns the explicit transformations that were enabled for this transformer - */ - @SuppressWarnings("deprecation") - protected List getExplicitTransformations() - { - return explicitTransformations; - } - - /** - * Set the transformations that this transformer can do regardless of what it returns - * via the reliability check. - * - * @param explicitTransformations explicit key mappings - */ - @SuppressWarnings("deprecation") - public void setExplicitTransformations(List explicitTransformations) - { - this.explicitTransformations = explicitTransformations; - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append(this.getClass().getSimpleName()) - .append("[ average=").append((long)averageTime).append("ms") - .append("]"); - return sb.toString(); - } - - /** - * Registers this instance with the {@link #setRegistry(ContentTransformerRegistry) registry} - * if it is present. - */ - public void register() - { - if (registry == null) - { - logger.warn("Property 'registry' has not been set. Ignoring auto-registration: \n" + - " transformer: " + this); - return; - } - // first register any explicit transformations - //if (explicitTransformations != null) - //{ - // for (ContentTransformerRegistry.TransformationKey key : explicitTransformations) - // / { - // registry.addExplicitTransformer(key, this); - // } - //} - // register this instance for the fallback case - registry.addTransformer(this); - } - - /** - * Convenience to fetch and check the mimetype for the given content - * - * @param content the reader/writer for the content - * @return Returns the mimetype for the content - * @throws AlfrescoRuntimeException if the content doesn't have a mimetype - */ - protected String getMimetype(ContentAccessor content) - { - String mimetype = content.getMimetype(); - if (mimetype == null) - { - throw new AlfrescoRuntimeException("Mimetype is mandatory for transformation: " + content); - } - // done - return mimetype; - } - - /** - * Added for backward compatibility of existing content transformers - * - * @param sourceMimetype the source mimetype - * @param targetMimetype the target mimetype - * @return double the reliability value of the content transformer ranging from 0 to 1 - */ - protected abstract double getReliability(String sourceMimetype, String targetMimetype); - - /** - * Convenience method to check the reliability of a transformation - * - * @param reader ContentReader - * @param writer ContentWriter - * @throws AlfrescoRuntimeException if the reliability isn't > 0 - */ - protected void checkReliability(ContentReader reader, ContentWriter writer) - { - String sourceMimetype = getMimetype(reader); - String targetMimetype = getMimetype(writer); - double reliability = getReliability(sourceMimetype, targetMimetype); - if (reliability <= 0.0) - { - throw new AlfrescoRuntimeException("Zero scoring transformation attempted: \n" + - " reader: " + reader + "\n" + - " writer: " + writer); - } - // it all checks out OK - } - - /** - * {@inheritDoc}

- * - * Implementation calls the deprecated overloaded method without the sourceSize parameter. - * Note: source size checked has not been added to this deprecated class. - */ - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - return - isTransformableMimetype(sourceMimetype, targetMimetype, options) && - isTransformableSize(sourceMimetype, sourceSize, targetMimetype, options); - } - - /** - * @deprecated use version with extra sourceSize parameter. - */ - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - ParameterCheck.mandatoryString("sourceMimetype", sourceMimetype); - ParameterCheck.mandatoryString("targetMimetype", targetMimetype); - - double reliability = getReliability(sourceMimetype, targetMimetype); - boolean result = true; - if (reliability <= 0.0) - { - result = false; - } - return result; - } - - /** - * Checks the supplied mimetypes are supported by calling the deprecated - * {@link #isTransformable(String, String, TransformationOptions)} method. - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - return isTransformable(sourceMimetype, targetMimetype, options); - } - - /** - * Always returns {@code true} to indicate size is not an issue. - */ - @Override - public boolean isTransformableSize(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - return true; - } - - /** - * Always returns {@code -1} to indicate an unlimited size. - */ - @Override - public long getMaxSourceSizeKBytes(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return -1; - } - - /** - * @see org.alfresco.repo.content.transform.ContentTransformer#isTransformable(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions) - */ - @SuppressWarnings("deprecation") - public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - boolean result = false; - - if (this.explicitTransformations != null) - { - for (ContentTransformerRegistry.TransformationKey transformationKey : this.explicitTransformations) - { - if (transformationKey.getSourceMimetype().equals(sourceMimetype) == true && - transformationKey.getTargetMimetype().equals(targetMimetype) == true) - { - result = true; - break; - } - } - } - - return result; - } - - /** - * Method to be implemented by subclasses wishing to make use of the common infrastructural code - * provided by this class. - * - * @param reader the source of the content to transform - * @param writer the target to which to write the transformed content - * @param options a map of options to use when performing the transformation. The map - * will never be null. - * @throws Exception exceptions will be handled by this class - subclasses can throw anything - */ - protected abstract void transformInternal( - ContentReader reader, - ContentWriter writer, - Map options) throws Exception; - - /** - * @see #transform(ContentReader, ContentWriter, Map) - * @see #transformInternal(ContentReader, ContentWriter, Map) - */ - public final void transform(ContentReader reader, ContentWriter writer) throws ContentIOException - { - Map optionsMap = null; - transform(reader, writer, optionsMap); - } - - /** - * @see org.alfresco.repo.content.transform.ContentTransformer#transform(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions) - */ - public final void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws ContentIOException - { - Map optionsMap = options.toMap(); - transform(reader, writer, optionsMap); - } - - /** - * Performs the following: - *

- * Subclass need only be concerned with performing the transformation. - *

- * If the options provided are null, then an empty map will be created. - */ - @SuppressWarnings("deprecation") - public final void transform( - ContentReader reader, - ContentWriter writer, - Map options) throws ContentIOException - { - // begin timing - long before = System.currentTimeMillis(); - - // check options map - if (options == null) - { - options = Collections.emptyMap(); - } - - try - { - // Check the reliability - checkReliability(reader, writer); - - // Transform - transformInternal(reader, writer, options); - } - catch (Throwable e) - { - // Make sure that this transformation gets set back i.t.o. time taken. - // This will ensure that transformers that compete for the same transformation - // will be prejudiced against transformers that tend to fail - recordTime(10000); // 10 seconds, i.e. rubbish - - throw new ContentIOException("Content conversion failed: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options, - e); - } - finally - { - // check that the reader and writer are both closed - if (reader.isChannelOpen()) - { - logger.error("Content reader not closed by transformer: \n" + - " reader: " + reader + "\n" + - " transformer: " + this); - } - if (writer.isChannelOpen()) - { - logger.error("Content writer not closed by transformer: \n" + - " writer: " + writer + "\n" + - " transformer: " + this); - } - } - - // record time - long after = System.currentTimeMillis(); - recordTime(after - before); - - // done - if (logger.isDebugEnabled()) - { - logger.debug("Completed transformation: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options + "\n" + - " transformer: " + this); - } - } - - /** - * @return Returns the calculated running average of the current transformations - */ - public synchronized long getTransformationTime() - { - return (long) averageTime; - } - - public long getTransformationTime(String sourceMimetype, String targetMimetype) - { - return (long) averageTime; - } - - /** - * Records and updates the average transformation time for this transformer. - *

- * Subclasses should call this after every transformation in order to keep - * the running average of the transformation times up to date. - *

- * This method is thread-safe. The time spent in this method is negligible - * so the impact will be minor. - * - * @param transformationTime the time it took to perform the transformation. - * The value may be 0. - */ - protected final synchronized void recordTime(long transformationTime) - { - if (count == Long.MAX_VALUE) - { - // we have reached the max count - reduce it by half - // the average fluctuation won't be extreme - count /= 2L; - } - // adjust the average - count++; - double diffTime = ((double) transformationTime) - averageTime; - averageTime += diffTime / (double) count; - } - - /** - * Sets the Spring bean name. - */ - @Override - public void setBeanName(String beanName) - { - this.beanName = beanName; - } - - /** - * Returns the Spring bean name. - */ - public String getBeanName() - { - return beanName; - } - - /** - * Returns transformer name. Uses the Spring bean name, but if null uses the class name. - */ - public String getName() - { - return (beanName == null) ? getClass().getSimpleName() : beanName; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((beanName == null) ? 0 : beanName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - AbstractContentTransformer other = (AbstractContentTransformer) obj; - if (beanName == null) - { - if (other.beanName != null) - return false; - } - else if (!beanName.equals(other.beanName)) - return false; - return true; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformer2.java b/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformer2.java deleted file mode 100644 index 1f0f601d53..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformer2.java +++ /dev/null @@ -1,669 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.AbstractStreamAwareProxy; -import org.alfresco.repo.content.StreamAwareContentReaderProxy; -import org.alfresco.repo.content.StreamAwareContentWriterProxy; -import org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentServiceTransientException; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Provides basic services for {@link org.alfresco.repo.content.transform.ContentTransformer} - * implementations. - *

- * This class maintains the performance measures for the transformers as well, making sure that - * there is an extra penalty for transformers that fail regularly. - * - * @author Derek Hulley - * @author Roy Wetherall - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public abstract class AbstractContentTransformer2 extends AbstractContentTransformerLimits -{ - private static final Log logger = LogFactory.getLog(AbstractContentTransformer2.class); - - private ExecutorService executorService; - - private ContentTransformerRegistry registry; - private boolean registerTransformer; - private boolean retryTransformOnDifferentMimeType; - private boolean strictMimeTypeCheck; - - /** - * A flag that indicates that the transformer should be started in it own Thread so - * that it may be interrupted rather than using the timeout in the Reader. - * Need only be set for transformers that read their source data quickly but then - * take a long time to process the data (such as {@link PoiOOXMLContentTransformer}. - */ - private Boolean useTimeoutThread = false; - - /** - * Extra time added the timeout when using a Thread for the transformation so that - * a timeout from the Reader has a chance to happen first. - */ - private long additionalThreadTimout = 2000; - - private static ThreadLocal depth = new ThreadLocal() - { - @Override - protected Integer initialValue() - { - return 0; - } - }; - - /** - * All transformers start with an average transformation time of 0.0 ms, - * unless there is an Alfresco global property {@code .time}. - * May also be set for given combinations of source and target mimetypes. - */ - protected AbstractContentTransformer2() - { - } - - /** - * The registry to auto-register with - * - * @param registry the transformer registry - */ - public void setRegistry(ContentTransformerRegistry registry) - { - this.registry = registry; - } - - /** - * @param registerTransformer as been available for selection. - * If {@code false} this indicates that the transformer may only be - * used as part of another transformer. - */ - public void setRegisterTransformer(boolean registerTransformer) - { - this.registerTransformer = registerTransformer; - } - - @Override - public String toString() - { - return this.getClass().getSimpleName(); - } - - /** - * Registers this instance with the {@link #setRegistry(ContentTransformerRegistry) registry} - * if it is present. - * - * THIS IS A CUSTOM SPRING INIT METHOD - */ - public void register() - { - super.register(); - if (registry == null) - { - logger.warn("Property 'registry' has not been set. Ignoring auto-registration: \n" + - " transformer: " + this.getName()); - } - else if (registerTransformer) - { - registry.addTransformer(this); - } - else - { - registry.addComponentTransformer(this); - logger.debug("Property 'registerTransformer' have not been set, so transformer (" + - this.getName() + ") may only be used as a component of a complex transformer."); - } - } - - /** - * Convenience method to check the transformability of a transformation - * - * @param reader content reader - * @param writer content writer - * @param options transformation options - * @throws AlfrescoRuntimeException if the the transformation isn't supported - */ - protected void checkTransformable(ContentReader reader, ContentWriter writer, TransformationOptions options) - { - String sourceMimetype = getMimetype(reader); - String targetMimetype = getMimetype(writer); - long sourceSize = reader.getSize(); - boolean transformable = isTransformable(sourceMimetype, sourceSize, targetMimetype, options); - if (transformable == false) - { - // 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*1024))); - throw transformerDebug.setCause(e); - } - // it all checks out OK - } - - /** - * Method to be implemented by subclasses wishing to make use of the common infrastructural code - * provided by this class. - * - * @param reader the source of the content to transform - * @param writer the target to which to write the transformed content - * @param options a map of options to use when performing the transformation. The map - * will never be null. - * @throws Exception exceptions will be handled by this class - subclasses can throw anything - */ - protected abstract void transformInternal( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception; - - /** - * @see #transform(ContentReader, ContentWriter, Map) - * @see #transformInternal(ContentReader, ContentWriter, TransformationOptions) - */ - public final void transform(ContentReader reader, ContentWriter writer) throws ContentIOException - { - transform(reader, writer, new TransformationOptions()); - } - - /** - * @see org.alfresco.repo.content.transform.ContentTransformer#transform(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions) - */ - public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws ContentIOException - { - try - { - depth.set(depth.get()+1); - - // begin timing - long before = System.currentTimeMillis(); - - String sourceMimetype = reader.getMimetype(); - String targetMimetype = writer.getMimetype(); - - // check options map - if (options == null) - { - options = new TransformationOptions(); - } - - try - { - if (transformerDebug.isEnabled()) - { - ((LegacyTransformerDebug)transformerDebug).pushTransform(this, reader.getContentUrl(), sourceMimetype, - targetMimetype, reader.getSize(), options); - } - - // MNT-16381: check the mimetype of the file supplied by the user - // matches the sourceMimetype of the reader. Intermediate files are - // not checked. - strictMimetypeCheck(reader, options, sourceMimetype); - - // Check the transformability - checkTransformable(reader, writer, options); - - // Pass on any limits to the reader - setReaderLimits(reader, writer, options); - - // Transform - // MNT-12238: CLONE - CLONE - Upload of PPTX causes very high memory usage leading to system instability - // Limiting transformation up to configured amount of milliseconds to avoid very high RAM consumption - // and OOM during transforming problematic documents - TransformationOptionLimits limits = getLimits(reader.getMimetype(), writer.getMimetype(), options); - - long timeoutMs = limits.getTimeoutMs(); - if (!useTimeoutThread || (null == limits) || (-1 == timeoutMs)) - { - transformInternal(reader, writer, options); - } - else - { - Future submittedTask = null; - StreamAwareContentReaderProxy proxiedReader = new StreamAwareContentReaderProxy(reader); - StreamAwareContentWriterProxy proxiedWriter = new StreamAwareContentWriterProxy(writer); - - try - { - submittedTask = getExecutorService().submit(new TransformInternalCallable(proxiedReader, proxiedWriter, options)); - submittedTask.get(timeoutMs + additionalThreadTimout, TimeUnit.MILLISECONDS); - } - catch (TimeoutException e) - { - releaseResources(submittedTask, proxiedReader, proxiedWriter); - throw new TimeoutException("Transformation failed due to timeout limit"); - } - catch (InterruptedException e) - { - releaseResources(submittedTask, proxiedReader, proxiedWriter); - throw new InterruptedException("Transformation failed, because the thread of the transformation was interrupted"); - } - catch (ExecutionException e) - { - Throwable cause = e.getCause(); - if (cause instanceof TransformInternalCallableException) - { - cause = ((TransformInternalCallableException) cause).getCause(); - } - - throw cause; - } - } - - // record time - long after = System.currentTimeMillis(); - recordTime(sourceMimetype, targetMimetype, after - before); - } - catch (ContentServiceTransientException cste) - { - // A transient failure has occurred within the content transformer. - // This should not be interpreted as a failure and therefore we should not - // update the transformer's average time. - if (logger.isDebugEnabled()) - { - logger.debug("Transformation has been transiently declined: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options + "\n" + - " transformer: " + this); - } - // the finally block below will still perform tidyup. Otherwise we're done. - // 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. - // This will ensure that transformers that compete for the same transformation - // will be prejudiced against transformers that tend to fail - long after = System.currentTimeMillis(); - recordError(sourceMimetype, targetMimetype, after - before); - - // Ask Tika to detect the document, and report back on if - // the current mime type is plausible - String differentType = getMimetypeService().getMimetypeIfNotMatches(reader.getReader()); - - // Report the error - if (differentType == null) - { - transformerDebug.debug(" Failed", e); - throw new ContentIOException("Content conversion failed: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options.toString(false) + "\n" + - " limits: " + getLimits(reader, writer, options), - e); - } - else - { - transformerDebug.debug(" Failed: Mime type was '"+differentType+"'", e); - - if (retryTransformOnDifferentMimeType) - { - // MNT-11015 fix. - // Set a new reader to refresh the input stream. - reader = reader.getReader(); - // set the actual file MIME type detected by Tika for content reader - reader.setMimetype(differentType); - - // Get correct transformer according actual file MIME type and try to transform file with - // actual transformer - ContentTransformer transformer = this.registry.getTransformer(differentType, reader.getSize(), - targetMimetype, options); - if (null != transformer) - { - transformer.transform(reader, writer, options); - } - else - { - transformerDebug.debug(" Failed", e); - throw new ContentIOException("Content conversion failed: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options.toString(false) + "\n" + - " limits: " + getLimits(reader, writer, options) + "\n" + - " claimed mime type: " + reader.getMimetype() + "\n" + - " detected mime type: " + differentType + "\n" + - " transformer not found" + "\n", - e - ); - } - } - else - { - throw new ContentIOException("Content conversion failed: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options.toString(false) + "\n" + - " limits: " + getLimits(reader, writer, options) + "\n" + - " claimed mime type: " + reader.getMimetype() + "\n" + - " detected mime type: " + differentType, - e - ); - } - } - } - finally - { - transformerDebug.popTransform(); - - // check that the reader and writer are both closed - if (reader.isChannelOpen()) - { - logger.error("Content reader not closed by transformer: \n" + - " reader: " + reader + "\n" + - " transformer: " + this); - } - if (writer.isChannelOpen()) - { - logger.error("Content writer not closed by transformer: \n" + - " writer: " + writer + "\n" + - " transformer: " + this); - } - } - - // done - if (logger.isDebugEnabled()) - { - logger.debug("Completed transformation: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " options: " + options + "\n" + - " transformer: " + this); - } - } - finally - { - depth.set(depth.get()-1); - } - } - - private void strictMimetypeCheck(ContentReader reader, TransformationOptions options, String sourceMimetype) - throws UnsupportedTransformationException - { - if (strictMimeTypeCheck && depth.get() == 1) - { - String differentType = getMimetypeService().getMimetypeIfNotMatches(reader.getReader()); - - if (!transformerConfig.strictMimetypeCheck(sourceMimetype, differentType)) - { - String fileName = ((LegacyTransformerDebug)transformerDebug).getFileName(options, true, 0); - String readerSourceMimetype = reader.getMimetype(); - String message = "Transformation of ("+fileName+ - ") has not taken place because the declared mimetype ("+ - readerSourceMimetype+") does not match the detected mimetype ("+ - differentType+")."; - logger.warn(message); - throw new UnsupportedTransformationException(message); - } - } - } - - /** - * Cancels task and closes content accessors - * - * @param task - {@link Future} task instance which specifies a transformation action - * @param proxiedReader - {@link AbstractStreamAwareProxy} instance which represents channel closing mechanism for content reader - * @param proxiedWriter - {@link AbstractStreamAwareProxy} instance which represents channel closing mechanism for content writer - */ - private void releaseResources(Future task, AbstractStreamAwareProxy proxiedReader, AbstractStreamAwareProxy proxiedWriter) - { - if (null != task) - { - task.cancel(true); - } - - if (null != proxiedReader) - { - proxiedReader.release(); - } - - if (null != proxiedWriter) - { - proxiedWriter.release(); - } - } - - public final void transform( - ContentReader reader, - ContentWriter writer, - Map options) throws ContentIOException - { - this.transform(reader, writer, new TransformationOptions(options)); - } - - /** - * @return Returns the calculated running average of the current transformations - */ - public synchronized long getTransformationTime() - { - return transformerConfig.getStatistics(this, null, null, true).getAverageTime(); - } - - /** - * @return Returns the calculated running average of the current transformations - */ - public synchronized long getTransformationTime(String sourceMimetype, String targetMimetype) - { - return transformerConfig.getStatistics(this, sourceMimetype, targetMimetype, true).getAverageTime(); - } - - /** - * @deprecated use method with mimetypes. - */ - protected final synchronized void recordTime(long transformationTime) - { - recordTime(TransformerConfig.ANY, TransformerConfig.ANY, transformationTime); - } - - /** - * Records and updates the average transformation time for this transformer. - *

- * Subclasses should call this after every transformation in order to keep - * the running average of the transformation times up to date. - *

- * This method is thread-safe. The time spent in this method is negligible - * so the impact will be minor. - * - * @param sourceMimetype String - * @param targetMimetype String - * @param transformationTime the time it took to perform the transformation. - */ - protected final synchronized void recordTime(String sourceMimetype, String targetMimetype, - long transformationTime) - { - transformerConfig.getStatistics(this, sourceMimetype, targetMimetype, true).recordTime(transformationTime); - if (depth.get() == 1) - { - transformerConfig.getStatistics(null, sourceMimetype, targetMimetype, true).recordTime(transformationTime); - } - } - - /** - * Gets the ExecutorService to be used for timeout-aware extraction. - *

- * If no ExecutorService has been defined a default of Executors.newCachedThreadPool() is used during {@link AbstractMappingMetadataExtracter}. - * - * @return the defined or default ExecutorService - */ - protected ExecutorService getExecutorService() - { - if (null == executorService) - { - executorService = Executors.newCachedThreadPool(); - } - - return executorService; - } - - /** - * Sets the ExecutorService to be used for timeout-aware transformation. - * - * @param executorService - {@link ExecutorService} instance for timeouts - */ - public void setExecutorService(ExecutorService executorService) - { - this.executorService = executorService; - } - - /** - * {@link Callable} wrapper for the {@link AbstractContentTransformer2#transformInternal(ContentReader, ContentWriter, TransformationOptions)} method to handle timeouts. - */ - private class TransformInternalCallable implements Callable - { - private ContentReader reader; - - private ContentWriter writer; - - private TransformationOptions options; - - public TransformInternalCallable(ContentReader reader, ContentWriter writer, TransformationOptions options) - { - this.reader = reader; - this.writer = writer; - this.options = options; - } - - @Override - public Void call() throws Exception - { - try - { - transformInternal(reader, writer, options); - return null; - } - catch (Throwable e) - { - throw new TransformInternalCallableException(e); - } - } - } - - /** - * Exception wrapper to handle any {@link Throwable} from {@link AbstractContentTransformer2#transformInternal(ContentReader, ContentWriter, TransformationOptions)} - */ - private class TransformInternalCallableException extends Exception - { - private static final long serialVersionUID = 7740560508772740658L; - - public TransformInternalCallableException(Throwable cause) - { - super(cause); - } - } - - /** - * @param useTimeoutThread - {@link Boolean} value which specifies timeout limiting mechanism for the current transformer - * @see AbstractContentTransformer2#useTimeoutThread - */ - public void setUseTimeoutThread(Boolean useTimeoutThread) - { - if (null == useTimeoutThread) - { - useTimeoutThread = true; - } - - this.useTimeoutThread = useTimeoutThread; - } - - public void setAdditionalThreadTimout(long additionalThreadTimout) - { - this.additionalThreadTimout = additionalThreadTimout; - } - - public Boolean isTransformationLimitedInternally() - { - return useTimeoutThread; - } - - /** - * Records an error and updates the average time as if the transformation took a - * long time, so that it is less likely to be called again. - * @param sourceMimetype String - * @param targetMimetype String - * @param transformationTime the time it took to perform the transformation. - */ - protected final synchronized void recordError(String sourceMimetype, String targetMimetype, - long transformationTime) - { - transformerConfig.getStatistics(this, sourceMimetype, targetMimetype, true).recordError(transformationTime); - if (depth.get() == 1) - { - transformerConfig.getStatistics(null, sourceMimetype, targetMimetype, true).recordError(transformationTime); - } - } - - public Object getRetryTransformOnDifferentMimeType() - { - return retryTransformOnDifferentMimeType; - } - - public void setRetryTransformOnDifferentMimeType(boolean retryTransformOnDifferentMimeType) - { - this.retryTransformOnDifferentMimeType = retryTransformOnDifferentMimeType; - } - - public boolean getStrictMimeTypeCheck() - { - return strictMimeTypeCheck; - } - - public void setStrictMimeTypeCheck(boolean strictMimeTypeCheck) - { - this.strictMimeTypeCheck = strictMimeTypeCheck; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformerLimits.java b/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformerLimits.java deleted file mode 100644 index e9f54bf6f5..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractContentTransformerLimits.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.service.cmr.repository.TransformationOptionLimits.OPT_MAX_PAGES; -import static org.alfresco.service.cmr.repository.TransformationOptionLimits.OPT_MAX_SOURCE_SIZE_K_BYTES; -import static org.alfresco.service.cmr.repository.TransformationOptionLimits.OPT_PAGE_LIMIT; -import static org.alfresco.service.cmr.repository.TransformationOptionLimits.OPT_READ_LIMIT_K_BYTES; -import static org.alfresco.service.cmr.repository.TransformationOptionLimits.OPT_READ_LIMIT_TIME_MS; -import static org.alfresco.service.cmr.repository.TransformationOptionLimits.OPT_TIMEOUT_MS; - -import java.util.Map; -import java.util.Map.Entry; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.repo.content.AbstractContentReader; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Provides transformation limits for {@link org.alfresco.repo.content.transform.ContentTransformer} - * implementations. - *

- * This class maintains the limits and provides methods that combine limits: - * a) for the transformer as a whole - * b) for specific combinations if source and target mimetypes - * c) for the {@link TransformationOptions} provided for a specific transform. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public abstract class AbstractContentTransformerLimits extends ContentTransformerHelper implements ContentTransformer -{ - /** Indicates if 'page' limits are supported. */ - private boolean pageLimitsSupported; - - /** For debug **/ - protected TransformerDebug transformerDebug; - - /** - * Indicates if 'page' limits are supported. - * @return false by default. - */ - protected boolean isPageLimitSupported(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return pageLimitsSupported; - } - - /** - * Indicates if 'page' limits are supported. - */ - public void setPageLimitsSupported(boolean pageLimitsSupported) - { - this.pageLimitsSupported = pageLimitsSupported; - } - - /** - * Helper setter of the transformer debug. - * @param transformerDebug TransformerDebug - */ - public void setTransformerDebug(TransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - throw new IllegalStateException("Method should no longer be called. Override isTransformableMimetype in subclass."); - } - - /** - * {@inheritDoc}

- * - * Implementation calls the deprecated overloaded method without the sourceSize parameter - * and then {@link #isTransformableSize(String, long, String, TransformationOptions)}. - */ - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - // To make TransformerDebug output clearer, check the mimetypes and then the sizes. - // If not done, 'unavailable' transformers due to size might be reported even - // though they cannot transform the source to the target mimetype. - - return - isSupportedTransformation(sourceMimetype, targetMimetype, options) && - isTransformableMimetype(sourceMimetype, targetMimetype, options) && - isTransformableSize(sourceMimetype, sourceSize, targetMimetype, options); - } - - /** - * Indicates if this transformer is able to transform the given source mimetype - * to the target mimetype. If overridden, consider also overriding - * {@link ContentTransformerHelper#getComments(boolean)}. - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return isTransformable(sourceMimetype, targetMimetype, options); - } - - /** - * Indicates if this transformer is able to transform the given {@code sourceSize}. - * The {@code maxSourceSizeKBytes} property may indicate that only small source files - * may be transformed. - * @param sourceSize size in bytes of the source. If negative, the source size is unknown. - * @return {@code true} if the source is transformable. - */ - @Override - public boolean isTransformableSize(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - boolean sizeOkay = true; - if (sourceSize >= 0) - { - // if maxSourceSizeKBytes == 0 this implies the transformation is disabled - long maxSourceSizeKBytes = getMaxSourceSizeKBytes(sourceMimetype, targetMimetype, options); - sizeOkay = maxSourceSizeKBytes < 0 || (maxSourceSizeKBytes > 0 && sourceSize <= maxSourceSizeKBytes*1024); - if (!sizeOkay && transformerDebug.isEnabled()) - { - ((LegacyTransformerDebug)transformerDebug).unavailableTransformer(this, sourceMimetype, targetMimetype, maxSourceSizeKBytes); - } - } - return sizeOkay; - } - - /** - * Returns the maximum source size (in KBytes) allowed given the supplied values. - * @return 0 if the the transformation is disabled, -1 if there is no limit, otherwise the size in KBytes. - */ - @Override - public long getMaxSourceSizeKBytes(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - long maxSourceSizeKBytes = -1; - - // The maxSourceSizeKbytes value is ignored if this transformer is able to use - // page limits and the limits include a pageLimit. Normally used in the creation - // of icons. Note the readLimitKBytes value is not checked as the combined limits - // only have the max or limit KBytes value set (the smaller value is returned). - TransformationOptionLimits limits = getLimits(sourceMimetype, targetMimetype, options); - if (!isPageLimitSupported(sourceMimetype, targetMimetype, options) || limits.getPageLimit() <= 0) - { - maxSourceSizeKBytes = limits.getMaxSourceSizeKBytes(); - } - - return maxSourceSizeKBytes; - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions) getTimeoutMs()} - * which allows the limits to be selected based on mimetype and use. - */ - protected long getTimeoutMs() - { - return getLimits().getTimeoutMs(); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setTimeoutMs(long timeoutMs) - { - deprecatedSetter(null, null, OPT_TIMEOUT_MS+'='+timeoutMs); - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions) getReadLimitTimeMs()} - * which allows the limits to be selected based on mimetype and use. - */ - protected long getReadLimitTimeMs() - { - return getLimits().getReadLimitTimeMs(); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setReadLimitTimeMs(long readLimitTimeMs) - { - deprecatedSetter(null, null, OPT_READ_LIMIT_TIME_MS+'='+readLimitTimeMs); - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions) getMaxSourceSizeKBytes()} - * which allows the limits to be selected based on mimetype and use. - */ - protected long getMaxSourceSizeKBytes() - { - return getLimits().getMaxSourceSizeKBytes(); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setMaxSourceSizeKBytes(long maxSourceSizeKBytes) - { - deprecatedSetter(null, null, OPT_MAX_SOURCE_SIZE_K_BYTES+'='+maxSourceSizeKBytes); - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions) getReadLimitKBytes()} - * which allows the limits to be selected based on mimetype and use. - */ - protected long getReadLimitKBytes() - { - return getLimits().getReadLimitKBytes(); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setReadLimitKBytes(long readLimitKBytes) - { - deprecatedSetter(null, null, OPT_READ_LIMIT_K_BYTES+'='+readLimitKBytes); - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions) getMaxPages()} - * which allows the limits to be selected based on mimetype and use. - */ - protected int getMaxPages() - { - return getLimits().getMaxPages(); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setMaxPages(int maxPages) - { - deprecatedSetter(null, null, OPT_MAX_PAGES+'='+maxPages); - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions) getPageLimit()} - * which allows the limits to be selected based on mimetype and use. - */ - protected int getPageLimit() - { - return getLimits().getPageLimit(); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setPageLimit(int pageLimit) - { - deprecatedSetter(null, null, OPT_PAGE_LIMIT+'='+pageLimit); - } - - /** - * @deprecated use {@link #getLimits(String, String, TransformationOptions)} which allows the - * limits to be selected based on mimetype and use. - */ - protected TransformationOptionLimits getLimits() - { - return transformerConfig.getLimits(this, null, null, null); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setLimits(TransformationOptionLimits limits) - { - deprecatedLimitsSetter(null, null, limits); - } - - /** - * @deprecated transformation limits are now set with global properties rather than spring configuration. - */ - public void setMimetypeLimits(Map> mimetypeLimits) - { - for (Entry> source: mimetypeLimits.entrySet()) - { - String sourceMimetype = source.getKey(); - for (Entry target: source.getValue().entrySet()) - { - String targetMimetype = target.getKey(); - TransformationOptionLimits limits = target.getValue(); - deprecatedLimitsSetter(sourceMimetype, targetMimetype, limits); - } - } - } - - private void deprecatedLimitsSetter(String sourceMimetype, String targetMimetype, TransformationOptionLimits limits) - { - if (limits.supported()) - { - // Ignore limit pairs that are not specified - for (String limit: new String[] { - limits.getTimePair().toString(OPT_TIMEOUT_MS, OPT_READ_LIMIT_TIME_MS), - limits.getKBytesPair().toString(OPT_MAX_SOURCE_SIZE_K_BYTES, OPT_READ_LIMIT_K_BYTES), - limits.getPagesPair().toString(OPT_MAX_PAGES, OPT_PAGE_LIMIT) - }) - { - if (limit != null) - { - deprecatedSetter(sourceMimetype, targetMimetype, '.'+limit); - } - } - } - else - { - deprecatedSetter(sourceMimetype, targetMimetype, TransformerConfig.SUPPORTED+"=false"); - } - } - - /** - * Returns max and limit values for time, size and pages for a specified source and - * target mimetypes, combined with this Transformer's general limits and optionally - * the supplied transformation option's limits. - */ - protected TransformationOptionLimits getLimits(ContentReader reader, ContentWriter writer, - TransformationOptions options) - { - return (reader == null || writer == null) - ? transformerConfig.getLimits(this, null, null, options.getUse()).combine(options.getLimits()) - : getLimits(reader.getMimetype(), writer.getMimetype(), options); - } - - /** - * Returns max and limit values for time, size and pages for a specified source and - * target mimetypes, combined with this Transformer's general limits and optionally - * the supplied transformation option's limits. - */ - protected TransformationOptionLimits getLimits(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - TransformationOptionLimits limits = transformerConfig.getLimits(this, sourceMimetype, targetMimetype, (options == null ? null : options.getUse())); - return (options == null) ? limits : limits.combine(options.getLimits()); - } - - /** - * Pass on any limits to the reader. Will only do so if the reader is an - * {@link AbstractContentReader}. - * @param reader passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions)}. - * @param writer passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions)}. - * @param options passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions)}. - */ - protected void setReaderLimits(ContentReader reader, ContentWriter writer, - TransformationOptions options) - { - if (reader instanceof AbstractContentReader) - { - AbstractContentReader abstractContentReader = (AbstractContentReader)reader; - TransformationOptionLimits limits = getLimits(reader, writer, options); - abstractContentReader.setLimits(limits); - abstractContentReader.setTransformerDebug(transformerDebug); - } - } -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractRemoteContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/AbstractRemoteContentTransformer.java deleted file mode 100644 index eb144c4554..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/AbstractRemoteContentTransformer.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; - -/** - * Optionally sends transformations to a remote transformer if a {@link RemoteTransformerClient} is set and - * the ".url" Alfresco global property is set. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public abstract class AbstractRemoteContentTransformer extends AbstractContentTransformer2 -{ - private boolean enabled = true; - - private RemoteTransformerClient remoteTransformerClient; - - private boolean available = false; - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - /** - * Sets the optional remote transformer client which will be used in preference to a local command if available. - * - * @param remoteTransformerClient may be null; - */ - public void setRemoteTransformerClient(RemoteTransformerClient remoteTransformerClient) - { - this.remoteTransformerClient = remoteTransformerClient; - } - - boolean remoteTransformerClientConfigured() - { - return remoteTransformerClient != null && remoteTransformerClient.getBaseUrl() != null; - } - - protected abstract Log getLogger(); - - /** - * THIS IS A CUSTOM SPRING INIT METHOD - */ - @Override - public void register() - { - super.register(); - afterPropertiesSet(); - } - - public void afterPropertiesSet() - { - if (enabled) - { - // check availability - if (remoteTransformerClientConfigured()) - { - Log logger = getLogger(); - try - { - Pair result = remoteTransformerClient.check(logger); - Boolean isAvailable = result.getFirst(); - String msg = result.getSecond() == null ? "" : result.getSecond(); - if (isAvailable != null && isAvailable) - { - String versionString = msg; - setAvailable(true); - logger.debug("Using legacy " + getName() + ": " + versionString); - } - else - { - setAvailable(false); - String message = "Legacy " + getName() + " is not available for transformations. " + msg; - if (isAvailable == null) - { - logger.debug(message); - } - else - { - logger.error(message); - } - } - } - catch (Throwable e) - { - setAvailable(false); - logger.error("Remote " + getName() + " is not available: " + (e.getMessage() != null ? e.getMessage() : "")); - // debug so that we can trace the issue if required - logger.debug(e); - } - } - else - { - available = true; - } - } - } - - public boolean isAvailable() - { - if (remoteTransformerClientConfigured() && !remoteTransformerClient.isAvailable()) - { - afterPropertiesSet(); - } - - return available; - } - - protected void setAvailable(boolean available) - { - this.available = available; - } - - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - if (!isAvailable()) - { - return false; - } - - return super.isTransformable(sourceMimetype, sourceSize, targetMimetype, options); - } - - public void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception - { - if (remoteTransformerClientConfigured()) - { - String sourceMimetype = getMimetype(reader); - String targetMimetype = writer.getMimetype(); - String targetEncoding = writer.getEncoding(); - - MimetypeService mimetypeService = getMimetypeService(); - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - if (sourceExtension == null || targetExtension == null) - { - throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" + - " source mimetype: " + sourceMimetype + "\n" + - " source extension: " + sourceExtension + "\n" + - " target mimetype: " + targetMimetype + "\n" + - " target extension: " + targetExtension + "\n" + - " target encoding: " + targetEncoding); - } - - transformRemote(remoteTransformerClient, reader, writer, options, sourceMimetype, targetMimetype, - sourceExtension, targetExtension, targetEncoding); - } - else - { - transformLocal(reader, writer, options); - } - - Log logger = getLogger(); - if (logger.isDebugEnabled()) - { - logger.debug("Transformation completed: \n" + - " source: " + reader + "\n" + - " target: " + writer + "\n" + - " options: " + options); - } - } - - protected abstract void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception; - - protected abstract void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension, - String targetEncoding) throws Exception; -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/AdminUiTransformerDebug.java b/repository/src/main/java/org/alfresco/repo/content/transform/AdminUiTransformerDebug.java index 8e0ffe5e5f..655047b001 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/AdminUiTransformerDebug.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/AdminUiTransformerDebug.java @@ -67,16 +67,16 @@ import java.util.regex.Pattern; public class AdminUiTransformerDebug extends TransformerDebug implements ApplicationContextAware { protected TransformServiceRegistry remoteTransformServiceRegistry; - protected LocalTransformServiceRegistry localTransformServiceRegistryImpl; + protected LocalTransformServiceRegistry localTransformServiceRegistry; private ApplicationContext applicationContext; private ContentService contentService; private SynchronousTransformClient synchronousTransformClient; private Repository repositoryHelper; private TransactionService transactionService; - public void setLocalTransformServiceRegistryImpl(LocalTransformServiceRegistry localTransformServiceRegistryImpl) + public void setLocalTransformServiceRegistry(LocalTransformServiceRegistry localTransformServiceRegistry) { - this.localTransformServiceRegistryImpl = localTransformServiceRegistryImpl; + this.localTransformServiceRegistry = localTransformServiceRegistry; } public void setRemoteTransformServiceRegistry(TransformServiceRegistry remoteTransformServiceRegistry) @@ -108,7 +108,7 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica { if (synchronousTransformClient == null) { - synchronousTransformClient = (SynchronousTransformClient) applicationContext.getBean("legacySynchronousTransformClient"); + synchronousTransformClient = (SynchronousTransformClient) applicationContext.getBean("synchronousTransformClient"); } return synchronousTransformClient; } @@ -150,7 +150,7 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - PropertyCheck.mandatory(this, "localTransformServiceRegistryImpl", localTransformServiceRegistryImpl); + PropertyCheck.mandatory(this, "localTransformServiceRegistry", localTransformServiceRegistry); PropertyCheck.mandatory(this, "remoteTransformServiceRegistry", remoteTransformServiceRegistry); } @@ -160,12 +160,8 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica * @param sourceExtension restricts the list to one source extension. Unrestricted if null. * @param targetExtension restricts the list to one target extension. Unrestricted if null. * @param toString indicates that a String value should be returned in addition to any debug. - * @param format42 ignored - * @param onlyNonDeterministic ignored - * @param renditionName ignored */ - public String transformationsByExtension(String sourceExtension, String targetExtension, boolean toString, - boolean format42, boolean onlyNonDeterministic, String renditionName) + public String transformationsByExtension(String sourceExtension, String targetExtension, boolean toString) { // Do not generate this type of debug if already generating other debug to a StringBuilder // (for example a test transform). @@ -174,10 +170,10 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica return null; } - Collection sourceMimetypes = format42 || sourceExtension != null + Collection sourceMimetypes = sourceExtension != null ? getSourceMimetypes(sourceExtension) : mimetypeService.getMimetypes(); - Collection targetMimetypes = format42 || targetExtension != null + Collection targetMimetypes = targetExtension != null ? getTargetMimetypes(sourceExtension, targetExtension, sourceMimetypes) : mimetypeService.getMimetypes(); @@ -200,9 +196,9 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica ? false : remoteTransformServiceRegistry.isSupported(sourceMimetype, -1, targetMimetype, Collections.emptyMap(), null); - List localTransformers = localTransformServiceRegistryImpl == null + List localTransformers = localTransformServiceRegistry == null ? Collections.emptyList() - : localTransformServiceRegistryImpl.findTransformers(sourceMimetype, + : localTransformServiceRegistry.findTransformers(sourceMimetype, targetMimetype, Collections.emptyMap(), null); if (!localTransformers.isEmpty() || supportedByTransformService) { @@ -327,9 +323,9 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica } - public String testTransform(String sourceExtension, String targetExtension, String renditionName) + public String testTransform(String sourceExtension, String targetExtension) { - return new TestTransform().run(sourceExtension, targetExtension, renditionName); + return new TestTransform().run(sourceExtension, targetExtension); } public String[] getTestFileExtensionsAndMimetypes() @@ -369,7 +365,7 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica { protected LinkedList nodesToDeleteAfterTest = new LinkedList(); - String run(String sourceExtension, String targetExtension, String renditionName) + String run(String sourceExtension, String targetExtension) { RetryingTransactionHelper.RetryingTransactionCallback makeNodeCallback = new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -403,7 +399,7 @@ public class AdminUiTransformerDebug extends TransformerDebug implements Applica } catch (Exception e) { - logger.debug("Unexpected test transform error", e); + sb.append(e.getMessage()); } finally { diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/AppleIWorksContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/AppleIWorksContentTransformer.java deleted file mode 100644 index e68da54128..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/AppleIWorksContentTransformer.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; -import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -/** - * Converts Apple iWorks files to JPEGs for thumbnailing & previewing. - * The transformer will only work for iWorks 2013/14 files. Support for iWorks 2008/9 has been dropped as we cannot - * support both, because the newer format does not contain a PDF. If we say this transformer supports PDF, Share will - * assume incorrectly that we can convert to PDF and we would only get a preview for the older format and never the - * newer one. Both formats have the same mimetype. - * - * @author Neil Mc Erlean - * @since 4.0 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class AppleIWorksContentTransformer extends AbstractRemoteContentTransformer -{ - private static final Log logger = LogFactory.getLog(AppleIWorksContentTransformer.class); - - // Apple's zip entry names for previews in iWorks have changed over time. - private static final List PDF_PATHS = Arrays.asList( - "QuickLook/Preview.pdf"); // iWorks 2008/9 - private static final List JPG_PATHS = Arrays.asList( - "QuickLook/Thumbnail.jpg", // iWorks 2008/9 - "preview.jpg"); // iWorks 2013/14 (720 x 552) We use the best quality image. Others are: - // (225 x 173) preview-web.jpg - // (53 x 41) preview-micro.jpg - - private static final List IWORKS_MIMETYPES = Arrays.asList(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, - MimetypeMap.MIMETYPE_IWORK_NUMBERS, - MimetypeMap.MIMETYPE_IWORK_PAGES); - private static final List TARGET_MIMETYPES = Arrays.asList(MimetypeMap.MIMETYPE_IMAGE_JPEG -// Commented out rather than removed, in case we can get SHARE to fall back to using JPEG when a PDF is not available -// ,MimetypeMap.MIMETYPE_PDF - ); - - @Override - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - // only support [iWorks] -> JPEG but only if these are embedded in the file. - // This is because iWorks 13+ files are zip files containing embedded jpeg previews. - return TARGET_MIMETYPES.contains(targetMimetype) && IWORKS_MIMETYPES.contains(sourceMimetype); - } - - @Override - public String getComments(boolean available) - { - return getCommentsOnlySupports(IWORKS_MIMETYPES, TARGET_MIMETYPES, available); - } - - @Override - protected Log getLogger() - { - return logger; - } - - @Override - protected void transformLocal(ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - final String sourceMimetype = reader.getMimetype(); - final String sourceExtension = getMimetypeService().getExtension(sourceMimetype); - final String targetMimetype = writer.getMimetype(); - final String targetExtension = getMimetypeService().getExtension(targetMimetype); - - if (logger.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Transforming from ").append(sourceMimetype) - .append(" to ").append(targetMimetype); - logger.debug(msg.toString()); - } - - ZipArchiveInputStream iWorksZip = null; - try - { - // iWorks files are zip (or package) files. - // If it's not a zip file, the resultant ZipException will be caught as an IOException below. - iWorksZip = new ZipArchiveInputStream(reader.getContentInputStream()); - - // Look through the zip file entries for the preview/thumbnail. - List paths = MimetypeMap.MIMETYPE_IMAGE_JPEG.equals(targetMimetype) ? JPG_PATHS : PDF_PATHS; - ZipArchiveEntry entry; - boolean found = false; - while ((entry=iWorksZip.getNextZipEntry()) != null) - { - String name = entry.getName(); - if (paths.contains(name)) - { - writer.putContent( iWorksZip ); - found = true; - break; - } - } - - if (! found) - { - throw new AlfrescoRuntimeException("The source " + sourceExtension + " file did not contain a " + targetExtension + " preview"); - } - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("Unable to transform " + sourceExtension + " file. It should have been a zip format file.", e); - } - finally - { - if (iWorksZip != null) - { - iWorksZip.close(); - } - } - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, String sourceMimetype, - String targetMimetype, String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - long timeoutMs = options.getTimeoutMs(); - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "appleIWorks", - "sourceMimetype", sourceMimetype, - "sourceExtension", sourceExtension, - "targetMimetype", targetMimetype); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ArchiveContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/ArchiveContentTransformer.java deleted file mode 100644 index 0cfe65c193..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ArchiveContentTransformer.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; - -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tika.config.TikaConfig; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.mime.MediaType; -import org.apache.tika.parser.AutoDetectParser; -import org.apache.tika.parser.EmptyParser; -import org.apache.tika.parser.ParseContext; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.pkg.PackageParser; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.TARGET_ENCODING; - -/** - * This class transforms archive files (zip, tar etc) to text, which enables indexing - * and searching of archives as well as webpreviewing. - * The transformation can simply list the names of the entries within the archive, or - * it can also include the textual content of the entries themselves. - * The former is suggested for web preview, the latter for indexing. - * This behaviour is controlled by the recurse flag. - * - * @author Neil McErlean - * @author Nick Burch - * @since 3.4 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ArchiveContentTransformer extends TikaPoweredContentTransformer -{ - /** - * The logger - */ - private static Log logger = LogFactory.getLog(ArchiveContentTransformer.class); - - private boolean includeContents = false; - private TikaConfig tikaConfig; - - /** - * We support all the archive mimetypes that the Tika - * package parser can handle - */ - public static ArrayList SUPPORTED_MIMETYPES; - static { - SUPPORTED_MIMETYPES = new ArrayList(); - Parser p = new PackageParser(); - for(MediaType mt : p.getSupportedTypes(null)) { - // Tika can probably do some useful text - SUPPORTED_MIMETYPES.add( mt.toString() ); - } - } - - public ArchiveContentTransformer() { - super(SUPPORTED_MIMETYPES); - } - - /** - * Injects the TikaConfig to use - * - * @param tikaConfig The Tika Config to use - */ - public void setTikaConfig(TikaConfig tikaConfig) - { - this.tikaConfig = tikaConfig; - } - - public void setIncludeContents(String includeContents) - { - // Spring really ought to be able to handle - // setting a boolean that might still be - // ${foo} (i.e. not overridden in a property). - // As we can't do that with spring, we do it... - this.includeContents = false; - if(includeContents != null && includeContents.length() > 0) - { - this.includeContents = TransformationOptions.relaxedBooleanTypeConverter.convert(includeContents).booleanValue(); - } - } - - @Override - protected Parser getParser() { - return new PackageParser(); - } - - @Override - protected ParseContext buildParseContext(Metadata metadata, - String targetMimeType, TransformationOptions options) { - ParseContext context = super.buildParseContext(metadata, targetMimeType, options); - - boolean recurse = includeContents; - if(options.getIncludeEmbedded() != null) - { - recurse = options.getIncludeEmbedded(); - } - - if(recurse) - { - // Use an auto detect parser to handle the contents - if(tikaConfig == null) - { - tikaConfig = TikaConfig.getDefaultConfig(); - } - context.set(Parser.class, new AutoDetectParser(tikaConfig)); - } - else - { - // REPO-1066: an AutoDetectParser is the default in Tika after: https://issues.apache.org/jira/browse/TIKA-2096 - // so we need to specify an empty one if we don't want the recurse parsing to happen - context.set(Parser.class, new EmptyParser()); - } - return context; - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - long timeoutMs = options.getTimeoutMs(); - boolean recurse = includeContents; - if(options.getIncludeEmbedded() != null) - { - recurse = options.getIncludeEmbedded(); - } - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "Archive", - "includeContents", Boolean.toString(recurse), - "sourceMimetype", sourceMimetype, - "sourceExtension", sourceExtension, - "targetMimetype", targetMimetype, - TARGET_ENCODING, targetEncoding); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/BinaryPassThroughContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/BinaryPassThroughContentTransformer.java deleted file mode 100644 index bb33bcb7da..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/BinaryPassThroughContentTransformer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Allows direct streaming from source to target when the respective mimetypes - * are identical, except where the mimetype is text. - *

- * Text has to be transformed based on the encoding even if the mimetypes don't - * reflect it. - * - * @see org.alfresco.repo.content.transform.StringExtractingContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class BinaryPassThroughContentTransformer extends AbstractContentTransformer2 -{ - @SuppressWarnings("unused") - private static final Log logger = LogFactory.getLog(BinaryPassThroughContentTransformer.class); - - @Override - protected void transformInternal(ContentReader reader, - ContentWriter writer, TransformationOptions options) - throws Exception - { - // just stream it - writer.putContent(reader.getContentInputStream()); - - } - - @Override - public boolean isTransformableMimetype(String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - if (sourceMimetype.startsWith(StringExtractingContentTransformer.PREFIX_TEXT)) - { - // we can only stream binary content through - return false; - } - else if (!sourceMimetype.equals(targetMimetype)) - { - // no transformation is possible so formats must be exact - return false; - } - else - { - if (options == null || TransformationOptions.class.equals(options.getClass()) == true) - { - // formats are the same and are not text - return true; - } - else - { - // If it has meaningful options then we assume there is another transformer better equiped - // to deal with it - return false; - } - } - } - - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(super.getComments(available)); - sb.append("# Only supports streaming to the same type but excludes txt\n"); - return sb.toString(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ComplexContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/ComplexContentTransformer.java deleted file mode 100644 index 189e8eb03c..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ComplexContentTransformer.java +++ /dev/null @@ -1,549 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.beans.PropertyDescriptor; -import java.io.File; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayDeque; -import java.util.Collections; -import java.util.Deque; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.rendition2.LegacySynchronousTransformClient; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * Transformer that passes a document through several nested transformations - * in order to accomplish its goal. - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public class ComplexContentTransformer extends AbstractContentTransformer2 implements InitializingBean -{ - /** - * The logger - */ - private static Log logger = LogFactory.getLog(ComplexContentTransformer.class); - - /** - * Complex transformers contain lower level transformers. In order to find dynamic - * (defined as null) child transformers to use, they recursively check available - * transformers. It makes no sense to have a transformer that is its own child. - */ - static final ThreadLocal> parentTransformers = new ThreadLocal>() { - @Override - protected Deque initialValue() { - return new ArrayDeque(); - } - }; - - private List transformers; - private List intermediateMimetypes; - private Map transformationOptionOverrides; - private LegacySynchronousTransformClient legacySynchronousTransformClient; - - public ComplexContentTransformer() - { - } - - /** - * The list of transformers to use. If any element is null - * all possible transformers will be considered. If any element - * is null, the legacySynchronousTransformClient property must be set. - *

- * If a single transformer is supplied, then it will still be used. - * - * @param transformers list of at least one transformer - */ - public void setTransformers(List transformers) - { - this.transformers = transformers; - } - - /** - * Set the intermediate mimetypes that the transformer must take the content - * through. If the transformation A..B..C is performed in order to - * simulate A..C, then B is the intermediate mimetype. There - * must always be n-1 intermediate mimetypes, where n is the - * number of {@link #setTransformers(List) transformers} taking part in the - * transformation. - * - * @param intermediateMimetypes intermediate mimetypes to transition the content - * through. - */ - public void setIntermediateMimetypes(List intermediateMimetypes) - { - this.intermediateMimetypes = intermediateMimetypes; - } - - /** - * Sets any properties to be set on the TransformationOption as passed in. - * This allows you to force certain properties to always be set on it, - * to control the transformers in a different way to their default. - * Note that only properties that are supported by the passed-in - * {@link TransformationOptions} are changed, others are ignored. - */ - public void setTransformationOptionOverrides( - Map transformationOptionOverrides) - { - this.transformationOptionOverrides = transformationOptionOverrides; - } - - public void setLegacySynchronousTransformClient(LegacySynchronousTransformClient legacySynchronousTransformClient) - { - this.legacySynchronousTransformClient = legacySynchronousTransformClient; - } - - /** - * Ensures that required properties have been set - */ - public void afterPropertiesSet() throws Exception - { - if (transformers == null || transformers.size() == 0) - { - throw new AlfrescoRuntimeException("At least one inner transformer must be supplied: " + this); - } - if (intermediateMimetypes == null || intermediateMimetypes.size() != transformers.size() - 1) - { - throw new AlfrescoRuntimeException( - "There must be n-1 intermediate mimetypes, where n is the number of transformers"); - } - if (getMimetypeService() == null) - { - throw new AlfrescoRuntimeException("'mimetypeService' is a required property"); - } - for (ContentTransformer transformer: transformers) - { - if (transformer == null) - { - if (legacySynchronousTransformClient == null) - { - throw new AlfrescoRuntimeException("'legacySynchronousTransformClient' is a required property if " + - "there are any null (dynamic) transformers"); - } - break; - } - } - } - - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, - TransformationOptions options) - { - if (!isSupportedTransformation(sourceMimetype, targetMimetype, options)) - { - return false; - } - - // Don't allow transformer to be its own child. - if (parentTransformers.get().contains(this)) - { - return false; - } - - overrideTransformationOptions(options); - - // Can use super isTransformableSize as it indirectly calls getLimits in this class - // which combines the limits from the first transformer. Other transformer in the chain - // are no checked as sizes are unknown. - return - isTransformableMimetype(sourceMimetype, targetMimetype, options) && - isTransformableSize(sourceMimetype, sourceSize, targetMimetype, options); - } - - /** - * Sets any transformation option overrides it can. - */ - private void overrideTransformationOptions(TransformationOptions options) - { - // Set any transformation options overrides if we can - if(options != null && transformationOptionOverrides != null) - { - for(String key : transformationOptionOverrides.keySet()) - { - if(PropertyUtils.isWriteable(options, key)) - { - try - { - PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(options, key); - Class propertyClass = pd.getPropertyType(); - - Object value = transformationOptionOverrides.get(key); - if(value != null) - { - if(propertyClass.isInstance(value)) - { - // Nothing to do - } - else if(value instanceof String && propertyClass.isInstance(Boolean.TRUE)) - { - // Use relaxed converter - value = TransformationOptions.relaxedBooleanTypeConverter.convert((String)value); - } - else - { - value = DefaultTypeConverter.INSTANCE.convert(propertyClass, value); - } - } - PropertyUtils.setProperty(options, key, value); - } - catch(NoSuchMethodException nsme) {} - catch(InvocationTargetException ite) {} - catch(IllegalAccessException iae) {} - } - else - { - logger.warn("Unable to set override Transformation Option " + key + " on " + options); - } - } - } - } - - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - boolean result = true; - String currentSourceMimetype = sourceMimetype; - Iterator transformerIterator = transformers.iterator(); - - // When using a wild card (null) intermediate transformer, don't - // say we support a transformation that one of the none null intermediate - // transformers can do on its own, to avoid double transformations. - // Not done when there are no wild card transformers, as there are cases - // where it makes sense to go via an intermediate format (quality/speed). - while (transformerIterator.hasNext()) - { - ContentTransformer transformer = transformerIterator.next(); - if (transformer == null) - { - transformerIterator = transformers.iterator(); - while (transformerIterator.hasNext()) - { - transformer = transformerIterator.next(); - if (transformer != null) - { - if (transformer.isTransformable(sourceMimetype, -1, targetMimetype, options)) - { - return false; - } - } - } - break; - } - } - - transformerIterator = transformers.iterator(); - Iterator intermediateMimetypeIterator = intermediateMimetypes.iterator(); - while (transformerIterator.hasNext()) - { - ContentTransformer transformer = transformerIterator.next(); - - // determine the target mimetype. This is the final target if we are on the last transformation - String currentTargetMimetype = transformerIterator.hasNext() ? intermediateMimetypeIterator.next() : targetMimetype; - if (transformer == null) - { - try - { - parentTransformers.get().push(this); - @SuppressWarnings("deprecation") - List firstTansformers = legacySynchronousTransformClient.getActiveTransformers( - currentSourceMimetype, -1, currentTargetMimetype, options); - if (firstTansformers.isEmpty()) - { - result = false; - break; - } - } - finally - { - parentTransformers.get().pop(); - } - } - else - { - if (transformer.isTransformable(currentSourceMimetype, -1, currentTargetMimetype, options) == false) - { - result = false; - break; - } - } - - // move on - currentSourceMimetype = currentTargetMimetype; - } - - return result; - } - - /** - * Indicates if 'page' limits are supported by the first transformer in the chain. - * If the first transformer is dynamic, all possible first transformers must support it. - * @return true if the first transformer supports them. - */ - @Override - protected boolean isPageLimitSupported(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - boolean pageLimitSupported; - ContentTransformer firstTransformer = transformers.get(0); - String firstTargetMimetype = intermediateMimetypes.get(0); - if (firstTransformer == null) - { - try - { - parentTransformers.get().push(this); - @SuppressWarnings("deprecation") - List firstTansformers = legacySynchronousTransformClient.getActiveTransformers( - sourceMimetype, -1, firstTargetMimetype, options); - pageLimitSupported = !firstTansformers.isEmpty(); - if (pageLimitSupported) - { - for (ContentTransformer transformer: firstTansformers) - { - if (!isPageLimitSupported(transformer, sourceMimetype, targetMimetype, options)) - { - pageLimitSupported = false; - break; - } - } - } - } - finally - { - parentTransformers.get().pop(); - } - } - else - { - pageLimitSupported = isPageLimitSupported(firstTransformer, sourceMimetype, targetMimetype, options); - } - return pageLimitSupported; - } - - private boolean isPageLimitSupported(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - return (transformer instanceof AbstractContentTransformerLimits) - ? ((AbstractContentTransformerLimits)transformer).isPageLimitSupported(sourceMimetype, targetMimetype, options) - : false; - } - - /** - * Returns the limits from this transformer combined with those of the first transformer in the chain. - * If the first transformer is dynamic, the lowest common denominator between all possible first transformers - * are combined. - */ - protected TransformationOptionLimits getLimits(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - TransformationOptionLimits firstTransformerLimits = null; - TransformationOptionLimits limits = super.getLimits(sourceMimetype, targetMimetype, options); - ContentTransformer firstTransformer = transformers.get(0); - String firstTargetMimetype = intermediateMimetypes.get(0); - if (firstTransformer == null) - { - try - { - parentTransformers.get().push(this); - @SuppressWarnings("deprecation") - List firstTansformers = legacySynchronousTransformClient.getActiveTransformers( - sourceMimetype, -1, firstTargetMimetype, options); - if (!firstTansformers.isEmpty()) - { - for (ContentTransformer transformer: firstTansformers) - { - if (transformer instanceof AbstractContentTransformerLimits) - { - TransformationOptionLimits transformerLimits = ((AbstractContentTransformerLimits)transformer). - getLimits(sourceMimetype, firstTargetMimetype, options); - firstTransformerLimits = (firstTransformerLimits == null) - ? transformerLimits - : firstTransformerLimits.combineUpper(transformerLimits); - } - } - } - } - finally - { - parentTransformers.get().pop(); - } - } - else - { - if (firstTransformer instanceof AbstractContentTransformerLimits) - { - firstTransformerLimits = ((AbstractContentTransformerLimits)firstTransformer). - getLimits(sourceMimetype, firstTargetMimetype, options); - } - } - - if (firstTransformerLimits != null) - { - limits = limits.combine(firstTransformerLimits); - } - - return limits; - } - - /** - * @see org.alfresco.repo.content.transform.AbstractContentTransformer2#transformInternal(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions) - */ - @Override - public void transformInternal( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - NodeRef origSourceNodeRef = options.getSourceNodeRef(); - try - { - ContentReader currentReader = reader; - - Iterator transformerIterator = transformers.iterator(); - Iterator intermediateMimetypeIterator = intermediateMimetypes.iterator(); - while (transformerIterator.hasNext()) - { - ContentTransformer transformer = transformerIterator.next(); - // determine the target mimetype. This is the final target if we are on the last transformation - ContentWriter currentWriter = null; - if (!transformerIterator.hasNext()) - { - currentWriter = writer; - } - else - { - String nextMimetype = intermediateMimetypeIterator.next(); - // make a temp file writer with the correct extension - String sourceExt = getMimetypeService().getExtension(currentReader.getMimetype()); - String targetExt = getMimetypeService().getExtension(nextMimetype); - File tempFile = TempFileProvider.createTempFile( - "ComplextTransformer_intermediate_" + sourceExt + "_", - "." + targetExt); - currentWriter = new FileContentWriter(tempFile); - currentWriter.setMimetype(nextMimetype); - } - - // transform - if (transformer == null) - { - try - { - parentTransformers.get().push(this); - legacySynchronousTransformClient.transform(currentReader, currentWriter, options); - } - finally - { - parentTransformers.get().pop(); - } - } - else - { - transformer.transform(currentReader, currentWriter, options); - } - - // Must clear the sourceNodeRef after the first transformation to avoid later - // transformers thinking the intermediate file is the original node. However as - // we put the original sourceNodeRef back at the end of this try block (so that we are - // not changing any data), we must setting the value to null just after the - // transformation. Really only needs to be done after the first transformation - // but doing it every time is simpler and faster. - options.setSourceNodeRef(null); - - // move the source on - currentReader = currentWriter.getReader(); - } - // done - } - finally - { - options.setSourceNodeRef(origSourceNodeRef); - } - } - - public List getIntermediateMimetypes() - { - return Collections.unmodifiableList(intermediateMimetypes); - } - - public List getIntermediateTransformers() - { - return Collections.unmodifiableList(transformers); - } - - /** - * Returns the transformer properties predefined (hard coded or implied) by this transformer. - */ - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(super.getComments(available)); - sb.append("# "); - sb.append(TransformerConfig.CONTENT); - sb.append(getName()); - sb.append(TransformerConfig.PIPELINE); - sb.append('='); - Iterator iterator = intermediateMimetypes.iterator(); - for (ContentTransformer transformer: transformers) - { - sb.append(transformer != null ? getSimpleName(transformer) : TransformerConfig.ANY); - if (iterator.hasNext()) - { - sb.append(TransformerConfig.PIPE); - String mimetype = iterator.next(); - if (mimetype != null && mimetype.length() != 0) - { - String extension = getMimetypeService().getExtension(mimetype); - sb.append(extension); - } - sb.append(TransformerConfig.PIPE); - } - } - sb.append('\n'); - return sb.toString(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformer.java deleted file mode 100644 index ab9fc731b3..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformer.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.List; -import java.util.Map; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.repo.content.ContentWorker; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Interface for class that allow content transformation from one mimetype to another. - * - * @author Derek Hulley - * - * @deprecated The RenditionService is being replace by the simpler async RenditionService2. - */ -@Deprecated -@AlfrescoPublicApi -public interface ContentTransformer extends ContentWorker -{ - /** - * @deprecated use version with extra sourceSize parameter. - */ - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * Indicates whether the provided source mimetype can be transformed into the target mimetype with - * the options specified by this content transformer. - * - * @param sourceMimetype the source mimetype - * @param sourceSize the size (bytes) of the source. If negative it is unknown. - * @param targetMimetype the target mimetype - * @param options the transformation options - * @return boolean true if this content transformer can satify the mimetypes and options specified, false otherwise - */ - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options); - - /** - * Sub component of {@link #isTransformable(String, long, String, TransformationOptions)} - * that checks just the mimetypes. - * @param sourceMimetype the source mimetype - * @param targetMimetype the target mimetype - * @param options the transformation options - * @return boolean true if this content transformer can satify the mimetypes, false otherwise - */ - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * Sub component of {@link #isTransformable(String, long, String, TransformationOptions)} - * that checks just the size limits. - * @param sourceMimetype the source mimetype - * @param sourceSize the size (bytes) of the source. If negative it is unknown. - * @param targetMimetype the target mimetype - * @param options the transformation options - * @return boolean true if this content transformer can satify the mimetypes, false otherwise - */ - public boolean isTransformableSize(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options); - - /** - * Overridden to supply a comment or String of commented out transformation properties - * that specify any (hard coded or implied) supported transformations. Used - * when providing a list of properties to an administrators who may be setting - * other transformation properties, via JMX. Consider overriding if - * {link {@link AbstractContentTransformerLimits#isTransformableMimetype(String, String, TransformationOptions)} - * or {@link ContentTransformerWorker#isTransformable(String, String, TransformationOptions)} - * have been overridden. - * @param available indicates if the transformer has been registered and is available to be selected. - * {@code false} indicates that the transformer is only available as a component of a - * complex transformer. - * @return one line per property. The simple transformer name is returned by default as a comment. - */ - public String getComments(boolean available); - - /** - * Returns the maximum source size (in KBytes) allowed given the supplied values. - * @return 0 if the the transformation is disabled, -1 if there is no limit, otherwise the size in KBytes. - */ - public long getMaxSourceSizeKBytes(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * @deprecated Use transformer priority and unsupported transformer properties. - * - * Indicates whether given the provided transformation parameters this transformer can provide an explicit - * transformation. - * - * An explicit transformation indicates that the transformation happens directly and not as a result of - * another transformation process. Explicit transformation always take presidency over normal transformations. - * - * @param sourceMimetype the source mimetype - * @param targetMimetype the target mimetype - * @param options the transformation options - * @return boolean true if it is an explicit transformation, false otherwise - */ - public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * @deprecated use mimetype specific version. - */ - public long getTransformationTime(); - - /** - * Provides an estimate, usually a worst case guess, of how long a transformation - * will take. Null mimetype values provide the overall value for the transformer. - *

- * This method is used to determine, up front, which of a set of - * equally reliant transformers will be used for a specific transformation. - * - * @param sourceMimetype the source mimetype - * @param targetMimetype the target mimetype - * - * @return Returns the approximate number of milliseconds per transformation - */ - public long getTransformationTime(String sourceMimetype, String targetMimetype); - - /** - * @see #transform(ContentReader, ContentWriter, TransformationOptions) - * - * @deprecated - * Deprecated use {link {@link #transform(ContentReader, ContentWriter, TransformationOptions)}. - */ - public void transform(ContentReader reader, ContentWriter writer) throws ContentIOException; - - /** - * Transforms the content provided by the reader and source mimetype - * to the writer and target mimetype. - *

- * The source and target mimetypes must be available on the - * {@link org.alfresco.service.cmr.repository.ContentAccessor#getMimetype()} methods of - * both the reader and the writer. - *

- * Both reader and writer will be closed after the transformation completes. - * - * @param reader the source of the content - * @param writer the destination of the transformed content - * @param options options to pass to the transformer. These are transformer dependent - * and may be null. - * @throws ContentIOException if an IO exception occurs - * - * @deprecated - * Deprecated since 3.0. Options should now be provided as a TransformationOptions object. - */ - @Deprecated - public void transform( - ContentReader reader, - ContentWriter writer, - Map options) throws ContentIOException; - - /** - * Transforms the content provided by the reader and source mimetype - * to the writer and target mimetype with the provided transformation options. - *

- * The transformation viability can be determined by an up front call - * to {@link #isTransformable(String, String, TransformationOptions)}. - *

- * The source and target mimetypes must be available on the - * {@link org.alfresco.service.cmr.repository.ContentAccessor#getMimetype()} methods of - * both the reader and the writer. - *

- * Both reader and writer will be closed after the transformation completes. - *

- * The provided options can be null. - * - * @param reader the source of the content - * @param contentWriter the destination of the transformed content - * @param options transformation options, these can be null - * @throws ContentIOException if an IO exception occurs - */ - public void transform(ContentReader reader, ContentWriter contentWriter, TransformationOptions options) - throws ContentIOException; - - /** - * Returns transformer's name used in configuration. - */ - public String getName(); -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerHelper.java b/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerHelper.java deleted file mode 100644 index e667d1018e..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerHelper.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.ContentAccessor; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.BeanNameAware; - -/** - * A class providing basic functionality shared by both {@link ContentTransformer}s and {@link ContentTransformerWorker}s. - * - * @author dward - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public class ContentTransformerHelper implements BeanNameAware -{ - private static final Log logger = LogFactory.getLog(ContentTransformerHelper.class); - - private MimetypeService mimetypeService; - protected TransformerConfig transformerConfig; - - List deprecatedSetterMessages; - private static boolean firstDeprecatedSetter = true; - - /** The bean name. */ - private String beanName; - - /** - * Helper setter of the mimetype service. This is not always required. - * - * @param mimetypeService MimetypeService - */ - public void setMimetypeService(MimetypeService mimetypeService) - { - this.mimetypeService = mimetypeService; - } - - /** - * @return Returns the mimetype helper - */ - protected MimetypeService getMimetypeService() - { - return mimetypeService; - } - - /** - * @deprecated supported transformations are now set with global properties rather than spring configuration. - */ - public void setExplicitTransformations(List explicitTransformations) - { - deprecatedSupportedTransformations(explicitTransformations, null); - } - - /** - * @deprecated supported transformations are now set with global properties rather than spring configuration. - */ - public void setSupportedTransformations(List supportedTransformations) - { - deprecatedSupportedTransformations(supportedTransformations, "true"); - } - - /** - * @deprecated supported transformations are now set with global properties rather than spring configuration. - */ - public void setUnsupportedTransformations(List unsupportedTransformations) - { - deprecatedSupportedTransformations(unsupportedTransformations, "false"); - } - - public void setTransformerConfig(TransformerConfig transformerConfig) - { - this.transformerConfig = transformerConfig; - } - - /** - * Convenience to fetch and check the mimetype for the given content - * - * @param content - * the reader/writer for the content - * @return Returns the mimetype for the content - * @throws AlfrescoRuntimeException - * if the content doesn't have a mimetype - */ - protected String getMimetype(ContentAccessor content) - { - String mimetype = content.getMimetype(); - if (mimetype == null) - { - throw new AlfrescoRuntimeException("Mimetype is mandatory for transformation: " + content); - } - // done - return mimetype; - } - - /** - * @deprecated Should now use priority and unsupported transformer properties. - * - * @see org.alfresco.repo.content.transform.ContentTransformer#isExplicitTransformation(java.lang.String, - * java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions) - */ - public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return transformerConfig.getPriority(((ContentTransformer)this), sourceMimetype, targetMimetype) == TransformerConfig.PRIORITY_EXPLICIT; - } - - public boolean isSupportedTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return transformerConfig.isSupportedTransformation(((ContentTransformer)this), sourceMimetype, targetMimetype, options); - } - - /** - * Sets the Spring bean name. - */ - @Override - public void setBeanName(String beanName) - { - this.beanName = beanName; - } - - /** - * THIS IS A CUSTOM SPRING INIT METHOD - */ - public void register() - { - logDeprecatedSetter(deprecatedSetterMessages); - } - - /** - * Returns the Spring bean name. - */ - public String getBeanName() - { - return beanName; - } - - /** - * Returns transformer name. Uses the Spring bean name, but if null uses the class name. - */ - public String getName() - { - return (beanName == null) ? getClass().getSimpleName() : beanName; - } - - /** - * Returns the simple form of the transformer name, which has had the normal - * "transformer." prefix to the Spring bean name removed. - */ - public static String getSimpleName(ContentTransformer transformer) - { - String transformerName = transformer.getName(); - return transformerName.startsWith(TransformerConfig.TRANSFORMER) - ? transformerName.substring(TransformerConfig.TRANSFORMER.length()) - : transformerName; - } - - /** - * Called by deprecated property setter methods that should no longer be called - * by Spring configuration as the values are now set using global properties. - * @param sourceMimetype so that the source extension can be worked out once the mimetypeService - * has been set. - * @param targetMimetype so that the target extension can be worked out once the mimetypeService - * has been set. - * @param suffixAndValue that should be used. - */ - protected void deprecatedSetter(String sourceMimetype, String targetMimetype, String suffixAndValue) - { - if (deprecatedSetterMessages == null) - { - deprecatedSetterMessages = new ArrayList(); - } - deprecatedSetterMessages.add(new DeprecatedSetter(sourceMimetype, targetMimetype, suffixAndValue)); - } - - /** - * Called when the bean name is set after all the deprecated setters to log - * INFO messages with the Alfresco global properties that should now be set - * (if not set) to replace Spring configuration. - */ - void logDeprecatedSetter(List deprecatedSetterMessages) - { - if (deprecatedSetterMessages != null) - { - StringBuilder sb = new StringBuilder(); - for (DeprecatedSetter deprecatedSetter: deprecatedSetterMessages) - { - String propertyNameAndValue = deprecatedSetter.getPropertyNameAndValue(beanName); - String propertyName = propertyNameAndValue.replaceAll("=.*", ""); - if (transformerConfig.getProperty(propertyName) == null) - { - if (firstDeprecatedSetter) - { - firstDeprecatedSetter = false; - logger.error("In order to support dynamic setting of transformer options, Spring XML configuration"); - logger.error("is no longer used to initialise these options."); - logger.error(" "); - logger.error("Your system appears to contains custom Spring configuration which should be replace by"); - logger.error("the following Alfresco global properties. In the case of the Enterprise edition these"); - logger.error("values may then be dynamically changed via JMX."); - logger.error(" "); - // Note: Cannot set these automatically because, an MBean reset would clear them. - } - logger.error(propertyNameAndValue); - - sb.append(propertyNameAndValue); - sb.append('\n'); - } - else - { - logger.warn(propertyNameAndValue+" is set, but spring config still exists"); - } - } - deprecatedSetterMessages = null; - if (sb.length() > 0) - { - // Add subsystem's properties anyway (even though an MBean reset would clear them), - // so that existing unit tests work. - transformerConfig.setProperties(sb.toString()); - } - } - } - - private void deprecatedSupportedTransformations(List transformations, String value) - { - if (transformations != null) - { - for (SupportedTransformation transformation: transformations) - { - String sourceMimetype = transformation.getSourceMimetype(); - String targetMimetype = transformation.getTargetMimetype(); - - if (value == null) - { - deprecatedSetter(sourceMimetype, targetMimetype, TransformerConfig.PRIORITY+"="+TransformerConfig.PRIORITY_EXPLICIT); - deprecatedSetter(sourceMimetype, targetMimetype, TransformerConfig.SUPPORTED+"=true"); - } - else - { - deprecatedSetter(sourceMimetype, targetMimetype, TransformerConfig.SUPPORTED+"="+value); - } - } - } - } - - protected String getExtensionOrAny(String mimetype) - { - return mimetype == null || ANY.equals(mimetype) ? ANY : mimetypeService.getExtension(mimetype); - } - - public String toString() - { - return getName(); - } - - /** - * Overridden to supply a comment or String of commented out transformation properties - * that specify any (hard coded or implied) supported transformations. Used - * when providing a list of properties to an administrators who may be setting - * other transformation properties, via JMX. Consider overriding if - * {link {@link AbstractContentTransformerLimits#isTransformableMimetype(String, String, TransformationOptions)} - * or {@link ContentTransformerWorker#isTransformable(String, String, TransformationOptions)} - * have been overridden. - * See {@link #getCommentsOnlySupports(List, List, boolean)} which may be used to help construct a comment. - * @param available indicates if the transformer has been registered and is available to be selected. - * {@code false} indicates that the transformer is only available as a component of a - * complex transformer. - * @return one line per property. The simple transformer name is returned by default as a comment. - */ - public String getComments(boolean available) - { - return getCommentNameAndAvailable(available); - } - - /** - * Helper method for {@link #getComments(boolean)} to - * create a line that indicates which source and target mimetypes - * it supports. - * @param available TODO - * @return a String of the form "# only supports xxx, yyy or zzz to aaa or bb\n". - */ - protected String getCommentsOnlySupports(List sourceMimetypes, List targetMimetypes, boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(getCommentNameAndAvailable(available)); - sb.append("# Only supports "); - sb.append(getExtensions(sourceMimetypes)); - sb.append(" to "); - sb.append(getExtensions(targetMimetypes)); - sb.append("\n"); - return sb.toString(); - } - - /** - * Returns the transformer's simple name and an indication if the transformer is not - * available for selection. - */ - String getCommentNameAndAvailable(boolean available) - { - String name = this instanceof ContentTransformer ? getSimpleName((ContentTransformer)this) : getName(); - StringBuilder sb = new StringBuilder(); - sb.append(getCommentName(name)); - if (!available) - { - sb.append("# "); - sb.append(TransformerConfig.CONTENT); - sb.append(getName()); - sb.append(TransformerConfig.AVAILABLE); - sb.append("=false\n"); - } - return sb.toString(); - } - - static String getCommentName(String name) - { - StringBuilder sb = new StringBuilder(); - sb.append("# "); - sb.append(name); - sb.append('\n'); - sb.append("# "); - for (int i = name.length(); i > 0; i--) - { - sb.append('-'); - } - sb.append('\n'); - return sb.toString(); - } - - /** - * Helper method for {@link #getComments(boolean)} to - * create a line that indicates which source and target mimetypes - * it supports. - * @param sourceMimetype String - * @param targetMimetype String - * @param available TODO - * @return a String of the form "# only supports xxx to aaa\n". - */ - protected String onlySupports(String sourceMimetype, String targetMimetype, boolean available) - { - return getCommentsOnlySupports( - Arrays.asList(new String[] {sourceMimetype}), - Arrays.asList(new String[] {targetMimetype}), available); - } - - /** - * Returns a comma separated String of mimetype file extensions. - */ - private String getExtensions(List origMimetypes) - { - // Only use the mimetypes we have registered - List mimetypes = new ArrayList(origMimetypes); - mimetypes.retainAll(getMimetypeService().getMimetypes()); - - StringBuilder sb = new StringBuilder(); - int j = mimetypes.size(); - int i=1; - for (String mimetype: mimetypes) - { - sb.append(getMimetypeService().getExtension(mimetype)); - if (i < j) - { - sb.append(++i < j ? ", " : " or "); - } - } - return sb.toString(); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((beanName == null) ? 0 : beanName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ContentTransformerHelper other = (ContentTransformerHelper) obj; - if (beanName == null) - { - if (other.beanName != null) - return false; - } - else if (!beanName.equals(other.beanName)) - return false; - return true; - } - - private class DeprecatedSetter - { - private final String sourceMimetype; - private final String targetMimetype; - private final String suffixAndValue; - - DeprecatedSetter(String sourceMimetype, String targetMimetype, String suffixAndValue) - { - this.sourceMimetype = sourceMimetype; - this.targetMimetype = targetMimetype; - this.suffixAndValue = suffixAndValue; - } - - public String getPropertyNameAndValue(String beanName) - { - return TransformerConfig.CONTENT+beanName+ - (sourceMimetype != null - ? TransformerConfig.EXTENSIONS+getExtensionOrAny(sourceMimetype)+'.'+getExtensionOrAny(targetMimetype) - : ".")+ - suffixAndValue; - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerRegistry.java b/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerRegistry.java deleted file mode 100644 index aa8e3036a8..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerRegistry.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Holds and provides the most appropriate content transformer for - * a particular source and target mimetype transformation request. - *

- * The transformers themselves are used to determine the applicability - * of a particular transformation. - *

- * The actual selection of a transformer is done by the injected - * {@link TransformerSelector}. - * - * @see org.alfresco.repo.content.transform.ContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public class ContentTransformerRegistry -{ - private static final Log logger = LogFactory.getLog(ContentTransformerRegistry.class); - - private final List transformers; - private final List allTransformers; - - private final TransformerSelector transformerSelector; - private boolean enabled = true; - private boolean firstTime = true; - private TransformerDebug transformerDebug; - - /** - * @param transformerSelector Transformer selector - */ - public ContentTransformerRegistry(TransformerSelector transformerSelector) - { - this.transformerSelector = transformerSelector; - this.transformers = new ArrayList(70); - this.allTransformers = new ArrayList(70); - } - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - firstTime = true; - } - - public void setTransformerDebug(TransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - /** - * Registers an individual transformer that can be queried to check for applicability. - * - * @param transformer a content transformer - */ - public synchronized void addTransformer(ContentTransformer transformer) - { - transformers.add(transformer); - allTransformers.add(transformer); - // done - if (logger.isDebugEnabled()) - { - logger.debug("Registered general transformer: \n" + - " transformer: " + transformer.getName() + " (" + transformer + ")"); - } - } - - /** - * Records a transformer that can NOT be queried for applicability, but may be - * included as a component of complex transformers. - * @param transformer a content transformer - */ - public synchronized void addComponentTransformer(ContentTransformer transformer) - { - allTransformers.add(transformer); - } - - /** - * Removes a dynamically created transformer. - * @param transformer to be removed. - */ - public synchronized void removeTransformer(ContentTransformer transformer) - { - transformers.remove(transformer); - allTransformers.remove(transformer); - } - - /** - * @return a list of transformers that may be queried to check for applicability. - */ - public synchronized List getTransformers() - { - return Collections.unmodifiableList(transformers); - } - - /** - * @return a list of all transformers, including those that only exist as a - * component of another transformer. - */ - public synchronized List getAllTransformers() - { - return Collections.unmodifiableList(allTransformers); - } - - /** - * Returns a transformer identified by name. - * @throws IllegalArgumentException if transformerName is not found. - */ - public synchronized ContentTransformer getTransformer(String transformerName) - { - if (transformerName != null) - { - for (ContentTransformer transformer: allTransformers) - { - if (transformerName.equals(transformer.getName())) - { - return transformer; - } - } - throw new IllegalArgumentException("Unknown transformer: "+ - (transformerName.startsWith(TransformerConfig.TRANSFORMER) - ? transformerName.substring(TransformerConfig.TRANSFORMER.length()) - : transformerName)); - } - return null; - } - - /** - * @deprecated use overloaded version with sourceSize parameter. - */ - public ContentTransformer getTransformer(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return getTransformer(sourceMimetype, -1, targetMimetype, options); - } - - /** - * Gets the best transformer possible. This is a combination of the most reliable - * and the most performant transformer. - */ - public ContentTransformer getTransformer(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - // Get the sorted list of transformers - List transformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options); - - // select the most performant transformer - ContentTransformer bestTransformer = null; - if(transformers.size() > 0) - { - bestTransformer = transformers.get(0); - } - // done - return bestTransformer; - } - - /** - * @since 3.5 - */ - public List getActiveTransformers(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - if (firstTime) - { - firstTime = false; - transformerDebug.debug("Legacy transforms are " + (enabled ? "enabled" : "disabled")); - } - - // Get the list of transformers - List transformers; - if (enabled) - { - transformers = transformerSelector.selectTransformers(sourceMimetype, sourceSize, targetMimetype, options); - - } - else - { - transformers = Collections.EMPTY_LIST; - } - if (logger.isDebugEnabled()) - { - logger.debug("Searched for transformer: \n" + - " source mimetype: " + sourceMimetype + "\n" + - " target mimetype: " + targetMimetype + "\n" + - " transformers: " + transformers); - } - return transformers; - } - - /** - * Recursive method to build up a list of content transformers - */ - @SuppressWarnings("unused") - private void buildTransformer(List transformers, - double reliability, - List touchedMimetypes, - String currentMimetype, - String targetMimetype) - { - throw new UnsupportedOperationException(); - } - - /** - * A key for a combination of a source and target mimetype - * - * Deprecated since 3.0 - */ - @Deprecated - public static class TransformationKey - { - private final String sourceMimetype; - private final String targetMimetype; - private final String key; - - public TransformationKey(String sourceMimetype, String targetMimetype) - { - this.key = (sourceMimetype + "_" + targetMimetype); - this.sourceMimetype = sourceMimetype; - this.targetMimetype = targetMimetype; - } - - public String getSourceMimetype() - { - return sourceMimetype; - } - public String getTargetMimetype() - { - return targetMimetype; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - else if (this == obj) - { - return true; - } - else if (!(obj instanceof TransformationKey)) - { - return false; - } - TransformationKey that = (TransformationKey) obj; - return this.key.equals(that.key); - } - @Override - public int hashCode() - { - return key.hashCode(); - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerWorker.java deleted file mode 100644 index fe4c50e743..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ContentTransformerWorker.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * An interface that allows separation between the content transformer registry and the various third party subsystems - * performing the transformation. - * - * @author dward - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -// TODO Modify ContentTransformerWorker to understand transformer limits. At the moment no workers use them -@Deprecated -@AlfrescoPublicApi -public interface ContentTransformerWorker -{ - /** - * Checks if this worker is available. - * - * @return true if it is available - */ - public boolean isAvailable(); - - /** - * Gets a string returning product and version information. - * - * @return the version string - */ - public String getVersionString(); - - /** - * Unlike {@link ContentTransformer#isTransformable(String, String, TransformationOptions)} - * should not include the transformer name, as that is added by the ContentTransformer in - * the parent context. - */ - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * @see ContentTransformer#getComments(boolean) - */ - public String getComments(boolean available); - - /** - * @see ContentTransformer#transform(ContentReader, ContentWriter, TransformationOptions) - */ - public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception; - - /** - * @return true if ther worker is using a remote server. - */ - public default boolean remoteTransformerClientConfigured() - { - return false; - } - - public default void setRemoteTransformerClient(RemoteTransformerClient remoteTransformerClient) - { - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/DoubleMap.java b/repository/src/main/java/org/alfresco/repo/content/transform/DoubleMap.java deleted file mode 100644 index 397d38bdbf..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/DoubleMap.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Provides simple get and put access to a Map like object with a double key that allows - * either or both keys to be a wild card that matches any value. May not contain null - * keys or values.

- * - * Originally created for mapping source and target mimetypes to transformer configuration data.

- * - * For example: - *

- *       DoubleMap foodLikes = new DoubleMap("*", "*");
- *       
- *       foodLikes.put("cat",   "mouse", "likes");
- *       
- *       foodLikes.get("cat", "mouse"); // returns "likes"
- *       foodLikes.get("cat", "meat");  // returns null
- *       
- *       foodLikes.put("dog",   "meat",  "likes");
- *       foodLikes.put("dog",   "stick", "unsure");
- *       foodLikes.put("child", "olive", "dislikes");
- *       foodLikes.put("bird",  "*",     "worms only");
- *       foodLikes.put("*",     "meat",  "unknown");
- *       foodLikes.put("*",     "*",     "no idea at all");
- *       
- *       foodLikes.get("cat", "mouse"); // returns "likes"
- *       foodLikes.get("cat", "meat");  // returns "unknown"
- *       foodLikes.get("cat", "tea");   // returns "unknown"
- *       foodLikes.get("*",   "mouse"); // returns "no idea at all"
- *       foodLikes.get("dog", "*");     // returns "no idea at all"
- *       foodLikes.get("bird","*");     // returns "worms only"
- *       foodLikes.get("bird","tea");   // returns "worms only"
- * 
- * - * @author Alan Davis - * - */ -@Deprecated -public class DoubleMap -{ - private final Map> mapMap = new ConcurrentHashMap>(); - private final K1 anyKey1; - private final K2 anyKey2; - - public DoubleMap(K1 anyKey1, K2 anyKey2) - { - this.anyKey1 = anyKey1; - this.anyKey2 = anyKey2; - } - - /** - * Returns a value for the given keys. - */ - public V get(K1 key1, K2 key2) - { - V value = null; - - Map map = mapMap.get(key1); - boolean anySource = false; - if (map == null) - { - map = mapMap.get(anyKey1); - anySource = true; - } - if (map != null) - { - value = map.get(key2); - if (value == null) - { - value = map.get(anyKey2); - - // Handle the case were there is no match using an non wildcarded key1 and - // key2 but is a match if key1 is wildcarded. - if (value == null && !anySource) - { - map = mapMap.get(anyKey1); - if (map != null) - { - value = map.get(key2); - if (value == null) - { - value = map.get(anyKey2); - } - } - } - } - } - - return value; - } - - /** - * Returns a value for the given keys without using wildcards. - */ - public V getNoWildcards(K1 key1, K2 key2) - { - V value = null; - - Map map = mapMap.get(key1); - if (map != null) - { - value = map.get(key2); - } - - return value; - } - - /** - * Adds a value for the given keys. - */ - public void put(K1 key1, K2 key2, V t) - { - Map map = mapMap.get(key1); - if (map == null) - { - map = new ConcurrentHashMap(); - mapMap.put(key1, map); - } - - map.put(key2, t); - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - for (Entry> outerEntry: mapMap.entrySet()) - { - for (Entry innerEntry: outerEntry.getValue().entrySet()) - { - if (sb.length() > 0) - { - sb.append("\n"); - } - sb.append(outerEntry.getKey()). - append(", "). - append(innerEntry.getKey()). - append(" = "). - append(innerEntry.getValue()); - } - } - return sb.toString(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/EMLTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/EMLTransformer.java deleted file mode 100644 index 115ca646fc..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/EMLTransformer.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2020 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 . - * #L% - */ - -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.Part; -import javax.mail.Session; -import javax.mail.internet.MimeMessage; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.TARGET_ENCODING; - - -/** - * Uses javax.mail.MimeMessage to generate plain text versions of RFC822 email - * messages. Searches for all text content parts, and returns them. Any - * attachments are ignored. TIKA Note - could be replaced with the Tika email - * parser. Would require a recursing parser to be specified, but not the full - * Auto one (we don't want attachments), just one containing text and html - * related parsers. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class EMLTransformer extends AbstractRemoteContentTransformer -{ - private static final Log logger = LogFactory.getLog(EMLTransformer.class); - private static final String CHARSET = "charset"; - private static final String DEFAULT_ENCODING = "UTF-8"; - - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (!MimetypeMap.MIMETYPE_RFC822.equals(sourceMimetype) - || !MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(targetMimetype)) - { - // only support RFC822 -> TEXT - return false; - } - else - { - return true; - } - } - - @Override - public String getComments(boolean available) - { - return onlySupports(MimetypeMap.MIMETYPE_RFC822, MimetypeMap.MIMETYPE_TEXT_PLAIN, available); - } - - @Override - protected Log getLogger() - { - return logger; - } - - @Override - protected void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception - { - InputStream contentInputStream = null; - try{ - contentInputStream = reader.getContentInputStream(); - MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()), contentInputStream); - - final StringBuilder sb = new StringBuilder(); - Object content = mimeMessage.getContent(); - if (content instanceof Multipart) - { - processMultiPart((Multipart) content,sb); - } - else - { - sb.append(content.toString()); - } - writer.putContent(sb.toString()); - } - finally - { - if (contentInputStream != null) - { - try - { - contentInputStream.close(); - } - catch ( IOException e) - { - //stop exception propagation - } - } - } - } - - /** - * Find "text" parts of message recursively and appends it to sb StringBuilder - * - * @param multipart Multipart to process - * @param sb StringBuilder - * @throws MessagingException - * @throws IOException - */ - private void processMultiPart(Multipart multipart, StringBuilder sb) throws MessagingException, IOException - { - boolean isAlternativeMultipart = multipart.getContentType().contains(MimetypeMap.MIMETYPE_MULTIPART_ALTERNATIVE); - if (isAlternativeMultipart) - { - processAlternativeMultipart(multipart, sb); - } - else - { - for (int i = 0, n = multipart.getCount(); i < n; i++) - { - Part part = multipart.getBodyPart(i); - if (part.getContent() instanceof Multipart) - { - processMultiPart((Multipart) part.getContent(), sb); - } - else - { - processPart(part, sb); - } - } - } - } - - - /** - * Finds the suitable part from an multipart/alternative and appends it's text content to StringBuilder sb - * - * @param multipart - * @param sb - * @throws IOException - * @throws MessagingException - */ - private void processAlternativeMultipart(Multipart multipart, StringBuilder sb) throws IOException, MessagingException - { - Part partToUse = null; - for (int i = 0, n = multipart.getCount(); i < n; i++) - { - Part part = multipart.getBodyPart(i); - if (part.getContentType().contains(MimetypeMap.MIMETYPE_TEXT_PLAIN)) - { - partToUse = part; - break; - } - else if (part.getContentType().contains(MimetypeMap.MIMETYPE_HTML)) - { - partToUse = part; - } - else if (part.getContentType().contains(MimetypeMap.MIMETYPE_MULTIPART_ALTERNATIVE)) - { - if (part.getContent() instanceof Multipart) - { - processAlternativeMultipart((Multipart) part.getContent(), sb); - } - } - } - if (partToUse != null) - { - processPart(partToUse, sb); - } - } - - /** - * Finds text on a given mail part. Accepted parts types are text/html and text/plain. - * Attachments are ignored - * - * @param part - * @param sb - * @throws IOException - * @throws MessagingException - */ - private void processPart(Part part, StringBuilder sb) throws IOException, MessagingException - { - boolean isAttachment = Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition()); - if (isAttachment) - { - return; - } - if (part.getContentType().contains(MimetypeMap.MIMETYPE_TEXT_PLAIN)) - { - sb.append(part.getContent().toString()); - } - else if (part.getContentType().contains(MimetypeMap.MIMETYPE_HTML)) - { - String mailPartContent = part.getContent().toString(); - - //create a temporary html file with same mail part content and encoding - File tempHtmlFile = TempFileProvider.createTempFile("EMLTransformer_", ".html"); - ContentWriter contentWriter = new FileContentWriter(tempHtmlFile); - contentWriter.setEncoding(getMailPartContentEncoding(part)); - contentWriter.setMimetype(MimetypeMap.MIMETYPE_HTML); - contentWriter.putContent(mailPartContent); - - //transform html file's content to plain text - EncodingAwareStringBean extractor = new EncodingAwareStringBean(); - extractor.setCollapse(false); - extractor.setLinks(false); - extractor.setReplaceNonBreakingSpaces(false); - extractor.setURL(tempHtmlFile, contentWriter.getEncoding()); - sb.append(extractor.getStrings()); - - tempHtmlFile.delete(); - } - } - - private String getMailPartContentEncoding(Part part) throws MessagingException - { - String encoding = DEFAULT_ENCODING; - String contentType = part.getContentType(); - int startIndex = contentType.indexOf(CHARSET); - if (startIndex > 0) - { - encoding = contentType.substring(startIndex + CHARSET.length() + 1).replaceAll("\"", ""); - } - return encoding; - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - long timeoutMs = options.getTimeoutMs(); - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "rfc822", - "sourceMimetype", sourceMimetype, - "targetMimetype", targetMimetype, - "targetExtension", targetExtension); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/EncodingAwareStringBean.java b/repository/src/main/java/org/alfresco/repo/content/transform/EncodingAwareStringBean.java deleted file mode 100644 index a203d71ec3..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/EncodingAwareStringBean.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.net.URLConnection; - -import org.htmlparser.Parser; -import org.htmlparser.beans.StringBean; -import org.htmlparser.util.ParserException; - -/** - * A version of {@link StringBean} which allows control of the - * encoding in the underlying HTML Parser. - * Unfortunately, StringBean doesn't allow easy over-riding of - * this, so we have to duplicate some code to control this. - * This allows us to correctly handle HTML files where the encoding - * is specified against the content property (rather than in the - * HTML Head Meta), see ALF-10466 for details. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -class EncodingAwareStringBean extends StringBean -{ - private static final long serialVersionUID = -9033414360428669553L; - - /** - * Sets the File to extract strings from, and the encoding - * it's in (if known to Alfresco) - * - * @param file The File that text should be fetched from. - * @param encoding The encoding of the input - */ - public void setURL(File file, String encoding) - { - String previousURL = getURL(); - String newURL = file.getAbsolutePath(); - - if ( (previousURL == null) || (!newURL.equals(previousURL)) ) - { - try - { - URLConnection conn = getConnection(); - - if (null == mParser) - { - mParser = new Parser(newURL); - } - else - { - mParser.setURL(newURL); - } - - if (encoding != null) - { - mParser.setEncoding(encoding); - } - - mPropertySupport.firePropertyChange(PROP_URL_PROPERTY, previousURL, getURL()); - mPropertySupport.firePropertyChange(PROP_CONNECTION_PROPERTY, conn, mParser.getConnection()); - setStrings(); - } - catch (ParserException pe) - { - updateStrings(pe.toString()); - } - } - } - - public String getEncoding(){ - return mParser.getEncoding(); - } -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ExplictTransformationDetails.java b/repository/src/main/java/org/alfresco/repo/content/transform/ExplictTransformationDetails.java deleted file mode 100644 index dcad7d7a88..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ExplictTransformationDetails.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -/** - * Specifies transformations that are considered to be 'exceptional' so - * should be used in preference to other transformers that can perform - * the same transformation. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ExplictTransformationDetails extends SupportedTransformation -{ - public ExplictTransformationDetails() - { - super(); - } - - public ExplictTransformationDetails(String sourceMimetype, String targetMimetype) - { - super(sourceMimetype, targetMimetype); - } -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/FailoverContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/FailoverContentTransformer.java deleted file mode 100644 index 1b2e96906c..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/FailoverContentTransformer.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.util.List; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -/** - * This class is a transformer which contains a fixed sequence of delegate transformers. - * Requests to transform a document will be passed to the first transformer in the sequence. - * If that transformer successfully transforms the document then the process is complete. However - * should it fail, the transformation will be passed on to the next transformer in the sequence and - * so on. - *

Transformers are considered to have failed of they throw an exception. - * - * @author Neil McErlean - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public class FailoverContentTransformer extends AbstractContentTransformer2 implements InitializingBean -{ - private static Log logger = LogFactory.getLog(FailoverContentTransformer.class); - private List transformers; - - public FailoverContentTransformer() - { - // Intentionally empty - } - - /** - * The list of transformers to use. There must be at least one, but for failover behaviour to work - * there should be at least two. - * - * @param transformers list of transformers. - */ - public void setTransformers(List transformers) - { - this.transformers = transformers; - } - - /** - * Ensures that required properties have been set - */ - public void afterPropertiesSet() throws Exception - { - if (transformers == null || transformers.size() == 0) - { - throw new AlfrescoRuntimeException("At least one inner transformer must be supplied: " + this); - } - if (getMimetypeService() == null) - { - throw new AlfrescoRuntimeException("'mimetypeService' is a required property"); - } - } - - /** - * Overrides super class method to avoid calling - * {@link #isTransformableMimetype(String, String, TransformationOptions)} - * twice on each transformer in the list, as - * {@link #isTransformableSize(String, long, String, TransformationOptions)} - * in this class must check the mimetype too. - */ - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - return - isSupportedTransformation(sourceMimetype, targetMimetype, options) && - // isTransformableSize must check the mimetype anyway - (((sourceSize >= 0) && isTransformableSize(sourceMimetype, sourceSize, targetMimetype, options)) || - ((sourceSize < 0) && isTransformableMimetype(sourceMimetype,targetMimetype, options))); - } - - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return isTransformableMimetypeAndSize(sourceMimetype, -1, targetMimetype, options); - } - - @Override - public boolean isTransformableSize(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - return (sourceSize < 0) || - super.isTransformableSize(sourceMimetype, sourceSize, targetMimetype, options) && - isTransformableMimetypeAndSize(sourceMimetype, sourceSize, targetMimetype, options); - } - - private boolean isTransformableMimetypeAndSize(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - boolean result = false; - for (ContentTransformer ct : this.transformers) - { - if (ct.isTransformableMimetype(sourceMimetype, targetMimetype, options)) - { - if (sourceSize < 0) - { - result = true; - break; - } - else - { - try - { - ((LegacyTransformerDebug)transformerDebug).pushIsTransformableSize(this); - if (ct.isTransformableSize(sourceMimetype, sourceSize, targetMimetype, options)) - { - result = true; - break; - } - } - finally - { - ((LegacyTransformerDebug)transformerDebug).popIsTransformableSize(); - } - } - } - } - return result; - } - - @SuppressWarnings("deprecation") - public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - boolean result = true; - for (ContentTransformer ct : this.transformers) - { - if (ct.isExplicitTransformation(sourceMimetype, targetMimetype, options) == false) - { - result = false; - } - } - return result; - } - - - /** - * @see org.alfresco.repo.content.transform.AbstractContentTransformer2#transformInternal(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions) - */ - @Override - public void transformInternal( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - final String outputMimetype = writer.getMimetype(); - final String outputFileExt = getMimetypeService().getExtension(outputMimetype); - - // We need to keep a reference to thrown exceptions as we're going to catch them and - // then move on to the next transformer. In the event that they all fail, we will throw - // the final exception. - Exception transformationException = null; - - for (int i = 0; i < transformers.size(); i++) - { - int oneBasedCount = i + 1; - ContentTransformer transf = transformers.get(i); - ContentWriter currentWriter = null; - File tempFile = null; - try - { - if (logger.isDebugEnabled()) - { - logger.debug("Transformation attempt " + oneBasedCount + " of " + transformers.size() + ": " + transf); - } - - if (!transf.isTransformable(reader.getMimetype(), reader.getSize(), outputMimetype, options)) - { - throw new UnsupportedTransformationException("Unsupported transformation: " +reader.getMimetype()+" to "+outputMimetype); - } - - // We can't know in advance which transformer in the sequence will work - if any. - // Therefore we can't write into the ContentWriter stream. - // So make a temporary file writer with the current transformer name. - tempFile = TempFileProvider.createTempFile( - "FailoverTransformer_intermediate_" + transf.getClass().getSimpleName() + "_", - "." + outputFileExt); - currentWriter = new FileContentWriter(tempFile); - currentWriter.setMimetype(outputMimetype); - currentWriter.setEncoding(writer.getEncoding()); - - // attempt to transform - transf.transform(reader, currentWriter, options); - - // TODO Could add a check for zero-length output and treat that as a failure - // final long writtenSize = currentWriter.getSize(); - } - catch (Exception are) - { - if (transformationException == null) - { - transformationException = are; - } - - if (logger.isDebugEnabled()) - { - logger.debug("Transformation " + oneBasedCount + " was unsuccessful."); - if (i != transformers.size() - 1) - { - // We don't log the last exception as we're going to throw it. - logger.debug("The below exception is provided for information purposes only.", are); - } - } - - // Set a new reader to refresh the input stream. - reader = reader.getReader(); - // and move to the next transformer - continue; - } - // No need to close input or output streams - - // At this point the current transformation was successful i.e. it did not throw an exception. - - // Now we must copy the content from the temporary file into the ContentWriter stream. - if (tempFile != null) - { - writer.putContent(tempFile); - } - - if (logger.isInfoEnabled()) - { - logger.info("Transformation was successful"); - } - return; - } - // At this point we have tried all transformers in the sequence without apparent success. - if (transformationException != null) - { - transformerDebug.debug(" No more transformations to failover to"); - if (logger.isDebugEnabled()) - { - logger.debug("All transformations were unsuccessful. Throwing first exception.", transformationException); - } - throw transformationException; - } - } - - /** - * Returns the transformer properties predefined (hard coded or implied) by this transformer. - */ - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(super.getComments(available)); - sb.append("# "); - sb.append(TransformerConfig.CONTENT); - sb.append(getName()); - sb.append(TransformerConfig.FAILOVER); - sb.append('='); - boolean first = true; - for (ContentTransformer transformer: transformers) - { - if (!first) - { - sb.append(TransformerConfig.PIPE); - } - first = false; - sb.append(transformer != null ? getSimpleName(transformer) : TransformerConfig.ANY); - } - sb.append('\n'); - return sb.toString(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/HtmlParserContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/HtmlParserContentTransformer.java deleted file mode 100644 index 0ed160af62..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/HtmlParserContentTransformer.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.SOURCE_ENCODING; - - -/** - * Content transformer which wraps the HTML Parser library for - * parsing HTML content. - * - *

- * Since HTML Parser was updated from v1.6 to v2.1, META tags - * defining an encoding for the content via http-equiv=Content-Type - * will ONLY be respected if the encoding of the content item - * itself is set to ISO-8859-1. - *

- * - *

- * Tika Note - could be converted to use the Tika HTML parser, - * but we'd potentially need a custom text handler to replicate - * the current settings around links and non-breaking spaces. - *

- * - * @see http://htmlparser.sourceforge.net - * @see org.htmlparser.beans.StringBean - * @see HTML Parser - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class HtmlParserContentTransformer extends AbstractRemoteContentTransformer -{ - @SuppressWarnings("unused") - private static final Log logger = LogFactory.getLog(HtmlParserContentTransformer.class); - - /** - * Only support HTML to TEXT. - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (!MimetypeMap.MIMETYPE_HTML.equals(sourceMimetype) || - !MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(targetMimetype)) - { - // only support HTML -> TEXT - return false; - } - else - { - return true; - } - } - - @Override - public String getComments(boolean available) - { - return onlySupports(MimetypeMap.MIMETYPE_HTML, MimetypeMap.MIMETYPE_TEXT_PLAIN, available); - } - - @Override - protected Log getLogger() - { - return logger; - } - - @Override - public void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception - { - - // We can only work from a file - File htmlFile = TempFileProvider.createTempFile("HtmlParserContentTransformer_", ".html"); - reader.getContent(htmlFile); - - // Fetch the encoding of the HTML, as set in the ContentReader - // This will default to 'UTF-8' if not specifically set - String encoding = reader.getEncoding(); - - // Create the extractor - EncodingAwareStringBean extractor = new EncodingAwareStringBean(); - extractor.setCollapse(false); - extractor.setLinks(false); - extractor.setReplaceNonBreakingSpaces(false); - extractor.setURL(htmlFile, encoding); - // get the text - String text = extractor.getStrings(); - // write it to the writer - writer.putContent(text); - - // Tidy up - htmlFile.delete(); - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, String sourceMimetype, - String targetMimetype, String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - String sourceEncoding = reader.getEncoding(); - long timeoutMs = options.getTimeoutMs(); - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "html", - "sourceMimetype", sourceMimetype, - "sourceExtension", sourceExtension, - "targetMimetype", targetMimetype, - SOURCE_ENCODING, sourceEncoding); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/JodContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/JodContentTransformer.java deleted file mode 100644 index cc4ed52e77..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/JodContentTransformer.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.JodConverter; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.artofsolving.jodconverter.OfficeDocumentConverter; -import org.artofsolving.jodconverter.document.DocumentFormat; -import org.springframework.beans.factory.InitializingBean; - -import java.io.File; - -/** - * Makes use of the {@link http://code.google.com/p/jodconverter/} library and an installed - * OpenOffice application to perform OpenOffice-driven conversions. - * - * @author Neil McErlean - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class JodContentTransformer extends OOoContentTransformerHelper implements ContentTransformerWorker, InitializingBean -{ - private static Log logger = LogFactory.getLog(JodContentTransformer.class); - - private boolean enabled = true; - - private JodConverter jodconverter; - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - public void setJodConverter(JodConverter jodc) - { - this.jodconverter = jodc; - } - - @Override - protected Log getLogger() - { - return logger; - } - - @Override - protected String getTempFilePrefix() - { - return "JodContentTransformer"; - } - - @Override - public boolean isAvailable() - { - if (remoteTransformerClientConfigured() && !remoteTransformerClient.isAvailable()) - { - afterPropertiesSet(); - } - - return remoteTransformerClientConfigured() - ? remoteTransformerClient.isAvailable() - : jodconverter.isAvailable(); - } - - @Override - public void afterPropertiesSet() - { - if (enabled) - { - super.afterPropertiesSet(); - if (remoteTransformerClientConfigured()) - { - Pair result = remoteTransformerClient.check(logger); - Boolean isAvailable = result.getFirst(); - if (isAvailable != null && isAvailable) - { - String versionString = result.getSecond().trim(); - logger.debug("Using legacy JodCoverter: " + versionString); - } - else - { - String message = "Legacy JodConverter is not available for transformations. " + result.getSecond(); - if (isAvailable == null) - { - logger.debug(message); - } - else - { - logger.error(message); - } - } - } - } - } - - @Override - protected void convert(File tempFromFile, DocumentFormat sourceFormat, File tempToFile, - DocumentFormat targetFormat) - { - OfficeDocumentConverter converter = new OfficeDocumentConverter(jodconverter.getOfficeManager()); - converter.convert(tempFromFile, tempToFile); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/LegacyTransformerDebug.java b/repository/src/main/java/org/alfresco/repo/content/transform/LegacyTransformerDebug.java deleted file mode 100644 index 7831333627..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/LegacyTransformerDebug.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.metadata.AsynchronousExtractor; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.transform.client.registry.SupportedTransform; -import org.alfresco.util.PropertyCheck; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Deque; -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.TreeSet; - -/** - * Debugs Legacy transformers selection and activity. Will be removed when Legacy transforms are removed. - * - * @author Alan Davis - */ -@Deprecated -public class LegacyTransformerDebug extends AdminUiTransformerDebug -{ - private ContentTransformerRegistry transformerRegistry; - private TransformerConfig transformerConfig; - - public void setTransformerRegistry(ContentTransformerRegistry transformerRegistry) - { - this.transformerRegistry = transformerRegistry; - } - - public void setTransformerConfig(TransformerConfig transformerConfig) - { - this.transformerConfig = transformerConfig; - } - - @Override - public void afterPropertiesSet() throws Exception - { - super.afterPropertiesSet(); - PropertyCheck.mandatory(this, "transformerRegistry", transformerRegistry); - PropertyCheck.mandatory(this, "transformerConfig", transformerConfig); - } - - @Deprecated - public void pushAvailable(String fromUrl, String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - String renditionName = options == null ? null : options.getUse(); - NodeRef sourceNodeRef = options == null ? null : options.getSourceNodeRef(); - pushAvailable(fromUrl, sourceMimetype, targetMimetype, renditionName, sourceNodeRef); - } - - /** - * Called prior to working out what transformers are available. - */ - @Deprecated - public void pushAvailable(String fromUrl, String sourceMimetype, String targetMimetype, - String renditionName, NodeRef sourceNodeRef) - { - if (isEnabled()) - { - push(null, fromUrl, sourceMimetype, targetMimetype, -1, - null, renditionName, sourceNodeRef, Call.AVAILABLE); - } - } - - /** - * Called when a transformer has been ignored because of a blacklist entry. - */ - @Deprecated - public void blacklistTransform(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - log("Blacklist "+getName(transformer)+" "+ getSourceAndTargetExt(sourceMimetype, targetMimetype)); - } - - @Deprecated - public void pushTransform(ContentTransformer transformer, String fromUrl, String sourceMimetype, - String targetMimetype, long sourceSize, TransformationOptions options) - { - String renditionName = options == null ? null : options.getUse(); - NodeRef sourceNodeRef = options == null ? null : options.getSourceNodeRef(); - pushTransform(transformer, fromUrl, sourceMimetype, targetMimetype, sourceSize, renditionName, sourceNodeRef); - } - - /** - * Called prior to performing a transform. - */ - @Deprecated - public void pushTransform(ContentTransformer transformer, String fromUrl, String sourceMimetype, - String targetMimetype, long sourceSize, String renditionName, NodeRef sourceNodeRef) - { - if (isEnabled()) - { - push(getName(transformer), fromUrl, sourceMimetype, targetMimetype, sourceSize, - null, renditionName, sourceNodeRef, Call.TRANSFORM); - } - } - - /** - * Called prior to calling a nested isTransformable. - */ - @Deprecated - public void pushIsTransformableSize(ContentTransformer transformer) - { - if (isEnabled()) - { - ThreadInfo.getIsTransformableStack().push(getName(transformer)); - } - } - - /** - * Called to identify a transformer that cannot be used during working out - * available transformers. - */ - @Deprecated - public void unavailableTransformer(ContentTransformer transformer, String sourceMimetype, String targetMimetype, long maxSourceSizeKBytes) - { - if (isEnabled()) - { - Deque ourStack = ThreadInfo.getStack(); - Frame frame = ourStack.peek(); - - if (frame != null) - { - Deque isTransformableStack = ThreadInfo.getIsTransformableStack(); - String name = (!isTransformableStack.isEmpty()) - ? isTransformableStack.getFirst() - : getName(transformer); - boolean debug = (maxSourceSizeKBytes != 0); - if (frame.unavailableTransformers == null) - { - frame.unavailableTransformers = new TreeSet(); - } - String priority = gePriority(transformer, sourceMimetype, targetMimetype); - frame.unavailableTransformers.add(new UnavailableTransformer(name, priority, maxSourceSizeKBytes, debug)); - } - } - } - - @Deprecated - public void availableTransformers(List transformers, long sourceSize, - TransformationOptions options, String calledFrom) - { - String renditionName = options == null ? null : options.getUse(); - NodeRef sourceNodeRef = options == null ? null : options.getSourceNodeRef(); - availableTransformers(transformers, sourceSize, renditionName, sourceNodeRef, calledFrom); - } - - /** - * Called once all available transformers have been identified. - */ - @Deprecated - public void availableTransformers(List transformers, long sourceSize, - String renditionName, NodeRef sourceNodeRef, String calledFrom) - { - if (isEnabled()) - { - Deque ourStack = ThreadInfo.getStack(); - Frame frame = ourStack.peek(); - boolean firstLevel = ourStack.size() == 1; - - // Override setDebugOutput(false) to allow debug when there are transformers but they are all unavailable - // Note once turned on we don't turn it off again. - if (transformers.size() == 0) - { - frame.setFailureReason(NO_TRANSFORMERS); - if (frame.unavailableTransformers != null && - frame.unavailableTransformers.size() != 0) - { - ThreadInfo.setDebugOutput(true); - } - } - frame.setSourceSize(sourceSize); - - // Log the basic info about this transformation - logBasicDetails(frame, sourceSize, null, renditionName, - calledFrom + ((transformers.size() == 0) ? " NO transformers" : ""), firstLevel); - - // Report available and unavailable transformers - char c = 'a'; - int longestNameLength = getLongestTransformerNameLength(transformers, frame); - for (ContentTransformer trans : transformers) - { - String name = getName(trans); - int padName = longestNameLength - name.length() + 1; - TransformationOptions options = new TransformationOptions(); - options.setUse(frame.renditionName); - options.setSourceNodeRef(frame.sourceNodeRef); - long maxSourceSizeKBytes = trans.getMaxSourceSizeKBytes(frame.sourceMimetype, frame.targetMimetype, options); - String size = maxSourceSizeKBytes > 0 ? "< "+fileSize(maxSourceSizeKBytes*1024) : ""; - int padSize = 10 - size.length(); - String priority = gePriority(trans, frame.sourceMimetype, frame.targetMimetype); - log((c == 'a' ? "**" : " ") + (c++) + ") " + priority + ' ' + name + spaces(padName) + - size + spaces(padSize) + ms(trans.getTransformationTime(frame.sourceMimetype, frame.targetMimetype))); - } - if (frame.unavailableTransformers != null) - { - for (UnavailableTransformer unavailable: frame.unavailableTransformers) - { - int pad = longestNameLength - unavailable.name.length(); - String reason = "> "+fileSize(unavailable.maxSourceSizeKBytes*1024); - if (unavailable.debug || logger.isTraceEnabled()) - { - log("--" + (c++) + ") " + unavailable.priority + ' ' + unavailable.name + spaces(pad+1) + reason, unavailable.debug); - } - } - } - } - } - - private String gePriority(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - String priority = - '[' + (isComponentTransformer(transformer) - ? "---" - : Integer.toString(transformerConfig.getPriority(transformer, sourceMimetype, targetMimetype))) + - ']'; - priority = spaces(5-priority.length())+priority; - return priority; - } - - @Deprecated - public void inactiveTransformer(ContentTransformer transformer) - { - log(getName(transformer)+' '+ms(transformer.getTransformationTime(null, null))+" INACTIVE"); - } - - @Deprecated - public void activeTransformer(int mimetypePairCount, ContentTransformer transformer, String sourceMimetype, - String targetMimetype, long maxSourceSizeKBytes, boolean firstMimetypePair) - { - if (firstMimetypePair) - { - log(getName(transformer)+' '+ms(transformer.getTransformationTime(sourceMimetype, targetMimetype))); - } - String i = Integer.toString(mimetypePairCount); - String priority = gePriority(transformer, sourceMimetype, targetMimetype); - String sourceExt = getMimetypeExt(sourceMimetype); - String targetExt = getMimetypeExt(targetMimetype); - targetExt = AsynchronousExtractor.getExtension(targetMimetype, sourceExt, targetExt); - log(spaces(5-i.length())+mimetypePairCount+") "+ sourceExt + targetExt + - priority + - ' '+fileSize((maxSourceSizeKBytes > 0) ? maxSourceSizeKBytes*1024 : maxSourceSizeKBytes)+ - (maxSourceSizeKBytes == 0 ? " disabled" : "")); - } - - @Deprecated - public void activeTransformer(String sourceMimetype, String targetMimetype, - int transformerCount, ContentTransformer transformer, long maxSourceSizeKBytes, - boolean firstTransformer) - { - String priority = gePriority(transformer, sourceMimetype, targetMimetype); - activeTransformer(sourceMimetype, targetMimetype, transformerCount, priority, getName(transformer), - maxSourceSizeKBytes, firstTransformer); - } - - private int getLongestTransformerNameLength(List transformers, - Frame frame) - { - int longestNameLength = 0; - for (ContentTransformer trans : transformers) - { - int length = getName(trans).length(); - if (longestNameLength < length) - longestNameLength = length; - } - if (frame != null && frame.unavailableTransformers != null) - { - for (UnavailableTransformer unavailable: frame.unavailableTransformers) - { - int length = unavailable.name.length(); - if (longestNameLength < length) - longestNameLength = length; - } - } - return longestNameLength; - } - - /** - * Called after working out what transformers are available and any - * resulting transform has been called. - */ - public void popAvailable() - { - if (isEnabled()) - { - pop(Call.AVAILABLE, false, false); - } - } - - - /** - * Called after returning from a nested isTransformable. - */ - public void popIsTransformableSize() - { - if (isEnabled()) - { - ThreadInfo.getIsTransformableStack().pop(); - } - } - - /** - * Returns a String and /or debug that provides a list of supported transformations for each - * transformer. - * @param transformerName restricts the list to one transformer. Unrestricted if null. - * @param toString indicates that a String value should be returned in addition to any debug. - * @param format42 indicates the old 4.1.4 format should be used which did not order the transformers - * and only included top level transformers. - * @param renditionName to which the transformation will be put (such as "Index", "Preview", null). - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ - @Deprecated - public String transformationsByTransformer(String transformerName, boolean toString, boolean format42, String renditionName) - { - // Do not generate this type of debug if already generating other debug to a StringBuilder - // (for example a test transform). - if (getStringBuilder() != null) - { - return null; - } - - Collection transformers = format42 || transformerName != null - ? sortTransformersByName(transformerName) - : transformerRegistry.getTransformers(); - Collection sourceMimetypes = format42 - ? getSourceMimetypes(null) - : mimetypeService.getMimetypes(); - Collection targetMimetypes = format42 - ? sourceMimetypes - : mimetypeService.getMimetypes(); - - TransformationOptions options = new TransformationOptions(); - options.setUse(renditionName); - StringBuilder sb = null; - try - { - if (toString) - { - sb = new StringBuilder(); - setStringBuilder(sb); - } - pushMisc(); - for (ContentTransformer transformer: transformers) - { - try - { - pushMisc(); - int mimetypePairCount = 0; - boolean first = true; - for (String sourceMimetype: sourceMimetypes) - { - for (String targetMimetype: targetMimetypes) - { - if (transformer.isTransformable(sourceMimetype, -1, targetMimetype, options)) - { - long maxSourceSizeKBytes = transformer.getMaxSourceSizeKBytes( - sourceMimetype, targetMimetype, options); - activeTransformer(++mimetypePairCount, transformer, - sourceMimetype, targetMimetype, maxSourceSizeKBytes, first); - first = false; - } - } - } - if (first) - { - inactiveTransformer(transformer); - } - } - finally - { - popMisc(); - } - } - } - finally - { - popMisc(); - setStringBuilder(null); - } - stripFinishedLine(sb); - return stripLeadingNumber(sb); - } - - /** - * Returns a String and /or debug that provides a list of supported transformations - * sorted by source and target mimetype extension. - * @param sourceExtension restricts the list to one source extension. Unrestricted if null. - * @param targetExtension restricts the list to one target extension. Unrestricted if null. - * @param toString indicates that a String value should be returned in addition to any debug. - * @param format42 indicates the new 4.2 rather than older 4.1.4 format should be used. - * The 4.1.4 format did not order the transformers or mimetypes and only included top - * level transformers. - * @param onlyNonDeterministic if true only report transformations where there is more than - * one transformer available with the same priority. - * @param renditionName to which the transformation will be put (such as "Index", "Preview", null). - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ - @Deprecated - @Override - public String transformationsByExtension(String sourceExtension, String targetExtension, boolean toString, - boolean format42, boolean onlyNonDeterministic, String renditionName) - { - // Do not generate this type of debug if already generating other debug to a StringBuilder - // (for example a test transform). - if (getStringBuilder() != null) - { - return null; - } - - Collection transformers = format42 && !onlyNonDeterministic - ? sortTransformersByName(null) - : transformerRegistry.getTransformers(); - Collection sourceMimetypes = format42 || sourceExtension != null - ? getSourceMimetypes(sourceExtension) - : mimetypeService.getMimetypes(); - Collection targetMimetypes = format42 || targetExtension != null - ? getTargetMimetypes(sourceExtension, targetExtension, sourceMimetypes) - : mimetypeService.getMimetypes(); - - TransformationOptions options = new TransformationOptions(); - options.setUse(renditionName); - StringBuilder sb = null; - try - { - if (toString) - { - sb = new StringBuilder(); - setStringBuilder(sb); - } - pushMisc(); - for (String sourceMimetype: sourceMimetypes) - { - for (String targetMimetype: targetMimetypes) - { - // Find available transformers - List availableTransformer = new ArrayList(); - for (ContentTransformer transformer: transformers) - { - if (transformer.isTransformable(sourceMimetype, -1, targetMimetype, options)) - { - availableTransformer.add(transformer); - } - } - - // Sort by priority - final String currSourceMimetype = sourceExtension; - final String currTargetMimetype = targetExtension; - Collections.sort(availableTransformer, new Comparator() - { - @Override - public int compare(ContentTransformer transformer1, ContentTransformer transformer2) - { - return transformerConfig.getPriority(transformer1, currSourceMimetype, currTargetMimetype) - - transformerConfig.getPriority(transformer2, currSourceMimetype, currTargetMimetype); - } - }); - - // Do we need to produce any output? - int size = availableTransformer.size(); - int priority = size >= 2 - ? transformerConfig.getPriority(availableTransformer.get(0), sourceMimetype, targetMimetype) - : -1; - if (!onlyNonDeterministic || (size >= 2 && priority == - transformerConfig.getPriority(availableTransformer.get(1), sourceMimetype, targetMimetype))) - { - // Log the transformers - boolean supportedByTransformService = remoteTransformServiceRegistry == null || - remoteTransformServiceRegistry instanceof DummyTransformServiceRegistry - ? false - : remoteTransformServiceRegistry.isSupported(sourceMimetype, - -1, targetMimetype, Collections.emptyMap(), null); - List localTransformers = localTransformServiceRegistryImpl == null - ? Collections.emptyList() - : localTransformServiceRegistryImpl.findTransformers(sourceMimetype, - targetMimetype, Collections.emptyMap(), null); - if (!localTransformers.isEmpty() || supportedByTransformService || size >= 1) - { - try - { - pushMisc(); - int transformerCount = 0; - if (supportedByTransformService) - { - long maxSourceSizeKBytes = remoteTransformServiceRegistry.findMaxSize(sourceMimetype, - targetMimetype, Collections.emptyMap(), null); - activeTransformer(sourceMimetype, targetMimetype, transformerCount, " ", - TRANSFORM_SERVICE_NAME, maxSourceSizeKBytes, transformerCount++ == 0); - } - for (SupportedTransform localTransformer : localTransformers) - { - long maxSourceSizeKBytes = localTransformer.getMaxSourceSizeBytes(); - String transformName = "Local:" + localTransformer.getName(); - String transformerPriority = "[" + localTransformer.getPriority() + ']'; - transformerPriority = spaces(5-transformerPriority.length())+transformerPriority; - activeTransformer(sourceMimetype, targetMimetype, transformerCount, transformerPriority, - transformName, maxSourceSizeKBytes, transformerCount++ == 0); - } - for (ContentTransformer transformer: availableTransformer) - { - if (!onlyNonDeterministic || transformerCount < 2 || - priority == transformerConfig.getPriority(transformer, sourceMimetype, targetMimetype)) - { - long maxSourceSizeKBytes = transformer.getMaxSourceSizeKBytes( - sourceMimetype, targetMimetype, options); - activeTransformer(sourceMimetype, targetMimetype, transformerCount, - transformer, maxSourceSizeKBytes, transformerCount++ == 0); - } - } - } - finally - { - popMisc(); - } - } - } - } - } - } - finally - { - popMisc(); - setStringBuilder(null); - } - stripFinishedLine(sb); - return stripLeadingNumber(sb); - } - - private String getName(ContentTransformer transformer) - { - String name = - transformer instanceof ContentTransformerHelper - ? ContentTransformerHelper.getSimpleName(transformer) - : transformer.getClass().getSimpleName(); - - String type = - ((transformer instanceof AbstractRemoteContentTransformer && - ((AbstractRemoteContentTransformer)transformer).remoteTransformerClientConfigured()) || - (transformer instanceof ProxyContentTransformer && - ((ProxyContentTransformer)transformer).remoteTransformerClientConfigured()) - ? "Remote" : "")+ - (transformer instanceof ComplexContentTransformer - ? "Complex" - : transformer instanceof FailoverContentTransformer - ? "Failover" - : transformer instanceof ProxyContentTransformer - ? (((ProxyContentTransformer)transformer).getWorker() instanceof RuntimeExecutableContentTransformerWorker) - ? "Runtime" - : "Proxy" - : ""); - - boolean componentTransformer = isComponentTransformer(transformer); - - StringBuilder sb = new StringBuilder("Legacy:").append(name); - if (componentTransformer || type.length() > 0) - { - sb.append("<<"); - sb.append(type); - if (componentTransformer) - { - sb.append("Component"); - } - sb.append(">>"); - } - - return sb.toString(); - } - - - private boolean isComponentTransformer(ContentTransformer transformer) - { - return !transformerRegistry.getTransformers().contains(transformer); - } - - @Deprecated - public String getFileName(TransformationOptions options, boolean firstLevel, long sourceSize) - { - NodeRef sourceNodeRef = options == null ? null : options.getSourceNodeRef(); - return getFileName(sourceNodeRef, firstLevel, sourceSize); - } - - /** - * Returns a sorted list of all transformers sorted by name. - * @param transformerName to restrict the collection to one entry - * @return a new Collection of sorted transformers - * @throws IllegalArgumentException if transformerName is not found. - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ - @Deprecated - public Collection sortTransformersByName(String transformerName) - { - Collection transformers = (transformerName != null) - ? Collections.singleton(transformerRegistry.getTransformer(transformerName)) - : transformerRegistry.getAllTransformers(); - - SortedMap map = new TreeMap(); - for (ContentTransformer transformer: transformers) - { - String name = transformer.getName(); - map.put(name, transformer); - } - Collection sorted = map.values(); - return sorted; - } - - /** - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ - @Deprecated - public String testTransform(final String transformerName, String sourceExtension, - String targetExtension, String renditionName) - { - logger.error("The testTransform operation for a specific transformer is no longer supported. " + - "Request redirected to the version of this method without a transformerName."); - return testTransform(sourceExtension, targetExtension, renditionName); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformImpl.java b/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformImpl.java index ef0ab8b3d5..c96b73fafe 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformImpl.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformImpl.java @@ -180,7 +180,7 @@ public class LocalTransformImpl extends AbstractLocalTransform } // These 3 values are commonly needed and are always supplied in the TransformRequest (message to the T-Router). - // The targetExtension is also supplied in the TransformRequest, but in the case of local and legacy transformers + // The targetExtension is also supplied in the TransformRequest, but in the case of local transforms // is added by the remoteTransformerClient.request call for historic reasons, so does not need to be added here. args[i++] = "sourceMimetype"; args[i++] = sourceMimetype; diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformServiceRegistry.java b/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformServiceRegistry.java index d74c1a103e..a493328d5c 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformServiceRegistry.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/LocalTransformServiceRegistry.java @@ -484,9 +484,7 @@ public class LocalTransformServiceRegistry extends TransformServiceRegistryImpl transformerDebug.debug("Local transforms "+getData()+" are " + (enabled ? "enabled" : "disabled")); } - return enabled - ? super.findMaxSize(sourceMimetype, targetMimetype, options, renditionName) - : 0; + return super.findMaxSize(sourceMimetype, targetMimetype, options, renditionName); } public LocalTransform getLocalTransform(String sourceMimetype, long sourceSizeInBytes, String targetMimetype, Map actualOptions, String renditionName) @@ -495,9 +493,14 @@ public class LocalTransformServiceRegistry extends TransformServiceRegistryImpl { return null; } + LocalTransform localTransform = null; String name = findTransformerName(sourceMimetype, sourceSizeInBytes, targetMimetype, actualOptions, renditionName); - LocalData data = getData(); - Map localTransforms = data.localTransforms; - return localTransforms.get(name); + if (name != null) + { + LocalData data = getData(); + Map localTransforms = data.localTransforms; + localTransform = localTransforms.get(name); + } + return localTransform; } } diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/LogEntries.java b/repository/src/main/java/org/alfresco/repo/content/transform/LogEntries.java index cefed5f35d..edddea498c 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/LogEntries.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/LogEntries.java @@ -29,10 +29,7 @@ import org.apache.commons.logging.Log; /** * Interface that gives access to Log entries - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated interface LogEntries extends Log { /** diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/MailContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/MailContentTransformer.java deleted file mode 100644 index f8f084aeef..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/MailContentTransformer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.microsoft.OfficeParser; - -/** - * Uses Apache Tika and - * Apache POI to transform - * Outlook email msg files. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class MailContentTransformer extends TikaPoweredContentTransformer -{ - public MailContentTransformer() { - super(new String[] { - MimetypeMap.MIMETYPE_OUTLOOK_MSG - }); - setTransformerName("OutlookMsg"); - } - - @Override - protected Parser getParser() { - return new OfficeParser(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/MediaWikiContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/MediaWikiContentTransformer.java deleted file mode 100644 index 4b0d4b4445..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/MediaWikiContentTransformer.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import info.bliki.wiki.filter.Encoder; -import info.bliki.wiki.model.WikiModel; -import info.bliki.wiki.tags.ATag; - -import java.util.Arrays; -import java.util.List; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.htmlcleaner.ContentToken; - -/** - * MediaWiki content transformer. Converts mediawiki markup into HTML. - * - *
@see Java_Wikipedia_API - * - * Tika Note - Tika doesn't currently support mediawiki markup, so this - * transformer cannot currently be converted to use Tika. - * - * @author Roy Wetherall - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class MediaWikiContentTransformer extends AbstractContentTransformer2 -{ - /** The file folder service */ - private FileFolderService fileFolderService; - - /** The node service */ - private NodeService nodeService; - - /** - * Sets the file folder service - * - * @param fileFolderService the file folder service - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * Sets the node service - * - * @param nodeService the node service - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Only transform from mediawiki to html - * - * @see org.alfresco.repo.content.transform.ContentTransformer#isTransformable(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions) - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (!MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI.equals(sourceMimetype) || - !MimetypeMap.MIMETYPE_HTML.equals(targetMimetype)) - { - // only support MEDIAWIKI -> HTML - return false; - } - else - { - return true; - } - } - - @Override - public String getComments(boolean available) - { - return onlySupports(MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI, MimetypeMap.MIMETYPE_HTML, available); - } - - /** - * @see org.alfresco.repo.content.transform.AbstractContentTransformer2#transformInternal(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions) - */ - public void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception - { - String imageURL = "{$image}"; - String pageURL = "${title}"; - - // If we have context about the destination of the transformation then use it - if (options.getTargetNodeRef() != null) - { - NodeRef parentNodeRef = this.nodeService.getPrimaryParent(options.getTargetNodeRef()).getParentRef(); - - StringBuffer folderPath = new StringBuffer(256); - List fileInfos = this.fileFolderService.getNamePath(null, parentNodeRef); - for (FileInfo fileInfo : fileInfos) - { - folderPath.append(fileInfo.getName()).append("/"); - } - - pageURL = "/alfresco/d/d?path=" + folderPath + "${title}.html"; - imageURL = "/alfresco/d/d?path=" + folderPath + "Images/${image}"; - } - - // Create the wikiModel and set the title and image link URL's - AlfrescoWikiModel wikiModel = new AlfrescoWikiModel(imageURL, pageURL); - - // Render the wiki content as HTML - writer.putContent(wikiModel.render(reader.getContentString())); - } - - /** - * Alfresco custom Wiki model used to generate links and image references - * - * @author Roy Wetherall - */ - private class AlfrescoWikiModel extends WikiModel - { - public AlfrescoWikiModel(String imageBaseURL, String linkBaseURL) - { - super(imageBaseURL, linkBaseURL); - } - - @Override - public void appendInternalLink(String link, String hashSection, String linkText) - { - link = link.replaceAll(":", " - "); - String encodedtopic = Encoder.encodeTitleUrl(link); - encodedtopic = encodedtopic.replaceAll("_", " "); - - String hrefLink = fExternalWikiBaseURL.replace("${title}", encodedtopic); - - ATag aTagNode = new ATag(); - append(aTagNode); - aTagNode.addAttribute("id", "w"); - String href = hrefLink; - if (hashSection != null) { - href = href + '#' + hashSection; - } - aTagNode.addAttribute("href", href); - aTagNode.addObjectAttribute("wikilink", hrefLink); - - ContentToken text = new ContentToken(linkText); - aTagNode.addChild(text); - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/OOXMLThumbnailContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/OOXMLThumbnailContentTransformer.java deleted file mode 100644 index 0410b72a33..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/OOXMLThumbnailContentTransformer.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.poi.openxml4j.opc.OPCPackage; -import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.openxml4j.opc.PackageRelationship; -import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; -import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; - -/** - * Extracts out Thumbnail JPEGs from OOXML files for thumbnailing & previewing. - * This transformer will only work for OOXML files where thumbnailing was enabled, - * which isn't on by default on Windows, but is more common on Mac. - * - * @author Nick Burch - * @since 4.0.1 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class OOXMLThumbnailContentTransformer extends AbstractContentTransformer2 -{ - public static final String NO_THUMBNAIL_PRESENT_IN_FILE = "No thumbnail present in file, unable to generate "; - - private static final Log log = LogFactory.getLog(OOXMLThumbnailContentTransformer.class); - - private static final List OOXML_MIMETYPES = Arrays.asList(new String[]{ - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING_MACRO, - MimetypeMap.MIMETYPE_OPENXML_WORD_TEMPLATE, - MimetypeMap.MIMETYPE_OPENXML_WORD_TEMPLATE_MACRO, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_MACRO, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW_MACRO, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_TEMPLATE, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_TEMPLATE_MACRO, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_ADDIN, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_SLIDE, - MimetypeMap.MIMETYPE_OPENXML_PRESENTATION_SLIDE_MACRO, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET_MACRO, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE_MACRO, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET_ADDIN_MACRO, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET_BINARY_MACRO}); - - private static final List TARGET_MIMETYPES = Arrays.asList(new String[]{MimetypeMap.MIMETYPE_IMAGE_JPEG}); - - @Override - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - // only support [OOXML] -> JPEG - return TARGET_MIMETYPES.contains(targetMimetype) && OOXML_MIMETYPES.contains(sourceMimetype); - } - - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(super.getComments(available)); - sb.append("# Only supports extraction of embedded jpegs from OOXML formats\n"); - return sb.toString(); - } - - @Override - protected void transformInternal(ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - final String sourceMimetype = reader.getMimetype(); - final String sourceExtension = getMimetypeService().getExtension(sourceMimetype); - final String targetMimetype = writer.getMimetype(); - - - if (log.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Transforming from ").append(sourceMimetype) - .append(" to ").append(targetMimetype); - log.debug(msg.toString()); - } - - - OPCPackage pkg = null; - try - { - File ooxmlTempFile = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_ooxml", sourceExtension); - reader.getContent(ooxmlTempFile); - - // Load the file - pkg = OPCPackage.open(ooxmlTempFile.getPath()); - - // Does it have a thumbnail? - PackageRelationshipCollection rels = - pkg.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL); - if (rels.size() > 0) - { - // Get the thumbnail part - PackageRelationship tRel = rels.getRelationship(0); - PackagePart tPart = pkg.getPart(tRel); - - // Write it to the target - InputStream tStream = tPart.getInputStream(); - writer.putContent( tStream ); - tStream.close(); - } - else - { - log.debug("No thumbnail present in " + reader.toString()); - throw new UnimportantTransformException(NO_THUMBNAIL_PRESENT_IN_FILE + targetMimetype); - } - } - catch (IOException e) - { - throw new AlfrescoRuntimeException("Unable to transform " + sourceExtension + " file.", e); - } - finally - { - if (pkg != null) - { - pkg.close(); - } - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/OOoContentTransformerHelper.java b/repository/src/main/java/org/alfresco/repo/content/transform/OOoContentTransformerHelper.java deleted file mode 100644 index d653e9c3e7..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/OOoContentTransformerHelper.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import com.sun.star.task.ErrorCodeIOException; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.pdmodel.PDPageContentStream; -import org.artofsolving.jodconverter.document.*; -import org.artofsolving.jodconverter.office.OfficeException; -import org.json.JSONException; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.util.FileCopyUtils; - -import java.io.*; - -/** - * A class providing basic OOo-related functionality shared by both - * {@link ContentTransformer}s and {@link ContentTransformerWorker}s. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public abstract class OOoContentTransformerHelper extends ContentTransformerHelper -{ - private String documentFormatsConfiguration; - private DocumentFormatRegistry formatRegistry; - protected LegacyTransformerDebug transformerDebug; - private static final int JODCONVERTER_TRANSFORMATION_ERROR_CODE = 3088; - - protected RemoteTransformerClient remoteTransformerClient; - - /** - * Set a non-default location from which to load the document format mappings. - * - * @param path - * a resource location supporting the file: or classpath: prefixes - */ - public void setDocumentFormatsConfiguration(String path) - { - this.documentFormatsConfiguration = path; - } - - protected abstract Log getLogger(); - - protected abstract String getTempFilePrefix(); - - public abstract boolean isAvailable(); - - protected abstract void convert(File tempFromFile, DocumentFormat sourceFormat, File tempToFile, - DocumentFormat targetFormat); - - /** - * Helper setter of the transformer debug. - * @param transformerDebug TransformerDebug - */ - public void setTransformerDebug(LegacyTransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - /** - * Sets the optional remote transformer client which will be used in preference to a local command if available. - * - * @param remoteTransformerClient may be null; - */ - public void setRemoteTransformerClient(RemoteTransformerClient remoteTransformerClient) - { - this.remoteTransformerClient = remoteTransformerClient; - } - - public boolean remoteTransformerClientConfigured() - { - return remoteTransformerClient != null && remoteTransformerClient.getBaseUrl() != null; - } - - public void afterPropertiesSet() - { - // load the document conversion configuration - if (formatRegistry == null) - { - if (documentFormatsConfiguration != null) - { - DefaultResourceLoader resourceLoader = new DefaultResourceLoader(); - try - { - InputStream is = resourceLoader.getResource(this.documentFormatsConfiguration).getInputStream(); - formatRegistry = new JsonDocumentFormatRegistry(is); - // We do not need to explicitly close this InputStream as it is closed for us within the XmlDocumentFormatRegistry - } - catch (IOException e) - { - throw new AlfrescoRuntimeException( - "Unable to load document formats configuration file: " - + this.documentFormatsConfiguration); - } - catch (JSONException e) - { - throw new AlfrescoRuntimeException( - "Unable to read document formats configuration file: " - + this.documentFormatsConfiguration); - } - } - else - { - formatRegistry = new DefaultDocumentFormatRegistry(); - } - } - } - - /** - * There are some conversions that fail, despite the converter believing them possible. - * This method can be used by subclasses to check if a targetMimetype or source/target - * Mimetype pair are blocked. - * - * @param sourceMimetype String - * @param targetMimetype String - * @return true if the mimetypes are blocked, else false - */ - protected boolean isTransformationBlocked(String sourceMimetype, String targetMimetype) - { - if (targetMimetype.equals(MimetypeMap.MIMETYPE_XHTML)) - { - return true; - } - else if (targetMimetype.equals(MimetypeMap.MIMETYPE_WORDPERFECT)) - { - return true; - } - else if (targetMimetype.equals(MimetypeMap.MIMETYPE_FLASH)) - { - return true; - } - else - { - return false; - } - } - - /** - * @see DocumentFormatRegistry - */ - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - // Use BinaryPassThroughContentTransformer if mimetypes are the same. - if (sourceMimetype.equals(targetMimetype)) - { - return false; - } - - if (!isAvailable()) - { - // The connection management is must take care of this - return false; - } - - if (isTransformationBlocked(sourceMimetype, targetMimetype)) - { - if (getLogger().isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Transformation from ") - .append(sourceMimetype).append(" to ") - .append(targetMimetype) - .append(" is blocked and therefore unavailable."); - getLogger().debug(msg.toString()); - } - return false; - } - - MimetypeService mimetypeService = getMimetypeService(); - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - // query the registry for the source format - DocumentFormat sourceFormat = formatRegistry.getFormatByExtension(sourceExtension); - if (sourceFormat == null) - { - // no document format - return false; - } - // query the registry for the target format - DocumentFormat targetFormat = formatRegistry.getFormatByExtension(targetExtension); - if (targetFormat == null) - { - // no document format - return false; - } - - // get the family of the target document - DocumentFamily sourceFamily = sourceFormat.getInputFamily(); - // does the format support the conversion - boolean transformable = formatRegistry.getOutputFormats(sourceFamily).contains(targetFormat); // same as: targetFormat.getStoreProperties(sourceFamily) != null - return transformable; - } - - @Override - public String getComments(boolean available) - { - return "# Transformations supported by OpenOffice/LibreOffice\n"; - } - - /** - * This method produces an empty PDF file at the specified File location. - * Apache's PDFBox is used to create the PDF file. - */ - private void produceEmptyPdfFile(File tempToFile) - { - // If improvement PDFBOX-914 is incorporated, we can do this with a straight call to - // org.apache.pdfbox.TextToPdf.createPDFFromText(new StringReader("")); - // https://issues.apache.org/jira/browse/PDFBOX-914 - - PDDocument pdfDoc = null; - PDPageContentStream contentStream = null; - try - { - pdfDoc = new PDDocument(); - PDPage pdfPage = new PDPage(); - // Even though, we want an empty PDF, some libs (e.g. PDFRenderer) object to PDFs - // that have literally nothing in them. So we'll put a content stream in it. - contentStream = new PDPageContentStream(pdfDoc, pdfPage); - pdfDoc.addPage(pdfPage); - - // Now write the in-memory PDF document into the temporary file. - pdfDoc.save(tempToFile.getAbsolutePath()); - - } - catch (IOException iox) - { - throw new ContentIOException("Error creating empty PDF file", iox); - } - finally - { - if (contentStream != null) - { - try - { - contentStream.close(); - } - catch (IOException ignored) - { - // Intentionally empty - } - } - if (pdfDoc != null) - { - try - { - pdfDoc.close(); - } - catch (IOException ignored) - { - // Intentionally empty. - } - } - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.repo.content.transform.ContentTransformerWorker#getVersionString() - */ - public String getVersionString() - { - return ""; - } - - public void transform( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - if (isAvailable() == false) - { - throw new ContentIOException("Content conversion failed (unavailable): \n" + - " reader: " + reader + "\n" + - " writer: " + writer); - } - - if (getLogger().isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("transforming content from ") - .append(reader.getMimetype()) - .append(" to ") - .append(writer.getMimetype()); - getLogger().debug(msg.toString()); - } - - String sourceMimetype = getMimetype(reader); - String targetMimetype = getMimetype(writer); - - MimetypeService mimetypeService = getMimetypeService(); - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - // query the registry for the source format - DocumentFormat sourceFormat = formatRegistry.getFormatByExtension(sourceExtension); - if (sourceFormat == null) - { - // source format is not recognised - throw new ContentIOException("No OpenOffice document format for source extension: " + sourceExtension); - } - // query the registry for the target format - DocumentFormat targetFormat = formatRegistry.getFormatByExtension(targetExtension); - if (targetFormat == null) - { - // target format is not recognised - throw new ContentIOException("No OpenOffice document format for target extension: " + targetExtension); - } - // get the family of the target document - DocumentFamily sourceFamily = sourceFormat.getInputFamily(); - // does the format support the conversion - if (!formatRegistry.getOutputFormats(sourceFamily).contains(targetFormat)) // same as: targetFormat.getStoreProperties(sourceFamily) == null - { - throw new ContentIOException( - "OpenOffice conversion not supported: \n" + - " reader: " + reader + "\n" + - " writer: " + writer); - } - - // There is a bug (reported in ALF-219) whereby JooConverter (the Alfresco Community Edition's 3rd party - // OpenOffice connector library) struggles to handle zero-size files being transformed to pdf. - // For zero-length .html files, it throws NullPointerExceptions. - // For zero-length .txt files, it produces a pdf transformation, but it is not a conformant - // pdf file and cannot be viewed (contains no pages). - // - // For these reasons, if the file is of zero length, we will not use JooConverter & OpenOffice - // and will instead ask Apache PDFBox to produce an empty pdf file for us. - final long documentSize = reader.getSize(); - if (documentSize == 0L || temporaryMsFile(options)) - { - File tempToFile = TempFileProvider.createTempFile( - getTempFilePrefix()+"-target-", - "." + targetExtension); - produceEmptyPdfFile(tempToFile); - writer.putContent(tempToFile); - } - else - { - if (remoteTransformerClientConfigured()) - { - transformRemote(reader, writer, options, sourceMimetype, sourceExtension, targetMimetype, targetExtension); - } - else - { - transformLocal(reader, writer, options, sourceMimetype, - sourceExtension, targetExtension, sourceFormat, targetFormat); - } - } - - if (getLogger().isDebugEnabled()) - { - getLogger().debug("transformation successful"); - } - } - - protected void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options, - String sourceMimetype, String sourceExtension, String targetExtension, - DocumentFormat sourceFormat, DocumentFormat targetFormat) - { - // create temporary files to convert from and to - File tempFromFile = TempFileProvider.createTempFile( - getTempFilePrefix()+"-source-", - "." + sourceExtension); - File tempToFile = TempFileProvider.createTempFile( - getTempFilePrefix()+"-target-", - "." + targetExtension); - - // download the content from the source reader - saveContentInFile(sourceMimetype, reader, tempFromFile); - - try - { - convert(tempFromFile, sourceFormat, tempToFile, targetFormat); - writer.putContent(tempToFile); - } - catch (OfficeException e) - { - throw new ContentIOException("OpenOffice server conversion failed: \n" + - " reader: " + reader + "\n" + - " writer: " + writer + "\n" + - " from file: " + tempFromFile + "\n" + - " to file: " + tempToFile, - e); - } - catch (Throwable throwable) - { - // Because of the known bug with empty Spreadsheets in JodConverter try to catch exception and produce empty pdf file - if (throwable.getCause() instanceof ErrorCodeIOException && - ((ErrorCodeIOException) throwable.getCause()).ErrCode == JODCONVERTER_TRANSFORMATION_ERROR_CODE) - { - getLogger().warn("Transformation failed: \n" + - "from file: " + tempFromFile + "\n" + - "to file: " + tempToFile + - "Source file " + tempFromFile + " has no content"); - produceEmptyPdfFile(tempToFile); - } - else - { - throw throwable; - } - } - } - - protected void transformRemote(ContentReader reader, ContentWriter writer, TransformationOptions options, - String sourceMimetype, String sourceExtension, - String targetMimetype, String targetExtension) throws IllegalAccessException - { - long timeoutMs = options.getTimeoutMs(); - Log logger = getLogger(); - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "libreoffice", - "sourceMimetype", sourceMimetype, - "sourceExtension", sourceExtension, - "targetMimetype", targetMimetype); - } - - private boolean temporaryMsFile(TransformationOptions options) - { - String fileName = transformerDebug == null ? null : transformerDebug.getFileName(options, true, -1); - return fileName != null && fileName.startsWith("~$"); - } - - /** - * Populates a file with the content in the reader. - */ - public void saveContentInFile(String sourceMimetype, ContentReader reader, File file) throws ContentIOException - { - String encoding = reader.getEncoding(); - if (encodeAsUtf8(sourceMimetype, encoding)) - { - saveContentInUtf8File(reader, file); - } - else - { - reader.getContent(file); - } - } - - /** - * Returns {@code true} if the input file should be transformed to UTF8 encoding.

- * - * OpenOffice/LibreOffice is unable to support the import of text files that are SHIFT JIS encoded - * (and others: windows-1252...) so transformed to UTF-8. - */ - protected boolean encodeAsUtf8(String sourceMimetype, String encoding) - { - return MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(sourceMimetype) && !"UTF-8".equals(encoding); - } - - /** - * Populates a file with the content in the reader, but also converts the encoding to UTF-8. - */ - private void saveContentInUtf8File(ContentReader reader, File file) - { - String encoding = reader.getEncoding(); - try - { - Reader in = new InputStreamReader(reader.getContentInputStream(), encoding); - Writer out = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file)), "UTF-8"); - - FileCopyUtils.copy(in, out); // both streams are closed - } - catch (IOException e) - { - throw new ContentIOException("Failed to copy content to file and convert "+encoding+" to UTF-8: \n" + - " file: " + file, - e); - } - } -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/PdfBoxContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/PdfBoxContentTransformer.java deleted file mode 100644 index 51ec70160a..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/PdfBoxContentTransformer.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.parser.ParseContext; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.pdf.PDFParser; -import org.apache.tika.parser.pdf.PDFParserConfig; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.TARGET_ENCODING; - -/** - * Uses Apache Tika and - * Apache PDFBox to perform - * conversions from PDF documents. - * - * @author Nick Burch - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PdfBoxContentTransformer extends TikaPoweredContentTransformer -{ - /** - * The logger - */ - private static Log logger = LogFactory.getLog(PdfBoxContentTransformer.class); - protected PDFParserConfig pdfParserConfig; - private boolean extractBookmarksText = true; - - public PdfBoxContentTransformer() { - super(new String[] { - MimetypeMap.MIMETYPE_PDF - }); - } - - @Override - protected Parser getParser() { - return new PDFParser(); - } - - /** - * Sets the PDFParserConfig for inclusion in the ParseContext sent to the PDFBox parser, - * useful for setting config like spacingTolerance. - * - * @param pdfParserConfig - */ - public void setPdfParserConfig(PDFParserConfig pdfParserConfig) - { - this.pdfParserConfig = pdfParserConfig; - } - - public void setExtractBookmarksText(boolean extractBookmarksText) - { - this.extractBookmarksText = extractBookmarksText; - } - - - @Override - protected ParseContext buildParseContext(Metadata metadata, String targetMimeType, TransformationOptions options) - { - ParseContext context = super.buildParseContext(metadata, targetMimeType, options); - if (pdfParserConfig != null) - { - pdfParserConfig.setExtractBookmarksText(extractBookmarksText); - context.set(PDFParserConfig.class, pdfParserConfig); - } - // TODO: Possibly extend TransformationOptions to allow for per-transform PDFParserConfig? - return context; - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - long timeoutMs = options.getTimeoutMs(); - String notExtractBookmarksText = null; - - if (!extractBookmarksText) - { - notExtractBookmarksText = Boolean.TRUE.toString(); - } - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "PdfBox", - "notExtractBookmarksText", notExtractBookmarksText, - "sourceMimetype", sourceMimetype, - "targetMimetype", targetMimetype, - "targetExtension", targetExtension, - TARGET_ENCODING, targetEncoding); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/PoiContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/PoiContentTransformer.java deleted file mode 100644 index a1970f5ca0..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/PoiContentTransformer.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; - -import org.alfresco.repo.content.MimetypeMap; -import org.apache.tika.mime.MediaType; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.microsoft.OfficeParser; - -/** - * Uses Apache Tika and - * Apache POI to perform - * conversions from Office documents. - * - * {@link PoiHssfContentTransformer} handles the Excel - * transformations (mostly for compatibility), while - * this does all the other Office file formats. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PoiContentTransformer extends TikaPoweredContentTransformer -{ - /** - * We support all the office mimetypes that the Tika - * office parser can handle, except for excel - * (handled by {@link PoiHssfContentTransformer} - */ - public static ArrayList SUPPORTED_MIMETYPES; - static { - SUPPORTED_MIMETYPES = new ArrayList(); - Parser p = new OfficeParser(); - for(MediaType mt : p.getSupportedTypes(null)) { - if(mt.toString().equals(MimetypeMap.MIMETYPE_EXCEL)) - { - // Skip, handled elsewhere - continue; - } - // Tika can probably do some useful text - SUPPORTED_MIMETYPES.add( mt.toString() ); - } - } - - public PoiContentTransformer() { - super(SUPPORTED_MIMETYPES); - setTransformerName("Office"); - } - - @Override - protected Parser getParser() { - return new OfficeParser(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/PoiHssfContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/PoiHssfContentTransformer.java deleted file mode 100644 index e2a2ba78cf..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/PoiHssfContentTransformer.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.Writer; -import java.util.regex.Pattern; - -import javax.xml.transform.TransformerConfigurationException; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.TikaOfficeDetectParser; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tika.parser.Parser; -import org.apache.tika.sax.BodyContentHandler; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -/** - * Uses Apache Tika and - * Apache POI to perform - * conversions from Excel spreadsheets. - *

Will transform from Excel spreadsheets into Html, - * Xml or Text (space or comma separated) - *

Handles all sheets in the file. - * - * @author Nick Burch - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PoiHssfContentTransformer extends TikaPoweredContentTransformer -{ - /** - * Error message to delegate to NodeInfoBean - */ - public static final String WRONG_FORMAT_MESSAGE_ID = "transform.err.format_or_password"; - private static Log logger = LogFactory.getLog(PoiHssfContentTransformer.class); - - public PoiHssfContentTransformer() - { - super(new String[] { - MimetypeMap.MIMETYPE_EXCEL, - MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET - }); - setTransformerName("Poi"); - } - - @Override - protected Parser getParser() - { - return new TikaOfficeDetectParser(); - } - - /** - * Can we do the requested transformation via Tika? - * We support transforming to HTML, XML, Text or CSV - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if(sourceMimeTypes.contains(sourceMimetype) && - MimetypeMap.MIMETYPE_TEXT_CSV.equals(targetMimetype)) - { - // Special case for CSV - return true; - } - - // Otherwise fall back on the default Tika rules - return super.isTransformableMimetype(sourceMimetype, targetMimetype, options); - } - - /** - * Make sure we win over openoffice when it comes to producing - * HTML - */ - @Override - public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if(sourceMimeTypes.contains(sourceMimetype) && - (MimetypeMap.MIMETYPE_HTML.equals(targetMimetype) || - MimetypeMap.MIMETYPE_XHTML.equals(targetMimetype)) ) - { - // Special case to win for HTML - return true; - } - - // Otherwise fall back on the default Tika rules - return super.isTransformableMimetype(sourceMimetype, targetMimetype, options); - } - - @Override - protected ContentHandler getContentHandler(String targetMimeType, Writer output) - throws TransformerConfigurationException - { - if(MimetypeMap.MIMETYPE_TEXT_CSV.equals(targetMimeType)) - { - return new CsvContentHandler(output); - } - - // Otherwise use the normal Tika rules - return super.getContentHandler(targetMimeType, output); - } - - /** - * A wrapper around the normal Tika BodyContentHandler, - * which causes things to be CSV encoded rather than - * tab separated - */ - protected static class CsvContentHandler extends BodyContentHandler { - private static final char[] comma = new char[]{ ',' }; - private static final Pattern all_nums = Pattern.compile("[\\d\\.\\-\\+]+"); - - private boolean inCell = false; - private boolean needsComma = false; - - protected CsvContentHandler(Writer output) { - super(output); - } - - @Override - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException { - if(length == 1 && ch[0] == '\t') { - // Ignore tabs, as they mess up the CSV output - } else { - super.ignorableWhitespace(ch, start, length); - } - } - - @Override - public void characters(char[] ch, int start, int length) - throws SAXException { - if(inCell) { - StringBuffer t = new StringBuffer(new String(ch,start,length)); - - // Quote if not all numbers - if(all_nums.matcher(t).matches()) - { - super.characters(ch, start, length); - } - else - { - for(int i=t.length()-1; i>=0; i--) { - if(t.charAt(i) == '\"') { - // Double up double quotes - t.insert(i, '\"'); - i--; - } - } - t.insert(0, '\"'); - t.append('\"'); - char[] c = t.toString().toCharArray(); - super.characters(c, 0, c.length); - } - } else { - super.characters(ch, start, length); - } - } - - @Override - public void startElement(String uri, String localName, String name, - Attributes atts) throws SAXException { - if(localName.equals("td")) { - inCell = true; - if(needsComma) { - super.characters(comma, 0, 1); - needsComma = true; - } - } else { - super.startElement(uri, localName, name, atts); - } - } - - @Override - public void endElement(String uri, String localName, String name) - throws SAXException { - if(localName.equals("td")) { - needsComma = true; - inCell = false; - } else { - if(localName.equals("tr")) { - needsComma = false; - } - super.endElement(uri, localName, name); - } - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/PoiOOXMLContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/PoiOOXMLContentTransformer.java deleted file mode 100644 index 056239dae9..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/PoiOOXMLContentTransformer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; - -import org.apache.tika.mime.MediaType; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.microsoft.ooxml.OOXMLParser; - -/** - * Uses Apache Tika and - * Apache POI to perform - * conversions from the newer OOXML Office documents. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PoiOOXMLContentTransformer extends TikaPoweredContentTransformer -{ - /** - * We support all the office mimetypes that the Tika - * office parser can handle - */ - public static ArrayList SUPPORTED_MIMETYPES; - static { - SUPPORTED_MIMETYPES = new ArrayList(); - Parser p = new OOXMLParser(); - for(MediaType mt : p.getSupportedTypes(null)) { - SUPPORTED_MIMETYPES.add( mt.toString() ); - } - } - - public PoiOOXMLContentTransformer() { - super(SUPPORTED_MIMETYPES); - setUseTimeoutThread(true); - setTransformerName("OOXML"); - } - - @Override - protected Parser getParser() { - return new OOXMLParser(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/ProxyContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/ProxyContentTransformer.java deleted file mode 100644 index 529c4fa0b7..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/ProxyContentTransformer.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.artofsolving.jodconverter.document.DocumentFormatRegistry; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Makes use of a {@link ContentTransformerWorker} to perform conversions. - * - * @author dward - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public class ProxyContentTransformer extends AbstractContentTransformer2 -{ - private ContentTransformerWorker worker; - - public ProxyContentTransformer() - { - } - - /** - * @param worker - * the worker that the converter uses - */ - public void setWorker(ContentTransformerWorker worker) - { - this.worker = worker; - } - - /** - * Returns the worker that the converter uses - */ - public ContentTransformerWorker getWorker() - { - return this.worker; - } - - /** - * THIS IS A CUSTOM SPRING INIT METHOD - */ - public void register() - { - if (worker instanceof ContentTransformerHelper) - { - logDeprecatedSetter(((ContentTransformerHelper)worker).deprecatedSetterMessages); - } - super.register(); - } - - /** - * @see DocumentFormatRegistry - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return this.worker.isTransformable(sourceMimetype, targetMimetype, options); - } - - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(super.getComments(available)); - sb.append(worker.getComments(false)); - return sb.toString(); - } - - protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception - { - TransformationOptionLimits original = options.getLimits(); - try - { - // Combine the transformer's limit values into the options so they are available to the worker - options.setLimits(getLimits(reader, writer, options)); - - // Perform the transformation - this.worker.transform(reader, writer, options); - } - finally - { - options.setLimits(original); - } - } - - boolean remoteTransformerClientConfigured() - { - return worker.remoteTransformerClientConfigured(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerWorker.java deleted file mode 100644 index bd6c6ecc89..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerWorker.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -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; -import org.springframework.beans.factory.InitializingBean; - -/** - * This configurable wrapper is able to execute any command line transformation that - * accepts an input and an output file on the command line. - *

- * The following parameters are use: - *

    - *
  • {@link #VAR_SOURCE target} - full path to the source file
  • - *
  • {@link #VAR_TARGET source} - full path to the target file
  • - *
- * Provided that the command executed ultimately transforms the source file - * and leaves the result in the target file, the transformation should be - * successful. - *

- * NOTE: It is only the contents of the files that can be transformed. - * Any attempt to modify the source or target file metadata will, at best, have - * no effect, but may ultimately lead to the transformation failing. This is - * because the files provided are both temporary files that reside in a location - * outside the system's content store. - *

- * This transformer requires the setting of the explicitTransformations - * property. - * - * @see org.alfresco.util.exec.RuntimeExec - * - * @since 1.1 - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public class RuntimeExecutableContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean -{ - public static final String VAR_SOURCE = "source"; - public static final String VAR_TARGET = "target"; - public static final String VAR_PAGE_RANGE = "pageRange"; - - private static Log logger = LogFactory.getLog(RuntimeExecutableContentTransformerWorker.class); - - private boolean available; - private RuntimeExec checkCommand; - private RuntimeExec transformCommand; - - /** Stores the output from the check command */ - private String versionString; - - public RuntimeExecutableContentTransformerWorker() - { - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append(this.getClass().getSimpleName()) - .append("[ transform=").append(transformCommand).append("\n") - .append("]"); - return sb.toString(); - } - - /** - * Set the runtime executer that will be called as part of the initialisation - * to determine if the transformer is able to function. This is optional, but allows - * the transformer registry to detect and avoid using this instance if it is not working. - *

- * The command will be considered to have failed if the - * - * @param checkCommand the initialisation check command - */ - public void setCheckCommand(RuntimeExec checkCommand) - { - this.checkCommand = checkCommand; - } - - /** - * Set the runtime executer that will called to perform the actual transformation. - * - * @param transformCommand the runtime transform command - */ - public void setTransformCommand(RuntimeExec transformCommand) - { - this.transformCommand = transformCommand; - } - - /** - * A comma or space separated list of values that, if returned by the executed command, - * indicate an error value. This defaults to "1, 2". - * - * @param errCodesStr String - */ - public void setErrorCodes(String errCodesStr) - { - throw new AlfrescoRuntimeException("content.runtime_exec.property_moved"); - } - - - /** - * Executes the check command, if present. Any errors will result in this component - * being rendered unusable within the transformer registry, but may still be called - * directly. - */ - public void afterPropertiesSet() - { - if (transformCommand == null) - { - throw new AlfrescoRuntimeException("Mandatory property 'transformCommand' not set"); - } - - // execute the command - if (checkCommand != null) - { - ExecutionResult result = checkCommand.execute(); - // check the return code - if (this.available = result.getSuccess()) - { - this.versionString = result.getStdOut().trim(); - } - else - { - logger.error("Failed to start a runtime executable content transformer: \n" + result); - } - } - else - { - // no check - just assume it is available - available = true; - } - } - - /** - * If the initialization failed, then it returns 0.0. - * Otherwise the explicit transformations are checked for the reliability. - * - * @return Returns 1.0 if initialization succeeded, otherwise 0.0. - * - * @see AbstractContentTransformer#setExplicitTransformations(List) - */ - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return isAvailable(); - } - - @Override - public String getComments(boolean available) - { - return ""; - } - - /** - * 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; - } - - /** - * Converts the source and target content to temporary files with the - * correct extensions for the mimetype that they map to. - * - */ - public final void transform( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - // get mimetypes - String sourceMimetype = getMimetype(reader); - String targetMimetype = getMimetype(writer); - - // get the extensions to use - String sourceExtension = getMimetypeService().getExtension(sourceMimetype); - String targetExtension = getMimetypeService().getExtension(targetMimetype); - if (sourceExtension == null || targetExtension == null) - { - throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" + - " source mimetype: " + sourceMimetype + "\n" + - " source extension: " + sourceExtension + "\n" + - " target mimetype: " + targetMimetype + "\n" + - " target extension: " + targetExtension); - } - - // create required temp files - File sourceFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_source_", - "." + sourceExtension); - File targetFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_target_", - "." + targetExtension); - - Map properties = new HashMap(5); - // copy options over - Map optionsMap = options.toMap(); - for (Map.Entry entry : optionsMap.entrySet()) - { - String key = entry.getKey(); - Object value = entry.getValue(); - properties.put(key, (value == null ? null : value.toString())); - } - // add the source and target properties - properties.put(VAR_SOURCE, sourceFile.getAbsolutePath()); - properties.put(VAR_TARGET, targetFile.getAbsolutePath()); - properties.put(VAR_PAGE_RANGE, "0-"+(options.getPageLimit() >=0 ? options.getPageLimit() : "")); - - // pull reader file into source temp file - reader.getContent(sourceFile); - - // execute the transformation command - long timeoutMs = options.getTimeoutMs(); - ExecutionResult result = null; - try - { - result = transformCommand.execute(properties, timeoutMs); - } - catch (Throwable e) - { - throw new ContentIOException("Transformation failed during command execution: \n" + transformCommand, e); - } - - // check - if (!result.getSuccess()) - { - throw new ContentIOException("Transformation failed - status indicates an error: \n" + result); - } - - // check that the file was created - if (!targetFile.exists()) - { - throw new ContentIOException("Transformation failed - target file doesn't exist: \n" + result); - } - // copy the target file back into the repo - writer.putContent(targetFile); - - // done - if (logger.isDebugEnabled()) - { - logger.debug("Transformation completed: \n" + - " source: " + reader + "\n" + - " target: " + writer + "\n" + - " options: " + options + "\n" + - " result: \n" + result); - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/StringExtractingContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/StringExtractingContentTransformer.java deleted file mode 100644 index 12a1fbbc46..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/StringExtractingContentTransformer.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.SOURCE_ENCODING; -import static org.alfresco.repo.rendition2.RenditionDefinition2.TARGET_ENCODING; - -/** - * Converts any textual format to plain text. - *

- * The transformation is sensitive to the source and target string encodings. - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class StringExtractingContentTransformer extends AbstractRemoteContentTransformer -{ - public static final String PREFIX_TEXT = "text/"; - - private static final Log logger = LogFactory.getLog(StringExtractingContentTransformer.class); - - /** - * Gives a high reliability for all translations from text/sometype to - * text/plain. As the text formats are already text, the characters - * are preserved and no actual conversion takes place. - *

- * Extraction of text from binary data is wholly unreliable. - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (!targetMimetype.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN)) - { - // can only convert to plain text - return false; - } - else if (sourceMimetype.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN) || - sourceMimetype.equals(MimetypeMap.MIMETYPE_JAVASCRIPT)) - { - // conversions from any plain text format are very reliable - return true; - } - else if (sourceMimetype.startsWith(PREFIX_TEXT) || - sourceMimetype.equals(MimetypeMap.MIMETYPE_DITA)) - { - // the source is text, but probably with some kind of markup - return true; - } - else - { - // extracting text from binary is not useful - return false; - } - } - - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append(super.getComments(available)); - sb.append("# Only supports transformation of js, dita and mimetypes starting with \""); - sb.append(PREFIX_TEXT); - sb.append("\" to txt.\n"); - return sb.toString(); - } - - @Override - protected Log getLogger() - { - return logger; - } - - /** - * Text to text conversions are done directly using the content reader and writer string - * manipulation methods. - *

- * Extraction of text from binary content attempts to take the possible character - * encoding into account. The text produced from this will, if the encoding was correct, - * be unformatted but valid. - */ - @Override - public void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception - { - // is this a straight text-text transformation - transformText(reader, writer, options); - } - - /** - * Transformation optimized for text-to-text conversion - */ - private void transformText(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception - { - // get a char reader and writer - Reader charReader = null; - Writer charWriter = null; - try - { - if (reader.getEncoding() == null) - { - charReader = new InputStreamReader(reader.getContentInputStream()); - } - else - { - charReader = new InputStreamReader(reader.getContentInputStream(), reader.getEncoding()); - } - if (writer.getEncoding() == null) - { - charWriter = new OutputStreamWriter(writer.getContentOutputStream()); - } - else - { - charWriter = new OutputStreamWriter(writer.getContentOutputStream(), writer.getEncoding()); - } - // copy from the one to the other - char[] buffer = new char[8192]; - int readCount = 0; - while (readCount > -1) - { - // write the last read count number of bytes - charWriter.write(buffer, 0, readCount); - // fill the buffer again - readCount = charReader.read(buffer); - } - } - finally - { - if (charReader != null) - { - try { charReader.close(); } catch (Throwable e) { logger.error(e); } - } - if (charWriter != null) - { - try { charWriter.close(); } catch (Throwable e) { logger.error(e); } - } - } - // done - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, String sourceMimetype, - String targetMimetype, String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - String sourceEncoding = reader.getEncoding(); - long timeoutMs = options.getTimeoutMs(); - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "string", - "sourceMimetype", sourceMimetype, - "targetMimetype", targetMimetype, - "targetExtension", targetExtension, - SOURCE_ENCODING, sourceEncoding, - TARGET_ENCODING, targetEncoding); - - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/SupportedTransformation.java b/repository/src/main/java/org/alfresco/repo/content/transform/SupportedTransformation.java deleted file mode 100644 index b26bdf9d50..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/SupportedTransformation.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -/** - * Represents a supported transformation. Normally used in a spring bean that limits - * the number of supported configures. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class SupportedTransformation -{ - private String sourceMimetype; - private String targetMimetype; - - public SupportedTransformation() - { - } - - public SupportedTransformation(String sourceMimetype, String targetMimetype) - { - this.sourceMimetype = sourceMimetype; - this.targetMimetype = targetMimetype; - } - - public void setSourceMimetype(String sourceMimetype) - { - this.sourceMimetype = sourceMimetype; - } - - public String getSourceMimetype() - { - return sourceMimetype; - } - - public void setTargetMimetype(String targetMimetype) - { - this.targetMimetype = targetMimetype; - } - - public String getTargetMimetype() - { - return targetMimetype; - } -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TextMiningContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/TextMiningContentTransformer.java deleted file mode 100644 index a13fb007dd..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TextMiningContentTransformer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.apache.tika.parser.Parser; -import org.apache.tika.parser.microsoft.OfficeParser; - -/** - * This badly named transformer turns Microsoft Word documents - * (Word 6, 95, 97, 2000, 2003) into plain text, using Apache Tika. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TextMiningContentTransformer extends TikaPoweredContentTransformer -{ - public TextMiningContentTransformer() - { - super(new String[] { - MimetypeMap.MIMETYPE_WORD - }); - setTransformerName("TextMining"); - } - - @Override - protected Parser getParser() { - return new OfficeParser(); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TextToPdfContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/TextToPdfContentTransformer.java deleted file mode 100644 index 9c7ee37483..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TextToPdfContentTransformer.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptionPair; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.pdmodel.PDPageContentStream; -import org.apache.pdfbox.pdmodel.font.PDType1Font; -import org.apache.pdfbox.tools.TextToPDF; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.SOURCE_ENCODING; - -/** - * Makes use of the PDFBox library's TextToPDF utility. - * - * @author Derek Hulley - * @since 2.1.0 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TextToPdfContentTransformer extends AbstractRemoteContentTransformer -{ - private static final Log logger = LogFactory.getLog(TextToPdfContentTransformer.class); - - private PagedTextToPDF transformer; - - public TextToPdfContentTransformer() - { - setPageLimitsSupported(true); - transformer = new PagedTextToPDF(); - } - - public void setStandardFont(String fontName) - { - try - { - transformer.setFont(transformer.getStandardFont(fontName)); - } - catch (Throwable e) - { - throw new AlfrescoRuntimeException("Unable to set Standard Font for PDF generation: " + fontName, e); - } - } - - public void setFontSize(int fontSize) - { - try - { - transformer.setFontSize(fontSize); - } - catch (Throwable e) - { - throw new AlfrescoRuntimeException("Unable to set Font Size for PDF generation: " + fontSize); - } - } - - /** - * Only supports Text to PDF - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if ( (!MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(sourceMimetype) && - !MimetypeMap.MIMETYPE_TEXT_CSV.equals(sourceMimetype) && - !MimetypeMap.MIMETYPE_DITA.equals(sourceMimetype) && - !MimetypeMap.MIMETYPE_XML.equals(sourceMimetype) ) || - !MimetypeMap.MIMETYPE_PDF.equals(targetMimetype)) - { - // only support (text/plain OR text/csv OR text/xml) to (application/pdf) - return false; - } - else - { - return true; - } - } - - @Override - public String getComments(boolean available) - { - return getCommentsOnlySupports( - Arrays.asList(new String[] {MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_TEXT_CSV, - MimetypeMap.MIMETYPE_DITA, MimetypeMap.MIMETYPE_XML}), - Arrays.asList(new String[] {MimetypeMap.MIMETYPE_PDF}), available); - } - - @Override - protected Log getLogger() - { - return logger; - } - - @Override - protected void transformLocal( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - PDDocument pdf = null; - InputStream is = null; - InputStreamReader ir = null; - OutputStream os = null; - try - { - is = reader.getContentInputStream(); - ir = buildReader(is, reader.getEncoding(), reader.getContentUrl()); - - TransformationOptionLimits limits = getLimits(reader, writer, options); - TransformationOptionPair pageLimits = limits.getPagesPair(); - pdf = transformer.createPDFFromText(ir, pageLimits, reader.getContentUrl(), transformerDebug); - - // dump it all to the writer - os = writer.getContentOutputStream(); - pdf.save(os); - } - finally - { - if (pdf != null) - { - try { pdf.close(); } catch (Throwable e) {e.printStackTrace(); } - } - if (ir != null) - { - try { ir.close(); } catch (Throwable e) {e.printStackTrace(); } - } - if (is != null) - { - try { is.close(); } catch (Throwable e) {e.printStackTrace(); } - } - if (os != null) - { - try { os.close(); } catch (Throwable e) {e.printStackTrace(); } - } - } - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, String sourceMimetype, - String targetMimetype, String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - String sourceEncoding = reader.getEncoding(); - long timeoutMs = options.getTimeoutMs(); - - TransformationOptionLimits limits = getLimits(reader, writer, options); - TransformationOptionPair pageLimits = limits.getPagesPair(); - int pageLimit = (int)pageLimits.getValue(); - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "textToPdf", - "sourceMimetype", sourceMimetype, - "targetMimetype", targetMimetype, - "targetExtension", targetExtension, - SOURCE_ENCODING, sourceEncoding, - "pageLimit", String.valueOf(pageLimit)); - } - - protected InputStreamReader buildReader(InputStream is, String encoding, String node) - { - // If they gave an encoding, try to use it - if(encoding != null) - { - Charset charset = null; - try - { - charset = Charset.forName(encoding); - } catch(Exception e) - { - logger.warn("JVM doesn't understand encoding '" + encoding + - "' when transforming " + node); - } - if(charset != null) - { - logger.debug("Processing plain text in encoding " + charset.displayName()); - return new InputStreamReader(is, charset); - } - } - - // Fall back on the system default - logger.debug("Processing plain text using system default encoding"); - return new InputStreamReader(is); - } - - private static class PagedTextToPDF extends TextToPDF - { - // REPO-1066: duplicating the following lines from org.apache.pdfbox.tools.TextToPDF because they made them private - // before the upgrade to pdfbox 2.0.8, in pdfbox 1.8, this piece of code was public in org.apache.pdfbox.pdmodel.font.PDType1Font - static PDType1Font getStandardFont(String name) { - return (PDType1Font)STANDARD_14.get(name); - } - private static final Map STANDARD_14 = new HashMap(); - static - { - STANDARD_14.put(PDType1Font.TIMES_ROMAN.getBaseFont(), PDType1Font.TIMES_ROMAN); - STANDARD_14.put(PDType1Font.TIMES_BOLD.getBaseFont(), PDType1Font.TIMES_BOLD); - STANDARD_14.put(PDType1Font.TIMES_ITALIC.getBaseFont(), PDType1Font.TIMES_ITALIC); - STANDARD_14.put(PDType1Font.TIMES_BOLD_ITALIC.getBaseFont(), PDType1Font.TIMES_BOLD_ITALIC); - STANDARD_14.put(PDType1Font.HELVETICA.getBaseFont(), PDType1Font.HELVETICA); - STANDARD_14.put(PDType1Font.HELVETICA_BOLD.getBaseFont(), PDType1Font.HELVETICA_BOLD); - STANDARD_14.put(PDType1Font.HELVETICA_OBLIQUE.getBaseFont(), PDType1Font.HELVETICA_OBLIQUE); - STANDARD_14.put(PDType1Font.HELVETICA_BOLD_OBLIQUE.getBaseFont(), PDType1Font.HELVETICA_BOLD_OBLIQUE); - STANDARD_14.put(PDType1Font.COURIER.getBaseFont(), PDType1Font.COURIER); - STANDARD_14.put(PDType1Font.COURIER_BOLD.getBaseFont(), PDType1Font.COURIER_BOLD); - STANDARD_14.put(PDType1Font.COURIER_OBLIQUE.getBaseFont(), PDType1Font.COURIER_OBLIQUE); - STANDARD_14.put(PDType1Font.COURIER_BOLD_OBLIQUE.getBaseFont(), PDType1Font.COURIER_BOLD_OBLIQUE); - STANDARD_14.put(PDType1Font.SYMBOL.getBaseFont(), PDType1Font.SYMBOL); - STANDARD_14.put(PDType1Font.ZAPF_DINGBATS.getBaseFont(), PDType1Font.ZAPF_DINGBATS); - } - //duplicating until here - - // The following code is based on the code in TextToPDF with the addition of - // checks for page limits. - // The calling code must close the PDDocument once finished with it. - public PDDocument createPDFFromText(Reader text, TransformationOptionPair pageLimits, String contentUrl, TransformerDebug transformerDebug) - throws IOException - { - int pageLimit = (int)pageLimits.getValue(); - PDDocument doc = null; - int pageCount = 0; - try - { - final int margin = 40; - float height = getFont().getFontDescriptor().getFontBoundingBox().getHeight()/1000; - - //calculate font height and increase by 5 percent. - height = height*getFontSize()*1.05f; - doc = new PDDocument(); - BufferedReader data = new BufferedReader( text ); - String nextLine = null; - PDPage page = new PDPage(); - PDPageContentStream contentStream = null; - float y = -1; - float maxStringLength = page.getMediaBox().getWidth() - 2*margin; - - // There is a special case of creating a PDF document from an empty string. - boolean textIsEmpty = true; - - outer: - while( (nextLine = data.readLine()) != null ) - { - - // The input text is nonEmpty. New pages will be created and added - // to the PDF document as they are needed, depending on the length of - // the text. - textIsEmpty = false; - - String[] lineWords = nextLine.trim().split( " " ); - int lineIndex = 0; - while( lineIndex < lineWords.length ) - { - StringBuffer nextLineToDraw = new StringBuffer(); - float lengthIfUsingNextWord = 0; - do - { - nextLineToDraw.append( lineWords[lineIndex] ); - nextLineToDraw.append( " " ); - lineIndex++; - if( lineIndex < lineWords.length ) - { - String lineWithNextWord = nextLineToDraw.toString() + lineWords[lineIndex]; - lengthIfUsingNextWord = - (getFont().getStringWidth( lineWithNextWord )/1000) * getFontSize(); - } - } - while( lineIndex < lineWords.length && - lengthIfUsingNextWord < maxStringLength ); - if( y < margin ) - { - if (pageLimit > 0 && pageCount++ >= pageLimit) - { - pageLimits.getAction().throwIOExceptionIfRequired("Page limit ("+pageLimit+ - ") reached.", transformerDebug); - break outer; - } - - // We have crossed the end-of-page boundary and need to extend the - // document by another page. - page = new PDPage(); - doc.addPage( page ); - if( contentStream != null ) - { - contentStream.endText(); - contentStream.close(); - } - contentStream = new PDPageContentStream(doc, page); - contentStream.setFont(getFont(), getFontSize()); - contentStream.beginText(); - y = page.getMediaBox().getHeight() - margin + height; - contentStream.moveTextPositionByAmount( - margin, y ); - } - //System.out.println( "Drawing string at " + x + "," + y ); - - if( contentStream == null ) - { - throw new IOException( "Error:Expected non-null content stream." ); - } - contentStream.moveTextPositionByAmount( 0, -height); - y -= height; - contentStream.drawString( nextLineToDraw.toString() ); - } - } - - // If the input text was the empty string, then the above while loop will have short-circuited - // and we will not have added any PDPages to the document. - // So in order to make the resultant PDF document readable by Adobe Reader etc, we'll add an empty page. - if (textIsEmpty) - { - doc.addPage(page); - } - - if( contentStream != null ) - { - contentStream.endText(); - contentStream.close(); - } - } - catch( IOException io ) - { - if( doc != null ) - { - doc.close(); - } - throw io; - } - return doc; - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TikaAutoContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/TikaAutoContentTransformer.java deleted file mode 100644 index 0e52b8f76e..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TikaAutoContentTransformer.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; - -import org.apache.tika.config.TikaConfig; -import org.apache.tika.mime.MediaType; -import org.apache.tika.parser.AutoDetectParser; -import org.apache.tika.parser.Parser; - -/** - * A Content Extractor for XML, HTML and Text, - * which makes use of the Apache Tika - * auto-detection to select the best parser - * to process your document. - * This will be used for all files which Tika can - * handle, but where no other more explicit - * extractor is defined. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TikaAutoContentTransformer extends TikaPoweredContentTransformer -{ - private static AutoDetectParser parser; - private static TikaConfig config; - - /** - * We support all the mimetypes that the Tika - * auto-detect parser can handle, except for - * Image, Audio and Video ones which don't - * make much sense - */ - public static ArrayList SUPPORTED_MIMETYPES; - private static ArrayList buildMimeTypes(TikaConfig tikaConfig) - { - config = tikaConfig; - parser = new AutoDetectParser(config); - - SUPPORTED_MIMETYPES = new ArrayList(); - for(MediaType baseType : parser.getParsers().keySet()) - { - // Register both the canonical type, and any alias it may have - // Alfresco sometimes uses the canonical type, and sometimes an alias - ArrayList types = new ArrayList(); - types.add(baseType); - types.addAll( config.getMediaTypeRegistry().getAliases(baseType) ); - - for(MediaType mt : types) - { - if(mt.toString().startsWith("application/vnd.oasis.opendocument.formula")) { - // TODO Tika support for quick.odf, mimetype=application/vnd.oasis.opendocument.formula - // TODO Tika support for quick.otf, mimetype=application/vnd.oasis.opendocument.formula-template - continue; - } - if(mt.toString().startsWith("application/vnd.oasis.opendocument.graphics")) { - // TODO Tika support for quick.odg, mimetype=application/vnd.oasis.opendocument.graphics - // TODO Tika support for quick.otg, mimetype=application/vnd.oasis.opendocument.graphics-template - continue; - } - - if(mt.getType().equals("image") || - mt.getType().equals("audio") || - mt.getType().equals("video")) - { - // Skip these, as Tika mostly just does - // metadata rather than content - } - else if(mt.toString().equals("application/zip") || - mt.toString().equals("application/tar") || - mt.toString().equals("application/x-tar")) - { - // Skip these, as we handle container formats in a different - // transformer to give the user control over recursion - } - else if(mt.toString().equals("message/rfc822") || - mt.toString().equals("application/vnd.ms-outlook")) - { - // Skip these, as we want our textual representations to include - // parts of the metadata (eg people, subjects, dates) too - } - else - { - // Tika can probably do some useful text - SUPPORTED_MIMETYPES.add( mt.toString() ); - } - } - } - return SUPPORTED_MIMETYPES; - } - - public TikaAutoContentTransformer(TikaConfig tikaConfig) - { - super( buildMimeTypes(tikaConfig) ); - setUseTimeoutThread(true); - setTransformerName("TikaAuto"); - } - - /** - * Returns the Tika Auto-Detection - * parser, which will try to - * process all documents that Tika - * knows about - */ - protected Parser getParser() - { - return parser; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TikaPoweredContainerExtractor.java b/repository/src/main/java/org/alfresco/repo/content/transform/TikaPoweredContainerExtractor.java deleted file mode 100644 index 4b1011800c..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TikaPoweredContainerExtractor.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.ParameterDefinitionImpl; -import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ParameterDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tika.config.TikaConfig; -import org.apache.tika.detect.DefaultDetector; -import org.apache.tika.detect.Detector; -import org.apache.tika.exception.TikaException; -import org.apache.tika.extractor.EmbeddedResourceHandler; -import org.apache.tika.extractor.ParserContainerExtractor; -import org.apache.tika.io.TikaInputStream; -import org.apache.tika.mime.MediaType; -import org.apache.tika.parser.AutoDetectParser; - -/** - * Warning - this is a prototype service, and will likely change dramatically - * in Alfresco 4.0! - * - * This proto-service provides a way to have Apache Tika extract out - * certain kinds of embedded resources from within a container file. - * - * One use might be to extract all the images in a zip file, another might - * be to fetch all the Word Documents embedded in an Excel Spreadsheet. - * - * Uses the Apache Tika ContainerExtractor framework, along with the - * Apache Tika Auto-Parser. - * - * Not sprung-in by default, you will need to manually list this in - * an extension context file. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TikaPoweredContainerExtractor -{ - private static final Log logger = LogFactory.getLog(TikaPoweredContainerExtractor.class); - - private NodeService nodeService; - private ContentService contentService; - - private TikaConfig config; - private AutoDetectParser parser; - private Detector detector; - - /** - * Injects the nodeService bean. - * - * @param nodeService the nodeService. - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Injects the contentService bean. - * - * @param contentService the contentService. - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * Injects the TikaConfig to use - * - * @param tikaConfig The Tika Config to use - */ - public void setTikaConfig(TikaConfig tikaConfig) - { - this.config = tikaConfig; - - // Setup the detector and parser - detector = new DefaultDetector(config.getMimeRepository()); - parser = new AutoDetectParser(detector); - } - - /** - * Extracts out all the entries from the container - * that match the supplied list of mime types. - * If no mime types are specified, extracts all - * available embedded resources. - */ - public List extract(NodeRef source, List mimetypes) - { - // Grab the directory to put the nodes into - // Will be the parent folder of the source - NodeRef folder = nodeService.getPrimaryParent(source).getParentRef(); - - // Get the contents - ContentReader reader = contentService.getReader(source, ContentModel.PROP_CONTENT); - InputStream wrappedInputStream = null; - TikaInputStream stream = null; - Extractor handler = null; - try { - wrappedInputStream = reader.getContentInputStream(); - stream = TikaInputStream.get(wrappedInputStream); - // Build the recursing parser - handler = new Extractor(folder, mimetypes); - - // Have Tika look for things - ParserContainerExtractor extractor = new ParserContainerExtractor( - parser, detector - ); - logger.info("Beginning extraction of " + source.toString()); - extractor.extract(stream, null, handler); - logger.info("Completed extraction of " + source.toString()); - } catch(TikaException te) { - throw new AlfrescoRuntimeException("Extraction Failed", te); - } catch(IOException ie) { - throw new AlfrescoRuntimeException("Extraction Failed", ie); - } - finally - { - // Tidy up - if (stream != null) - { - try - { - stream.close(); - } - catch (IOException error) - { - logger.debug("Error while closing stream.", error); - } - } - if (wrappedInputStream != null) - { - try - { - wrappedInputStream.close(); - } - catch (IOException error) - { - logger.debug("Error while closing stream.", error); - } - } - } - - // All done - return handler.extracted; - } - - /** - * This EmbeddedResourceHandler is called by Tika for each - * embedded resource. It decides if the resource is to - * be extracted or not, and if it is, saves it into the - * specified folder. - */ - private class Extractor implements EmbeddedResourceHandler - { - private List extracted; - private Set acceptTypes; - private NodeRef folder; - private int anonymousCount = 0; - - private Extractor(NodeRef folder, List types) - { - this.folder = folder; - this.extracted = new ArrayList(); - - if(types != null && types.size() > 0) - { - acceptTypes = new HashSet(); - for(String type : types) - { - acceptTypes.add(MediaType.parse(type)); - } - } - } - - @Override - public void handle(String filename, MediaType mediaType, - InputStream stream) { - // Do we want it? - if(acceptTypes == null || acceptTypes.contains(mediaType)) - { - // Ensure we have a filename - if(filename == null) - { - anonymousCount++; - filename = "embedded"+anonymousCount+"."+mediaType.getSubtype(); - } - - logger.info("Extracting embedded " + mediaType + " entry " + filename); - - // Save it - Map properties = new HashMap(); - properties.put(ContentModel.PROP_NAME, filename); - NodeRef node = nodeService.createNode( - folder, - ContentModel.ASSOC_CONTAINS, - QName.createQName(filename), - ContentModel.TYPE_CONTENT, - properties - ).getChildRef(); - - ContentWriter writer = contentService.getWriter( - node, ContentModel.PROP_CONTENT, true - ); - writer.setMimetype(mediaType.toString()); - writer.putContent(stream); - } - else - { - logger.info("Skipping embedded " + mediaType + " entry " + filename); - } - } - } - - /** - * This action executor allows you to trigger extraction as an - * action, perhaps from a rule. - * - * Not sprung-in by default, you will need to manually list this in - * an extension context file. You will also need to add properties - * files entries. - */ - public static class ExtractorActionExecutor extends ActionExecuterAbstractBase - { - public static final String NAME = "extractEmbeddedResources"; - public static final String PARAM_MIME_TYPES = "mime-types"; - - private TikaPoweredContainerExtractor extractor; - public void setTikaPoweredContainerExtractor(TikaPoweredContainerExtractor extractor) - { - this.extractor = extractor; - } - - @Override - protected void addParameterDefinitions(List paramList) { - paramList.add(new ParameterDefinitionImpl( - PARAM_MIME_TYPES, - DataTypeDefinition.TEXT, - false, - getParamDisplayLabel(PARAM_MIME_TYPES) - )); - } - - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { - List mimeTypes = null; - String rawTypes = (String)action.getParameterValue(PARAM_MIME_TYPES); - if(rawTypes != null && rawTypes.length() > 0) - { - mimeTypes = new ArrayList(); - StringTokenizer st = new StringTokenizer(rawTypes, ","); - while(st.hasMoreTokens()) - { - mimeTypes.add( st.nextToken().trim() ); - } - } - - extractor.extract(actionedUponNodeRef, mimeTypes); - } - } -/* - - - - - - - - - - - - - - - - - - - - - - - alfresco.extension.extractor-action-messages - - - - - */ -/* -extractEmbeddedResources.title=Extract embedded resources -extractEmbeddedResources.description=Extract resources from within container files, such as .zip or .docx -extractEmbeddedResources.param_mime-types.display-label=Mime Types - */ -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TikaPoweredContentTransformer.java b/repository/src/main/java/org/alfresco/repo/content/transform/TikaPoweredContentTransformer.java deleted file mode 100644 index 65bf884c0d..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TikaPoweredContentTransformer.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.Arrays; -import java.util.List; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tika.extractor.DocumentSelector; -import org.apache.tika.metadata.Metadata; -import org.apache.tika.parser.ParseContext; -import org.apache.tika.parser.Parser; -import org.apache.tika.sax.BodyContentHandler; -import org.apache.tika.sax.ExpandedTitleContentHandler; -import org.xml.sax.ContentHandler; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.TARGET_ENCODING; - -/** - * Provides helpful services for {@link org.alfresco.repo.content.transform.ContentTransformer} - * implementations which are powered by Apache Tika. - * - * To use Tika to transform some content into Text, Html or XML, create an - * implementation of this / use the Auto Detect transformer. - * - * For now, all transformers are registered as regular, rather than explicit - * transformations. This should allow you to register your own explicit - * transformers and have them nicely take priority. - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public abstract class TikaPoweredContentTransformer extends AbstractRemoteContentTransformer -{ - private static final Log logger = LogFactory.getLog(TikaPoweredContentTransformer.class); - private static final List TARGET_MIMETYPES = Arrays.asList(new String[] { - MimetypeMap.MIMETYPE_TEXT_PLAIN, - MimetypeMap.MIMETYPE_HTML, - MimetypeMap.MIMETYPE_XHTML, - MimetypeMap.MIMETYPE_XML}); - - private static final double MEGABYTES = 1024.0 * 1024.0; - - private static final String USAGE_PATTERN = "Content transformation has completed:\n" + - " Transformer: %s\n" + - " Content Reader: %s\n" + - " Memory (MB): Used/Total/Maximum - %f/%f/%f\n" + - " Time Spent: %d ms"; - - protected List sourceMimeTypes; - private String transformerName; - protected DocumentSelector documentSelector; - - /** - * Windows carriage return line feed pair. - */ - protected static final String LINE_BREAK = "\r\n"; - public static final String WRONG_FORMAT_MESSAGE_ID = "transform.err.format_or_password"; - - protected TikaPoweredContentTransformer(List sourceMimeTypes) - { - this.sourceMimeTypes = sourceMimeTypes; - } - - protected TikaPoweredContentTransformer(String[] sourceMimeTypes) - { - this(Arrays.asList(sourceMimeTypes)); - } - - public void setTransformerName(String transformerName) - { - this.transformerName = transformerName; - } - - @Override - protected Log getLogger() - { - return logger; - } - - /** - * Returns the correct Tika Parser to process - * the document. - * If you don't know which you want, use - * {@link TikaAutoContentTransformer} which - * makes use of the Tika auto-detection. - */ - protected abstract Parser getParser(); - - /** - * Can we do the requested transformation via Tika? - * We support transforming to HTML, XML or Text - */ - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if(! sourceMimeTypes.contains(sourceMimetype)) - { - // The source isn't one of ours - return false; - } - - if (TARGET_MIMETYPES.contains(targetMimetype)) - { - // We can output to this - return true; - } - else - { - // We support the source, but not the target - return false; - } - } - - @Override - public String getComments(boolean available) - { - return getCommentsOnlySupports(sourceMimeTypes, TARGET_MIMETYPES, available); - } - - /** - * Returns an appropriate Tika ContentHandler for the - * requested content type. Normally you'll let this - * work as default, but if you need fine-grained - * control of how the Tika events become text then - * override and supply your own. - */ - protected ContentHandler getContentHandler(String targetMimeType, Writer output) - throws TransformerConfigurationException - { - if(MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(targetMimeType)) - { - return new BodyContentHandler(output); - } - - SAXTransformerFactory factory = (SAXTransformerFactory) - SAXTransformerFactory.newInstance(); - TransformerHandler handler = factory.newTransformerHandler(); - handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes"); - handler.setResult(new StreamResult(output)); - - if(MimetypeMap.MIMETYPE_HTML.equals(targetMimeType)) - { - handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "html"); - return new ExpandedTitleContentHandler(handler); - } - else if(MimetypeMap.MIMETYPE_XHTML.equals(targetMimeType) || - MimetypeMap.MIMETYPE_XML.equals(targetMimeType)) - { - handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml"); - } - else - { - throw new TransformerInfoException( - WRONG_FORMAT_MESSAGE_ID, - new IllegalArgumentException("Requested target type " + targetMimeType + " not supported") - ); - } - return handler; - } - - /** - * Sets the document selector, used for determining whether to parse embedded resources. - * - * @param documentSelector DocumentSelector - */ - public void setDocumentSelector(DocumentSelector documentSelector) - { - this.documentSelector = documentSelector; - } - /** - * Gets the document selector, used for determining whether to parse embedded resources, - * null by default so parse all. - * - * @param metadata Metadata - * @param targetMimeType String - * @param options TransformationOptions - * @return the document selector - */ - protected DocumentSelector getDocumentSelector(Metadata metadata, String targetMimeType, TransformationOptions options) - { - return documentSelector; - } - - /** - * By default returns a ParseContent that does not recurse - */ - protected ParseContext buildParseContext(Metadata metadata, String targetMimeType, TransformationOptions options) - { - ParseContext context = new ParseContext(); - DocumentSelector selector = getDocumentSelector(metadata, targetMimeType, options); - if (selector != null) - { - context.set(DocumentSelector.class, selector); - } - return context; - } - - @Override - public void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws Exception - { - OutputStream os = writer.getContentOutputStream(); - String encoding = writer.getEncoding(); - String targetMimeType = writer.getMimetype(); - - Writer ow = new OutputStreamWriter(os, encoding); - - Parser parser = getParser(); - Metadata metadata = new Metadata(); - - ParseContext context = buildParseContext(metadata, targetMimeType, options); - - ContentHandler handler = getContentHandler(targetMimeType, ow); - if(handler == null) - { - throw new TransformerConfigurationException( - "Unable to create Tika Handler for configured output " + targetMimeType - ); - } - - InputStream is = null; - - long startTime = 0; - try { - is = reader.getContentInputStream(); - if (logger.isDebugEnabled()) - { - startTime = System.currentTimeMillis(); - } - - parser.parse(is, handler, metadata, context); - } - finally - { - if(logger.isDebugEnabled()) - { - logger.debug(calculateMemoryAndTimeUsage(reader, startTime)); - } - - if (is != null) - { - try { is.close(); } catch (Throwable e) {} - } - if (ow != null) - { - try { ow.close(); } catch (Throwable e) {} - } - if (os != null) - { - try { os.close(); } catch (Throwable e) {} - } - } - } - - @Override - protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, - ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension, - String targetEncoding) throws Exception - { - long timeoutMs = options.getTimeoutMs(); - - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", transformerName, - "sourceMimetype", sourceMimetype, - "targetMimetype", targetMimetype, - "targetExtension", targetExtension, - TARGET_ENCODING, targetEncoding); - } - - private String calculateMemoryAndTimeUsage(ContentReader reader, long startTime) - { - long endTime = System.currentTimeMillis(); - Runtime runtime = Runtime.getRuntime(); - long totalMemory = runtime.totalMemory(); - return String.format(USAGE_PATTERN, this.getClass().getName(), reader, (totalMemory - runtime.freeMemory()) / MEGABYTES, totalMemory / MEGABYTES, runtime.maxMemory() - / MEGABYTES, (endTime - startTime)); - } - -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfig.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfig.java deleted file mode 100644 index 5c1114ba9f..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfig.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Provides access to transformer configuration and current performance data. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public interface TransformerConfig -{ - /** - * Wild card mimetype and mimetype extension. - */ - public static final String ANY = "*"; - - /** - * Prefix before the transformer name of all property names that contain transformer - * information - */ - static final String CONTENT = "content."; - - /** - * Prefix for all transformer names - */ - static final String TRANSFORMER = "transformer."; - - /** - * The combined content and transformer name prefix of for all property names that contain - * transformer information - */ - static final String PREFIX = CONTENT+TRANSFORMER; - - /** - * The 'transformer name' for system wide defaults for all transformers - */ - static final String DEFAULT_TRANSFORMER = TRANSFORMER+"default"; - - /** - * Name given to the 'SUMMARY' dummy (does not exist) transformer that gathers data - * from all root level transformations - */ - static final String SUMMARY_TRANSFORMER_NAME = "SUMMARY"; - - /** - * An optional separator appended after the normal suffix and following value that - * identifies the 'use' or 'application' of the property. Example uses include 'index' - * 'doclib' and 'preview'. The corresponding configuration value is only used in the - * context of the specified usage. - */ - static final String USE = ".use."; - - /** - * The separator between the transformer name and two mimetype extensions in a property name. - */ - static final String EXTENSIONS = ".extensions."; - - /** - * The separator between the transformer name and wildcarded mimetypes rather than extensions in a property name. - * Effectively equivalent to multiple properties using the {@link #EXTENSIONS}. - */ - static final String MIMETYPES = ".mimetypes."; - - /** - * Both extension and minetype separators. - */ - public static String[] SEPARATORS = new String[] {EXTENSIONS , MIMETYPES}; - - /** - * The suffix to property names for creating dynamic complex transformers - */ - public static final String PIPELINE = ".pipeline"; - - /** - * The suffix to property names for creating dynamic failover transformers - */ - public static final String FAILOVER = ".failover"; - - /** - * The suffix to property names to indicate that a transformer is available. - * If not specified, defaults to true, indicating it may be selected rather - * only being available as a component of another transformer. - */ - public static final String AVAILABLE = ".available"; - - /** - * Separator between transformers and mimetype extensions in a dynamic compound property value. - */ - public static final char PIPE = '|'; - - /** - * The suffix to property names for supported and unsupported combinations. - */ - static final String SUPPORTED = ".supported"; - - /** - * The suffix to property names for the priority. - */ - static final String PRIORITY = ".priority"; - - /** - * The suffix to property names for the blacklist. - */ - static final String BLACKLIST = ".blacklist"; - - /** - * The suffix to property names to indicate which Alfresco version the transformer is - * available with. If not specified it is not restricted. So if set to "Enterprise" it - * is not available to Community. - * @see #AMP - */ - static final String EDITION = ".edition"; - - /** - * The suffix to property names to indicate which Alfresco AMPs the transformer is - * available with. The value should be the AMP's ID. If not specified it is not restricted. - * @see #EDITION - */ - static final String AMP = ".amp"; - - /** - * The suffix to property names for the threshold count. - */ - static final String THRESHOLD_COUNT = ".thresholdCount"; - - /** - * The suffix to property names for the error time. - */ - static final String ERROR_TIME = ".errorTime"; - - /** - * The suffix to property names for the the average time. Only used in the initial setup of - * TransformerData. This is a historical property used by the 'Transformation Server' to set - * an effective priority. - */ - static final String INITIAL_TIME = ".time"; - - /** - * The suffix to property names for the the average count. Only used in the initial setup of - * TransformerData. This is a historical property used by the 'Transformation Server' to set - * an effective priority. - */ - static final String INITIAL_COUNT = ".count"; - - /** - * Suffixes for limits. - */ - static final String MAX_SOURCE_SIZE_K_BYTES = '.'+TransformationOptionLimits.OPT_MAX_SOURCE_SIZE_K_BYTES; - static final String TIMEOUT_MS = '.'+TransformationOptionLimits.OPT_TIMEOUT_MS; - static final String MAX_PAGES = '.'+TransformationOptionLimits.OPT_MAX_PAGES; - static final String READ_LIMIT_K_BYTES = '.'+TransformationOptionLimits.OPT_READ_LIMIT_K_BYTES; - static final String READ_LIMIT_TIME_MS = '.'+TransformationOptionLimits.OPT_READ_LIMIT_TIME_MS; - static final String PAGE_LIMIT = '.'+TransformationOptionLimits.OPT_PAGE_LIMIT; - - /** - * To support the historical concept of EXPLICIT transformers, all such transformers - * are given a {@link #PRIORITY_EXPLICIT} (50). By default transformers have a default of 10. - * A value of 5 allows better transformers to be added later. - */ - public int PRIORITY_EXPLICIT = 50; - - /** - * By default transformers have a priority of 100. - */ - public int PRIORITY_DEFAULT = 100; - - /** - * Suffixes to property names used to define transformation limits - */ - static final Collection LIMIT_SUFFIXES = Arrays.asList(new String [] { - MAX_SOURCE_SIZE_K_BYTES, - TIMEOUT_MS, - MAX_PAGES, - READ_LIMIT_K_BYTES, - READ_LIMIT_TIME_MS, - PAGE_LIMIT - }); - - /** - * Suffix pairs (max and limit values) to property names used to define transformation limits - */ - public final String[][] LIMIT_PAIR_SUFFIXES = new String[][] - { - {MAX_SOURCE_SIZE_K_BYTES, READ_LIMIT_K_BYTES}, - {TIMEOUT_MS, READ_LIMIT_TIME_MS}, - {MAX_PAGES, PAGE_LIMIT} - }; - - /** - * All suffixes to property names used to transformer configuration - */ - static final Collection ALL_SUFFIXES = Arrays.asList(new String [] { - MAX_SOURCE_SIZE_K_BYTES, - TIMEOUT_MS, - MAX_PAGES, - READ_LIMIT_K_BYTES, - READ_LIMIT_TIME_MS, - PAGE_LIMIT, - SUPPORTED, - AVAILABLE, - PRIORITY, - BLACKLIST, - ERROR_TIME, - INITIAL_TIME, - INITIAL_COUNT, - THRESHOLD_COUNT, - FAILOVER, - PIPELINE - }); - - /** - * No suffixes to property names used to define transformer settings. - */ - public static final Collection NO_SUFFIXES = Collections.singletonList(""); - - static final String ENTRIES = "entries"; - - /** - * The number of debug lines to keep. Turned off if <= 0. - */ - public static final String DEBUG_ENTRIES = TRANSFORMER+"debug."+ENTRIES; - - /** - * The number of log lines to keep. Turned off if <= 0. - */ - public static final String LOG_ENTRIES = TRANSFORMER+"log."+ENTRIES; - - /** - * A white list of declared and detected mimetypes, that don't match, but should still be transformed. - */ - // Has ".mimetypes" on the end as we might one day wish to use extensions too (to simplify the entry). - static final String STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES = TRANSFORMER+"strict.mimetype.check.whitelist"+MIMETYPES.substring(0, MIMETYPES.length()-1); - - /** - * Returns a transformer property value. - * @param name of the property. - * @return a transformer property or {@code null} if not set. - */ - String getProperty(String name); - - /** - * Returns a sorted set of all transformer properties, their values and includes - * comments about the properties. - * @param changesOnly only custom values will be included. - * @return a multi-line String which is never {code null}. - */ - String getProperties(boolean changesOnly); - - /** - * Removes transformer properties. - * - * @param propertyNames new line separated names. Any values will be ignored. - * @return the number of properties removed. - * @throws IllegalArgumentException if the properties were not set or the - * list contains errors. - */ - int removeProperties(String propertyNames); - - /** - * Sets a transformer property values. These will be stored in the database but on an MBean - * reset is cleared. - * - * @param propertyNamesAndValues new line separated name and values - * @return the number of properties set. - * @throws IllegalArgumentException the list contains errors. - */ - int setProperties(String propertyNamesAndValues); - - /** - * Returns and creates if needed the {@link TransformerStatistics} object for the combination of - * transformer, sourceMimetype and targetMimetype. When transformer is null this is the - * system wide summary object for a combination of sourceMimetype and targetMimetype. - * When both sourceMimetype and targetMimetype are null this is the transformer's summary - * object. When all three parameters are null this is the system wide summary for all - * transformers. - * @param transformer the transformer for which data is being recorded. - * @param sourceMimetype the source mimetype. - * @param targetMimetype the source mimetype. - * @param createNew indicates if a new object should be created if it does not exist. - * @return the requested {@link TransformerStatistics}. - */ - public TransformerStatistics getStatistics(ContentTransformer transformer, String sourceMimetype, String targetMimetype, boolean createNew); - - /** - * Returns the limits defined for the combination of transformer, sourceMimetype and targetMimetype. - * When the transformer is null, this is a default value. When both sourceMimetype and targetMimetype - * are null this is a default for the specified transformer. - * @param transformer - * @param sourceMimetype - * @param targetMimetype - * @param use to which the limits will be put. For example "index", "webpreview", "doclib", "syncRule", - * "aysncRule". {@code null} is the default. - * @return the combined (takes into account defaults from higher levels) limits for the combination. - */ - public TransformationOptionLimits getLimits(ContentTransformer transformer, String sourceMimetype, String targetMimetype, String use); - - /** - * Returns true if the supplied mimetype transformation pair is allowed by the list of supported - * and unsupported transformations. - * @param transformer - * @param sourceMimetype - * @param targetMimetype - * @param options not currently used - */ - public boolean isSupportedTransformation(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, TransformationOptions options); - - /** - * Returns the priority of the specified transformer for the the combination of source and target mimetype. - * @param contentTransformerHelper - * @param sourceMimetype - * @param targetMimetype - * @return the priority. To support the historical concept of EXPLICIT transformers, all such transformers - * are given a {@link #PRIORITY_EXPLICIT} (50). By default transformers have a default of 100. - */ - public int getPriority(ContentTransformer contentTransformerHelper, - String sourceMimetype, String targetMimetype); - - - /** - * Returns a list of blacklisted NodeRefs of the specified transformer for the the combination of source and target mimetype. - * @param transformer - * @param sourceMimetype - * @param targetMimetype - * @return the blacklist or null is none. - */ - List getBlacklist(ContentTransformer transformer, String sourceMimetype, - String targetMimetype); - - /** - * When strict mimetype checking is performed before a transformation, this method is called. - * There are a few issues with the Tika mimetype detection. As a result we still allow some - * transformations to take place even if there is a discrepancy between the detected and - * declared mimetypes. - * @param declaredMimetype the mimetype on the source node - * @param detectedMimetype returned by Tika having looked at the content. - * @return true if the transformation should take place. This includes the case where the - * detectedMimetype is null (returned by Tika when the mimetypes are the same), or - * the supplied pair of mimetypes have been added to the - * {@code}transformer.strict.mimetype.check.whitelist{@code}. - */ - boolean strictMimetypeCheck(String declaredMimetype, String detectedMimetype); - - /** - * Returns the threshold of the transformer. It is only after this number of transformation attempts - * that the average time is used. - * @param contentTransformerHelper - * @param sourceMimetype - * @param targetMimetype - * @return the threshold. - */ - - public int getThresholdCount(ContentTransformer contentTransformerHelper, String sourceMimetype, - String targetMimetype); -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigDynamicTransformers.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigDynamicTransformers.java deleted file mode 100644 index 5c3d1ffd5c..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigDynamicTransformers.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.AMP; -import static org.alfresco.repo.content.transform.TransformerConfig.AVAILABLE; -import static org.alfresco.repo.content.transform.TransformerConfig.EDITION; -import static org.alfresco.repo.content.transform.TransformerConfig.FAILOVER; -import static org.alfresco.repo.content.transform.TransformerConfig.PIPE; -import static org.alfresco.repo.content.transform.TransformerConfig.PIPELINE; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.rendition2.LegacySynchronousTransformClient; -import org.alfresco.service.cmr.module.ModuleService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.descriptor.DescriptorService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Adds dynamic transformers defined in alfresco global properties to the ContentTransformerRegistry. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigDynamicTransformers extends TransformerPropertyNameExtractor -{ - private static final Log logger = LogFactory.getLog(TransformerConfigDynamicTransformers.class); - int errorCount = 0; - private final List dynamicTransformers = new ArrayList(); - - public TransformerConfigDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties, - MimetypeService mimetypeService, LegacySynchronousTransformClient legacySynchronousTransformClient, ContentTransformerRegistry transformerRegistry, - TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService, - Properties globalProperties) - { - createDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, moduleService, descriptorService, globalProperties); - } - - private void createDynamicTransformers(TransformerConfig transformerConfig, TransformerProperties transformerProperties, - MimetypeService mimetypeService, LegacySynchronousTransformClient legacySynchronousTransformClient, ContentTransformerRegistry transformerRegistry, - TransformerDebug transformerDebug, ModuleService moduleService, DescriptorService descriptorService, - Properties globalProperties) - { - Collection SUFFIXES = Arrays.asList(new String [] { - FAILOVER, - PIPELINE, - AVAILABLE, - EDITION, - AMP - }); - - Map - transformerSourceTargetSuffixValues = - getTransformerSourceTargetValuesMap(SUFFIXES, true, true, false, transformerProperties, mimetypeService); - Collection properties = - transformerSourceTargetSuffixValues.values(); - - // Repeat until we cannot create any more transformers or all have been created - Collection processed = - new ArrayList(); - do - { - processed.clear(); - for (TransformerSourceTargetSuffixValue property: properties) - { - if (property.suffix.equals(PIPELINE) || property.suffix.equals(FAILOVER)) - { - try - { - String edition = getProperty(property.transformerName, null, null, EDITION, - null, transformerSourceTargetSuffixValues); - String moduleId = getProperty(property.transformerName, null, null, AMP, - null, transformerSourceTargetSuffixValues); - if (!supportedEdition(descriptorService, edition)) - { - processed.add(property); - logger.debug(property.transformerName+" ignored. As it is an "+edition+" only transformer."); - } - else if (!supportedModule(moduleService, moduleId)) - { - processed.add(property); - logger.debug(property.transformerName+" ignored. As the AMP "+moduleId+" is not installed."); - } - else - { - String availableStr = getProperty(property.transformerName, null, null, AVAILABLE, - null, transformerSourceTargetSuffixValues); - boolean available = availableStr == null || "true".equalsIgnoreCase(availableStr); - - AbstractContentTransformer2 transformer = property.suffix.equals(PIPELINE) - ? createComplexTransformer(property, transformerConfig, mimetypeService, - legacySynchronousTransformClient, transformerRegistry, transformerDebug, available, - globalProperties) - : createFailoverTransformer(property, transformerConfig, mimetypeService, - transformerRegistry, transformerDebug, available, - globalProperties); - transformer.register(); - processed.add(property); - dynamicTransformers.add(transformer); - logger.debug(property.transformerName+" added"); - } - } - catch (IllegalArgumentException e) - { - // Thrown if unknown sub transformer name - it might be dynamic - } - catch (AlfrescoRuntimeException e) - { - // Thrown if the mimetype is invalid or the transformer already exists - processed.add(property); - error(e.getMessage()); - } - } - } - } while (properties.removeAll(processed) && properties.size() > 0); - - for (TransformerSourceTargetSuffixValue property: properties) - { - if (property.suffix.equals(PIPELINE) || property.suffix.equals(FAILOVER)) - { - error("Cannot create dynamic transformer "+property.transformerName+ - " as sub transformers could not be found or created (\""+ - property.value+"\")."); - } - } - } - - private boolean supportedEdition(DescriptorService descriptorService, String edition) - { - return descriptorService == null || edition == null || - descriptorService.getServerDescriptor().getEdition().equals(edition); - } - - private boolean supportedModule(ModuleService moduleService, String moduleId) - { - return moduleService == null || moduleId == null || - moduleService.getModule(moduleId) != null; - } - - private AbstractContentTransformer2 createComplexTransformer(TransformerSourceTargetSuffixValue property, - TransformerConfig transformerConfig, - MimetypeService mimetypeService, LegacySynchronousTransformClient legacySynchronousTransformClient, - ContentTransformerRegistry transformerRegistry, TransformerDebug transformerDebug, - boolean available, Properties globalProperties) - { - List transformers = new ArrayList(); - List intermediateMimetypes = new ArrayList(); - - extractTransformersAndMimetypes(property, transformers, intermediateMimetypes, - mimetypeService, transformerRegistry); - - ComplexContentTransformer transformer = new ComplexContentTransformer() - { - @Override - public String getComments(boolean available) - { - return getCommentNameAndAvailable(true); // suppress the ...available=false line as it is reported anyway if set - } - }; - setupContentTransformer2(property, transformerConfig, mimetypeService, - transformerRegistry, transformerDebug, available, transformer, transformers, globalProperties); - - // baseComplexContentTransformer - transformer.setLegacySynchronousTransformClient(legacySynchronousTransformClient); - - // ComplexContentTransformer - transformer.setTransformers(transformers); - transformer.setIntermediateMimetypes(intermediateMimetypes); - - return transformer; - } - - private AbstractContentTransformer2 createFailoverTransformer(TransformerSourceTargetSuffixValue property, - TransformerConfig transformerConfig, - MimetypeService mimetypeService, - ContentTransformerRegistry transformerRegistry, TransformerDebug transformerDebug, - boolean available, Properties globalProperties) - { - List transformers = new ArrayList(); - - extractTransformersAndMimetypes(property, transformers, null, - mimetypeService, transformerRegistry); - - FailoverContentTransformer transformer = new FailoverContentTransformer() - { - @Override - public String getComments(boolean available) - { - return getCommentNameAndAvailable(true); // suppress the ...available=false line as it is reported anyway if set - } - }; - setupContentTransformer2(property, transformerConfig, mimetypeService, - transformerRegistry, transformerDebug, available, transformer, transformers, globalProperties); - - // FailoverContentTransformer - transformer.setTransformers(transformers); - - return transformer; - } - - /** - * Populates transformers and intermediateMimetypes (optional) from the supplied property value. - * @throws AlfrescoRuntimeException if the value is invalid - * @throws IllegalArgumentException if sub-transformer does not exist - */ - private void extractTransformersAndMimetypes(TransformerSourceTargetSuffixValue property, - List transformers, List intermediateMimetypes, - MimetypeService mimetypeService, ContentTransformerRegistry transformerRegistry) - { - String[] subTransformersAndMimetypes = property.value.split("\\"+PIPE); - - - boolean hasMimetypes = intermediateMimetypes != null; - if ((!hasMimetypes && subTransformersAndMimetypes.length < 2) || - (hasMimetypes && (subTransformersAndMimetypes.length < 3 || subTransformersAndMimetypes.length%2 == 0))) - { - throw new AlfrescoRuntimeException("Cannot create dynamic transformer "+ - property.transformerName+" as the value "+property.value+" has the wrong number of components."); - } - - boolean isTransformerName = true; - for (String name: subTransformersAndMimetypes) - { - if (isTransformerName) - { - try - { - ContentTransformer subTransformer = TransformerConfig.ANY.equals(name) - ? null - // throws IllegalArgumentException if sub-transformer does not exist - : transformerRegistry.getTransformer(TransformerConfig.TRANSFORMER+name); - transformers.add(subTransformer); - } - catch (IllegalArgumentException e) - { - logger.trace(property.transformerName+" did not find "+TransformerConfig.TRANSFORMER+name); - throw e; - } - } - else - { - String mimetype = mimetypeService.getMimetype(name); - if (!MimetypeMap.EXTENSION_BINARY.equals(name) && MimetypeMap.MIMETYPE_BINARY.equals(mimetype)) - { - throw new AlfrescoRuntimeException("Cannot create dynamic transformer "+ - property.transformerName+" as the extension "+name+" is unregistered."); - } - intermediateMimetypes.add(mimetype); - } - if (hasMimetypes) - { - isTransformerName = !isTransformerName; - } - } - } - - // Set properties common to ComplexContentTransformer and FailoverContentTransformer. - private void setupContentTransformer2(TransformerSourceTargetSuffixValue property, - TransformerConfig transformerConfig, MimetypeService mimetypeService, - ContentTransformerRegistry transformerRegistry, - TransformerDebug transformerDebug, boolean available, - AbstractContentTransformer2 transformer, List transformers, - Properties globalProperties) - { - try - { - // Throws an exception if it does not exist - transformerRegistry.getTransformer(property.transformerName); - throw new AlfrescoRuntimeException("Cannot create dynamic transformer "+ - property.transformerName+" as a transformer with that name already exists."); - } - catch (IllegalArgumentException e) - { - // good news it does not exist - } - - // unregisteredBaseContentTransformer - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug((LegacyTransformerDebug)transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.setRegistry(transformerRegistry); - - // baseContentTransformer - transformer.setRegisterTransformer(true); - - // AbstractContentTransformer2 - transformer.setBeanName(property.transformerName); - transformer.setRegisterTransformer(available); - transformer.setStrictMimeTypeCheck(getBoolean(globalProperties, "transformer.strict.mimetype.check")); - transformer.setRetryTransformOnDifferentMimeType(getBoolean(globalProperties, "content.transformer.retryOn.different.mimetype")); - } - - private boolean getBoolean(Properties properties, String name) - { - String value = properties == null ? null : properties.getProperty(name); - return "true".equalsIgnoreCase(value); - } - - private void error(String msg) - { - errorCount++; - logger.error(msg); - } - - int getErrorCount() - { - return errorCount; - } - - public void removeTransformers(ContentTransformerRegistry transformerRegistry) - { - for (ContentTransformer transformer: dynamicTransformers) - { - transformerRegistry.removeTransformer(transformer); - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigImpl.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigImpl.java deleted file mode 100644 index 093e37ca95..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigImpl.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.repo.rendition2.LegacySynchronousTransformClient; -import org.alfresco.service.cmr.module.ModuleService; -import org.alfresco.service.cmr.repository.MalformedNodeRefException; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.descriptor.DescriptorService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * Provides access to transformer configuration and current performance data. - * - * @author Alan Davis - * - * @deprecated The RenditionService is being replace by the simpler async RenditionService2. - */ -@Deprecated -public class TransformerConfigImpl extends AbstractLifecycleBean implements TransformerConfig -{ - private static final Log logger = LogFactory.getLog(TransformerConfigImpl.class); - - private MimetypeService mimetypeService; - - private LegacySynchronousTransformClient legacySynchronousTransformClient; - - private ContentTransformerRegistry transformerRegistry; - - private TransformerDebug transformerDebug; - - // Log - private TransformerLog transformerLog; - - // Log Debug - private TransformerDebugLog transformerDebugLog; - - // Holds statistics about each transformer, sourceMimeType and targetMimetype combination. - // A null transformer is the system wide value. Null sourceMimeType and targetMimetype values are - // transformer wide summaries. - private TransformerConfigStatistics statistics; - - // Transformer limits. - private TransformerConfigLimits limits; - - // Supported and unsupported transformations. - private TransformerConfigSupported supported; - - // Priorities - private TransformerConfigProperty priorities; - - // Blacklist - private TransformerConfigProperty blacklist; - - // Threshold counts - Initially there will only be the system wide value, but - // having this structure provides flexibility. - private TransformerConfigProperty thresholdCounts; - - // Times to be recorded if there is an error - Initially there will only be the system wide value, but - // having this structure provides flexibility. - private TransformerConfigProperty errorTimes; - - // For backward compatibility where priority could not be set, with AMPs that need to have their - // transformer used rather than an inbuilt one. Achieved by making the inbuilt transformers look - // poor. Generally contains no entries, other than the system wide 0 values. - private TransformerConfigProperty initialAverageTimes; - private TransformerConfigProperty initialCounts; - - private TransformerPropertySetter propertySetter; - - // Needed to read properties. - private ChildApplicationContextFactory subsystemFactory; - - // Needed to read global properties. - private Properties globalProperties; - - private ModuleService moduleService; - - private DescriptorService descriptorService; - - private TransformerProperties transformerProperties; - - private TransformerConfigDynamicTransformers dynamicTransformers; - - private Map> strictMimetypeExceptions; - - /** - * Sets of the mimetype service. - * - * @param mimetypeService - */ - public void setMimetypeService(MimetypeService mimetypeService) - { - this.mimetypeService = mimetypeService; - } - - public void setLegacySynchronousTransformClient(LegacySynchronousTransformClient legacySynchronousTransformClient) - { - this.legacySynchronousTransformClient = legacySynchronousTransformClient; - } - - public void setContentTransformerRegistry(ContentTransformerRegistry transformerRegistry) - { - this.transformerRegistry = transformerRegistry; - } - - public void setTransformerDebug(TransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - public void setTransformerLog(TransformerLog transformerLog) - { - this.transformerLog = transformerLog; - } - - public void setTransformerDebugLog(TransformerDebugLog transformerDebugLog) - { - this.transformerDebugLog = transformerDebugLog; - } - - public void setGlobalProperties(Properties globalProperties) - { - this.globalProperties = globalProperties; - } - - public void setModuleService(ModuleService moduleService) - { - this.moduleService = moduleService; - } - - public void setDescriptorService(DescriptorService descriptorService) - { - this.descriptorService = descriptorService; - } - - /** - * Called by spring after bean is initialised. - */ - public void initialise() - { - ChildApplicationContextFactory subsystem = getSubsystem(); - transformerProperties = new TransformerProperties(subsystem, globalProperties); - - dynamicTransformers = new TransformerConfigDynamicTransformers(this, transformerProperties, mimetypeService, - legacySynchronousTransformClient, transformerRegistry, transformerDebug, moduleService, descriptorService, globalProperties); - statistics= new TransformerConfigStatistics(this, mimetypeService); - limits = new TransformerConfigLimits(transformerProperties, mimetypeService); - supported = new TransformerConfigSupported(transformerProperties, mimetypeService); - priorities = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, Integer.toString(PRIORITY_DEFAULT)); - blacklist = new TransformerConfigProperty(transformerProperties, mimetypeService, BLACKLIST, ""); - thresholdCounts = new TransformerConfigProperty(transformerProperties, mimetypeService, THRESHOLD_COUNT, "3"); - errorTimes = new TransformerConfigProperty(transformerProperties, mimetypeService, ERROR_TIME, "120000"); - initialAverageTimes = new TransformerConfigProperty(transformerProperties, mimetypeService, INITIAL_TIME, "0"); - initialCounts = new TransformerConfigProperty(transformerProperties, mimetypeService, INITIAL_COUNT, "100000"); - propertySetter = new TransformerPropertySetter(transformerProperties, mimetypeService, transformerRegistry); - strictMimetypeExceptions = getStrictMimetypeExceptions(transformerProperties); - } - - /** - * Returns the 'transformers' subsystem which among other things holds transformer properties. - */ - synchronized ChildApplicationContextFactory getSubsystem() - { - if (subsystemFactory == null) - { - subsystemFactory = getApplicationContext().getBean("Transformers", ChildApplicationContextFactory.class); - } - return subsystemFactory; - } - - @Override - protected void onBootstrap(ApplicationEvent event) - { - } - - @Override - protected void onShutdown(ApplicationEvent event) - { - dynamicTransformers.removeTransformers(transformerRegistry); - } - - /** - * {@inheritDoc} - */ - @Override - public String getProperty(String name) - { - return transformerProperties.getProperty(name); - } - - @Override - public String getProperties(boolean changesOnly) - { - return new TransformerPropertyGetter(changesOnly, transformerProperties, mimetypeService, - transformerRegistry, transformerLog, transformerDebugLog).toString(); - } - - /** - * {@inheritDoc} - */ - @Override - public int setProperties(String propertyNamesAndValues) - { - return propertySetter.setProperties(propertyNamesAndValues); - } - - @Override - public int removeProperties(String propertyNames) - { - return propertySetter.removeProperties(propertyNames); - } - - /** - * {@inheritDoc} - */ - @Override - public TransformerStatistics getStatistics(ContentTransformer transformer, String sourceMimetype, String targetMimetype, boolean createNew) - { - return statistics.getStatistics(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype), createNew); - } - - /** - * {@inheritDoc} - */ - @Override - public TransformationOptionLimits getLimits(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, String use) - { - return limits.getLimits(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype), use); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSupportedTransformation(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - return supported.isSupportedTransformation(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype), options); - } - - /** - * {@inheritDoc} - */ - @Override - public int getPriority(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - try - { - return priorities.getInt(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype)); - } - catch (NumberFormatException e1) - { - try - { - return priorities.getInt(null, null, null); - } - catch (NumberFormatException e2) - { - return 0; - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public List getBlacklist(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - try - { - return blacklist.getNodeRefs(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype)); - } - catch (MalformedNodeRefException e1) - { - try - { - return priorities.getNodeRefs(null, null, null); - } - catch (MalformedNodeRefException e2) - { - return null; - } - } - } - - // Build up a Map keyed on declared source node mimetype to a Set of detected mimetypes that should allow - // the transformation to take place. i.e. The cases that Tika gets wrong. - private Map> getStrictMimetypeExceptions(TransformerProperties transformerProperties2) - { - Map> strictMimetypeExceptions = new HashMap<>(); - - String whitelist = getProperty(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES); - whitelist = whitelist == null ? "" : whitelist.trim(); - if (whitelist.length() > 0) - { - String[] mimetypes = whitelist.split(";"); - - if (mimetypes.length % 2 != 0) - { - logger.error(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES+" should have an even number of mimetypes as a ; separated list."); - } - else - { - Set detectedMimetypes = null; - for (String mimetype: mimetypes) - { - mimetype = mimetype.trim(); - if (mimetype.isEmpty()) - { - logger.error(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES+" contains a blank mimetype."); - // Still okay to use it in the map though, but it will be ignored. - } - - if (detectedMimetypes == null) - { - detectedMimetypes = strictMimetypeExceptions.get(mimetype); - if (detectedMimetypes == null) - { - detectedMimetypes = new HashSet<>(); - strictMimetypeExceptions.put(mimetype, detectedMimetypes); - } - } - else - { - detectedMimetypes.add(mimetype); - detectedMimetypes = null; - } - } - } - } - - return strictMimetypeExceptions; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean strictMimetypeCheck(String declaredMimetype, String detectedMimetype) - { - if (detectedMimetype == null) - { - return true; - } - - Set detectedMimetypes = strictMimetypeExceptions.get(declaredMimetype); - return detectedMimetypes != null && detectedMimetypes.contains(detectedMimetype); - } - - /** - * {@inheritDoc} - */ - @Override - public int getThresholdCount(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - try - { - return thresholdCounts.getInt(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype)); - } - catch (NumberFormatException e1) - { - try - { - return thresholdCounts.getInt(null, null, null); - } - catch (NumberFormatException e2) - { - return 0; - } - } - } - - /** - * Gets the time to be recorded if there is an error. - */ - long getErrorTime(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - try - { - return errorTimes.getLong(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype)); - } - catch (NumberFormatException e1) - { - try - { - return errorTimes.getInt(null, null, null); - } - catch (NumberFormatException e2) - { - return 0; - } - } - } - - /** - * Gets the initial average time to be set for a transformer. Used historically to set the priority of transformers in AMPs. - * The initial count value may also obtained via {@link #getInitialCount(ContentTransformer, String, String)}. - */ - long getInitialAverageTime(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - try - { - return initialAverageTimes.getLong(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype)); - } - catch (NumberFormatException e1) - { - try - { - return initialAverageTimes.getInt(null, null, null); - } - catch (NumberFormatException e2) - { - return 0; - } - } - } - - /** - * Gets the initial transformer count to be set for a transformer. Used historically to set the priority of transformers in AMPs. - * Only called if {@link #getInitialAverageTime(ContentTransformer, String, String)} returns a value larger than 0. - */ - int getInitialCount(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - { - try - { - return initialCounts.getInt(transformer, stdMimetype(sourceMimetype), stdMimetype(targetMimetype)); - } - catch (NumberFormatException e1) - { - try - { - return initialCounts.getInt(null, null, null); - } - catch (NumberFormatException e2) - { - return 0; - } - } - } - - // Returns the main or standard mimetype. Needed were multiple mimetypes share the same extension or are unknown so binary. - private String stdMimetype(String mimetype) - { - return mimetypeService.getMimetype(mimetypeService.getExtension(mimetype)); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java deleted file mode 100644 index a451e8fd74..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.DEFAULT_TRANSFORMER; -import static org.alfresco.repo.content.transform.TransformerConfig.LIMIT_SUFFIXES; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptionPair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Provides access to transformer limits defined via properties. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigLimits extends TransformerPropertyNameExtractor -{ - private static Log logger = LogFactory.getLog(TransformerConfigLimits.class); - - private static final String NOT_THROWN_MESSAGE = "Both max and limit should not be set."; - - // Map using use, transformer, source mimetype and target mimetype to a set of limits. - // Entries higher up the hierarchy are added so that values may be defaulted down. - // Entries are added lower down the hierarchy when a search takes place. - private Map>> limitsMap; - - // The 'use' value that had properties defined, including ANY for the default. - private Set uses; - - public TransformerConfigLimits(TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - setLimits(transformerProperties, mimetypeService); - } - - /** - * Sets the transformer limits created from properties. - */ - private void setLimits(TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - limitsMap = new ConcurrentHashMap>>(); - uses = new HashSet(); - - // Gets all the transformer, source and target combinations in properties that define limits. - Map allUseMap = - getTransformerSourceTargetValuesMap(LIMIT_SUFFIXES, true, true, true, transformerProperties, mimetypeService); - - // Get the set 'use' values. - uses.add(ANY); - for (TransformerSourceTargetSuffixValue property: allUseMap.values()) - { - String propertyUse = property.use == null ? ANY : property.use; - uses.add(propertyUse); - } - - // Populate the limitsMap for each 'use'. - for (String use: uses) - { - Collection properties = getPropertiesForUse(use, allUseMap); - - // Add the system wide default just in case it is not included, as we always need this one - getOrCreateTransformerOptionLimits(DEFAULT_TRANSFORMER, ANY, ANY, use); - - TransformationOptionLimits limits; - for (int pass=0; pass<=3; pass++) - { - for (TransformerSourceTargetSuffixValue property1: properties) - { - int origLevel = getLevel(property1.transformerName, property1.sourceMimetype); - if (pass == origLevel) - { - logger.debug(property1); - String transformerName = (property1.transformerName == null) - ? DEFAULT_TRANSFORMER : property1.transformerName; - limits = getOrCreateTransformerOptionLimits(transformerName, - property1.sourceMimetype, property1.targetMimetype, use); - setTransformationLimitsFromProperties(limits, property1.value, property1.suffix); - debug("V", transformerName, property1.sourceMimetype, property1.targetMimetype, use, limits); - } - } - } - } - logger.debug(this); - } - - /** - * Sets the transformer limits for a single use from properties. Method extracted so that - * it is possible to write a simpler unit test, that changes to the order of the - * properties. The order changed between Java 6, 7 and 8, resulting in MNT-14295. The original - * outer method cannot be used as it creates the list from a map (allUseMap) that it also - * creates and the order of values from that map cannot be controlled from a test. - */ - void setLimits(String use, Collection properties) - { - // Add the system wide default just in case it is not included, as we always need this one - getOrCreateTransformerOptionLimits(DEFAULT_TRANSFORMER, ANY, ANY, use); - - TransformationOptionLimits limits; - for (int pass=0; pass<=3; pass++) - { - for (TransformerSourceTargetSuffixValue property: properties) - { - int origLevel = getLevel(property.transformerName, property.sourceMimetype); - if (pass == origLevel) - { - logger.debug(property); - String transformerName = (property.transformerName == null) - ? DEFAULT_TRANSFORMER : property.transformerName; - limits = getOrCreateTransformerOptionLimits(transformerName, - property.sourceMimetype, property.targetMimetype, use); - setTransformationLimitsFromProperties(limits, property.value, property.suffix); - debug("V", transformerName, property.sourceMimetype, property.targetMimetype, use, limits); - } - } - } - } - - /** - * Returns the 'effective' properties for the given 'use'. - * - * These will be made up from the properties defined for that use plus default properties - * that don't have a matching use property, as long as there is not a matching use at a - * higher level.

- * - *

  • If there is a system wide property with the use value, all other properties without - * the same use value are ignored.
  • - *
  • If there is a transformer wide property with this use value, all other transformer - * wide properties for the same transformer without a use value are ignored. - *
  • If there is mimetype property with the use value, the default property for - * the same combination is ignored.
  • - * @param use value such as "doclib" or "index" - * @param allUseMap the complete set of transformer properties that includes blank and all - * use values. - * @return a set of properties for the specific use. - */ - private Collection getPropertiesForUse(String use, - Map allUseMap) - { - Collection properties = new ArrayList(); - - boolean systemWideUse = false; - Set transformerWideUse = new HashSet<>(); - for (TransformerSourceTargetSuffixValue property: allUseMap.values()) - { - String propertyUse = property.use == null ? ANY : property.use; - if (propertyUse.equals(use)) - { - if (DEFAULT_TRANSFORMER.equals(property.transformerName)) - { - systemWideUse = true; - break; - } - - transformerWideUse.add(property.transformerName); - } - } - - for (TransformerSourceTargetSuffixValue property: allUseMap.values()) - { - String propertyUse = property.use == null ? ANY : property.use; - if (propertyUse.equals(use)) - { - properties.add(property); - } - else if (!systemWideUse && propertyUse.equals(ANY)) - { - if (DEFAULT_TRANSFORMER.equals(property.transformerName) || - !transformerWideUse.contains(property.transformerName)) - { - // If there is NOT a similar 'use' property... - if (getProperty(property.transformerName, property.sourceExt, property.targetExt, - property.suffix, use, allUseMap) == null) - { - properties.add(property); - } - } - } - } - - return properties; - } - - /** - * Returns the TransformationOptionLimits for the use, transformer and mimetype combination, - * creating and adding one if not already included. - */ - private TransformationOptionLimits getOrCreateTransformerOptionLimits(String transformerName, - String sourceMimetype, String targetMimetype, String use) - { - Map> transformerLimits = limitsMap.get(use); - if (transformerLimits == null) - { - transformerLimits = new ConcurrentHashMap>(); - limitsMap.put(use, transformerLimits); - } - - DoubleMap mimetypeLimits = transformerLimits.get(transformerName); - if (mimetypeLimits == null) - { - mimetypeLimits = new DoubleMap(ANY, ANY); - transformerLimits.put(transformerName, mimetypeLimits); - } - - TransformationOptionLimits limits = mimetypeLimits.getNoWildcards(sourceMimetype, targetMimetype); - if (limits == null) - { - // Try the wildcard version, and use any match as the basis for a new entry - limits = mimetypeLimits.get(sourceMimetype, targetMimetype); - - limits = newTransformationOptionLimits(transformerName, sourceMimetype, targetMimetype, limits, use); - mimetypeLimits.put(sourceMimetype, targetMimetype, limits); - } - else - { - debug("G", transformerName, sourceMimetype, targetMimetype, use, limits); - } - - return limits; - } - - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - for (Entry>> useEntry: limitsMap.entrySet()) - { - for (Entry> transformerEntry: useEntry.getValue().entrySet()) - { - if (sb.length() > 0) - { - sb.append("\n"); - } - sb.append(useEntry.getKey()). - append(", "). - append(transformerEntry.getKey()). - append(" =>\n"). - append(transformerEntry.getValue()); - } - } - return sb.toString(); - } - - /** - * Creates a new TransformationOptionLimits for the use, transformer and mimetype combination, - * defaulting values from lower levels. - * @param wildCardLimits if not null this is a limit found using a wildcard so should - * form the basis of the new object. - */ - private TransformationOptionLimits newTransformationOptionLimits(String transformerName, - String sourceMimetype, String targetMimetype, TransformationOptionLimits wildCardLimits, - String use) - { - int origLevel = getLevel(transformerName, sourceMimetype); - - TransformationOptionLimits limits = new TransformationOptionLimits(); - // Start at the most general limits and then override with more specific values so that - // defaults from the most general get used if there is not something more specific. - for (int level=0; level= newValue) - { - optionPair.setLimit(-1, NOT_THROWN_MESSAGE); - optionPair.setMax(newValue, NOT_THROWN_MESSAGE); - } - } - else - { - long max = optionPair.getMax(); - if (max < 0 || max > newValue) - { - optionPair.setMax(-1, NOT_THROWN_MESSAGE); - optionPair.setLimit(newValue, NOT_THROWN_MESSAGE); - } - } - } - - private void debug(String msg, String transformerName, String sourceMimetype, - String targetMimetype, String use, TransformationOptionLimits limits) - { - if (logger.isDebugEnabled()) - { - StringBuilder sb = new StringBuilder(""); - if (msg != null) - { - int x = getLevel(transformerName, sourceMimetype); - sb.append(x); - sb.append(' '); - sb.append(msg); - for (; x>-1; x--) - { - sb.append(' '); - } - sb.append(transformerName); - sb.append('.'); - sb.append(sourceMimetype); - sb.append('.'); - sb.append(targetMimetype); - sb.append('.'); - sb.append(use); - sb.append('='); - sb.append(limits); - } - String line = sb.toString(); - logger.debug(line); - } - } - - /** - * See {@link TransformerConfig#getLimits(ContentTransformer, String, String, String)}. - */ - public TransformationOptionLimits getLimits(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, String use) - { - String transformerName = (transformer == null) ? DEFAULT_TRANSFORMER : transformer.getName(); - - if (sourceMimetype == null) - { - sourceMimetype = ANY; - } - - if (targetMimetype == null) - { - targetMimetype = ANY; - } - - if (use == null) - { - use = ANY; - } - - debug(null, transformerName, sourceMimetype, targetMimetype, use, null); - - String searchUse = uses.contains(use) ? use : ANY; - TransformationOptionLimits limits = getOrCreateTransformerOptionLimits(transformerName, sourceMimetype, targetMimetype, searchUse); - - debug("S", transformerName, sourceMimetype, targetMimetype, use, limits); - - return limits; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBean.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBean.java index 1975309677..6d8601a792 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBean.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBean.java @@ -30,48 +30,20 @@ package org.alfresco.repo.content.transform; * and statistics. * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated public interface TransformerConfigMBean { - /** - * Lists the names of all top level transformers. - */ - public String[] getTransformerNames(); - /** * Lists all configured mimetypes, proceeded by its primary file extension. */ public String[] getExtensionsAndMimetypes(); - /** - * Lists all possible transformations sorted by Transformer name. - * @param transformerName to be checked. If null all transformers are included. - * @param use or context in which the transformation will be used ("doclib", - * "index", "webpreview", "syncRule", "asyncRule"...) or null for the default. - */ - @Deprecated - public String getTransformationsByTransformer(String transformerName, String use); - /** * Lists all possible transformations sorted by source and then target mimetype extension. * @param sourceExtension to be checked. If null all source mimetypes are included. * @param targetExtension to be checked. If null all target mimetypes are included. - * @param use or context in which the transformation will be used ("doclib", - * "index", "webpreview", "syncRule", "asyncRule"...) or null for the default. */ - public String getTransformationsByExtension(String sourceExtension, String targetExtension, String use); - - /** - * Lists the transformation statistics for the current node. - * @param transformerName to be checked. If null all transformers are included. - * @param sourceExtension to be checked. If null all source mimetypes are included. - * @param targetExtension to be checked. If null all target mimetypes are included. - */ - @Deprecated - public String getTransformationStatistics(String transformerName, String sourceExtension, String targetExtension); + public String getTransformationsByExtension(String sourceExtension, String targetExtension); /** * Returns the last n entries in the transformation log. @@ -83,51 +55,14 @@ public interface TransformerConfigMBean */ public String[] getTransformationDebugLog(int n); - /** - * Returns custom and default transformer propertiest. - * @param listAll list both default and custom values, otherwise includes - * only custom values. - */ - @Deprecated - public String getProperties(boolean listAll); - - /** - * Adds or replaces new transformer properties. - * @param propertyNamesAndValues - * @return a confirmation or failure message - */ - @Deprecated - public String setProperties(String propertyNamesAndValues); - - /** - * Removes transformer properties. - * @param propertyNames to be removed. Any values after the property name are ignored. - * @return a confirmation or failure message - */ - @Deprecated - String removeProperties(String propertyNames); - /** * Transforms a small test file from one mimetype to another and then shows the debug of the * transform, which would indicate if it was successful or even if it was possible. - * @param transformerName to be used. If not specified the ContentService is used to select one. * @param sourceExtension used to identify the mimetype * @param targetExtension used to identify the mimetype - * @param use or context in which to test the transformation ("doclib", "index", "webpreview", - * "syncRule", "asyncRule"...) or blank for the default."; * @return Text indicating if the transform was possible and any debug */ - public String testTransform(String transformerName, String sourceExtension, String targetExtension, String use); - - /** - * Lists the names of the contexts or uses. - */ - public String[] getContextNames(); - - /** - * Lists custom (non default) property names. - */ - public String[] getCustomePropertyNames(); + public String testTransform(String sourceExtension, String targetExtension); /** * Lists the extensions of available test files. diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImpl.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImpl.java index 7109b588c8..a36a76762e 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImpl.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImpl.java @@ -26,9 +26,7 @@ package org.alfresco.repo.content.transform; import java.util.ArrayList; -import java.util.Collection; import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; import org.alfresco.service.cmr.repository.MimetypeService; @@ -37,35 +35,20 @@ import org.alfresco.service.cmr.repository.MimetypeService; * and statistics. * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated public class TransformerConfigMBeanImpl implements TransformerConfigMBean { private static final String NO_TRANSFORMATIONS_TO_REPORT = "No transformations to report"; - private ContentTransformerRegistry transformerRegistry; private AdminUiTransformerDebug transformerDebug; - private TransformerConfig transformerConfig; private MimetypeService mimetypeService; private LogEntries transformerLog; private LogEntries transformerDebugLog; - public void setContentTransformerRegistry(ContentTransformerRegistry transformerRegistry) - { - this.transformerRegistry = transformerRegistry; - } - public void setTransformerDebug(AdminUiTransformerDebug transformerDebug) { this.transformerDebug = transformerDebug; } - public void setTransformerConfig(TransformerConfig transformerConfig) - { - this.transformerConfig = transformerConfig; - } - public void setMimetypeService(MimetypeService mimetypeService) { this.mimetypeService = mimetypeService; @@ -81,22 +64,6 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean this.transformerDebugLog = transformerDebugLog; } - @Override - public String[] getTransformerNames() - { - List transformerNames = new ArrayList(); - Collection transformers = ((LegacyTransformerDebug)transformerDebug).sortTransformersByName(null); - for (ContentTransformer transformer: transformers) - { - String name = transformer.getName(); - name = name.startsWith(TransformerConfig.TRANSFORMER) - ? name.substring(TransformerConfig.TRANSFORMER.length()) - : name; - transformerNames.add(name); - } - return transformerNames.toArray(new String[transformerNames.size()]); - } - @Override public String[] getExtensionsAndMimetypes() { @@ -110,18 +77,12 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean } @Override - public String getTransformationsByTransformer(String simpleTransformerName, String use) + public String getTransformationsByExtension(String sourceExtension, String targetExtension) { - use = nullDefaultParam(use); try { - // Need to be able to generate 4.1.4ish output to compare with previous - // releases without too much effort cutting and pasting to change the order - return "41".equals(simpleTransformerName) - ? ((LegacyTransformerDebug)transformerDebug).transformationsByTransformer( - null, true, false, use) - : ((LegacyTransformerDebug)transformerDebug).transformationsByTransformer( - getTransformerNameParam(simpleTransformerName), true, true, use); + return transformerDebug.transformationsByExtension(nullDefaultLowerParam(sourceExtension), + nullDefaultLowerParam(targetExtension), true); } catch (IllegalArgumentException e) { @@ -129,141 +90,6 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean } } - @Override - public String getTransformationsByExtension(String sourceExtension, String targetExtension, String use) - { - use = nullDefaultParam(use); - try - { - // 41: Need to be able to generate 4.1.4ish output to compare with previous - // releases without too much effort cutting and pasting to change the order - // 00: (prefix) Finds only non deterministic transformations - if ("41".equals(sourceExtension)) - { - return transformerDebug.transformationsByExtension(null, null, true, false, false, null); - } - else - { - boolean onlyNonDeterministic = false; - if (sourceExtension != null && sourceExtension.startsWith("00")) - { - onlyNonDeterministic = true; - sourceExtension = sourceExtension.substring(2); - } - return transformerDebug.transformationsByExtension(nullDefaultLowerParam(sourceExtension), - nullDefaultLowerParam(targetExtension), true, true, onlyNonDeterministic, use); - } - } - catch (IllegalArgumentException e) - { - return e.getMessage(); - } - } - - @Override - public String getTransformationStatistics(String simpleTransformerName, String sourceExtension, String targetExtension) - { - try - { - StringBuilder sb = new StringBuilder(); - - String transformerName = getTransformerNameParam(simpleTransformerName); - sourceExtension = nullDefaultLowerParam(sourceExtension); - targetExtension = nullDefaultLowerParam(targetExtension); - - Collection transformers = ((LegacyTransformerDebug)transformerDebug).sortTransformersByName(transformerName); - Collection sourceMimetypes = transformerDebug.getSourceMimetypes(sourceExtension); - Collection targetMimetypes = transformerDebug.getTargetMimetypes(sourceExtension, targetExtension, sourceMimetypes); - - // Only report system wide mimetype summary if transformer not specified - boolean includeSystemWideSummary = transformerName == null; - if (includeSystemWideSummary) - { - getTransformationStatistics(sourceExtension, targetExtension, sb, - null, sourceMimetypes, targetMimetypes, false); - } - - for (ContentTransformer transformer: transformers) - { - getTransformationStatistics(sourceExtension, targetExtension, sb, - transformer, sourceMimetypes, targetMimetypes, includeSystemWideSummary); - } - - if (sb.length() == 0) - { - sb.append(NO_TRANSFORMATIONS_TO_REPORT); - } - - return sb.toString(); - } - catch (IllegalArgumentException e) - { - return e.getMessage(); - } - } - - private void getTransformationStatistics(String sourceExtension, String targetExtension, - StringBuilder sb, ContentTransformer transformer, Collection sourceMimetypes, - Collection targetMimetypes, boolean includeSystemWideSummary) - { - AtomicInteger counter = new AtomicInteger(0); - int i = sb.length(); - - for (String sourceMimetype: sourceMimetypes) - { - for (String targetMimetype: targetMimetypes) - { - getTransformationStatistics(sb, transformer, sourceMimetype, targetMimetype, counter, includeSystemWideSummary); - } - } - - // Only report transformer summary if there is more than one to summarise - // and we were asked for all - if (sourceExtension == null && targetExtension == null && counter.get() > 1) - { - StringBuilder sb2 = new StringBuilder(); - getTransformationStatistics(sb2, transformer, null, null, counter, includeSystemWideSummary); - sb2.append('\n'); - sb.insert((i == 0 ? 0 : i+2), sb2); - } - } - - private void getTransformationStatistics(StringBuilder sb, ContentTransformer transformer, - String sourceMimetype, String targetMimetype, AtomicInteger counter, - boolean includeSystemWideSummary) - { - TransformerStatistics statistics = transformerConfig.getStatistics(transformer, - sourceMimetype, targetMimetype, false); - if (statistics != null) - { - long count = statistics.getCount(); - if (count > 0) - { - if (sb.length() > 0) - { - sb.append('\n'); - } - if (counter.incrementAndGet() == 1 && includeSystemWideSummary) - { - sb.append('\n'); - } - - sb.append(statistics.getTransformerName()); - sb.append(' '); - sb.append(statistics.getSourceExt()); - sb.append(' '); - sb.append(statistics.getTargetExt()); - sb.append(" count="); - sb.append(count); - sb.append(" errors="); - sb.append(statistics.getErrorCount()); - sb.append(" averageTime="); - sb.append(statistics.getAverageTime()); - sb.append(" ms"); - } - } - } - @Override public String[] getTransformationLog(int n) { @@ -283,21 +109,11 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean } @Override - public String getProperties(boolean listAll) - { - return transformerConfig.getProperties(!listAll); - } - - @Override - public String setProperties(String propertyNamesAndValues) + public String testTransform(String sourceExtension, String targetExtension) { try { - String nullPropertyNamesAndValues = nullDefaultParam(propertyNamesAndValues); - int n = nullPropertyNamesAndValues == null - ? 0 - : transformerConfig.setProperties(nullPropertyNamesAndValues); - return "Properties added or changed: "+n; + return transformerDebug.testTransform(sourceExtension, targetExtension); } catch (IllegalArgumentException e) { @@ -305,91 +121,12 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean } } - @Override - public String removeProperties(String propertyNames) - { - try - { - propertyNames = nullDefaultParam(propertyNames); - return "Properties removed: "+ - (propertyNames == null - ? 0 - : transformerConfig.removeProperties(propertyNames)); - } - catch (IllegalArgumentException e) - { - return e.getMessage(); - } - } - - @Override - public String testTransform(final String simpleTransformerName, String sourceExtension, - String targetExtension, String use) - { - use = nullDefaultParam(use); - try - { - return transformerDebug.testTransform( sourceExtension, targetExtension, use); - } - catch (IllegalArgumentException e) - { - return e.getMessage(); - } - } - - @Override - public String[] getContextNames() - { - return new String[] {"", "doclib", "index", "webpreview", "syncRule", "asyncRule", "pdf"}; - } - - @Override - public String[] getCustomePropertyNames() - { - List propertyNames = new ArrayList(); - String[] lines = getProperties(false).split("\\n"); - for (String line: lines) - { - if (!line.isEmpty() && !line.startsWith("#") && line.indexOf(" # default=") == -1) - { - int i = line.indexOf('='); - if (i != 0) - { - String propertyName = line.substring(0, i); - propertyNames.add(propertyName); - } - } - } - return propertyNames.toArray(new String[propertyNames.size()]); - } - @Override public String[] getTestFileExtensionsAndMimetypes() { return transformerDebug.getTestFileExtensionsAndMimetypes(); } - /** - * Returns a full transformer name given a simple transformer name parameter. - * @param simpleTransformerName the name of the transformer without the - * {@link TransformerConfig#TRANSFORMER} prefix. - * @return a null or a full transformer name - */ - private String getTransformerNameParam(String simpleTransformerName) - { - simpleTransformerName = nullDefaultParam(simpleTransformerName); - String transformerName = simpleTransformerName == null - ? null - : simpleTransformerName.startsWith(TransformerConfig.TRANSFORMER) - ? simpleTransformerName - : TransformerConfig.TRANSFORMER+simpleTransformerName; - - // Throws an IllegalArgumentException if unknown - transformerRegistry.getTransformer(transformerName); - - return transformerName; - } - /** * Changes the default JConsole parameter value "String" (and the zero length * String) to null and forces other values to lower case. @@ -420,18 +157,7 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean @Override public String help() { - return "getProperties(listAll)\n" + - " Lists all transformer properties that are set.\n" + - " - listAll if true, list both default and custom values, otherwise includes\n" + - " only custom values\n" + - "\n" + - "setProperties(propertyNamesAndValues)\n" + - " Adds or replaces transformer properties.\n" + - " - propertyNamesAndValues to be set. May include comments but these are removed.\n" + - " To clear a custom values, set its value back to the default.\n" + - " To remove a custom property use removeProperties(...)\n" + - "\n" + - "getTransformationDebugLog(n)\n" + + return "getTransformationDebugLog(n)\n" + " Lists the latest entries in the transformation debug log.\n" + " - n the number of entries to include. If blank all available entries are listed\n" + "\n" + @@ -439,34 +165,19 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean " Lists the latest entries in the transformation log.\n" + " - n the number of entries to include. If blank all available entries are listed\n" + "\n" + - "getTransformationStatistics(transformerName, sourceExtension, targetExtension)\n" + - " Lists the transformation statistics for the current node.\n" + - " - transformerName to be checked. If blank all transformers are included\n" + - " - sourceExtension to be checked. If blank all source mimetypes are included\n" + - " - targetExtension to be checked. If blank all target mimetypes are included\n" + - "\n" + "getExtensionsAndMimetypes()\n" + " Lists all configured mimetypes and the primary file extension\n" + "\n" + - "getTransformerNames()\n" + - " Lists the names of all top level transformers\n" + - "\n" + - "testTransform(transformerName, sourceExtension, targetExtension, use)\n" + + "testTransform(sourceExtension, targetExtension, use)\n" + " Transforms a small test file from one mimetype to another and then shows the \n" + " debug of the transform, which would indicate if it was successful or even if \n" + " it was possible.\n" + - " - transformerName to be used. If blank the ContentService is used to select one.\n" + " - sourceExtension used to identify the mimetype\n" + " - targetExtension used to identify the mimetype\n" + " - use or context in which to test the transformation (\"doclib\",\n" + " \"index\", \"webpreview\", \"syncRule\", \"asyncRule\"...) or blank for\n" + " the default.\n" + "\n" + - "removeProperties(String propertyNames)\n" + - " Removes transformer properties.\n" + - " - propertyNames to be removed. May include = after the property name.\n" + - " The value is ignored. Only custom properties should be removed.\n" + - "\n" + "getTransformationsByExtension(sourceExtension, targetExtension, use)\n" + " Lists all possible transformations sorted by source and then target mimetype\n" + " extension.\n" + @@ -476,19 +187,6 @@ public class TransformerConfigMBeanImpl implements TransformerConfigMBean " \"index\", \"webpreview\", \"syncRule\", \"asyncRule\"...) or blank for\n" + " the default.\n" + "\n" + - "getTransformationsByTransformer(transformerName, use)\n" + - " Lists all possible transformations sorted by Transformer name\n" + - " - transformerName to be checked. If blank all transformers are included\n" + - " - use or context in which the transformation will be used (\"doclib\",\n" + - " \"index\", \"webpreview\", \"syncRule\", \"asyncRule\"...) or blank for\n" + - " the default.\n"+ - "\n" + - "getCustomePropertyNames()\n" + - " Lists custom (non default) property names\n" + - "\n" + - "getContextNames()\n" + - " Lists the names of the contexts or uses\n" + - "\n" + "getTestFileExtensionsAndMimetypes()\n" + " Lists the extensions of available test files"; } diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigProperty.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigProperty.java deleted file mode 100644 index 03a5484f52..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigProperty.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.DEFAULT_TRANSFORMER; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.MalformedNodeRefException; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Provides access to a single transformer configuration property depending on the - * transformer and source and target mimetypes, falling back to defaults. - * - * @author Alan Davis - * - * @deprecated The RenditionService is being replace by the simpler async RenditionService2. - */ -@Deprecated -public class TransformerConfigProperty extends TransformerPropertyNameExtractor -{ - private Map> values; - - public TransformerConfigProperty(TransformerProperties transformerProperties, - MimetypeService mimetypeService, String propertySuffix, String defaultValue) - { - setValues(transformerProperties, mimetypeService, propertySuffix, defaultValue); - } - - /** - * Sets the transformer values created from system properties. - */ - private void setValues(TransformerProperties transformerProperties, MimetypeService mimetypeService, - String suffix, String defaultValue) - { - values = new HashMap>(); - - // Gets all the transformer, source and target combinations in properties that define - // this value. - Map properties = - getTransformerSourceTargetValuesMap(Collections.singletonList(suffix), true, true, false, transformerProperties, mimetypeService); - - // Add the system wide default if it does not exist, as we always need this one - TransformerSourceTargetSuffixValue transformerSourceTargetValue = - new TransformerSourceTargetSuffixValue(DEFAULT_TRANSFORMER, ANY, ANY, suffix, null, defaultValue, mimetypeService); - TransformerSourceTargetSuffixKey key = transformerSourceTargetValue.key(); - if (!properties.containsKey(key)) - { - properties.put(key, transformerSourceTargetValue); - } - - // Populate the transformer values - for (TransformerSourceTargetSuffixValue property: properties.values()) - { - DoubleMap mimetypeValues = values.get(property.transformerName); - if (mimetypeValues == null) - { - mimetypeValues = new DoubleMap(ANY, ANY); - values.put(property.transformerName, mimetypeValues); - } - mimetypeValues.put(property.sourceMimetype, property.targetMimetype, property.value); - } - } - - private String getString(ContentTransformer transformer, String sourceMimetype, - String targetMimetype) - { - if (sourceMimetype == null) - { - sourceMimetype = ANY; - } - - if (targetMimetype == null) - { - targetMimetype = ANY; - } - - String name = (transformer == null) ? DEFAULT_TRANSFORMER : transformer.getName(); - - DoubleMap mimetypeLimits = values.get(name); - - String value = (mimetypeLimits == null) ? null : mimetypeLimits.get(sourceMimetype, targetMimetype); - - if (value == null && transformer != null) - { - // System wide 'default' limits should exist, but individual transformer values might not. - value = getString(null, sourceMimetype, targetMimetype); - } - - return value; - } - - public long getLong(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - throws NumberFormatException - { - return Long.parseLong(getString(transformer, sourceMimetype, targetMimetype)); - } - - public int getInt(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - throws NumberFormatException - { - return Integer.parseInt(getString(transformer, sourceMimetype, targetMimetype)); - } - - public List getNodeRefs(ContentTransformer transformer, String sourceMimetype, String targetMimetype) - throws MalformedNodeRefException - { - List nodeRefs = new ArrayList<>(); - String[] nodeRefStrings = getString(transformer, sourceMimetype, targetMimetype).split(", *"); - for (String nodeRefString: nodeRefStrings) - { - nodeRefString = nodeRefString.trim(); - if (nodeRefString.length() > 0) - { - NodeRef nodeRef = new NodeRef(nodeRefString); - nodeRefs.add(nodeRef); - } - } - return nodeRefs; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigStatistics.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigStatistics.java deleted file mode 100644 index 20da18f618..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigStatistics.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.SUMMARY_TRANSFORMER_NAME; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.MimetypeService; - -/** - * Provides a place to store statistics about: - * a) the combination of transformer, source and target mimetype; - * b) a summary for each transformer; - * c) a summary of top level transformations (++) for each combination of - * source and target mimetype; - * d) a summary of all top level transformations. - * These values are not shared across the cluster but are node specific.

    - * - * ++ Top level transformations don't include transformations performed as part - * of another transformation. - * - * @author Alan Davis - * - * @deprecated The RenditionService is being replace by the simpler async RenditionService2. - */ -@Deprecated -public class TransformerConfigStatistics -{ - private TransformerConfigImpl transformerConfigImpl; - private MimetypeService mimetypeService; - - // Holds statistics about each transformer, sourceMimeType and targetMimetype combination. - // A null transformer is the system wide value. Null sourceMimeType and targetMimetype values are - // transformer wide summaries. - private Map> statistics = - new HashMap>(); - - public TransformerConfigStatistics(TransformerConfigImpl transformerConfigImpl, - MimetypeService mimetypeService) - { - this.transformerConfigImpl = transformerConfigImpl; - this.mimetypeService = mimetypeService; - } - - public TransformerStatistics getStatistics(ContentTransformer transformer, String sourceMimetype, String targetMimetype, boolean createNew) - { - if (sourceMimetype == null) - { - sourceMimetype = ANY; - } - - if (targetMimetype == null) - { - targetMimetype = ANY; - } - - TransformerStatistics transformerStatistics; - - String name = (transformer == null) ? SUMMARY_TRANSFORMER_NAME : transformer.getName(); - DoubleMap mimetypeStatistics = statistics.get(name); - - if (!createNew) - { - transformerStatistics = (mimetypeStatistics == null) - ? null - : mimetypeStatistics.getNoWildcards(sourceMimetype, targetMimetype); - return transformerStatistics; - } - - if (mimetypeStatistics == null) - { - // Create the summary for the transformer as a whole - mimetypeStatistics = new DoubleMap(ANY, ANY); - statistics.put(name, mimetypeStatistics); - transformerStatistics = newTransformerStatistics(transformer, ANY, ANY, null); - mimetypeStatistics.put(ANY, ANY, transformerStatistics); - } - - if (ANY.equals(sourceMimetype) && ANY.equals(targetMimetype)) - { - transformerStatistics = mimetypeStatistics.get(ANY, ANY); - } - else - { - // Not looking for the summary, so will have to create it if not found or the summary is returned - transformerStatistics = mimetypeStatistics.get(sourceMimetype, targetMimetype); - if (transformerStatistics == null || transformerStatistics.isSummary()) - { - // Create individual mimetype to mimetype transformation by this transformer - transformerStatistics = newTransformerStatistics(transformer, sourceMimetype, targetMimetype, mimetypeStatistics.get(ANY, ANY)); - mimetypeStatistics.put(sourceMimetype, targetMimetype, transformerStatistics); - } - } - - return transformerStatistics; - } - - private TransformerStatistics newTransformerStatistics(ContentTransformer transformer, - String sourceMimetype, String targetMimetype, TransformerStatistics parent) - { - long initialAverageTime = transformerConfigImpl.getInitialAverageTime(transformer, sourceMimetype, targetMimetype); - long initialCount = initialAverageTime <= 0 - ? 0 - : transformerConfigImpl.getInitialCount(transformer, sourceMimetype, targetMimetype); - long errorTime = transformerConfigImpl.getErrorTime(transformer, sourceMimetype, targetMimetype); - - TransformerStatistics transformerStatistics = new TransformerStatisticsImpl(mimetypeService, sourceMimetype, targetMimetype, - transformer, parent, errorTime, initialAverageTime, initialCount); - - return transformerStatistics; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java deleted file mode 100644 index 424880cacf..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.SUPPORTED; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Provides access to the lists of supported and unsupported mimetype transformations - * defined via properties for all transformers. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigSupported extends TransformerPropertyNameExtractor -{ - // Holds configured (entries only exist if configured rather than for all possible combinations) - // of supported and unsupported mimetypes transformations for a transformer. - // SourceMimetype and targetMimetype may be 'ANY' values to act as wild cards. - private Map supported; - - public TransformerConfigSupported(TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - setSupported(transformerProperties, mimetypeService); - } - - /** - * Sets the supported/unsupported mimetype transformations created from system properties. - */ - private void setSupported(TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - supported = new HashMap(); - - // Gets all the supported and unsupported transformer, source and target combinations - Collection properties = - getTransformerSourceTargetValues(Collections.singletonList(SUPPORTED), - false, false, transformerProperties, mimetypeService); - - // Populate the transformer values - for (TransformerSourceTargetSuffixValue property: properties) - { - SupportedAndUnsupportedTransformations supportedBytransformer = this.supported.get(property.transformerName); - if (supportedBytransformer == null) - { - supportedBytransformer = new SupportedAndUnsupportedTransformations(); - this.supported.put(property.transformerName, supportedBytransformer); - } - boolean supported = property.value == null || property.value.equalsIgnoreCase("true"); - supportedBytransformer.put(property.sourceMimetype, property.targetMimetype, supported); - } - } - - /** - * See {@link TransformerConfig#isSupportedTransformation(ContentTransformer, String, String, TransformationOptions)}. - */ - public boolean isSupportedTransformation(ContentTransformer transformer, String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - if (sourceMimetype == null) - { - sourceMimetype = ANY; - } - - if (targetMimetype == null) - { - targetMimetype = ANY; - } - - boolean isSupported = true; - String name = transformer.getName(); - SupportedAndUnsupportedTransformations supportedBytransformer = supported.get(name); - if (supportedBytransformer != null) - { - isSupported = supportedBytransformer.isSupported(sourceMimetype, targetMimetype); - } - return isSupported; - } - - private class SupportedAndUnsupportedTransformations - { - DoubleMap supportedTransformations; - boolean supportedSet = false; - - SupportedAndUnsupportedTransformations() - { - } - - public void put(String sourceMimetype, String targetMimetype, boolean supported) - { - if (supportedTransformations == null) - { - supportedTransformations = new DoubleMap(ANY, ANY); - } - supportedTransformations.put(sourceMimetype, targetMimetype, supported); - if (supported) - { - supportedSet = true; - } - } - - boolean isSupported(String sourceMimetype, String targetMimetype) - { - // To be backward compatible, the default (ANY to ANY) transformation - // needs to be true if only unsupported values are set or neither - // unsupported nor supported values are set. If supported values are - // set the default is false. - boolean isSupported = !supportedSet; - - if (supportedTransformations != null) - { - Boolean sup = supportedTransformations.get(sourceMimetype, targetMimetype); - if (sup != null) - { - isSupported = sup; - } - } - return isSupported; - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebug.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebug.java index bd6d656f89..8b7cac01b4 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebug.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebug.java @@ -56,7 +56,6 @@ import static org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT; * messages include a prefix to identify the transformation. A numeric dot notation * is used (such as {@code 123.1.2} indicating the second third level transformation * of the 123rd top level transformation). - * * @author Alan Davis */ public class TransformerDebug diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebugLog.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebugLog.java index 83ff6513a0..75de185bba 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebugLog.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerDebugLog.java @@ -38,10 +38,7 @@ import org.apache.commons.logging.Log; * {@link TransformerConfigMBean#getTransformationDebugLog(int)}.

    * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated public class TransformerDebugLog extends TransformerLogger { private static Pattern END_OF_REQUEST_ID_PATTERN = Pattern.compile("[^0-9]"); @@ -63,7 +60,7 @@ public class TransformerDebugLog extends TransformerLogger @Override protected String getPropertyName() { - return TransformerConfig.DEBUG_ENTRIES; + return "transformer.debug.entries"; } @Override @@ -108,7 +105,6 @@ public class TransformerDebugLog extends TransformerLogger } // Collects multiple lines of debug for the same transformer request. -@Deprecated class DebugEntry { final String requestId; diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerInfoException.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerInfoException.java deleted file mode 100644 index dd8c39edc3..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerInfoException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.error.AlfrescoRuntimeException; - -/** - * - * Wraps an exception that could be thrown in any transformer to - * propagate it up to NodeInfoBean.sendNodeInfo method. - * NodeInfoBean can handle this exception to display it in NodeInfo frame - * to avoid error message box with "Exception in Transaction" message. - * - * See {@link org.alfresco.repo.content.transform.PoiHssfContentTransformer} for pattern. - * - * @author Arseny Kovalchuk - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerInfoException extends AlfrescoRuntimeException -{ - private static final long serialVersionUID = -4343331677825559617L; - - public TransformerInfoException(String msg) - { - super(msg); - } - - public TransformerInfoException(String msg, Throwable err) - { - super(msg, err); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLog.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLog.java index 782d2a69f6..880eb7e062 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLog.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLog.java @@ -37,10 +37,7 @@ import org.alfresco.api.AlfrescoPublicApi; * {@link TransformerConfigMBean#getTransformationLog(int)}.

    * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated @AlfrescoPublicApi public class TransformerLog extends TransformerLogger { @@ -60,7 +57,7 @@ public class TransformerLog extends TransformerLogger @Override protected String getPropertyName() { - return TransformerConfig.LOG_ENTRIES; + return "transformer.log.entries"; } @Override diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLogger.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLogger.java index a725d6c015..ae92901853 100644 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLogger.java +++ b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerLogger.java @@ -42,17 +42,14 @@ import org.apache.commons.logging.Log; * Only supports debug level logging. * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated @AlfrescoPublicApi abstract class TransformerLogger extends LogAdapter implements LogEntries { static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("d MMM yyyy HH:mm:ss"); private TransformerDebug transformerDebug; - private TransformerConfig transformerConfig; + private Properties properties; private int maxEntries = -1; private Deque entries = new LinkedList(); @@ -67,22 +64,19 @@ abstract class TransformerLogger extends LogAdapter implements LogEntries this.transformerDebug = transformerDebug; } - /** - * @param transformerConfig used to access the property. - */ - public void setTransformerConfig(TransformerConfig transformerConfig) + public void setProperties(Properties properties) { - this.transformerConfig = transformerConfig; + this.properties = properties; } - + /** * Returns an int from a property. * @param propertyName */ - private int getProperty(TransformerConfig transformerConfig, String propertyName, int min, int max) + private int getProperty(String propertyName, int min, int max) { int i = 0; - String value = transformerConfig.getProperty(propertyName); + String value = properties.getProperty(propertyName); if (value != null) { try @@ -106,7 +100,7 @@ abstract class TransformerLogger extends LogAdapter implements LogEntries { if (maxEntries < 0) { - maxEntries = getProperty(transformerConfig, getPropertyName(), 0, getUpperMaxEntries()); + maxEntries = getProperty(getPropertyName(), 0, getUpperMaxEntries()); } return maxEntries; } @@ -185,26 +179,22 @@ abstract class TransformerLogger extends LogAdapter implements LogEntries } } - /** - * The transformer property and value used to set this logger. This is commented - * out if the property has not been overridden (default is 0). - * @param defaultProperties the transformer.properties file values that may be overridden. - * @return the transformer property and value. - */ - public String getPropertyAndValue(Properties defaultProperties) + private static void appendProperty(StringBuilder sb, String propertyName, String value, String defaultValue) { - getMaxEntries(); - String value = Integer.toString(maxEntries); - - String propertyName = getPropertyName(); - String defaultValue = defaultProperties == null ? null : defaultProperties.getProperty(propertyName); - defaultValue = defaultValue == null ? "0" : defaultValue; - - StringBuilder sb = new StringBuilder(); - TransformerPropertyGetter.appendProperty(sb, propertyName, value, defaultValue); - return sb.toString(); + boolean isDefaultValue = value.equals(defaultValue); + if (isDefaultValue) + { + sb.append("# "); + } + sb.append(propertyName); + sb.append('='); + sb.append(value); + if (!isDefaultValue) + { + sb.append(" # default="); + sb.append(defaultValue); + } } - /** * Overridden to specify the maximum value the maxEntries property may set. * Generally quite a small number as values are stored in memory. diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerProperties.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerProperties.java deleted file mode 100644 index 664feb3950..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerProperties.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Provides access to transformer properties which come from the Transformer sub system AND - * the those that start with "content.transformer." in the parent context.

    - * - * By default a subsystem only provides properties defined within itself and only those - * properties may be overridden by alfresco.global.properties. New properties may not be added. - * As this class allows this to happen for the Transformers subsystem. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerProperties -{ - private static final String TRANSFORMERS_PROPERTIES = "alfresco/subsystems/Transformers/default/transformers.properties"; - - private static Log logger = LogFactory.getLog(TransformerProperties.class); - - private static final String JOD_CONVERTER = ".JodConverter."; - private static final String OPEN_OFFICE = ".OpenOffice."; - - private final ChildApplicationContextFactory subsystem; - - private final Properties globalProperties; - - TransformerProperties(ChildApplicationContextFactory subsystem, Properties globalProperties) - { - this.subsystem = subsystem; - this.globalProperties = globalProperties; - } - - public String getProperty(String name) - { - String value = subsystem.getProperty(name); - if (value == null) - { - value = globalProperties.getProperty(name); - - if (value == null) - { - name = alias(name, JOD_CONVERTER, OPEN_OFFICE); - value = globalProperties.getProperty(name); - } - } - return value; - } - - /** - * Returns the default properties from the transformers.properties file. These may be overridden by customers in - * other property files and JMX. - */ - public Properties getDefaultProperties() - { - Properties defaultProperties = new Properties(); - InputStream propertiesStream = getClass().getClassLoader().getResourceAsStream(TRANSFORMERS_PROPERTIES); - if (propertiesStream != null) - { - try - { - defaultProperties.load(propertiesStream); - } - catch (IOException e) - { - logger.error("Could not read "+TRANSFORMERS_PROPERTIES+" so all properties will appear to be overridden by the customer", e); - } - } - else - { - logger.error("Could not find "+TRANSFORMERS_PROPERTIES+" so all properties will appear to be overridden by the customer"); - } - return defaultProperties; - } - - public Set getPropertyNames() - { - Set propertyNames = new HashSet(subsystem.getPropertyNames()); - for (String name: globalProperties.stringPropertyNames()) - { - if (name.startsWith(TransformerConfig.PREFIX)) - { - name = alias(name, OPEN_OFFICE, JOD_CONVERTER); - if (!propertyNames.contains(name)) - { - propertyNames.add(name); - } - } - } - - return propertyNames; - } - - // When we moved the JodConverter into the Community edition (after 6.0.0-ea) we wanted to allow any Community - // settings for content.transformer.OpenOffice (and related pipeline transformers specified) in - // alfresco.global.properties to apply to the JodConverter (and related pipeline transformers), but where there - // is jodConverter that value should be used. - // content.transformer.JodConverter. - // content.transformer.JodConverter.Html2Pdf. - // content.transformer.JodConverter.2Pdf. - // content.transformer.complex.JodConverter.Image. - // content.transformer.complex.JodConverter.PdfBox - private String alias(String name, String from, String to) - { - int i = name.indexOf(from); - if (i != -1) - { - name = name.substring(0, i) + to + name.substring(i+from.length()); - } - return name; - } - - public void setProperties(Map map) - { - subsystem.setProperties(map); - } - - public void removeProperties(Collection propertyNames) - { - subsystem.removeProperties(propertyNames); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertyGetter.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertyGetter.java deleted file mode 100644 index 3d51089328..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertyGetter.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.PREFIX; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -import org.alfresco.service.cmr.repository.MimetypeService; - - -/** - * Provides access to a String representation of all transformer properties and values - * where these are sorted into groups. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerPropertyGetter -{ - private final String string; - - public TransformerPropertyGetter(boolean changesOnly, TransformerProperties transformerProperties, - MimetypeService mimetypeService, ContentTransformerRegistry transformerRegistry, - TransformerLog transformerLog, TransformerDebugLog transformerDebugLog) - { - List availableTransformers = transformerRegistry.getTransformers(); - StringBuilder sb = new StringBuilder(); - - // Log entries - appendLoggerSetting(sb, changesOnly, transformerLog, transformerDebugLog, transformerProperties); - - // Miscellaneous - appendMiscellaneousSettings(sb, changesOnly, transformerProperties); - - // Default transformer - Set alreadySpecified = new HashSet(); - appendConfiguredTransformerSettings(sb, changesOnly, transformerProperties, mimetypeService, availableTransformers, - transformerRegistry, true, alreadySpecified, - "# Default transformer settings\n" + - "# ============================\n"); - - // Other transformers with configuration properties - appendConfiguredTransformerSettings(sb, changesOnly, transformerProperties, mimetypeService, availableTransformers, - transformerRegistry, false, alreadySpecified, - "# Transformers with configuration settings\n" + - "# ========================================\n" + - "# Commented out settings are hard coded values for information purposes\n"); - - // Other transformers without configuration properties - if (!changesOnly) - { - appendUnconfiguredTransformerSettings(sb, mimetypeService, alreadySpecified, - availableTransformers, transformerRegistry); - } - - if (sb.length() == 0) - { - sb.append(changesOnly - ? "No custom transformer properties defined" - : "No transformer properties defined"); - } - - string = sb.toString(); - } - - private void appendLoggerSetting(StringBuilder sb, boolean changesOnly, TransformerLog transformerLog, - TransformerDebugLog transformerDebugLog, TransformerProperties transformerProperties) - { - Properties defaultProperties = transformerProperties.getDefaultProperties(); - String logEntries = transformerLog.getPropertyAndValue(defaultProperties); - String debugEntries = transformerDebugLog.getPropertyAndValue(defaultProperties); - boolean logEntriesChanged = !logEntries.startsWith("#"); - boolean debugEntriesChanged = !debugEntries.startsWith("#"); - - if (!changesOnly || logEntriesChanged || debugEntriesChanged) - { - sb.append("# LOG and DEBUG history sizes\n"); - sb.append("# ===========================\n"); - sb.append("# Use small values as these logs are held in memory. 0 to disable.\n"); - if (!changesOnly || logEntriesChanged) - { - sb.append(logEntries); - sb.append("\n"); - } - if (!changesOnly || debugEntriesChanged) - { - sb.append(debugEntries); - sb.append("\n"); - } - } - } - - private void appendMiscellaneousSettings(StringBuilder sb, boolean changesOnly, - TransformerProperties transformerProperties) - { - Properties defaultProperties = transformerProperties.getDefaultProperties(); - boolean first = true; - for (String propertyName: getMiscellaneousPropertyNames(defaultProperties)) - { - String defaultValue = defaultProperties.getProperty(propertyName); - String value = transformerProperties.getProperty(propertyName); - boolean isDefaultValue = value == null || value.equals(defaultValue); - value = value == null ? defaultValue : value; - - if (!changesOnly || !isDefaultValue) - { - if (first) - { - sb.append("\n"); - sb.append("# Miscellaneous settings\n"); - sb.append("# ======================\n"); - first = false; - } - appendProperty(sb, propertyName, value, defaultValue); - sb.append("\n"); - } - } - } - - // Gets names from transformers.properties that are not log or content.transformer values. - private Set getMiscellaneousPropertyNames(Properties defaultProperties) - { - Set propertyNames = new TreeSet(); - for (Object key: defaultProperties.keySet()) - { - String propertyName = key.toString(); - if (!propertyName.startsWith(PREFIX) && - !propertyName.equals(TransformerConfig.LOG_ENTRIES) && - !propertyName.equals(TransformerConfig.DEBUG_ENTRIES)) - { - propertyNames.add(propertyName); - } - } - return propertyNames; - } - - public static void appendProperty(StringBuilder sb, String propertyName, String value, String defaultValue) - { - boolean isDefaultValue = value.equals(defaultValue); - if (isDefaultValue) - { - sb.append("# "); - } - sb.append(propertyName); - sb.append('='); - sb.append(value); - if (!isDefaultValue) - { - sb.append(" # default="); - sb.append(defaultValue); - } - } - - private void appendConfiguredTransformerSettings(final StringBuilder sb, final boolean changesOnly, - TransformerProperties transformerProperties, MimetypeService mimetypeService, - final List availableTransformers, - final ContentTransformerRegistry transformerRegistry, - final boolean defaultTransformer, final Set alreadySpecified, - final String header) - { - final StringBuilder prefix = new StringBuilder(); - final StringBuilder general = new StringBuilder(); - final StringBuilder mimetypes = new StringBuilder(); - final AtomicInteger start = new AtomicInteger(-1); - final AtomicReference currentName = new AtomicReference(); - final Properties defaultProperties = transformerProperties.getDefaultProperties(); - - new TransformerPropertyNameExtractor() - { - /** - * Uses the propertyName and values rather than expanding the property name into multiple - * entries, in order to build up the string. - */ - @Override - protected void handleProperty( - String name, - String separator, - String firstExpression, - String secondExpression, - String suffix, - String use, - String value, - String propertyName, - Map transformerSourceTargetSuffixValues, MimetypeService mimetypeService) - { - if (defaultTransformer == TransformerConfig.DEFAULT_TRANSFORMER.equals(name)) - { - String defaultValue = defaultProperties == null ? null : defaultProperties.getProperty(propertyName); - boolean isDefaultValue = value.equals(defaultValue); - if (!changesOnly || !isDefaultValue) - { - String prevName = currentName.getAndSet(name); - if (prevName != null && !prevName.equals(name)) - { - appendTransformerSettings(sb, start, prevName, prefix, general, mimetypes, mimetypeService, - alreadySpecified, availableTransformers, transformerRegistry, defaultTransformer, header); - } - - StringBuilder tmp = - separator != null - ? mimetypes - : TransformerConfig.PIPELINE.equals(suffix) - ? prefix - : general; - if (isDefaultValue) - { - tmp.append("# "); - } - tmp.append(propertyName); - tmp.append('='); - tmp.append(value); - if (!isDefaultValue && defaultValue != null) - { - tmp.append(" # default="); - tmp.append(defaultValue); - } - tmp.append("\n"); - } - } - } - }.getTransformerSourceTargetValues(TransformerConfig.ALL_SUFFIXES, true, true, transformerProperties, mimetypeService); - String currName = currentName.get(); - if (currName != null) - { - if (defaultTransformer == TransformerConfig.DEFAULT_TRANSFORMER.equals(currName)) - { - appendTransformerSettings(sb, start, currName, prefix, general, mimetypes, mimetypeService, - alreadySpecified, availableTransformers, transformerRegistry, defaultTransformer, header); - } - } - } - - private void appendTransformerSettings(StringBuilder sb, AtomicInteger start, String transformerName, StringBuilder prefix, - StringBuilder general, StringBuilder mimetypes, MimetypeService mimetypeService, Set alreadySpecified, - List availableTransformers, ContentTransformerRegistry transformerRegistry, - boolean defaultTransformer, String header) - { - if (start.get() == -1) - { - if (sb.length() != 0) - { - sb.append('\n'); - } - sb.append(header); - start.set(sb.length()); - } - - if (!defaultTransformer) - { - alreadySpecified.add(transformerName); - ContentTransformer transformer; - prefix.insert(0, '\n'); - try - { - transformer = transformerRegistry.getTransformer(transformerName); - boolean available = availableTransformers.contains(transformer); - prefix.insert(1, transformer.getComments(available)); - } - catch (IllegalArgumentException e) - { - if (transformerName.startsWith(TransformerConfig.TRANSFORMER)) - { - transformerName = transformerName.substring(TransformerConfig.TRANSFORMER.length()); - } - prefix.insert(1, ContentTransformerHelper.getCommentName(transformerName)+"# Unregistered transformer\n"); - transformer = null; - } - - sb.append(prefix.toString()); - } - - sb.append(general.toString()); - sb.append(mimetypes.toString()); - - // Reset for next one - prefix.setLength(0); - general.setLength(0); - mimetypes.setLength(0); - } - - private void appendUnconfiguredTransformerSettings(StringBuilder sb, MimetypeService mimetypeService, - Set alreadySpecified, List availableTransformers, - ContentTransformerRegistry transformerRegistry) - { - boolean first = true; - for (ContentTransformer transformer: transformerRegistry.getAllTransformers()) - { - String name = transformer.getName(); - if (!alreadySpecified.contains(name)) - { - if (first) - { - sb.append("\n"); - sb.append("# Transformers without extra configuration settings\n"); - sb.append("# =================================================\n\n"); - first = false; - } - else - { - sb.append('\n'); - } - boolean available = availableTransformers.contains(transformer); - sb.append(transformer.getComments(available)); - } - } - } - - public String toString() - { - return string; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertyNameExtractor.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertyNameExtractor.java deleted file mode 100644 index 255d61f1da..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertyNameExtractor.java +++ /dev/null @@ -1,528 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.CONTENT; -import static org.alfresco.repo.content.transform.TransformerConfig.PREFIX; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.service.cmr.repository.MimetypeService; - -/** - * Provides access to transformer property names and values. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public abstract class TransformerPropertyNameExtractor -{ - private static Pattern EXTENSIONS_SEPARATOR = Pattern.compile("[^]\\\\]\\."); - private static String[] NO_EXT_MATCH = new String[0]; - - /** - * Returns a set of transformer name, source extension, target extension and value - * from property names that defined transformation limits. When the separator indicates - * it is followed by a regular expression that matches multiple mimetypes, more than one - * value may be added. When there is a value defined for specific extensions it wins over - * any regular expression value. - * @param suffixes possible endings to the property names after the target mimetype extension. - * Must start with a '.' if there is a suffix. - * @param includeSummary if true will also look for property names without the separator, - * source mimetype and target mimetype. - * @param includeUse if true, additionally checks for specific usage values that override - * the normal defaults. Such properties have a suffix of ".use." where - * is a value such as "index", "webpreview", "doclib", "syncRule", "aysncRule". - * @param transformerProperties that provides the properties - * @param mimetypeService MimetypeService - */ - protected Collection getTransformerSourceTargetValues(Collection suffixes, - boolean includeSummary, boolean includeUse, TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - return new ArrayList( - getTransformerSourceTargetValuesMap(suffixes, includeSummary, true, includeUse, transformerProperties, mimetypeService).values()); - } - - /** - * Returns a map to access transformer name, source extension and target extension to - * transformer name, source extension, target extension and value, created from property - * names that defined transformation limits. When the separator indicates - * it is followed by a regular expression that matches multiple mimetypes, more than one - * value may be added. When there is a value defined for specific extensions it wins over - * any regular expression value. - * @param suffixes possible endings to the property names after the target mimetype extension. - * Must start with a '.' if there is a suffix. - * @param includeSummary if true will include property names without the separator to - * source mimetype and target mimetype. - * @param includeExtensions if false will exclude property names with the separator to - * source mimetype and target mimetype. - * @param includeUse if true, additionally checks for specific usage values that override - * the normal defaults. Such properties have a suffix of ".use." where - * is a value such as "index", "webpreview", "doclib", "syncRule", "aysncRule". - * @param transformerProperties that provides the properties - * @param mimetypeService MimetypeService - */ - protected Map getTransformerSourceTargetValuesMap(Collection suffixes, - boolean includeSummary, boolean includeExtensions, boolean includeUse, TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - Map transformerSourceTargetSuffixValues = - new LinkedHashMap(); - - List propertyNames = new ArrayList(transformerProperties.getPropertyNames()); - Collections.sort(propertyNames); - for (String propertyName: propertyNames) - { - if (propertyName.startsWith(PREFIX)) - { - String use = null; - String propertyNameWithoutUse = propertyName; - if (includeUse) - { - int i = propertyName.lastIndexOf(TransformerConfig.USE); - if (i != -1) - { - int j = i+TransformerConfig.USE.length(); - if (propertyName.length()-j > 0) - { - use = propertyName.substring(j); - propertyNameWithoutUse = propertyName.substring(0, i); - } - } - } - - suffixesLoop: - for (String suffix: suffixes) - { - if (propertyNameWithoutUse.endsWith(suffix)) - { - String value = transformerProperties.getProperty(propertyName); - String transformerName = propertyNameWithoutUse.substring(CONTENT.length(), propertyNameWithoutUse.length()-suffix.length()); - boolean separatorMatch = false; - for (String separator: TransformerConfig.SEPARATORS) - { - int i = transformerName.lastIndexOf(separator); - if (i != -1) - { - separatorMatch = true; - if (includeExtensions) - { - String extensions = transformerName.substring(i+separator.length()); - String[] ext = splitExt(extensions); - if (ext.length == 2) - { - transformerName = transformerName.substring(0, i); - String firstExpression = ext[0]; - String secondExpression = ext[1]; - handleProperty(transformerName, - separator, firstExpression, secondExpression, - suffix, use, value, propertyName, transformerSourceTargetSuffixValues, mimetypeService); - break suffixesLoop; - } - } - } - } - - if (!separatorMatch && includeSummary) - { - handleProperty(transformerName, null, null, null, suffix, use, value, propertyName, transformerSourceTargetSuffixValues, mimetypeService); - break suffixesLoop; - } - } - } - } - } - - return transformerSourceTargetSuffixValues; - } - - /** - * Handles a property to add values to the supplied transformerSourceTargetSuffixValues. - * If the separator is null, this indicates that the property provides a transformer - * wide value, so firstExpression and secondExpression should also be ignored. - */ - protected void handleProperty(String transformerName, String separator, - String firstExpression, String secondExpression, String suffix, String use, String value, - String propertyName, - Map transformerSourceTargetSuffixValues, MimetypeService mimetypeService) - { - if (separator == null) - { - addTransformerSourceTargetValue(transformerSourceTargetSuffixValues, - false, - transformerName, ANY, ANY, suffix, - use, value, mimetypeService); - } - else - { - List sourceExtensions = (TransformerConfig.EXTENSIONS.equals(separator)) - ? getMatchingExtensionsFromExtensions(firstExpression, mimetypeService) - : getMatchingExtensionsFromMimetypes( firstExpression, mimetypeService); - List targetExtensions = (TransformerConfig.EXTENSIONS.equals(separator)) - ? getMatchingExtensionsFromExtensions(secondExpression, mimetypeService) - : getMatchingExtensionsFromMimetypes( secondExpression, mimetypeService); - for (String sourceExt : sourceExtensions) - { - for (String targetExt : targetExtensions) - { - addTransformerSourceTargetValue(transformerSourceTargetSuffixValues, - (TransformerConfig.MIMETYPES.equals(separator)), - transformerName, sourceExt, targetExt, suffix, - use, value, mimetypeService); - } - } - } - } - - /** - * Optionally adds a new TransformerSourceTargetValue and discards some when - * there is another 'better' property.

    - * - * If there is a property for the max value and another for the limit the lower - * one wins. If equal, the max value wins.

    - * - * If the supplied value is constructed from a mimetypes value it wins over one - * constructed from an extensions property. - */ - private void addTransformerSourceTargetValue( - Map transformerSourceTargetSuffixValues, - boolean mimetypeProperty, String transformerName, String sourceExt, String targetExt, String suffix, - String use, String value, MimetypeService mimetypeService) - { - TransformerSourceTargetSuffixValue transformerSourceTargetSuffixValue = - new TransformerSourceTargetSuffixValue(transformerName, sourceExt, targetExt, suffix, use, value, mimetypeService); - TransformerSourceTargetSuffixKey key = transformerSourceTargetSuffixValue.key(); - - if (mimetypeProperty || !transformerSourceTargetSuffixValues.containsKey(key)) - { - TransformerSourceTargetSuffixKey siblingKey = transformerSourceTargetSuffixValue.getSiblingKey(); - TransformerSourceTargetSuffixValue sibling = transformerSourceTargetSuffixValues.get(siblingKey); - - boolean doAdd = true; - if (sibling != null) - { - doAdd = false; - long newValue = Long.parseLong(value); - if (newValue > 0) - { - long oldValue = Long.parseLong(sibling.value); - - // If max rather than limit value - boolean isMax = - suffix == TransformerConfig.MAX_SOURCE_SIZE_K_BYTES || - suffix == TransformerConfig.TIMEOUT_MS || - suffix == TransformerConfig.MAX_PAGES; - if (oldValue < 0 || (isMax && oldValue >= newValue) || (!isMax && oldValue > newValue)) - { - transformerSourceTargetSuffixValues.remove(siblingKey); - doAdd = true; - } - } - } - - if (doAdd) - { - transformerSourceTargetSuffixValues.put(key, transformerSourceTargetSuffixValue); - } - } - } - - /** - * Splits the extensions into two parts. It does this by looking for a '.' - * that is not escaped (preceded by a back slash '\'). - * This is to allow regular expressions to be used for mimetypes. - */ - String[] splitExt(String extensions) - { - String[] ext = NO_EXT_MATCH; - Matcher matcher = EXTENSIONS_SEPARATOR.matcher(extensions); - if (matcher.find()) - { - int i = matcher.start(); - ext = new String[2]; - ext[0] = extensions.substring(0, i+1).replaceAll("\\\\\\.", "."); - ext[1] = extensions.substring(i+2).replaceAll("\\\\\\.", "."); - } - return ext; - } - - /** - * Returns a regex Pattern for the supplied expression where '*' represents zero - * or more characters. - */ - Pattern pattern(String expression) - { - // Turn the pattern into a regular expression where any special regex - // characters have no meaning and then get any * values to represent - // zero or more chars. - String regex = Pattern.quote(expression).replaceAll("\\*", "\\\\E.*\\\\Q"); - return Pattern.compile(regex); - } - - /** - * Gets the extensions of the mimetypes that match the given expression. - * However if the expression is "*", only the ANY ("*") extension is returned. - * @param expression which may contain '*' to represent zero or more characters. - * @param mimetypeService MimetypeService - * @return the list of extensions of mimetypes that match - */ - List getMatchingExtensionsFromMimetypes( - String expression, MimetypeService mimetypeService) - { - if (ANY.equals(expression)) - { - return Collections.singletonList(ANY); - } - Pattern pattern = pattern(expression); - List matchingMimetypes = new ArrayList(1); - for (String mimetype : mimetypeService.getMimetypes()) - { - if (pattern.matcher(mimetype).matches()) - { - String ext = mimetypeService.getExtension(mimetype); - matchingMimetypes.add(ext); - } - } - return matchingMimetypes; - } - - /** - * Gets the extensions that match the given expression. Only the main extension - * of each mimetype is checked. - * However if the expression is "*", only the ANY ("*") extension is returned. - * @param expression which may contain '*' to represent zero or more characters. - * @param mimetypeService MimetypeService - * @return the list of extensions that match - */ - List getMatchingExtensionsFromExtensions( - String expression, MimetypeService mimetypeService) - { - if (ANY.equals(expression)) - { - return Collections.singletonList(ANY); - } - Pattern pattern = pattern(expression); - List matchingMimetypes = new ArrayList(1); - for (String mimetype : mimetypeService.getMimetypes()) - { - String ext = mimetypeService.getExtension(mimetype); - if (pattern.matcher(ext).matches()) - { - matchingMimetypes.add(ext); - } - } - return matchingMimetypes; - } - - /** - * Returns a transformer property value if it exists from the supplied map. - * @param transformerName of the transformer - * @param sourceExt {@code null} indicates this is a transformer wide property. - * @param targetExt String - * @param suffix String - * @param use String - * @param transformerSourceTargetSuffixValues map of values - * @return the value or {@code null} if not set. - */ - protected String getProperty(String transformerName, String sourceExt, String targetExt, - String suffix, String use, Map transformerSourceTargetSuffixValues) - { - TransformerSourceTargetSuffixKey key = new TransformerSourceTargetSuffixKey(transformerName, - (sourceExt == null ? ANY : sourceExt), (targetExt == null ? ANY : targetExt), suffix, use); - TransformerSourceTargetSuffixValue value = transformerSourceTargetSuffixValues.get(key); - return value == null ? null : value.value; - } -} - -class TransformerSourceTargetSuffixKey -{ - final String transformerName; - final String sourceExt; - final String targetExt; - final String suffix; - final String use; - - // sourceExt and targetExt should never be null, but be set to ANY - public TransformerSourceTargetSuffixKey(String transformerName, String sourceExt, String targetExt, String suffix, String use) - { - this.transformerName = transformerName; - this.sourceExt = sourceExt; - this.targetExt = targetExt; - this.suffix = suffix; - this.use = use; - } - - public String toString() - { - return transformerName+(sourceExt.equals(ANY) && targetExt.equals(ANY) - ? "" - : TransformerConfig.EXTENSIONS+sourceExt+'.'+targetExt)+ - suffix+ - (use == null || ANY.equals(use) ? "" : TransformerConfig.USE + use); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((sourceExt == null) ? 0 : sourceExt.hashCode()); - result = prime * result + ((suffix == null) ? 0 : suffix.hashCode()); - result = prime * result + ((targetExt == null) ? 0 : targetExt.hashCode()); - result = prime * result + ((transformerName == null) ? 0 : transformerName.hashCode()); - result = prime * result + ((use == null) ? 0 : use.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TransformerSourceTargetSuffixKey other = (TransformerSourceTargetSuffixKey) obj; - if (sourceExt == null) - { - if (other.sourceExt != null) - return false; - } - else if (!sourceExt.equals(other.sourceExt)) - return false; - if (suffix == null) - { - if (other.suffix != null) - return false; - } - else if (!suffix.equals(other.suffix)) - return false; - if (targetExt == null) - { - if (other.targetExt != null) - return false; - } - else if (!targetExt.equals(other.targetExt)) - return false; - if (transformerName == null) - { - if (other.transformerName != null) - return false; - } - else if (!transformerName.equals(other.transformerName)) - return false; - if (use == null) - { - if (other.use != null) - return false; - } - else if (!use.equals(other.use)) - return false; - return true; - } -} - -class TransformerSourceTargetSuffixValue extends TransformerSourceTargetSuffixKey -{ - final String value; - final String sourceMimetype; - final String targetMimetype; - - // sourceExt and targetExt should never be null, but be set to ANY - public TransformerSourceTargetSuffixValue(String transformerName, String sourceExt, - String targetExt, String suffix, String use, String value, MimetypeService mimetypeService) - { - super(transformerName, sourceExt, targetExt, suffix, use); - - this.value = value; - this.sourceMimetype = ANY.equals(sourceExt) ? ANY : mimetypeService.getMimetype(sourceExt); - this.targetMimetype = ANY.equals(targetExt) ? ANY : mimetypeService.getMimetype(targetExt); - } - - public TransformerSourceTargetSuffixKey key() - { - return new TransformerSourceTargetSuffixKey(transformerName, sourceExt, targetExt, suffix, use); - } - - /** - * @return the key of the sibling property for the max value if this is the limit value and one - * for the limit value if the max value. - */ - public TransformerSourceTargetSuffixKey getSiblingKey() - { - String siblingSuffix = - suffix == TransformerConfig.MAX_SOURCE_SIZE_K_BYTES - ? TransformerConfig.READ_LIMIT_K_BYTES - : suffix == TransformerConfig.READ_LIMIT_K_BYTES - ? TransformerConfig.MAX_SOURCE_SIZE_K_BYTES - - : suffix == TransformerConfig.TIMEOUT_MS - ? TransformerConfig.READ_LIMIT_TIME_MS - : suffix == TransformerConfig.READ_LIMIT_TIME_MS - ? TransformerConfig.TIMEOUT_MS - - : suffix == TransformerConfig.MAX_PAGES - ? TransformerConfig.PAGE_LIMIT - : TransformerConfig.MAX_PAGES; - - return new TransformerSourceTargetSuffixKey(transformerName, sourceExt, targetExt, siblingSuffix, use); - } - - public String toString() - { - return super.toString()+'='+value; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (!super.equals(obj)) - return false; - TransformerSourceTargetSuffixValue other = (TransformerSourceTargetSuffixValue) obj; - if (!value.equals(other.value)) - return false; - return true; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertySetter.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertySetter.java deleted file mode 100644 index ad076d4b6e..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerPropertySetter.java +++ /dev/null @@ -1,619 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.AVAILABLE; -import static org.alfresco.repo.content.transform.TransformerConfig.CONTENT; -import static org.alfresco.repo.content.transform.TransformerConfig.ERROR_TIME; -import static org.alfresco.repo.content.transform.TransformerConfig.FAILOVER; -import static org.alfresco.repo.content.transform.TransformerConfig.INITIAL_COUNT; -import static org.alfresco.repo.content.transform.TransformerConfig.INITIAL_TIME; -import static org.alfresco.repo.content.transform.TransformerConfig.MAX_PAGES; -import static org.alfresco.repo.content.transform.TransformerConfig.MAX_SOURCE_SIZE_K_BYTES; -import static org.alfresco.repo.content.transform.TransformerConfig.PAGE_LIMIT; -import static org.alfresco.repo.content.transform.TransformerConfig.PIPELINE; -import static org.alfresco.repo.content.transform.TransformerConfig.PRIORITY; -import static org.alfresco.repo.content.transform.TransformerConfig.BLACKLIST; -import static org.alfresco.repo.content.transform.TransformerConfig.READ_LIMIT_K_BYTES; -import static org.alfresco.repo.content.transform.TransformerConfig.READ_LIMIT_TIME_MS; -import static org.alfresco.repo.content.transform.TransformerConfig.SUPPORTED; -import static org.alfresco.repo.content.transform.TransformerConfig.THRESHOLD_COUNT; -import static org.alfresco.repo.content.transform.TransformerConfig.TIMEOUT_MS; -import static org.alfresco.repo.content.transform.TransformerConfig.TRANSFORMER; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - - - -/** - * Provides methods to set and remove transformer properties and values. - * - * @author Alan Davis - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerPropertySetter -{ - /** - * Matches lines - */ - private static final Pattern LINE_SPLIT = Pattern.compile("^(.*)$", Pattern.MULTILINE); - - /** - * Matches leading white space and trailing comments - */ - private static final Pattern COMMENT = Pattern.compile("(^\\s+)|(\\s*#.*)|(\\s+$)"); - - /** - * Tries to match a space that should be a newline. JConsole has turned \n into spaces! - */ - private static Pattern NEWLINE_CORRECTION = Pattern.compile("([^#]\\s*) ((content\\.transformer\\.)|(transformer\\.))"); - - /** - * Integer Value - */ - private static final Pattern INTEGER = Pattern.compile("^-?\\d+$"); - - private final TransformerProperties transformerProperties; - private final MimetypeService mimetypeService; - private final ContentTransformerRegistry transformerRegistry; - - public TransformerPropertySetter(TransformerProperties transformerProperties, MimetypeService mimetypeService, - ContentTransformerRegistry transformerRegistry) - { - this.transformerProperties = transformerProperties; - this.mimetypeService = mimetypeService; - this.transformerRegistry = transformerRegistry; - } - - /** - * Sets transformer properties from the supplied multi line propertyNamesAndValues. - * @throws IllegalArgumentException if an unexpected line is found - */ - public int setProperties(String propertyNamesAndValues) - { - Map map = new HashMap(); - Map transformerReferences = new HashMap(); - Set dynamicTransformerNames = new HashSet(); - for (String propertyNameAndValue: extractProperties(propertyNamesAndValues, true, transformerReferences, dynamicTransformerNames)) - { - Pair pair = splitNameAndValue(propertyNameAndValue); - String propertyName = pair.getFirst(); - String value = pair.getSecond(); - if (map.containsKey(propertyName)) - { - throw new IllegalArgumentException(propertyName+" has been specified more than once"); - } - if (!value.equals(transformerProperties.getProperty(propertyName))) - { - map.put(propertyName, value); - } - } - - // Check transformer names exist or will exist - checkTransformerReferences(transformerReferences, dynamicTransformerNames); - - int size = map.size(); - if (size > 0) - { - transformerProperties.setProperties(map); - } - return size; - } - - private void checkTransformerReferences(Map transformerReferences, - Set dynamicTransformerNames) throws IllegalArgumentException - { - // Add on the static transformer names into the dynamic transformer names supplied - Set allTransformerNames = new HashSet(dynamicTransformerNames); - for (ContentTransformer transformer: transformerRegistry.getAllTransformers()) - { - String name = transformer.getName(); - allTransformerNames.add(name); - } - allTransformerNames.add(TransformerConfig.DEFAULT_TRANSFORMER); - - for (String transformerSimpleName: transformerReferences.keySet()) - { - if (!ANY.equals(transformerSimpleName)) - { - String name = TRANSFORMER+transformerSimpleName; - if (!allTransformerNames.contains(name)) - { - String line = transformerReferences.get(transformerSimpleName); - throw unexpectedProperty("Transformer "+transformerSimpleName+" does not exist", line); - } - } - } - } - - /** - * Removes transformer properties from the supplied multi line propertyNames. - * @param propertyNames which optionally include a value - * @throws IllegalArgumentException if an unexpected line is found - */ - public int removeProperties(String propertyNames) - { - Set remove = new HashSet(); - Map transformerReferences = new HashMap(); - Set dynamicTransformerNames = new HashSet(); - Properties defaultProperties = transformerProperties.getDefaultProperties(); - for (String propertyNameAndValue: extractProperties(propertyNames, false, transformerReferences, dynamicTransformerNames)) - { - Pair pair = splitNameAndValue(propertyNameAndValue); - String propertyName = pair.getFirst(); - if (transformerProperties.getProperty(propertyName) == null) - { - throw unexpectedProperty("Does not exist", propertyName); - } - if (defaultProperties.getProperty(propertyName) != null) - { - throw unexpectedProperty("Is a deafult property so may not be removed", propertyName); - } - remove.add(propertyName); - } - transformerProperties.removeProperties(remove); - return remove.size(); - } - - /** - * Returns an array of transformer property names (and optional values). - * @param text to be parsed - * @param hasValue values are required, optionally exist when false. - * @param transformerReferences map of transformerReferences to a line that referenced them. - * @param dynamicTransformerNames added via properties - * @return a list of cleaned up transformer properties from the text - * @throws IllegalArgumentException if an unexpected line is found - */ - private List extractProperties(String text, boolean hasValue, Map transformerReferences, Set dynamicTransformerNames) - { - List properties = new ArrayList(); - text = fixJConsolesMissingNewlines(text); - - // Split the lines - Matcher lineMatcher = LINE_SPLIT.matcher(text); - while (lineMatcher.find()) - { - String line = lineMatcher.group(); - - // Strip comments from lines - Matcher commentMatcher = COMMENT.matcher(line); - line = commentMatcher.replaceAll(""); - - // Ignore blank lines - if (line.length() != 0) - { - String lowerLine = line.toLowerCase(); // Should we set the lower case value anyway - if (lowerLine.startsWith(TransformerConfig.PREFIX)) - { - checkTransformerProperty(hasValue, line, transformerReferences, dynamicTransformerNames); - properties.add(line); - } - else if (lowerLine.startsWith(TransformerConfig.DEBUG_ENTRIES)) - { - checkInteger(hasValue, line, TransformerConfig.DEBUG_ENTRIES.length()); - properties.add(line); - } - else if (lowerLine.startsWith(TransformerConfig.LOG_ENTRIES)) - { - checkInteger(hasValue, line, TransformerConfig.LOG_ENTRIES.length()); - properties.add(line); - } - else if (lowerLine.startsWith(TransformerConfig.STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES)) - { - checkMimetypeList(hasValue, line, TransformerConfig.STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES.length(), true); - properties.add(line); - } - else - { - throw unexpectedProperty("Not a transformer property", line); - } - } - } - - return properties; - } - - /** - * Multi-line Strings from JConsole have their end of line bytes replaced by a - * single space. The following method tries to put them back in.

    - * - * It tries to avoid commented out transformers. - * - * @param text to scan - * @return modified text - */ - String fixJConsolesMissingNewlines(String text) - { - Matcher newlineMatcher = NEWLINE_CORRECTION.matcher(text); - text = newlineMatcher.replaceAll("$1\n$2"); - return text; - } - - private void checkTransformerProperty(boolean hasValue, String line, - Map transformerReferences, Set dynamicTransformerNames) - { - int j = line.indexOf('='); - String propertyName = j != -1 ? line.substring(0, j) : line; - TransformerPropertyNameExtractor extractor = new TransformerPropertyNameExtractor() {}; - - boolean validPropertyName = false; - String transformerName = null; - String suffix = null; - String separator = null; - - int k = propertyName.lastIndexOf(TransformerConfig.USE); - if (k != -1) - { - int l = k+TransformerConfig.USE.length(); - - if (propertyName.length()-l > 0) - { - propertyName = propertyName.substring(0, k); - } - else - { - throw unexpectedProperty("Missing use value after ...use. ", line); - } - } - - suffixesLoop: - for (String aSuffix: TransformerConfig.ALL_SUFFIXES) - { - if (propertyName.endsWith(aSuffix)) - { - transformerName = propertyName.substring(CONTENT.length(), propertyName.length()-aSuffix.length()); - suffix = aSuffix; - boolean separatorMatch = false; - for (String aSeparator: TransformerConfig.SEPARATORS) - { - int i = transformerName.lastIndexOf(aSeparator); - if (i != -1) - { - separatorMatch = true; - String extensions = transformerName.substring(i+aSeparator.length()); - String[] ext = extractor.splitExt(extensions); - if (ext.length == 2) - { - String firstExpression = ext[0]; - String secondExpression = ext[1]; - if (aSeparator == TransformerConfig.EXTENSIONS) - { - if (extractor.getMatchingExtensionsFromExtensions(firstExpression, mimetypeService).size() == 0) - { - throw unexpectedProperty("Invalid source extension "+firstExpression, line); - } - if (extractor.getMatchingExtensionsFromExtensions(secondExpression, mimetypeService).size() == 0) - { - throw unexpectedProperty("Invalid target extension "+secondExpression, line); - } - } - else // if (separator == TransformerConfig.MIMETYPES) - { - if (extractor.getMatchingExtensionsFromMimetypes(firstExpression, mimetypeService).size() == 0) - { - throw unexpectedProperty("Invalid source mimetype "+firstExpression, line); - } - if (extractor.getMatchingExtensionsFromMimetypes(secondExpression, mimetypeService).size() == 0) - { - throw unexpectedProperty("Invalid target mimetype "+secondExpression, line); - } - } - transformerName = transformerName.substring(0, i); - separator = aSeparator; - validPropertyName = true; - break suffixesLoop; - } - } - } - separator = null; - - if (!separatorMatch) - { - validPropertyName = true; - break suffixesLoop; - } - } - } - - if (!validPropertyName) - { - throw unexpectedProperty("Possible typo in the property name", line); - } - - checkTransformerPropertyValue(hasValue, line, j, transformerName, separator, suffix, - transformerReferences, dynamicTransformerNames); - } - - private void checkTransformerPropertyValue(boolean hasValue, String line, int i, - String transformerName, String separator, String suffix, - Map transformerReferences, Set dynamicTransformerNames) - { - if (MAX_SOURCE_SIZE_K_BYTES.equals(suffix) || - TIMEOUT_MS.equals(suffix) || - READ_LIMIT_K_BYTES.equals(suffix) || - READ_LIMIT_TIME_MS.equals(suffix) || - INITIAL_COUNT.equals(suffix) || - INITIAL_TIME.equals(suffix) || - ERROR_TIME.equals(suffix)) - { - checkLong(hasValue, line, i); - } - else if (MAX_PAGES.equals(suffix) || - PAGE_LIMIT.equals(suffix) || - THRESHOLD_COUNT.equals(suffix) || - PRIORITY.equals(suffix)) - { - checkInteger(hasValue, line, i); - } - else if (SUPPORTED.equals(suffix) || - AVAILABLE.equals(suffix)) - { - checkBoolean(hasValue, line, i); - } - else if (PIPELINE.equals(suffix) || - FAILOVER.equals(suffix)) - { - dynamicTransformerNames.add(transformerName); - if (separator != null) - { - throw unexpectedProperty("Separator was not expected", line); - } - - if (PIPELINE.equals(suffix)) - { - checkPipelineValue(hasValue, line, i, transformerReferences); - } - else - { - checkFailoverValue(hasValue, line, i, transformerReferences); - } - } - else if (BLACKLIST.equals(suffix)) - { - checkNodeRefList(hasValue, line, i); - } - } - - private void checkInteger(boolean hasValue, String line, int i) - { - String value = checkValue(hasValue, line, i); - - if (value != null) - { - if (!INTEGER.matcher(value).find()) - { - throw unexpectedProperty("Expected an integer value", line); - } - try - { - Integer.parseInt(value); - } - catch (NumberFormatException e) - { - throw unexpectedProperty("Expected an int value", line); - } - } - } - - private void checkLong(boolean hasValue, String line, int i) - { - String value = checkValue(hasValue, line, i); - - if (value != null) - { - if (!INTEGER.matcher(value).find()) - { - throw unexpectedProperty("Expected an integer value", line); - } - try - { - Long.parseLong(value); - } - catch (NumberFormatException e) - { - throw unexpectedProperty("Expected a long value", line); - } - } - } - - private void checkBoolean(boolean hasValue, String line, int i) - { - String value = checkValue(hasValue, line, i); - - if (value != null) - { - if (!value.equalsIgnoreCase("true") && - !value.equalsIgnoreCase("false")) - { - throw unexpectedProperty("Expected true or false value", line); - } - } - } - - private void checkPipelineValue(boolean hasValue, String line, int i, - Map transformerReferences) - { - String value = checkValue(hasValue, line, i); - - if (value != null) - { - String[] transformerNamesAndExtensions = value.split("\\|"); - - int count = transformerNamesAndExtensions.length; - - // Must be an even number of | characters, as they should be - // an initial transformer and then pairs of extension and transformer. - if (count < 2 || count % 2 == 0) - { - throw unexpectedProperty("Incomplete pipeline value", line); - } - - for (int j=0; j < count; j++) - { - if (j % 2 == 0) - { - // Added reference to the transformer if not ANY transformer - if (transformerNamesAndExtensions[j].length() > 0) - { - transformerReferences.put(transformerNamesAndExtensions[j], line); - } - } - else - { - String extension = transformerNamesAndExtensions[j]; - TransformerPropertyNameExtractor extractor= new TransformerPropertyNameExtractor() {}; - if (extractor.getMatchingExtensionsFromExtensions(extension, mimetypeService).size() == 0) - { - throw unexpectedProperty("Invalid intermediate extension "+extension, line); - } - } - } - } - } - - private void checkFailoverValue(boolean hasValue, String line, int i, - Map transformerReferences) - { - String value = checkValue(hasValue, line, i); - - if (value != null) - { - String[] transformerNames = value.split("\\|"); - int count = transformerNames.length; - - // Should be more than one transformer - if (count < 2) - { - throw unexpectedProperty("Can't failover if there is only on transformer", line); - } - - // Add every component - for (int j=0; j < count; j++) - { - if (transformerNames[j].length() > 0) - { - transformerReferences.put(transformerNames[j], line); - } - } - } - } - - private void checkNodeRefList(boolean hasValue, String line, int i) - { - String value = checkValue(hasValue, line, i); - - if (value != null) - { - for (String nodeRefString: line.split(", *")) - { - nodeRefString = nodeRefString.trim(); - if (nodeRefString.length() != 0 && !NodeRef.isNodeRef(nodeRefString)) - { - throw unexpectedProperty("Expected NodeRef value "+nodeRefString, line); - } - } - } - } - - private void checkMimetypeList(boolean hasValue, String line, int i, boolean evenNumberOfEntries) - { - String value = checkValue(hasValue, line, i); - value = value == null ? "" : value.trim(); - if (value.length() > 0) - { - String[] mimetypes = value.split(";"); - - if (evenNumberOfEntries && mimetypes.length % 2 != 0) - { - throw unexpectedProperty("There should be an even number of mimetypes.", line); - } - else - { - // Check the dericed mimetype on the Node are valid. Tika may have mimetypes we know nothing about. - List knownMimetypes = mimetypeService.getMimetypes(); - for (int j=0; j i && line.charAt(i) != '=')))) - { - throw unexpectedProperty("Expected a value after an '=' at char "+i, line); - } - - return (hasValue || (i != -1 && l > i)) ? line.substring(i+1) : null; - } - - private IllegalArgumentException unexpectedProperty(String context, String line) throws IllegalArgumentException - { - return new IllegalArgumentException("Unexpected property: "+line+" "+context); - } - - Pair splitNameAndValue(String propertyNameAndValue) - { - int i = propertyNameAndValue.indexOf('='); - String name = i != -1 ? propertyNameAndValue.substring(0, i) : propertyNameAndValue; - String value = i != -1 ? propertyNameAndValue.substring(i+1) : ""; - Pair pair = new Pair(name, value); - return pair; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelector.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelector.java deleted file mode 100644 index cccd96f2e9..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelector.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.List; - -import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Selects a transformer from a supplied list of transformers that appear - * able to handle a given transformation. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public interface TransformerSelector -{ - /** - * Returns a sorted list of transformers that identifies the order in which transformers - * should be tried. - * @param sourceMimetype - * @param sourceSize - * @param targetMimetype - * @param options transformation options - * @return a sorted list of transformers, with the best one first. - */ - List selectTransformers(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options); -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelectorImpl.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelectorImpl.java deleted file mode 100644 index ff8064d5de..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelectorImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Default transformer selector implementation, which sorts by priority and then - * by average transform time. The transform time is only used once a threshold - * (number of transforms) has been reached. This average is maintained for each - * source target mimetype pair.

    - * - * Prior to the introduction of this class the transformation time was only kept - * for each transformer. There was no threshold and there was a concept of - * 'Explicit' transformers, which would cause all other transformers to be discarded. - * It is still possible to disable transformers by giving adding unsupported mappings - * as has been done for transformers that would not have been used in the past as - * there existed one or more 'explicit' transformers (a concept not used by this - * TransformerSelector). By default a transformer has a priority of {@code 10}. - * Old 'Explicit' transformers have been given a priority of {@code 5}. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerSelectorImpl implements TransformerSelector -{ - private TransformerConfig transformerConfig; - private ContentTransformerRegistry contentTransformerRegistry; - private LegacyTransformerDebug transformerDebug; - - public void setTransformerConfig(TransformerConfig transformerConfig) - { - this.transformerConfig = transformerConfig; - } - - public void setContentTransformerRegistry(ContentTransformerRegistry contentTransformerRegistry) - { - this.contentTransformerRegistry = contentTransformerRegistry; - } - - public void setTransformerDebug(LegacyTransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - @Override - public List selectTransformers(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - // TODO cache results for reuse. This was a heavy operation in the past and still is. - - // TODO cache results of last few successful transforms as we tend to repeat some of them as part of compound transforms. - - List transformers = contentTransformerRegistry.getTransformers(); - List possibleTransformers = findTransformers(transformers, sourceMimetype, sourceSize, targetMimetype, options); - possibleTransformers = blacklistTransformers(possibleTransformers, sourceMimetype, sourceSize, targetMimetype, options); - return sortTransformers(possibleTransformers); - } - - /** - * Returns the list of possible transformers for the transformation. - */ - private List findTransformers(List allTransformers, String sourceMimetype, - long sourceSize, String targetMimetype, TransformationOptions options) - { - List transformers = new ArrayList(8); - for (ContentTransformer transformer : allTransformers) - { - int priority = transformerConfig.getPriority(transformer, sourceMimetype, targetMimetype); - if (priority > 0 && - transformer.isTransformable(sourceMimetype, sourceSize, targetMimetype, options) == true) - - { - transformers.add(new TransformerSortData(transformer, sourceMimetype, targetMimetype, priority)); - } - } - return transformers; - } - - /** - * Removes transformers from the list if the source NodeRef is in their blacklist. - */ - private List blacklistTransformers(List transformers, - String sourceMimetype, long sourceSize, String targetMimetype, - TransformationOptions options) - { - NodeRef nodeRef = options == null ? null : options.getSourceNodeRef(); - if (nodeRef != null) - { - List validTransformers = new ArrayList<>(transformers.size()); - for (TransformerSortData transformer: transformers) - { - List blacklist = transformerConfig.getBlacklist(transformer.transformer, sourceMimetype, targetMimetype); - - // Cannot just do if (blacklist == null || !blacklist.contains(nodeRef)) - // as files get moved to different content stores and get reindexed. - // So must just check the id. - boolean onBlacklist = false; - if (blacklist != null) - { - for (NodeRef blacklistNodeRef: blacklist) - { - if (blacklistNodeRef.getId().equals(nodeRef.getId())) - { - onBlacklist = true; - break; - } - } - } - - if (!onBlacklist) - { - validTransformers.add(transformer); - } - else - { - transformerDebug.blacklistTransform(transformer.transformer, sourceMimetype, targetMimetype, options); - } - } - transformers = validTransformers; - } - - return transformers; - } - - /** - * Returns a sorted list of transformers by priority and then average time (ignored if the threshold - * has not been reached). - */ - private List sortTransformers(List possibleTransformers) - { - Collections.sort(possibleTransformers); - - List transformers = new ArrayList(possibleTransformers.size()); - for (TransformerSortData possibleTransformer: possibleTransformers) - { - transformers.add(possibleTransformer.transformer); - } - return transformers; - } - - private class TransformerSortData implements Comparable - { - private final ContentTransformer transformer; - private final int priority; - private final long averageTime; - private final long count; - - TransformerSortData(ContentTransformer transformer, String sourceMimetype, String targetMimetype, int priority) - { - this.transformer = transformer; - this.priority = priority; - - TransformerStatistics stats = transformerConfig.getStatistics(transformer, sourceMimetype, targetMimetype, true); - int threashold = transformerConfig.getThresholdCount(transformer, sourceMimetype, targetMimetype); - count = stats.getCount(); - averageTime = (count < threashold) ? 0 : stats.getAverageTime(); - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + (int) (averageTime ^ (averageTime >>> 32)); - result = prime * result + priority; - return result; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof TransformerSortData && - transformer == ((TransformerSortData) obj).transformer; - } - - @Override - public int compareTo(TransformerSortData that) - { - int relativeInt = priority - that.priority; - if (relativeInt != 0) - { - return relativeInt; - } - - long relativeLong = averageTime - that.averageTime; - relativeInt = relativeLong > 0L ? 1 : relativeLong < 0L ? -1 : 0; - if (relativeInt != 0) - { - return relativeInt; - } - - relativeLong = count - that.count; - relativeInt = relativeLong > 0L ? 1 : relativeLong < 0L ? -1 : 0; - return relativeInt; - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelectorImplOriginal.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelectorImplOriginal.java deleted file mode 100644 index f692aa8ed6..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerSelectorImplOriginal.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Implementation of a transformer selector that matches the code that was in place - * before a selector was introduced. Class is not used but exists to allow customers - * to maintain the previous approach if they really wish. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerSelectorImplOriginal implements TransformerSelector -{ - private ContentTransformerRegistry contentTransformerRegistry; - - public void setContentTransformerRegistry(ContentTransformerRegistry contentTransformerRegistry) - { - this.contentTransformerRegistry = contentTransformerRegistry; - } - - @Override - public List selectTransformers( String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - List transformers = contentTransformerRegistry.getTransformers(); - transformers = findTransformers(transformers, sourceMimetype, sourceSize, targetMimetype, options); - transformers = discardNonExplicitTransformers(transformers, sourceMimetype, sourceSize, targetMimetype, options); - transformers = sortTransformers(transformers, sourceMimetype, sourceSize, targetMimetype, options); - return transformers; - } - - /** - * Reduces the list of transformers down to only those capable of doing the transformation. - */ - private List findTransformers(List allTransformers, String sourceMimetype, - long sourceSize, String targetMimetype, TransformationOptions options) - { - List transformers = new ArrayList(2); - - for (ContentTransformer transformer : allTransformers) - { - if (transformer.isTransformable(sourceMimetype, sourceSize, targetMimetype, options) == true) - { - transformers.add(transformer); - } - } - return transformers; - } - - /** - * Discards non explicit transformers if there are any explicit ones. - */ - private List discardNonExplicitTransformers(List allTransformers, String sourceMimetype, - long sourceSize, String targetMimetype, TransformationOptions options) - { - List transformers = new ArrayList(2); - boolean foundExplicit = false; - - for (ContentTransformer transformer : allTransformers) - { - if (transformer.isExplicitTransformation(sourceMimetype, targetMimetype, options) == true) - { - if (foundExplicit == false) - { - transformers.clear(); - foundExplicit = true; - } - transformers.add(transformer); - } - else - { - if (foundExplicit == false) - { - transformers.add(transformer); - } - } - } - return transformers; - } - - // sort by performance (quicker is "better") - private List sortTransformers(List transformers, - String sourceMimetype, long sourceSize, String targetMimetype, - TransformationOptions options) - { - final Map activeTransformers = new HashMap(); - for (ContentTransformer transformer : transformers) - { - long transformationTime = transformer.getTransformationTime(sourceMimetype, targetMimetype); - activeTransformers.put(transformer, transformationTime); - } - - List sorted = new ArrayList(activeTransformers.keySet()); - Collections.sort(sorted, new Comparator() { - @Override - public int compare(ContentTransformer a, ContentTransformer b) - { - return activeTransformers.get(a).compareTo(activeTransformers.get(b)); - } - }); - return sorted; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerStatistics.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerStatistics.java deleted file mode 100644 index 392512bc6f..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerStatistics.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.api.AlfrescoPublicApi; - -/** - * Interface to obtain the configuration and performance data for every - * source, target and transformer combination. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@AlfrescoPublicApi -public interface TransformerStatistics -{ - /** - * @return the extension of the source mimetype of the transformer. - */ - public String getSourceExt(); - - /** - * @return the extension of the target mimetype of the transformer. - */ - public String getTargetExt(); - - /** - * @return the name of the parent transformer. - */ - public String getTransformerName(); - - /** - * @return the number of time the transformer has been called. - */ - public long getCount(); - - /** - * @param count overrides the number of time the transformer has been called. - */ - public void setCount(long count); - - /** - * @return the number of time the transformer has failed. - */ - public long getErrorCount(); - - /** - * @param errorCount overrides the number of time the transformer has failed. - */ - public void setErrorCount(long errorCount); - - /** - * @return the average time taken by the the transformer. - */ - public long getAverageTime(); - - /** - * @param averageTime overrides the average time taken by the the transformer. - */ - public void setAverageTime(long averageTime); - - /** - * @return true if this is the summary of all transformations done - * by a transformer rather than just between two specific mimetypes. - */ - public boolean isSummary(); - - /** - * @param transformationTime to be added to this TransformationData and its parents. - */ - public void recordTime(long transformationTime); - - /** - * Adds 1 to the error count of this TransformationData and its parents. - */ - public void recordError(long transformationTime); -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerStatisticsImpl.java b/repository/src/main/java/org/alfresco/repo/content/transform/TransformerStatisticsImpl.java deleted file mode 100644 index 4328c7b676..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/TransformerStatisticsImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; - -import org.alfresco.service.cmr.repository.MimetypeService; - - -/** - * Implementation of a {@link TransformerStatistics}. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerStatisticsImpl implements TransformerStatistics -{ - private final MimetypeService mimetypeService; - private final String sourceMimetype; - private final String targetMimetype; - private final ContentTransformer transformer; - private final TransformerStatistics parent; - private final long errorTime; - - private double averageTime; - private long count = 0L; - private long errorCount = 0L; - - public TransformerStatisticsImpl(MimetypeService mimetypeService, String sourceMimetype, String targetMimetype, - ContentTransformer transformer, TransformerStatistics parent, long errorTime, - long initialAverageTime, long initialCount) - { - this.mimetypeService = mimetypeService; - this.sourceMimetype = sourceMimetype; - this.targetMimetype = targetMimetype; - this.transformer = transformer; - this.parent = parent; - this.errorTime = errorTime; - - averageTime = initialAverageTime; - count = initialCount; - } - - @Override - public String getSourceExt() - { - return ANY.equals(sourceMimetype) ? ANY : mimetypeService.getExtension(sourceMimetype); - } - - @Override - public String getTargetExt() - { - return ANY.equals(targetMimetype) ? ANY : mimetypeService.getExtension(targetMimetype); - } - - @Override - public String getTransformerName() - { - return transformer == null ? TransformerConfig.SUMMARY_TRANSFORMER_NAME : transformer.getName(); - } - - @Override - public synchronized void recordTime(long transformationTime) - { - if (count == Long.MAX_VALUE) - { - // we have reached the max count - reduce it by half - // the average fluctuation won't be extreme - count /= 2L; - } - // adjust the average - count++; - double diffTime = ((double) transformationTime) - averageTime; - averageTime += diffTime / (double) count; - - if (parent != null) - { - parent.recordTime(transformationTime); - } - } - - @Override - public synchronized void recordError(long transformationTime) - { - if (errorCount < Long.MAX_VALUE) - { - errorCount++; - } - - // Error time is only recorded for transformer, source and target combinations - recordTime((parent == null || transformer == null || errorTime <= 0 ? transformationTime : errorTime)); - - if (parent != null) - { - parent.recordError(transformationTime); - } - } - - @Override - public long getCount() - { - return count; - } - - @Override - public void setCount(long count) - { - this.count = count; - } - - @Override - public long getErrorCount() - { - return errorCount; - } - - @Override - public void setErrorCount(long errorCount) - { - this.errorCount = errorCount; - } - - @Override - public long getAverageTime() - { - return (long)averageTime; - } - - @Override - public void setAverageTime(long averageTime) - { - this.averageTime = (double)averageTime; - } - - public boolean isSummary() - { - return TransformerConfig.ANY.equals(sourceMimetype) && TransformerConfig.ANY.equals(targetMimetype); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java deleted file mode 100644 index b31a103e5a..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/magick/AbstractImageMagickContentTransformerWorker.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform.magick; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.content.transform.ContentTransformerHelper; -import org.alfresco.repo.content.transform.ContentTransformerWorker; -import org.alfresco.repo.content.transform.RemoteTransformerClient; -import org.alfresco.service.cmr.repository.*; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -import java.io.File; -import java.io.InputStream; - -/** - * Abstract helper for transformations based on ImageMagick - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public abstract class AbstractImageMagickContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean -{ - /** the prefix for mimetypes supported by the transformer */ - public static final String MIMETYPE_IMAGE_PREFIX = "image/"; - - private static final Log logger = LogFactory.getLog(AbstractImageMagickContentTransformerWorker.class); - - private boolean available; - - public AbstractImageMagickContentTransformerWorker() - { - this.available = false; - } - - /** - * @return Returns true if the transformer is functioning otherwise false - */ - public boolean isAvailable() - { - if (remoteTransformerClientConfigured() && !remoteTransformerClient.isAvailable()) - { - afterPropertiesSet(); - } - - return available; - } - - /** - * Make the transformer available - * @param available boolean - */ - protected void setAvailable(boolean available) - { - this.available = available; - } - - protected RemoteTransformerClient remoteTransformerClient; - - /** - * Sets the optional remote transformer client which will be used in preference to a local command if available. - * - * @param remoteTransformerClient may be null; - */ - public void setRemoteTransformerClient(RemoteTransformerClient remoteTransformerClient) - { - this.remoteTransformerClient = remoteTransformerClient; - } - - public boolean remoteTransformerClientConfigured() - { - return remoteTransformerClient != null && remoteTransformerClient.getBaseUrl() != null; - } - - /** - * Checks for the JMagick and ImageMagick dependencies, using the common - * {@link #transformInternal(File, String , File, java.lang.String, TransformationOptions) transformation method} to check - * that the sample image can be converted. - *

    - * If initialization is successful, then autoregistration takes place. - */ - public void afterPropertiesSet() - { - if (getMimetypeService() == null) - { - throw new AlfrescoRuntimeException("MimetypeMap not present"); - } - if (!remoteTransformerClientConfigured()) - { - try - { - // load, into memory the sample gif - String resourcePath = "org/alfresco/repo/content/transform/magick/alfresco.gif"; - InputStream imageStream = getClass().getClassLoader().getResourceAsStream(resourcePath); - if (imageStream == null) - { - throw new AlfrescoRuntimeException("Sample image not found: " + resourcePath); - } - // dump to a temp file - File inputFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_init_source_", - ".gif"); - FileContentWriter writer = new FileContentWriter(inputFile); - writer.putContent(imageStream); - - // create the output file - File outputFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_init_target_", - ".png"); - - // execute it - transformInternal( - inputFile, MimetypeMap.MIMETYPE_IMAGE_GIF, - outputFile, MimetypeMap.MIMETYPE_IMAGE_PNG, - new TransformationOptions()); - - // check that the file exists - if (!outputFile.exists() || outputFile.length() == 0) - { - throw new Exception("Image conversion failed: \n" + - " from: " + inputFile + "\n" + - " to: " + outputFile); - } - // we can be sure that it works - setAvailable(true); - } - catch (Throwable e) - { - logger.error( - getClass().getSimpleName() + " not available: " + - (e.getMessage() != null ? e.getMessage() : "")); - // debug so that we can trace the issue if required - logger.debug(e); - } - } - } - - /** - * Some image formats are not supported by ImageMagick, or at least appear not to work. - * - * @param mimetype the mimetype to check - * @return Returns true if ImageMagic can handle the given image format - */ - public static boolean isSupported(String mimetype) - { - // There are a few mimetypes in the system that do not start with "image/" but which - // nevertheless are supported by this transformer. - if (mimetype.equals(MimetypeMap.MIMETYPE_APPLICATION_EPS)) - { - return true; - } - else if (mimetype.equals(MimetypeMap.MIMETYPE_APPLICATION_PHOTOSHOP)) - { - return true; - } - - else if (!mimetype.startsWith(MIMETYPE_IMAGE_PREFIX)) - { - return false; // not an image - } - else if (mimetype.equals(MimetypeMap.MIMETYPE_IMAGE_RGB)) - { - return false; // rgb extension doesn't work - } - else if (mimetype.equals(MimetypeMap.MIMETYPE_IMAGE_SVG)) - { - return false; // svg extension doesn't work - } - else if (mimetype.equals(MimetypeMap.MIMETYPE_IMG_DWG)) - { - return false; // dwg extension doesn't work - } - else if (mimetype.equals(MimetypeMap.MIMETYPE_IMAGE_DWT)) - { - return false; // dwt extension doesn't work - } - else - { - return true; - } - } - - /** - * Supports image to image conversion, but only if the JMagick library and required - * libraries are available. - */ - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (!isAvailable()) - { - return false; - } - - // Add limited support (so lots of other transforms are not supported) for PDF to PNG. An ALF-14303 workaround. - // Will only be used as part of failover transformer.PdfToImage. Note .ai is the same format as .pdf - if ( (MimetypeMap.MIMETYPE_PDF.equals(sourceMimetype) || - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR.equals(sourceMimetype)) && - MimetypeMap.MIMETYPE_IMAGE_PNG.equals(targetMimetype)) - { - return true; - } - - // Add extra support for tiff to pdf to allow multiple page preview (ALF-7278) - if (MimetypeMap.MIMETYPE_IMAGE_TIFF.equals(sourceMimetype) && - MimetypeMap.MIMETYPE_PDF.equals(targetMimetype)) - { - return true; - } - - if (!AbstractImageMagickContentTransformerWorker.isSupported(sourceMimetype) || - !AbstractImageMagickContentTransformerWorker.isSupported(targetMimetype)) - { - // only support IMAGE -> IMAGE (excl. RGB) - return false; - } - else - { - return true; - } - } - - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append("# Supports transformations between mimetypes starting with \"image/\", but not\n"); - sb.append("# \""); - sb.append(MimetypeMap.MIMETYPE_IMAGE_RGB); - sb.append("\", \""); - sb.append(MimetypeMap.MIMETYPE_IMAGE_SVG); - sb.append("\" or \""); - sb.append(MimetypeMap.MIMETYPE_IMG_DWG); - sb.append("\".\n"); - sb.append("# eps as source or target.\n"); - sb.append("# pdf or ai to png.\n"); - sb.append("# tiff to pdf.\n"); - return sb.toString(); - } - - /** - * @see #transformInternal(File, String, File, String, TransformationOptions) - */ - public final void transform( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - // get mimetypes - String sourceMimetype = getMimetype(reader); - String targetMimetype = getMimetype(writer); - - // get the extensions to use - MimetypeService mimetypeService = getMimetypeService(); - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - if (sourceExtension == null || targetExtension == null) - { - throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" + - " source mimetype: " + sourceMimetype + "\n" + - " source extension: " + sourceExtension + "\n" + - " target mimetype: " + targetMimetype + "\n" + - " target extension: " + targetExtension); - } - - if (remoteTransformerClientConfigured()) - { - transformRemote(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); - } - else - { - transformLocal(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); - } - - // done - if (logger.isDebugEnabled()) - { - logger.debug("Transformation completed: \n" + - " source: " + reader + "\n" + - " target: " + writer + "\n" + - " options: " + options); - } - } - - private void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options, String sourceMimetype, String targetMimetype, String sourceExtension, String targetExtension) throws Exception - { - // create required temp files - File sourceFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_source_", - "." + sourceExtension); - File targetFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_target_", - "." + targetExtension); - - // pull reader file into source temp file - reader.getContent(sourceFile); - - // For most target mimetypes, it only makes sense to read the first page of the - // source, as the target is a single page, so set the pageLimit automatically. - // However for others, such as PDF (see ALF-7278) all pages should be read. - // transform the source temp file to the target temp file - transformInternal(sourceFile, sourceMimetype, targetFile, targetMimetype, options); - - // check that the file was created - if (!targetFile.exists() || targetFile.length() == 0) - { - throw new ContentIOException("ImageMagick transformation failed to write output file"); - } - // upload the output image - writer.putContent(targetFile); - } - - protected abstract void transformRemote(ContentReader reader, ContentWriter writer, TransformationOptions options, String sourceMimetype, String targetMimetype, String sourceExtension, String targetExtension) throws IllegalAccessException; - - /** - * Transform the image content from the source file to the target file - * - * @param sourceFile the source of the transformation - * @param sourceMimetype the mimetype of the source of the transformation - * @param targetFile the target of the transformation - * @param targetMimetype the mimetype of the target of the transformation - * @param options the transformation options supported by ImageMagick - * @throws Exception - */ - protected abstract void transformInternal( - File sourceFile, - String sourceMimetype, - File targetFile, - String targetMimetype, - TransformationOptions options) throws Exception; -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageCropOptions.java b/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageCropOptions.java deleted file mode 100644 index 3bc7b68a68..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageCropOptions.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ - -package org.alfresco.repo.content.transform.magick; - -import org.alfresco.service.cmr.repository.CropSourceOptions; - -/** - * Deprecated crop options. - * - * @deprecated replaced by {@link CropSourceOptions} - * @see CropSourceOptions - */ -public class ImageCropOptions extends CropSourceOptions -{ - -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java deleted file mode 100644 index 14aa1fb71b..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerWorker.java +++ /dev/null @@ -1,656 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2020 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 . - * #L% - */ -package org.alfresco.repo.content.transform.magick; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.*; -import org.alfresco.util.Pair; -import org.alfresco.util.TempFileProvider; -import org.alfresco.util.VersionNumber; -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; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.ALLOW_ENLARGEMENT; -import static org.alfresco.repo.rendition2.RenditionDefinition2.ALPHA_REMOVE; -import static org.alfresco.repo.rendition2.RenditionDefinition2.AUTO_ORIENT; -import static org.alfresco.repo.rendition2.RenditionDefinition2.CROP_GRAVITY; -import static org.alfresco.repo.rendition2.RenditionDefinition2.CROP_HEIGHT; -import static org.alfresco.repo.rendition2.RenditionDefinition2.CROP_PERCENTAGE; -import static org.alfresco.repo.rendition2.RenditionDefinition2.CROP_WIDTH; -import static org.alfresco.repo.rendition2.RenditionDefinition2.CROP_X_OFFSET; -import static org.alfresco.repo.rendition2.RenditionDefinition2.CROP_Y_OFFSET; -import static org.alfresco.repo.rendition2.RenditionDefinition2.END_PAGE; -import static org.alfresco.repo.rendition2.RenditionDefinition2.MAINTAIN_ASPECT_RATIO; -import static org.alfresco.repo.rendition2.RenditionDefinition2.RESIZE_HEIGHT; -import static org.alfresco.repo.rendition2.RenditionDefinition2.RESIZE_PERCENTAGE; -import static org.alfresco.repo.rendition2.RenditionDefinition2.RESIZE_WIDTH; -import static org.alfresco.repo.rendition2.RenditionDefinition2.START_PAGE; -import static org.alfresco.repo.rendition2.RenditionDefinition2.THUMBNAIL; - -/** - * Executes a statement to implement - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ImageMagickContentTransformerWorker extends AbstractImageMagickContentTransformerWorker -{ - /** options variable name */ - private static final String KEY_OPTIONS = "options"; - /** source variable name */ - private static final String VAR_SOURCE = "source"; - /** target variable name */ - private static final String VAR_TARGET = "target"; - - private static final Log logger = LogFactory.getLog(ImageMagickContentTransformerWorker.class); - - /** the system command executer */ - private RuntimeExec executer; - - private boolean enabled = true; - - /** the check command executer */ - private RuntimeExec checkCommand; - - /** the output from the check command */ - private String versionString; - - /** - * Default constructor - */ - public ImageMagickContentTransformerWorker() - { - // Intentionally empty - } - - /** - * Set the runtime command executer that must be executed in order to run - * ImageMagick. Whether or not this is the full path to the convertCommand - * or just the convertCommand itself depends the environment setup. - *

    - * The command must contain the variables ${source} and - * ${target}, which will be replaced by the names of the file to - * be transformed and the name of the output file respectively. - *

    -     *    convert ${source} ${target}
    -     * 
    - * - * @param executer the system command executer - */ - public void setExecuter(RuntimeExec executer) - { - executer.setProcessProperty( - "MAGICK_TMPDIR", TempFileProvider.getTempDir().getAbsolutePath()); - this.executer = executer; - } - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - /** - * 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 - * {@link #transformInternal(File, String, File, String, TransformationOptions) transformation method} to check - * that the sample image can be converted. - */ - @Override - public void afterPropertiesSet() - { - if (enabled) - { - if (!remoteTransformerClientConfigured() && executer == null) - { - throw new AlfrescoRuntimeException("System runtime executer not set"); - } - super.afterPropertiesSet(); - if (!remoteTransformerClientConfigured()) - { - if (isAvailable()) - { - try - { - // On some platforms / versions, the -version command seems to return an error code whilst still - // returning output, so let's not worry about the exit code! - ExecutionResult result = this.checkCommand.execute(); - this.versionString = result.getStdOut().trim(); - } - 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); - } - } - } - else - { - Pair result = remoteTransformerClient.check(logger); - Boolean isAvailable = result.getFirst(); - if (isAvailable != null && isAvailable) - { - setAvailable(true); - versionString = result.getSecond().trim(); - logger.debug("Using legacy ImageMagick: " + versionString); - } - else - { - setAvailable(false); - versionString = "unknown"; - String message = "Legacy remote ImageMagick is not available for transformations. " + result.getSecond(); - if (isAvailable == null) - { - logger.debug(message); - } - else - { - logger.error(message); - } - } - } - } - } - - /** - * Transform the image content from the source file to the target file - */ - @Override - protected void transformInternal(File sourceFile, String sourceMimetype, - File targetFile, String targetMimetype, TransformationOptions options) throws Exception - { - Map properties = new HashMap(5); - // set properties - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions)options; - CropSourceOptions cropOptions = imageOptions.getSourceOptions(CropSourceOptions.class); - ImageResizeOptions resizeOptions = imageOptions.getResizeOptions(); - String commandOptions = imageOptions.getCommandOptions(); - if (commandOptions == null) - { - commandOptions = ""; - } - // MNT-10882 : JPEG File Format, does not save the alpha (transparency) channel. - if (MimetypeMap.MIMETYPE_IMAGE_JPEG.equalsIgnoreCase(targetMimetype) && isAlphaOptionSupported()) - { - commandOptions += " -alpha remove"; - } - if (imageOptions.isAutoOrient()) - { - commandOptions = commandOptions + " -auto-orient"; - } - if (cropOptions != null) - { - commandOptions = commandOptions + " " + getImageCropCommandOptions(cropOptions); - } - if (resizeOptions != null) - { - commandOptions = commandOptions + " " + getImageResizeCommandOptions(resizeOptions); - } - properties.put(KEY_OPTIONS, commandOptions); - } - properties.put(VAR_SOURCE, sourceFile.getAbsolutePath() + - getSourcePageRange(options, sourceMimetype, targetMimetype)); - properties.put(VAR_TARGET, targetFile.getAbsolutePath()); - - // execute the statement - long timeoutMs = options.getTimeoutMs(); - RuntimeExec.ExecutionResult result = executer.execute(properties, timeoutMs); - if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0) - { - throw new ContentIOException("Failed to perform ImageMagick transformation: \n" + result); - } - - // success - if (logger.isDebugEnabled()) - { - logger.debug("ImageMagick executed successfully: \n" + executer); - } - } - - protected void transformRemote(ContentReader reader, ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension) throws IllegalAccessException - { - String[] args = getTEngineArgs(options, sourceMimetype, sourceExtension, targetMimetype, versionString); - long timeoutMs = options.getTimeoutMs(); - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, args); - } - - // Not to be called directly. Refactored to make it easier to test TransformationOptionsConverter. - public static String[] getTEngineArgs(TransformationOptions options, String sourceMimetype, String sourceExtension, - String targetMimetype, String versionString) - { - String startPage = null; - String endPage = null; - - String alphaRemove = null; - String autoOrient = null; - - String cropGravity = null; - String cropWidth = null; - String cropHeight = null; - String cropPercentage = null; - String cropXOffset = null; - String cropYOffset = null; - - String thumbnail = null; - String resizeWidth = null; - String resizeHeight = null; - String resizePercentage = null; - String allowEnlargement = null; - String maintainAspectRatio = null; - - String commandOptions = null; - - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions)options; - CropSourceOptions cropOptions = imageOptions.getSourceOptions(CropSourceOptions.class); - ImageResizeOptions resizeOptions = imageOptions.getResizeOptions(); - commandOptions = imageOptions.getCommandOptions(); - commandOptions = commandOptions == null || "".equals(commandOptions.trim()) ? null : commandOptions.trim(); - - // MNT-10882 : JPEG File Format, does not save the alpha (transparency) channel. - if (MimetypeMap.MIMETYPE_IMAGE_JPEG.equalsIgnoreCase(targetMimetype) && isAlphaOptionSupported(versionString)) - { - alphaRemove = Boolean.TRUE.toString(); - } - if (imageOptions.isAutoOrient()) - { - autoOrient = Boolean.TRUE.toString(); - } - if (cropOptions != null) - { - cropGravity = cropOptions.getGravity(); - int width = cropOptions.getWidth(); - if (width > -1) - { - cropWidth = Integer.toString(width); - } - - int height = cropOptions.getHeight(); - if (height > -1) - { - cropHeight = Integer.toString(height); - } - - if (cropOptions.isPercentageCrop()) - { - cropPercentage = Boolean.TRUE.toString(); - } - cropXOffset = Integer.toString(cropOptions.getXOffset()); - cropYOffset = Integer.toString(cropOptions.getYOffset()); - } - if (resizeOptions != null) - { - if (resizeOptions.isResizeToThumbnail()) - { - thumbnail = Boolean.TRUE.toString(); - } - if (resizeOptions.getWidth() > -1) - { - resizeWidth = Integer.toString(resizeOptions.getWidth()); - } - if (resizeOptions.getHeight() > -1) - { - resizeHeight = Integer.toString(resizeOptions.getHeight()); - } - if (resizeOptions.isPercentResize() == true) - { - resizePercentage = Boolean.TRUE.toString(); - } - if (!resizeOptions.getAllowEnlargement()) - { - allowEnlargement = Boolean.FALSE.toString(); - } - if (!resizeOptions.isMaintainAspectRatio()) - { - maintainAspectRatio = Boolean.FALSE.toString(); - } - } - } - - // Page range - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions) options; - PagedSourceOptions pagedSourceOptions = imageOptions.getSourceOptions(PagedSourceOptions.class); - if (pagedSourceOptions != null) - { - if (pagedSourceOptions.getStartPageNumber() != null) - { - startPage = Integer.toString(pagedSourceOptions.getStartPageNumber() - 1); - } - if (pagedSourceOptions.getEndPageNumber() != null) - { - endPage = Integer.toString(pagedSourceOptions.getEndPageNumber() - 1); - } - } - } - else - { - if (options.getPageLimit() == 1 || isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype)) - { - startPage = "0"; - } - } - - return new String[] { - "transformName", "imagemagick", - "sourceMimetype", sourceMimetype, - "sourceExtension", sourceExtension, - "targetMimetype", targetMimetype, - - START_PAGE, startPage, - END_PAGE, endPage, - - ALPHA_REMOVE, alphaRemove, - AUTO_ORIENT, autoOrient, - - CROP_GRAVITY, cropGravity, - CROP_WIDTH, cropWidth, - CROP_HEIGHT, cropHeight, - CROP_PERCENTAGE, cropPercentage, - CROP_X_OFFSET, cropXOffset, - CROP_Y_OFFSET, cropYOffset, - - THUMBNAIL, thumbnail, - RESIZE_WIDTH, resizeWidth, - RESIZE_HEIGHT, resizeHeight, - RESIZE_PERCENTAGE, resizePercentage, - ALLOW_ENLARGEMENT, allowEnlargement, - MAINTAIN_ASPECT_RATIO, maintainAspectRatio, - - // Parameter not to be taken forward into the Transform Service version - "commandOptions", commandOptions}; - } - - protected String getImageMagickVersionNumber() - { - return getImageMagickVersionNumber(versionString); - } - - private static String getImageMagickVersionNumber(String versionString) - { - Pattern verisonNumPattern = Pattern.compile("Version: ImageMagick ((\\d|\\.)+)(-.*){0,1}"); - try - { - Matcher versionNumMatcher = verisonNumPattern.matcher(versionString); - if (versionNumMatcher.find()) - { - return versionNumMatcher.group(1); - } - } - catch (Throwable e) - { - logger.info("Could not determine version of ImageMagick: " + e.getMessage()); - } - // version isn't extracted - return ""; - } - - /* - * MNT-10882 : Transparent PNG->JPG Transform Produces Ugly JPG Rendition - */ - protected boolean isAlphaOptionSupported() - { - return isAlphaOptionSupported(versionString); - } - - private static boolean isAlphaOptionSupported(String versionString) - { - // the "-alpha" option was only introduced in ImageMagick v6.7.5 and will fail in older versions. - String ALPHA_PROP_SUPPORTED_VERSION = "6.7.5"; - - try - { - VersionNumber supportedVersion = new VersionNumber(ALPHA_PROP_SUPPORTED_VERSION); - VersionNumber checkedVersion = new VersionNumber(getImageMagickVersionNumber(versionString)); - - return supportedVersion.compareTo(checkedVersion) > 0 ? false : true; - } - catch (Exception e) - { - logger.warn("Could not extract version of ImageMagick. Alpha-compatibility will be disabled: " + e.getMessage()); - } - return false; - } - - /** - * Gets the imagemagick command string for the image crop options provided - * - * @param cropOptions image resize options - * @return String the imagemagick command options - */ - private String getImageCropCommandOptions(CropSourceOptions cropOptions) - { - StringBuilder builder = new StringBuilder(32); - String gravity = cropOptions.getGravity(); - if(gravity!=null) - { - builder.append("-gravity "); - builder.append(gravity); - builder.append(" "); - } - builder.append("-crop "); - int width = cropOptions.getWidth(); - if (width > -1) - { - builder.append(width); - } - - int height = cropOptions.getHeight(); - if (height > -1) - { - builder.append("x"); - builder.append(height); - } - - if (cropOptions.isPercentageCrop()) - { - builder.append("%"); - } - appendOffset(builder, cropOptions.getXOffset()); - appendOffset(builder, cropOptions.getYOffset()); - builder.append(" +repage"); - return builder.toString(); - } - - /** - * @param builder - * @param xOffset - */ - private void appendOffset(StringBuilder builder, int xOffset) - { - if(xOffset>=0) - { - builder.append("+"); - } - builder.append(xOffset); - } - - /** - * Gets the imagemagick command string for the image resize options provided - * - * @param imageResizeOptions image resize options - * @return String the imagemagick command options - */ - private String getImageResizeCommandOptions(ImageResizeOptions imageResizeOptions) - { - StringBuilder builder = new StringBuilder(32); - - // These are ImageMagick options. See http://www.imagemagick.org/script/command-line-processing.php#geometry for details. - if (imageResizeOptions.isResizeToThumbnail() == true) - { - builder.append("-thumbnail "); - } - else - { - builder.append("-resize "); - } - - if (imageResizeOptions.getWidth() > -1) - { - builder.append(imageResizeOptions.getWidth()); - } - - if (imageResizeOptions.getHeight() > -1) - { - builder.append("x"); - builder.append(imageResizeOptions.getHeight()); - } - - if (imageResizeOptions.isPercentResize() == true) - { - builder.append("%"); - } - // ALF-7308. Disallow the enlargement of small images e.g. within imgpreview thumbnail. - if (!imageResizeOptions.getAllowEnlargement()) - { - builder.append(">"); - } - - if (imageResizeOptions.isMaintainAspectRatio() == false) - { - builder.append("!"); - } - - return builder.toString(); - } - - /** - * Determines whether or not a single page range is required for the given source and target mimetypes. - * - * @param sourceMimetype - * @param targetMimetype - * @return whether or not a page range must be specified for the transformer to read the target files - */ - private static boolean isSingleSourcePageRangeRequired(String sourceMimetype, String targetMimetype) - { - // Need a page source if we're transforming from PDF or TIFF to an image other than TIFF - // or from PSD - return ((sourceMimetype.equals(MimetypeMap.MIMETYPE_PDF) || - sourceMimetype.equals(MimetypeMap.MIMETYPE_IMAGE_TIFF)) && - ((!targetMimetype.equals(MimetypeMap.MIMETYPE_IMAGE_TIFF) - && targetMimetype.contains(MIMETYPE_IMAGE_PREFIX)) || - targetMimetype.equals(MimetypeMap.MIMETYPE_APPLICATION_PHOTOSHOP) || - targetMimetype.equals(MimetypeMap.MIMETYPE_APPLICATION_EPS)) || - sourceMimetype.equals(MimetypeMap.MIMETYPE_APPLICATION_PHOTOSHOP)); - } - - /** - * Gets the page range from the source to use in the command line. - * - * @param options the transformation options - * @param sourceMimetype the source mimetype - * @param targetMimetype the target mimetype - * @return the source page range for the command line - */ - private String getSourcePageRange(TransformationOptions options, String sourceMimetype, String targetMimetype) - { - // Check for PagedContentSourceOptions in the options - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions) options; - PagedSourceOptions pagedSourceOptions = imageOptions.getSourceOptions(PagedSourceOptions.class); - if (pagedSourceOptions != null) - { - if (pagedSourceOptions.getStartPageNumber() != null && - pagedSourceOptions.getEndPageNumber() != null) - { - if (pagedSourceOptions.getStartPageNumber().equals(pagedSourceOptions.getEndPageNumber())) - { - return "[" + (pagedSourceOptions.getStartPageNumber() - 1) + "]"; - } - else - { - if (isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype)) - { - throw new AlfrescoRuntimeException( - "A single page is required for targets of type " + targetMimetype); - } - return "[" + (pagedSourceOptions.getStartPageNumber() - 1) + - "-" + (pagedSourceOptions.getEndPageNumber() - 1) + "]"; - } - } - else - { - // TODO specified start to end of doc and start of doc to specified end not yet supported - // Just grab a single page specified by either start or end - if (pagedSourceOptions.getStartPageNumber() != null) - return "[" + (pagedSourceOptions.getStartPageNumber() - 1) + "]"; - if (pagedSourceOptions.getEndPageNumber() != null) - return "[" + (pagedSourceOptions.getEndPageNumber() - 1) + "]"; - } - } - } - if (options.getPageLimit() == 1 || isSingleSourcePageRangeRequired(sourceMimetype, targetMimetype)) - { - return "[0]"; - } - else - { - return ""; - } - } -} diff --git a/repository/src/main/java/org/alfresco/repo/content/transform/pdfrenderer/AlfrescoPdfRendererContentTransformerWorker.java b/repository/src/main/java/org/alfresco/repo/content/transform/pdfrenderer/AlfrescoPdfRendererContentTransformerWorker.java deleted file mode 100644 index d50e4700de..0000000000 --- a/repository/src/main/java/org/alfresco/repo/content/transform/pdfrenderer/AlfrescoPdfRendererContentTransformerWorker.java +++ /dev/null @@ -1,450 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ - -package org.alfresco.repo.content.transform.pdfrenderer; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.transform.ContentTransformerHelper; -import org.alfresco.repo.content.transform.ContentTransformerWorker; -import org.alfresco.repo.content.transform.RemoteTransformerClient; -import org.alfresco.repo.content.transform.magick.ImageResizeOptions; -import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.PagedSourceOptions; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.Pair; -import org.alfresco.util.PropertyCheck; -import org.alfresco.util.TempFileProvider; -import org.alfresco.util.exec.RuntimeExec; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import static org.alfresco.repo.rendition2.RenditionDefinition2.ALLOW_PDF_ENLARGEMENT; -import static org.alfresco.repo.rendition2.RenditionDefinition2.HEIGHT; -import static org.alfresco.repo.rendition2.RenditionDefinition2.MAINTAIN_PDF_ASPECT_RATIO; -import static org.alfresco.repo.rendition2.RenditionDefinition2.PAGE; -import static org.alfresco.repo.rendition2.RenditionDefinition2.WIDTH; - -/** - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class AlfrescoPdfRendererContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean -{ - - /** options variable name */ - private static final String KEY_OPTIONS = "options"; - /** source variable name */ - private static final String VAR_SOURCE = "source"; - /** target variable name */ - private static final String VAR_TARGET = "target"; - - private static final Log logger = LogFactory.getLog(AlfrescoPdfRendererContentTransformerWorker.class); - - /** the system command executer */ - private RuntimeExec executer; - - private boolean enabled = true; - - /** the check command executer */ - private RuntimeExec checkCommand; - - /** the output from the check command */ - private String versionString; - - private RemoteTransformerClient remoteTransformerClient; - - private boolean available; - - public AlfrescoPdfRendererContentTransformerWorker() - { - this.available = false; - } - - /** - * Set the runtime command executer that must be executed in order to run alfresco-pdf-renderer. Whether or not this is - * the full path to the command or just the command itself depends the environment setup. - *

    - * The command must contain the variables ${source} and ${target}, which will be replaced - * by the names of the file to be transformed and the name of the output file respectively. - * - *

    -     *    alfresco-pdf-renderer ${source} ${target}
    -     * 
    - * - * @param executer the system command executer - */ - public void setExecuter(RuntimeExec executer) - { - this.executer = executer; - } - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - /** - * Sets the optional remote transformer client which will be used in preference to a local command if available. - * - * @param remoteTransformerClient may be null; - */ - public void setRemoteTransformerClient(RemoteTransformerClient remoteTransformerClient) - { - this.remoteTransformerClient = remoteTransformerClient; - } - - @Override - public boolean remoteTransformerClientConfigured() - { - return remoteTransformerClient != null && remoteTransformerClient.getBaseUrl() != null; - } - - /** - * Sets the command that must be executed in order to retrieve version information from the 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; - } - - @Override - public void afterPropertiesSet() - { - if (enabled) - { - PropertyCheck.mandatory(this, "executer", executer); - PropertyCheck.mandatory(this, "isAvailable", checkCommand); - // check availability - try - { - Pair result = remoteTransformerClientConfigured() - ? remoteTransformerClient.check(logger) - : remoteTransformerClient.check(checkCommand); - Boolean isAvailable = result.getFirst(); - if (isAvailable != null && isAvailable) - { - versionString = result.getSecond(); - setAvailable(true); - logger.debug("Using legacy Alfresco PDF Renderer: " + versionString); - } - else - { - setAvailable(false); - String message = "Legacy Alfresco PDF Renderer is not available for transformations. " + result.getSecond(); - if (isAvailable == null) - { - logger.debug(message); - } - else - { - logger.error(message); - } - } - } - catch (Throwable e) - { - setAvailable(false); - logger.error("Remote Alfresco PDF Renderer is not available: " + (e.getMessage() != null ? e.getMessage() : "")); - // debug so that we can trace the issue if required - logger.debug(e); - } - } - } - - /** - * @return Returns true if the transformer is functioning otherwise false - */ - @Override - public boolean isAvailable() - { - if (remoteTransformerClientConfigured() && !remoteTransformerClient.isAvailable()) - { - afterPropertiesSet(); - } - - return available; - } - - /** - * Make the transformer available - * - * @param available boolean - */ - protected void setAvailable(boolean available) - { - this.available = available; - } - - @Override - public String getVersionString() - { - return this.versionString; - } - - @Override - public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (!isAvailable()) - { - return false; - } - - // Add limited support (so lots of other transforms are not supported) - // for PDF to PNG. - if ((MimetypeMap.MIMETYPE_PDF.equals(sourceMimetype) || MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR.equals(sourceMimetype)) && - MimetypeMap.MIMETYPE_IMAGE_PNG.equals(targetMimetype)) - { - return true; - } - - return false; - } - - @Override - public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception - { - // get mimetypes - String sourceMimetype = getMimetype(reader); - String targetMimetype = getMimetype(writer); - - // get the extensions to use - MimetypeService mimetypeService = getMimetypeService(); - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - if (sourceExtension == null || targetExtension == null) - { - throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" + - " source mimetype: " + sourceMimetype + "\n" + - " source extension: " + sourceExtension + "\n" + - " target mimetype: " + targetMimetype + "\n" + - " target extension: " + targetExtension); - } - - if (remoteTransformerClientConfigured()) - { - transformRemote(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); - } - else - { - transformLocal(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); - } - - // done - if (logger.isDebugEnabled()) - { - logger.debug("Transformation completed: \n" + - " source: " + reader + "\n" + - " target: " + writer + "\n" + - " options: " + options); - } - } - - private void transformLocal(ContentReader reader, ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension) throws Exception - { - // create required temp files - File sourceFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_source_", "." + sourceExtension); - File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_target_", "." + targetExtension); - - // pull reader file into source temp file - reader.getContent(sourceFile); - - Map properties = new HashMap(5); - // set properties - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions) options; - ImageResizeOptions resizeOptions = imageOptions.getResizeOptions(); - String commandOptions = imageOptions.getCommandOptions(); - if (commandOptions == null) - { - commandOptions = ""; - } - if(resizeOptions != null) - { - if (resizeOptions.getHeight() > -1) - { - commandOptions += " --height=" + resizeOptions.getHeight(); - } - if (resizeOptions.getWidth() > -1) - { - commandOptions += " --width=" + resizeOptions.getWidth(); - } - if (resizeOptions.getAllowEnlargement()) - { - commandOptions += " --allow-enlargement"; - } - if (resizeOptions.isMaintainAspectRatio()) - { - commandOptions += " --maintain-aspect-ratio"; - } - } - commandOptions += " --page=" + getSourcePageRange(imageOptions, sourceMimetype, targetMimetype); - - properties.put(KEY_OPTIONS, commandOptions); - } - - properties.put(VAR_SOURCE, sourceFile.getAbsolutePath()); - properties.put(VAR_TARGET, targetFile.getAbsolutePath()); - - // execute the statement - long timeoutMs = options.getTimeoutMs(); - RuntimeExec.ExecutionResult result = executer.execute(properties, timeoutMs); - if (result.getExitValue() != 0 && result.getStdErr() != null && result.getStdErr().length() > 0) - { - throw new ContentIOException("Failed to perform alfresco-pdf-renderer transformation: \n" + result); - } - // success - if (logger.isDebugEnabled()) - { - logger.debug("alfresco-pdf-renderer executed successfully: \n" + executer); - } - - // check that the file was created - if (!targetFile.exists() || targetFile.length() == 0) - { - throw new ContentIOException("alfresco-pdf-renderer transformation failed to write output file"); - } - - // upload the output image - writer.putContent(targetFile); - } - - /** - * Transform the pdf content using a remote transformer - */ - private void transformRemote(ContentReader reader, ContentWriter writer, TransformationOptions options, - String sourceMimetype, String targetMimetype, - String sourceExtension, String targetExtension) throws Exception - { - String page = null; - String width = null; - String height = null; - String allowEnlargement = null; - String maintainAspectRatio = null; - - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions) options; - ImageResizeOptions resizeOptions = imageOptions.getResizeOptions(); - if(resizeOptions != null) - { - if (resizeOptions.getWidth() > -1) - { - width = Integer.toString(resizeOptions.getWidth()); - } - if (resizeOptions.getHeight() > -1) - { - height = Integer.toString(resizeOptions.getHeight()); - } - if (resizeOptions.getAllowEnlargement()) - { - allowEnlargement = Boolean.TRUE.toString(); - } - if (resizeOptions.isMaintainAspectRatio()) - { - maintainAspectRatio = Boolean.TRUE.toString(); - } - } - page = getSourcePageRange(imageOptions, sourceMimetype, targetMimetype); - } - - long timeoutMs = options.getTimeoutMs(); - remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, - timeoutMs, logger, - "transformName", "pdfrenderer", - "sourceMimetype", sourceMimetype, - "targetMimetype", targetMimetype, - "targetExtension", targetExtension, - PAGE, page, - WIDTH, width, - HEIGHT, height, - ALLOW_PDF_ENLARGEMENT, allowEnlargement, - MAINTAIN_PDF_ASPECT_RATIO, maintainAspectRatio); - } - - @Override - public String getComments(boolean available) - { - StringBuilder sb = new StringBuilder(); - sb.append("# Supports transformations between mimetypes"); - sb.append("# pdf or ai to png.\n"); - return sb.toString(); - } - - /** - * Gets the page range from the source to use in the command line. - * - * @param options the transformation options - * @param sourceMimetype the source mimetype - * @param targetMimetype the target mimetype - * @return the source page range for the command line - */ - private String getSourcePageRange(TransformationOptions options, String sourceMimetype, String targetMimetype) - { - if (options instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions) options; - PagedSourceOptions pagedSourceOptions = imageOptions.getSourceOptions(PagedSourceOptions.class); - if (pagedSourceOptions != null) - { - if (pagedSourceOptions.getStartPageNumber() != null && pagedSourceOptions.getEndPageNumber() != null) - { - if (pagedSourceOptions.getStartPageNumber().equals(pagedSourceOptions.getEndPageNumber())) - { - return "" + (pagedSourceOptions.getStartPageNumber() - 1); - } - else - { - throw new AlfrescoRuntimeException("The alfresco-pdf-renderer can only convert single pages, no page ranges."); - } - } - else - { - throw new AlfrescoRuntimeException("The alfresco-pdf-renderer can only convert single pages, no page ranges."); - } - } - } - return "0"; - } - -} diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/ContentTransformServiceImpl.java b/repository/src/main/java/org/alfresco/repo/rendition2/ContentTransformServiceImpl.java deleted file mode 100644 index 2f3be4e45b..0000000000 --- a/repository/src/main/java/org/alfresco/repo/rendition2/ContentTransformServiceImpl.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.content.transform.ContentTransformerRegistry; -import org.alfresco.repo.content.transform.LegacyTransformerDebug; -import org.alfresco.repo.content.transform.UnimportantTransformException; -import org.alfresco.repo.content.transform.UnsupportedTransformationException; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NoTransformerException; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.PropertyCheck; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * Contains deprecated code originally from {@link org.alfresco.repo.content.ContentServiceImpl} that is used to perform - * Legacy transforms. - * - * @author adavis - */ -@Deprecated -public abstract class ContentTransformServiceImpl implements InitializingBean -{ - protected static Log logger = LogFactory.getLog(LegacyTransformClient.class); - - private MimetypeService mimetypeService; - private ContentTransformerRegistry transformerRegistry; - private LegacyTransformerDebug transformerDebug; - - private boolean transformerFailover = true; - - public void setMimetypeService(MimetypeService mimetypeService) - { - this.mimetypeService = mimetypeService; - } - - public void setTransformerRegistry(ContentTransformerRegistry transformerRegistry) - { - this.transformerRegistry = transformerRegistry; - } - - public void setTransformerDebug(LegacyTransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - public void setTransformerFailover(boolean transformerFailover) - { - this.transformerFailover = transformerFailover; - } - - @Override - public void afterPropertiesSet() throws Exception - { - PropertyCheck.mandatory(this, "mimetypeService", mimetypeService); - PropertyCheck.mandatory(this, "transformerRegistry", transformerRegistry); - PropertyCheck.mandatory(this, "transformerDebug", transformerDebug); - } - - @Deprecated - public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws NoTransformerException, ContentIOException - { - // check that source and target mimetypes are available - if (reader == null) - { - throw new AlfrescoRuntimeException("The content reader must be set"); - } - String sourceMimetype = reader.getMimetype(); - if (sourceMimetype == null) - { - throw new AlfrescoRuntimeException("The content reader mimetype must be set: " + reader); - } - String targetMimetype = writer.getMimetype(); - if (targetMimetype == null) - { - throw new AlfrescoRuntimeException("The content writer mimetype must be set: " + writer); - } - - long sourceSize = reader.getSize(); - try - { - // look for a transformer - transformerDebug.pushAvailable(reader.getContentUrl(), sourceMimetype, targetMimetype, options); - List transformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options); - transformerDebug.availableTransformers(transformers, sourceSize, options, "ContentService.transform(...)"); - - int count = transformers.size(); - if (count == 0) - { - throw new NoTransformerException(sourceMimetype, targetMimetype); - } - - if (count == 1 || !transformerFailover) - { - ContentTransformer transformer = transformers.size() == 0 ? null : transformers.get(0); - transformer.transform(reader, writer, options); - } - else - { - failoverTransformers(reader, writer, options, targetMimetype, transformers); - } - } - finally - { - if (transformerDebug.isEnabled()) - { - transformerDebug.popAvailable(); - debugTransformations(sourceMimetype, targetMimetype, sourceSize, options); - } - } - } - - private void failoverTransformers(ContentReader reader, ContentWriter writer, - TransformationOptions options, String targetMimetype, - List transformers) - { - List exceptions = null; - boolean done = false; - try - { - // Try the best transformer and then the next if it fails - // and so on down the list - char c = 'a'; - String outputFileExt = mimetypeService.getExtension(targetMimetype); - for (ContentTransformer transformer : transformers) - { - ContentWriter currentWriter = writer; - File tempFile = null; - try - { - // We can't know in advance which of the - // available transformer will work - if any. - // We can't write into the ContentWriter stream. - // So make a temporary file writer with the - // current transformer name. - tempFile = TempFileProvider.createTempFile( - "FailoverTransformer_intermediate_" - + transformer.getClass().getSimpleName() + "_", "." - + outputFileExt); - currentWriter = new FileContentWriter(tempFile); - currentWriter.setMimetype(targetMimetype); - currentWriter.setEncoding(writer.getEncoding()); - - if (c != 'a' && transformerDebug.isEnabled()) - { - transformerDebug.debug(""); - transformerDebug.debug("Try " + c + ")"); - } - c++; - - transformer.transform(reader, currentWriter, options); - - if (tempFile != null) - { - writer.putContent(tempFile); - } - - // No need to close input or output streams - // (according - // to comment in FailoverContentTransformer) - done = true; - return; - } - catch (Exception e) - { - if (exceptions == null) - { - exceptions = new ArrayList(); - } - if (!(e instanceof AlfrescoRuntimeException)) - { - e = new AlfrescoRuntimeException(e.getMessage(), e); - } - exceptions.add((AlfrescoRuntimeException)e); - - // Set a new reader to refresh the input stream. - reader = reader.getReader(); - } - } - // Throw the exception from the first transformer. The - // others are consumed. - if (exceptions != null) - { - throw exceptions.get(0); - } - } - finally - { - // Log exceptions that we have consumed. We may have thrown the first one if - // none of the transformers worked. - if (exceptions != null) - { - boolean first = true; - for (Exception e : exceptions) - { - Throwable rootCause = (e instanceof AlfrescoRuntimeException) ? ((AlfrescoRuntimeException)e).getRootCause() : null; - String message = (rootCause == null ? null : rootCause.getMessage()); - if (done) - { - message = "Transformer succeeded after previous transformer failed"+ (message == null ? "" : ": "+message); - if (rootCause instanceof UnsupportedTransformationException || - rootCause instanceof UnimportantTransformException) - { - logger.debug(message); - } - else - { - logger.warn(message, e); - } - } - else if (!first) // The first exception is logged later - { - message = "Transformer exception"+ (message == null ? "" : ": "+message); - if (rootCause instanceof UnsupportedTransformationException || - rootCause instanceof UnimportantTransformException) - { - logger.debug(message); - } - else - { - logger.error(message, e); - } - first = false; - } - } - } - } - } - - @Deprecated - public ContentTransformer getTransformer(String sourceUrl, String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - List transformers = null; - try - { - transformerDebug.pushAvailable(sourceUrl, sourceMimetype, targetMimetype, options); - List activeTransformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options); - transformerDebug.availableTransformers(activeTransformers, sourceSize, options, "ContentService.getTransformer(...)"); - transformers = activeTransformers.isEmpty() ? null : activeTransformers; - } - finally - { - transformerDebug.popAvailable(); - } - return (transformers == null) ? null : transformers.get(0); - } - - private void debugTransformations(String sourceMimetype, String targetMimetype, - long sourceSize, TransformationOptions transformOptions) - { - // check the file name - if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(sourceMimetype) && - MimetypeMap.MIMETYPE_IMAGE_PNG.equals(targetMimetype)) - { - String fileName = transformerDebug.getFileName(transformOptions, true, 0); - if (fileName != null && fileName.contains("debugTransformers.txt")) - { - transformerDebug.transformationsByTransformer(null, false, false, null); - transformerDebug.transformationsByExtension(null, null, false, false, false, null); - } - } - } - - @Deprecated - public List getTransformers(String sourceUrl, String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - try - { - // look for a transformer - transformerDebug.pushAvailable(sourceUrl, sourceMimetype, targetMimetype, options); - List transformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options); - transformerDebug.availableTransformers(transformers, sourceSize, options, "ContentService.getTransformer(...)"); - return transformers.isEmpty() ? null : transformers; - } - finally - { - transformerDebug.popAvailable(); - } - } - - @Deprecated - public long getMaxSourceSizeBytes(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - try - { - long maxSourceSize = 0; - transformerDebug.pushAvailable(null, sourceMimetype, targetMimetype, options); - List transformers = getActiveTransformers(sourceMimetype, -1, targetMimetype, options); - for (ContentTransformer transformer: transformers) - { - long maxSourceSizeKBytes = transformer.getMaxSourceSizeKBytes(sourceMimetype, targetMimetype, options); - if (maxSourceSize >= 0) - { - if (maxSourceSizeKBytes < 0) - { - maxSourceSize = -1; - } - else if (maxSourceSizeKBytes > 0 && maxSourceSize < maxSourceSizeKBytes) - { - maxSourceSize = maxSourceSizeKBytes; - } - } - // if maxSourceSizeKBytes == 0 this implies the transformation is disabled - } - if (transformerDebug.isEnabled()) - { - transformerDebug.availableTransformers(transformers, -1, options, - "ContentService.getMaxSourceSizeBytes() = "+transformerDebug.fileSize(maxSourceSize*1024)); - } - return (maxSourceSize > 0) ? maxSourceSize * 1024 : maxSourceSize; - } - finally - { - transformerDebug.popAvailable(); - } - } - - @Deprecated - public List getActiveTransformers(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) - { - return transformerRegistry.getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/LegacySynchronousTransformClient.java b/repository/src/main/java/org/alfresco/repo/rendition2/LegacySynchronousTransformClient.java deleted file mode 100644 index 23ea6cba3c..0000000000 --- a/repository/src/main/java/org/alfresco/repo/rendition2/LegacySynchronousTransformClient.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptions; - -import java.util.Map; - -/** - * Request synchronous transforms. Used in refactoring deprecated code, which called Legacy transforms, so that it will - * first try a Local transform, falling back to Legacy if not available. Transforms take place using transforms - * available on the local machine (based on {@link org.alfresco.repo.content.transform.AbstractContentTransformer2}). - * - * @author adavis - */ -@Deprecated -public class LegacySynchronousTransformClient extends ContentTransformServiceImpl implements SynchronousTransformClient -{ - private static final String TRANSFORM = "Legacy synchronous transform "; - - private TransformationOptionsConverter converter; - - public void setConverter(TransformationOptionsConverter converter) - { - this.converter = converter; - } - - @Override - public boolean isSupported(String sourceMimetype, long sourceSizeInBytes, String contentUrl, String targetMimetype, - Map actualOptions, String transformName, NodeRef sourceNodeRef) - { - String renditionName = TransformDefinition.convertToRenditionName(transformName); - TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, actualOptions); - transformationOptions.setSourceNodeRef(sourceNodeRef); - - ContentTransformer legacyTransform = getTransformer(contentUrl, sourceMimetype, - sourceSizeInBytes, targetMimetype, transformationOptions); - - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + renditionName + " from " + sourceMimetype + - (legacyTransform == null ? " is unsupported" : " is supported")); - } - return legacyTransform != null; - } - - @Override - public void transform(ContentReader reader, ContentWriter writer, Map actualOptions, - String transformName, NodeRef sourceNodeRef) - { - String renditionName = TransformDefinition.convertToRenditionName(transformName); - try - { - TransformationOptions options = converter.getTransformationOptions(renditionName, actualOptions); - options.setSourceNodeRef(sourceNodeRef); - - if (null == reader || !reader.exists()) - { - throw new IllegalArgumentException("sourceNodeRef "+sourceNodeRef+" has no content."); - } - - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "requested " + renditionName); - } - - // We don't obtain the Legacy transformer and then call its transform method as they unlike Local and - // Transform Service transforms automatically fail over to the next highest priority. This was not done - // for the newer transforms, as a fail over can always be defined and that makes it simpler to understand - // what is going on. - transform(reader, writer, options); - - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "created " + renditionName); - } - } - catch (Exception e) - { - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "failed " + renditionName, e); - } - throw e; - } - } - - @Override - public String getName() - { - return "Legacy"; - } -} diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/LegacyTransformClient.java b/repository/src/main/java/org/alfresco/repo/rendition2/LegacyTransformClient.java deleted file mode 100644 index 541819403f..0000000000 --- a/repository/src/main/java/org/alfresco/repo/rendition2/LegacyTransformClient.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.PropertyCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; - -import java.io.InputStream; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * Requests rendition transforms take place using legacy transforms available on the local machine (based on - * {@link org.alfresco.repo.content.transform.AbstractContentTransformer2}. The transform and consumption of the - * resulting content is linked into a single operation that will take place at some point in the future on the local - * machine. - * - * @author adavis - */ -@Deprecated -public class LegacyTransformClient implements TransformClient, InitializingBean -{ - private static final String TRANSFORM = "Legacy transform "; - private static Log logger = LogFactory.getLog(LegacyTransformClient.class); - - private TransactionService transactionService; - private ContentService contentService; - private RenditionService2Impl renditionService2; - private TransformationOptionsConverter converter; - private LegacySynchronousTransformClient legacySynchronousTransformClient; - - private ExecutorService executorService; - private ThreadLocal transform = new ThreadLocal<>(); - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - public void setRenditionService2(RenditionService2Impl renditionService2) - { - this.renditionService2 = renditionService2; - } - - public void setConverter(TransformationOptionsConverter converter) - { - this.converter = converter; - } - - public void setLegacySynchronousTransformClient(LegacySynchronousTransformClient legacySynchronousTransformClient) - { - this.legacySynchronousTransformClient = legacySynchronousTransformClient; - } - - public void setExecutorService(ExecutorService executorService) - { - this.executorService = executorService; - } - - @Override - public void afterPropertiesSet() throws Exception - { - PropertyCheck.mandatory(this, "transactionService", transactionService); - PropertyCheck.mandatory(this, "contentService", contentService); - PropertyCheck.mandatory(this, "renditionService2", renditionService2); - PropertyCheck.mandatory(this, "converter", converter); - PropertyCheck.mandatory(this, "legacySynchronousTransformClient", legacySynchronousTransformClient); - if (executorService == null) - { - executorService = Executors.newCachedThreadPool(); - } - } - - @Override - public void checkSupported(NodeRef sourceNodeRef, RenditionDefinition2 renditionDefinition, String sourceMimetype, long sourceSizeInBytes, String contentUrl) - { - String targetMimetype = renditionDefinition.getTargetMimetype(); - String renditionName = renditionDefinition.getRenditionName(); - Map options = renditionDefinition.getTransformOptions(); - - TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, options); - transformationOptions.setSourceNodeRef(sourceNodeRef); - - ContentTransformer legacyTransform = legacySynchronousTransformClient.getTransformer(contentUrl, sourceMimetype, sourceSizeInBytes, targetMimetype, transformationOptions); - transform.set(legacyTransform); - - String message = TRANSFORM + renditionName + " from " + sourceMimetype + - (legacyTransform == null ? " is unsupported" : " is supported"); - logger.debug(message); - if (legacyTransform == null) - { - throw new UnsupportedOperationException(message); - } - } - - @Override - public void transform(NodeRef sourceNodeRef, RenditionDefinition2 renditionDefinition, String user, int sourceContentHashCode) - { - String targetMimetype = renditionDefinition.getTargetMimetype(); - String renditionName = renditionDefinition.getRenditionName(); - Map actualOptions = renditionDefinition.getTransformOptions(); - TransformationOptions options = converter.getTransformationOptions(renditionName, actualOptions); - options.setSourceNodeRef(sourceNodeRef); - ContentTransformer legacyTransform = transform.get(); - - executorService.submit(() -> - { - AuthenticationUtil.runAs((AuthenticationUtil.RunAsWork) () -> - transactionService.getRetryingTransactionHelper().doInTransaction(() -> - { - try - { - if (legacyTransform == null) - { - throw new IllegalStateException("isSupported was not called prior to an asynchronous transform."); - } - - ContentReader reader = contentService.getReader(sourceNodeRef, ContentModel.PROP_CONTENT); - if (null == reader || !reader.exists()) - { - throw new IllegalArgumentException("sourceNodeRef "+sourceNodeRef+" has no content."); - } - - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "requested " + renditionName); - } - - // Note: we don't call legacyTransform.transform(reader, writer, options) as the Legacy - // transforms (unlike Local and Transform Service) automatically fail over to the next - // highest priority. This was not done for the newer transforms, as a fail over can always be - // defined and that makes it simpler to understand what is going on. - ContentWriter writer = contentService.getTempWriter(); - writer.setMimetype(targetMimetype); - legacySynchronousTransformClient.transform(reader, writer, options); - - InputStream inputStream = writer.getReader().getContentInputStream(); - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "to be consumed " + renditionName); - } - renditionService2.consume(sourceNodeRef, inputStream, renditionDefinition, sourceContentHashCode); - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "consumed " + renditionName); - } - } - catch (Exception e) - { - if (logger.isDebugEnabled()) - { - logger.debug(TRANSFORM + "failed " + renditionName, e); - } - if (renditionDefinition instanceof TransformDefinition) - { - ((TransformDefinition) renditionDefinition).setErrorMessage(e.getMessage()); - } - renditionService2.failure(sourceNodeRef, renditionDefinition, sourceContentHashCode); - throw e; - } - return null; - }), user); - }); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/LegacyTransformServiceRegistry.java b/repository/src/main/java/org/alfresco/repo/rendition2/LegacyTransformServiceRegistry.java deleted file mode 100644 index 0e8be7a48d..0000000000 --- a/repository/src/main/java/org/alfresco/repo/rendition2/LegacyTransformServiceRegistry.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2020 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.content.transform.TransformerDebug; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.transform.client.registry.TransformServiceRegistry; -import org.alfresco.util.PropertyCheck; -import org.springframework.beans.factory.InitializingBean; - -import java.util.List; -import java.util.Map; - - -/** - * Implements {@link TransformServiceRegistry} providing a mechanism of validating if a legacy transformation - * (based on {@link org.alfresco.repo.content.transform.AbstractContentTransformer2} request is supported. - * - * @author adavis - */ -@Deprecated -public class LegacyTransformServiceRegistry implements InitializingBean, TransformServiceRegistry -{ - private LegacySynchronousTransformClient legacySynchronousTransformClient; - private TransformationOptionsConverter converter; - private boolean enabled = true; - private boolean firstTime = true; - private TransformerDebug transformerDebug; - - public void setLegacySynchronousTransformClient(LegacySynchronousTransformClient legacySynchronousTransformClient) - { - this.legacySynchronousTransformClient = legacySynchronousTransformClient; - } - - public void setConverter(TransformationOptionsConverter converter) - { - this.converter = converter; - } - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - firstTime = true; - } - - public boolean isEnabled() - { - return enabled; - } - - public void setTransformerDebug(TransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - @Override - public void afterPropertiesSet() - { - PropertyCheck.mandatory(this, "legacySynchronousTransformClient", legacySynchronousTransformClient); - PropertyCheck.mandatory(this, "converter", converter); - PropertyCheck.mandatory(this, "transformerDebug", transformerDebug); - } - - @Override - public long findMaxSize(String sourceMimetype, String targetMimetype, Map options, String renditionName) - { - // This message is not logged if placed in afterPropertiesSet - if (firstTime) - { - firstTime = false; - transformerDebug.debug("Legacy transforms are " + (enabled ? "enabled" : "disabled")); - } - - long maxSize = 0; - if (enabled) - { - try - { - TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, options); - maxSize = legacySynchronousTransformClient.getMaxSourceSizeBytes(sourceMimetype, targetMimetype, transformationOptions); - } - catch (IllegalArgumentException ignore) - { - // Typically if the mimetype is invalid. - } - } - return maxSize; - } - - @Override - public String findTransformerName(String sourceMimetype, long sourceSizeInBytes, String targetMimetype, Map actualOptions, String renditionName) - { - String name = null; - try - { - TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, actualOptions); - List transformers = legacySynchronousTransformClient.getActiveTransformers( - sourceMimetype, sourceSizeInBytes, targetMimetype, transformationOptions); - if (!transformers.isEmpty()) - { - name = legacySynchronousTransformClient.getName() + ":" + transformers.get(0).getName(); - } - } - catch (IllegalArgumentException ignore) - { - // Typically if the mimetype is invalid. - } - return name; - } -} \ No newline at end of file diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/RenditionDefinitionRegistry2Impl.java b/repository/src/main/java/org/alfresco/repo/rendition2/RenditionDefinitionRegistry2Impl.java index a164b52f62..d955fbaa57 100644 --- a/repository/src/main/java/org/alfresco/repo/rendition2/RenditionDefinitionRegistry2Impl.java +++ b/repository/src/main/java/org/alfresco/repo/rendition2/RenditionDefinitionRegistry2Impl.java @@ -282,6 +282,7 @@ public class RenditionDefinitionRegistry2Impl implements RenditionDefinitionRegi public Data createData() { + // Reload static XML definitions Data currentData = null; if (firstTime) { diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/SwitchingSynchronousTransformClient.java b/repository/src/main/java/org/alfresco/repo/rendition2/SwitchingSynchronousTransformClient.java deleted file mode 100644 index 546ff72c1c..0000000000 --- a/repository/src/main/java/org/alfresco/repo/rendition2/SwitchingSynchronousTransformClient.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.alfresco.repo.content.transform.TransformerDebug; -import org.alfresco.repo.content.transform.UnsupportedTransformationException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.Pair; - -import java.util.Map; - -/** - * Request synchronous transforms. Used in refactoring deprecated code, which called Legacy transforms, so that it will - * first try a Local transform, falling back to Legacy if not available. Class provides the switch between Local and - * Legacy transforms. - * - * @author adavis - */ -@Deprecated -public class SwitchingSynchronousTransformClient implements SynchronousTransformClient -{ - private final SynchronousTransformClient primary; - private final SynchronousTransformClient secondary; - - private TransformerDebug transformerDebug; - - public SwitchingSynchronousTransformClient(SynchronousTransformClient primary, SynchronousTransformClient secondary) - { - this.primary = primary; - this.secondary = secondary; - } - - public void setTransformerDebug(TransformerDebug transformerDebug) - { - this.transformerDebug = transformerDebug; - } - - @Override - public boolean isSupported(String sourceMimetype, long sourceSizeInBytes, String contentUrl, String targetMimetype, - Map actualOptions, String transformName, NodeRef sourceNodeRef) - { - SynchronousTransformClient client = null; - - if (primary.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, actualOptions, - transformName, sourceNodeRef)) - { - client = primary; - } - else if (secondary.isSupported(sourceMimetype, sourceSizeInBytes, contentUrl, targetMimetype, actualOptions, - transformName, sourceNodeRef)) - { - client = secondary; - } - - if (transformerDebug.isEnabled()) - { - String renditionName = TransformDefinition.convertToRenditionName(transformName); - transformerDebug.debug(sourceMimetype, targetMimetype, sourceNodeRef, sourceSizeInBytes, - actualOptions, renditionName, - "synchronous transform is "+ - (client == null ? "NOT supported" : "supported by "+client.getName())); - } - return client != null; - } - - @Override - public void transform(ContentReader reader, ContentWriter writer, Map actualOptions, - String transformName, NodeRef sourceNodeRef) - { - try - { - primary.transform(reader, writer, actualOptions, transformName, sourceNodeRef); - } - catch (UnsupportedTransformationException primaryException) - { - try - { - secondary.transform(reader, writer, actualOptions, transformName, sourceNodeRef); - } - catch (UnsupportedTransformationException secondaryException) - { - throw primaryException; - } - } - } - - @Override - public String getName() - { - // If we start nesting SwitchingSynchronousTransformClients, we will need to get the current client from a ThreadLocal - throw new UnsupportedOperationException("SwitchingSynchronousTransformClients cannot be nested"); - } -} diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/SynchronousTransformClient.java b/repository/src/main/java/org/alfresco/repo/rendition2/SynchronousTransformClient.java index c91a501ea5..bff14dba53 100644 --- a/repository/src/main/java/org/alfresco/repo/rendition2/SynchronousTransformClient.java +++ b/repository/src/main/java/org/alfresco/repo/rendition2/SynchronousTransformClient.java @@ -25,15 +25,11 @@ */ package org.alfresco.repo.rendition2; -import org.alfresco.model.ContentModel; import org.alfresco.repo.content.transform.UnsupportedTransformationException; -import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.TransformationOptions; import java.util.Map; @@ -83,7 +79,7 @@ public interface SynchronousTransformClient throws UnsupportedTransformationException, ContentIOException; /** - * @return type of transform (Local, Legacy) for use in debug. + * @return type of transform (Local) for use in debug. */ String getName(); } diff --git a/repository/src/main/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java b/repository/src/main/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java index 48f232ba45..3d2a54cf0f 100644 --- a/repository/src/main/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java +++ b/repository/src/main/java/org/alfresco/repo/thumbnail/ThumbnailRegistry.java @@ -293,12 +293,6 @@ public class ThumbnailRegistry implements ApplicationContextAware, ApplicationLi // not cache the empty list. We prevent this because we want to allow for // transformers only coming online *during* system operation - as opposed // to coming online during startup. - // - // An example of such a transient transformer would be those that use OpenOffice.org. - // It is possible that the system might start without OOo-based transformers - // being available. Therefore we must not cache an empty list for the relevant - // MIME types - otherwise this class would hide the fact that OOo (soffice) has - // been launched and that new transformers are available. if (foundAtLeastOneTransformer) { this.mimetypeMap.put(mimetype, thumbnailDefinitionsLimitsForMimetype); diff --git a/repository/src/main/java/org/alfresco/service/cmr/action/ActionServiceTransientException.java b/repository/src/main/java/org/alfresco/service/cmr/action/ActionServiceTransientException.java index 2df7f13cc8..3d8ec4d953 100644 --- a/repository/src/main/java/org/alfresco/service/cmr/action/ActionServiceTransientException.java +++ b/repository/src/main/java/org/alfresco/service/cmr/action/ActionServiceTransientException.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2020 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 . + * #L% + */ package org.alfresco.service.cmr.action; /** @@ -31,8 +31,7 @@ package org.alfresco.service.cmr.action; * same action might succeed. *

    * An example of this would be the case where a request to create a thumbnail - * has failed because the necessary thumbnailing software is not available e.g. because the OpenOffice.org process - * is not currently running. + * has failed because the necessary thumbnailing software is not available. *

    * The {@link ActionService} can be configured to run a {@link Action#setCompensatingAction(Action) compensating action} * when another action fails with an exception. If however the exception thrown is an instance of {@link ActionServiceTransientException} diff --git a/repository/src/main/java/org/alfresco/service/cmr/repository/ContentService.java b/repository/src/main/java/org/alfresco/service/cmr/repository/ContentService.java index 986df27e34..81622ff41a 100644 --- a/repository/src/main/java/org/alfresco/service/cmr/repository/ContentService.java +++ b/repository/src/main/java/org/alfresco/service/cmr/repository/ContentService.java @@ -54,7 +54,7 @@ import java.util.Date; * @author Derek Hulley */ @AlfrescoPublicApi -public interface ContentService extends ContentTransformService +public interface ContentService { /** * Gets the total space of the underlying content store (not exclusively Alfresco-controlled binaries). diff --git a/repository/src/main/java/org/alfresco/service/cmr/repository/ContentTransformService.java b/repository/src/main/java/org/alfresco/service/cmr/repository/ContentTransformService.java deleted file mode 100644 index 9f9a5cd0f2..0000000000 --- a/repository/src/main/java/org/alfresco/service/cmr/repository/ContentTransformService.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ -package org.alfresco.service.cmr.repository; - -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.rendition2.SynchronousTransformClient; -import org.alfresco.service.Auditable; -import org.alfresco.transform.client.registry.TransformServiceRegistry; - -import java.util.List; -import java.util.Map; - -/** - * Contains deprecated code from {@link ContentService} that is used to perform Legacy transforms. - * - * @author adavis - */ -public interface ContentTransformService -{ - /** - * @deprecated use {@link SynchronousTransformClient#transform(ContentReader, ContentWriter, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"reader", "writer"}) - void transform(ContentReader reader, ContentWriter writer) - throws NoTransformerException, ContentIOException; - - - /** - * @deprecated use {@link SynchronousTransformClient#transform(ContentReader, ContentWriter, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"reader", "writer", "options"}) - void transform(ContentReader reader, ContentWriter writer, Map options) - throws NoTransformerException, ContentIOException; - - /** - * @deprecated use {@link SynchronousTransformClient#transform(ContentReader, ContentWriter, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"reader", "writer", "options"}) - void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) - throws NoTransformerException, ContentIOException; - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"sourceMimetype", "targetMimetype"}) - ContentTransformer getTransformer(String sourceMimetype, String targetMimetype); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"sourceMimetype", "sourceSize", "targetMimetype", "options"}) - List getTransformers(String sourceUrl, String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"sourceMimetype", "sourceSize", "targetMimetype", "options"}) - ContentTransformer getTransformer(String sourceUrl, String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Deprecated - ContentTransformer getTransformer(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * @deprecated use {@link TransformServiceRegistry#findMaxSize(String, String, Map, String)}. - */ - @Deprecated - @Auditable(parameters = {"sourceMimetype", "targetMimetype", "options"}) - long getMaxSourceSizeBytes(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Auditable(parameters = {"sourceMimetype", "sourceSize", "targetMimetype", "options"}) - List getActiveTransformers(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - List getActiveTransformers(String sourceMimetype, String targetMimetype, TransformationOptions options); - - /** - * @deprecated there is no longer a need to obtain a transformer specifically for images. - * Use {@link SynchronousTransformClient#transform(ContentReader, ContentWriter, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable - ContentTransformer getImageTransformer(); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"reader", "writer"}) - boolean isTransformable(ContentReader reader, ContentWriter writer); - - /** - * @deprecated use {@link SynchronousTransformClient#isSupported(String, long, String, String, Map, String, NodeRef)}. - */ - @Deprecated - @Auditable(parameters = {"reader", "writer", "options"}) - boolean isTransformable(ContentReader reader, ContentWriter writer, TransformationOptions options); -} diff --git a/repository/src/main/java/org/alfresco/service/cmr/repository/TransformationOptionLimitsMap.java b/repository/src/main/java/org/alfresco/service/cmr/repository/TransformationOptionLimitsMap.java deleted file mode 100644 index 505f6e9852..0000000000 --- a/repository/src/main/java/org/alfresco/service/cmr/repository/TransformationOptionLimitsMap.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.service.cmr.repository; - -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Helper class to create an immutable - * {@code Map>}, keyed on source and target mimetypes. Used to - * define transformation limits, without having to specify lots of spring XML. For example: - * - *

    - * <bean id="mimetypeLimits.OpenOffice" class="org.alfresco.service.cmr.repository.TransformationOptionLimitsMap">
    - *    <constructor-arg>
    - *       <i;value>
    - *          *   txt maxSourceSizeKBytes ${content.transformer.OpenOffice.mimeTypeLimits.txt.pdf.maxSourceSizeKBytes} ;
    - *          doc pdf maxSourceSizeKBytes ${content.transformer.OpenOffice.mimeTypeLimits.doc.pdf.maxSourceSizeKBytes}
    - *       </value>
    - *    </constructor-arg>
    - *    <constructor-arg>
    - *       <ref bean="mimetypeService" />
    - *    </constructor-arg>
    - * </bean>
    - * 
    - * The first constructor argument is a space separated list of values: - *
    - * configuration ::= [ <source extension> <target extension> <property name> <value> ]* ";" ]*
    - * property name ::= "maxSourceSizeKBytes" | "readLimitKBytes" | "readLimitTimeMs" | "timeoutMs" | "maxPages" | "pageLimit"
    - * 
    - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformationOptionLimitsMap extends - AbstractMap> -{ - private static final Log logger = LogFactory.getLog(TransformationOptionLimitsMap.class); - - private Map> map = new HashMap>(); - - private enum State - { - SOURCE, TARGET, NAME, VALUE - } - - private List propertyNames = Arrays.asList("maxsourcesizekbytes", "readlimitkbytes", - "readlimittimems", "timeoutms", "maxpages", "pagelimit"); - - /** - * Constructor. The {@code value} parameter takes a space separated list of - * values that define the map. See the class descriptor. - * - * @param values - * the configuration. - * @param mimetypeService - * used to lookup mimetypes. - */ - public TransformationOptionLimitsMap(String values, MimetypeService mimetypeService) - { - String sourceMimetype = null; - String targetMimetype = null; - TransformationOptionLimits limits = null; - String name = null; - long value; - int entry = 1; - State state = State.SOURCE; - - - String[] bits = values.split(" *"); - mimetypeService.getMimetypesByExtension(); - for (String bit: bits) - { - // ignore white space such as new lines - bit = bit.trim(); - if (bit.length() == 0) - { - continue; - } - - switch(state) - { - case SOURCE: - sourceMimetype = bit.equals("*") ? bit : mimetypeService.getMimetype(bit); - if (sourceMimetype == null) - { - logger.error("Entry "+entry+" invalid source extension '"+bit+"' - ignored"); - } - else - { - state = State.TARGET; - } - break; - case TARGET: - targetMimetype = bit.equals("*") ? bit : mimetypeService.getMimetype(bit); - if (targetMimetype == null) - { - logger.error("Entry "+entry+" invalid target extension '"+bit+"' - ignored"); - } - else - { - limits = new TransformationOptionLimits(); - state = State.NAME; - } - break; - case NAME: - if (";".equals(bit)) - { - add(sourceMimetype, targetMimetype, limits); - entry++; - state = State.SOURCE; - } - else - { - if (propertyNames.contains(bit.toLowerCase())) - { - name = bit.toLowerCase(); - state = State.VALUE; - } - else - { - logger.error("Entry " + entry + " invalid property name '" + bit - + "' - ignored"); - } - } - break; - case VALUE: - try - { - value = Long.parseLong(bit); - if (name.equalsIgnoreCase("maxSourceSizeKBytes")) - { - limits.setMaxSourceSizeKBytes(value); - } - else if (name.equalsIgnoreCase("readLimitKBytes")) - { - limits.setReadLimitKBytes(value); - } - else if (name.equalsIgnoreCase("readLimitTimeMs")) - { - limits.setReadLimitTimeMs(value); - } - else if (name.equalsIgnoreCase("timeoutMs")) - { - limits.setTimeoutMs(value); - } - else if (value > Integer.MAX_VALUE) - { - logger.error("Entry "+entry+" invalid property name '"+bit+"' - skipping property and value"); - } - else if (name.equalsIgnoreCase("maxPages")) - { - limits.setMaxPages((int)value); - } - else if (name.equalsIgnoreCase("pageLimit")) - { - limits.setPageLimit((int)value); - } - } - catch (NumberFormatException e) - { - logger.error("Entry " + entry + " invalid value '" + bit + "' - skipping property and value"); - } - state = State.NAME; - break; - } - } - // Optional last ; - if (state == State.NAME) - { - add(sourceMimetype, targetMimetype, limits); - } - else if (state != State.SOURCE) - { - logger.error("Entry " + entry + " is incomplete."); - } - } - - private void add(String sourceMimetype, String targetMimetype, TransformationOptionLimits limits) - { - Map map2 = map.get(sourceMimetype); - if (map2 == null) - { - map2 = new HashMap(); - map.put(sourceMimetype, map2); - } - map2.put(targetMimetype, limits); - } - - @Override - public Set>> entrySet() - { - return map.entrySet(); - } -} diff --git a/repository/src/main/java/org/alfresco/transform/client/registry/TransformServiceRegistryImpl.java b/repository/src/main/java/org/alfresco/transform/client/registry/TransformServiceRegistryImpl.java index 449708d57d..2467a924ff 100644 --- a/repository/src/main/java/org/alfresco/transform/client/registry/TransformServiceRegistryImpl.java +++ b/repository/src/main/java/org/alfresco/transform/client/registry/TransformServiceRegistryImpl.java @@ -34,6 +34,7 @@ import org.quartz.CronExpression; import org.springframework.beans.factory.InitializingBean; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -174,6 +175,25 @@ public abstract class TransformServiceRegistryImpl extends AbstractTransformRegi getLog().error(msg); } + @Override + public String findTransformerName(final String sourceMimetype, final long sourceSizeInBytes, + final String targetMimetype, final Map actualOptions, + final String renditionName) + { + return enabled + ? super.findTransformerName(sourceMimetype, sourceSizeInBytes, targetMimetype, actualOptions, renditionName) + : null; + } + + @Override + public long findMaxSize(final String sourceMimetype, final String targetMimetype, + final Map actualOptions, final String renditionName) + { + return enabled + ? super.findMaxSize(sourceMimetype, targetMimetype, actualOptions, renditionName) + : 0; + } + /** * Works out an ordered list of transformer that will be used to transform content of a given source mimetype * into a target mimetype given a list of actual transform option names and values (Strings) plus the data contained @@ -191,7 +211,8 @@ public abstract class TransformServiceRegistryImpl extends AbstractTransformRegi final Map actualOptions, final String renditionName) { - return retrieveTransformListBySize(getData(), sourceMimetype, targetMimetype, actualOptions, - renditionName); + return enabled + ? retrieveTransformListBySize(getData(), sourceMimetype, targetMimetype, actualOptions, renditionName) + : Collections.emptyList(); } } diff --git a/repository/src/main/java/org/alfresco/util/OpenOfficeCommandLine.java b/repository/src/main/java/org/alfresco/util/OpenOfficeCommandLine.java deleted file mode 100644 index f996001cc0..0000000000 --- a/repository/src/main/java/org/alfresco/util/OpenOfficeCommandLine.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.util; - -import java.io.File; -import java.io.IOException; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.util.OpenOfficeURI; -import org.alfresco.util.exec.RuntimeExec; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * A map giving the open office start up command, which depends on the version of - * OpenOffice or LibreOffice. - * - * @author Alan Davis - */ -public class OpenOfficeCommandLine extends AbstractMap> -{ - private static final Log logger = LogFactory.getLog(OpenOfficeCommandLine.class); - private Map> map = new HashMap>(); - private OpenOfficeVariant variant = new OpenOfficeVariant(); - - public OpenOfficeCommandLine(String exe, String port, String user) throws IOException - { - File executable = variant.findExecutable(exe); - File officeHome = variant.getOfficeHome(executable); - - List command = new ArrayList(); - String acceptValue = "socket,host=127.0.0.1,port="+port+";urp;StarOffice.ServiceManager"; - String userInstallation = new OpenOfficeURI(user).toString(); - command.add(executable == null ? exe : executable.getAbsolutePath()); - if (variant.isLibreOffice3Dot5(officeHome)) - { - command.add("--accept=" + acceptValue); - if (variant.isMac() && !variant.isLibreOffice3Dot6(officeHome)) - { - command.add("--env:UserInstallation=" + userInstallation); - } - else - { - command.add("-env:UserInstallation=" + userInstallation); - } - command.add("--headless"); - command.add("--nocrashreport"); - //command.add("--nodefault"); included by JOD - command.add("--nofirststartwizard"); - //command.add("--nolockcheck"); included by JOD - command.add("--nologo"); - command.add("--norestore"); - logger.info("Using GNU based LibreOffice "+ - (variant.isLibreOffice3Dot6(officeHome) ? "3.6" : "3.5")+" command"+ - (variant.isMac() ? " on Mac" : "")+": "+command); - } - else - { - command.add("-accept=" + acceptValue); - command.add("-env:UserInstallation=" + userInstallation); - command.add("-headless"); - command.add("-nocrashreport"); - //command.add("-nodefault"); included by JOD - command.add("-nofirststartwizard"); - //command.add("-nolockcheck"); included by JOD - command.add("-nologo"); - command.add("-norestore"); - logger.info("Using original OpenOffice command: "+command); - } - map.put(RuntimeExec.KEY_OS_DEFAULT, command); - } - - @Override - public Set>> entrySet() - { - return map.entrySet(); - } -} diff --git a/repository/src/main/java/org/alfresco/util/OpenOfficeURI.java b/repository/src/main/java/org/alfresco/util/OpenOfficeURI.java deleted file mode 100644 index 3bab70beed..0000000000 --- a/repository/src/main/java/org/alfresco/util/OpenOfficeURI.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.util; - -import java.io.File; -import java.io.IOException; - -/** - * A class that attempts to embody OpenOffice's rules for encoding file URIs which appear to differ from Java's. A - * Windows style path is always prefixed "file:///" whereas a unix one is prefixed "file://". - * - * @author dward - */ -public class OpenOfficeURI -{ - - /** The source file. */ - private File source; - - /** - * Instantiates a new open office URI. - * - * @param source - * the source file name to convert to a URI - * @throws IOException - * if the string cannot be resolved to a canonical file path - */ - public OpenOfficeURI(String source) throws IOException - { - this.source = new File(source.replaceAll(" ", "%20")).getCanonicalFile(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - String absolute = this.source.getAbsolutePath(); - if (File.separatorChar != '/') - { - absolute = absolute.replace(File.separatorChar, '/'); - } - return (absolute.startsWith("/") ? "file://" : "file:///") + absolute; - } - -} diff --git a/repository/src/main/java/org/alfresco/util/OpenOfficeVariant.java b/repository/src/main/java/org/alfresco/util/OpenOfficeVariant.java deleted file mode 100644 index c2d2578822..0000000000 --- a/repository/src/main/java/org/alfresco/util/OpenOfficeVariant.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.util; - -import java.io.File; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Provides OpenOffice and LibreOffice variant information. - * - * @author Alan Davis - */ -public class OpenOfficeVariant -{ - private static final String[] EXTENSIONS = new String[] {"", ".exe", ".com", ".bat", ".cmd"}; - private static final Log logger = LogFactory.getLog(OpenOfficeCommandLine.class); - private static final String OS_NAME = System.getProperty("os.name").toLowerCase(); - - private final boolean windows = isWindows(); - - public File getOfficeHome(File executable) - { - // Get the grandparent - File officeHome = executable; - for (int i=1; officeHome != null && i <= 2; i++) - { - officeHome = officeHome.getParentFile(); - } - - if (officeHome == null && executable != null) - { - throw new AlfrescoRuntimeException("Did not find OppenOffice home from executable "+executable.getAbsolutePath()); - } - - return officeHome; - } - - public File findExecutable(String executableName) - { - File file = new File(executableName); - if (file.isAbsolute()) - { - file = canExecute(file); - } - else - { - file = findExecutableOnPath(executableName); - } - return file; - } - - private File findExecutableOnPath(String executableName) - { - String systemPath = System.getenv("PATH"); - systemPath = systemPath == null ? System.getenv("path") : systemPath; - String[] pathDirs = systemPath.split(File.pathSeparator); - - File fullyQualifiedExecutable = null; - for (String pathDir : pathDirs) - { - File file = canExecute(new File(pathDir, executableName)); - if (file != null) - { - fullyQualifiedExecutable = file; - break; - } - } - return fullyQualifiedExecutable; - } - - private File canExecute(File file) - { - File fullyQualifiedExecutable = null; - File dir = file.getParentFile(); - String name = file.getName(); - for (String ext: EXTENSIONS) - { - file = new File(dir, name+ext); - if (file.canExecute()) - { - fullyQualifiedExecutable = file; - break; - } - if (!windows) - { - break; - } - } - return fullyQualifiedExecutable; - } - - public boolean isLibreOffice3Dot5(File officeHome) - { - if (logger.isDebugEnabled()) - { - logger.debug("System.getProperty(\"os.name\")="+System.getProperty("os.name")); - logger.debug("officeHome="+(officeHome == null ? null : "'"+officeHome.getAbsolutePath()+"'")); - logger.debug("basis-link:"+new File(officeHome, "basis-link").isFile()); - logger.debug("basis-link:"+new File(officeHome, "basis-link").isDirectory()); - logger.debug(" ure-link:"+new File(officeHome, "ure-link").isFile()); - logger.debug(" ure-link:"+new File(officeHome, "ure-link").isDirectory()); - logger.debug(" NOTICE:"+new File(officeHome, "NOTICE").isFile()); - } - return - officeHome != null && - !new File(officeHome, "basis-link").isFile() && - (new File(officeHome, "ure-link").isFile() || new File(officeHome, "ure-link").isDirectory()); - } - - public boolean isLibreOffice3Dot6(File officeHome) - { - if (logger.isDebugEnabled()) - { - logger.debug(" NOTICE:"+new File(officeHome, "NOTICE").isFile()); - } - return isLibreOffice3Dot5(officeHome) && new File(officeHome, "NOTICE").isFile(); - } - - public boolean isLinux() - { - return OS_NAME.startsWith("linux"); - } - - public boolean isMac() - { - return OS_NAME.startsWith("mac"); - } - - public boolean isWindows() - { - return OS_NAME.startsWith("windows"); - } -} \ No newline at end of file diff --git a/repository/src/main/resources/alfresco-global.properties.sample b/repository/src/main/resources/alfresco-global.properties.sample index 1b0b953d68..390d8e6225 100644 --- a/repository/src/main/resources/alfresco-global.properties.sample +++ b/repository/src/main/resources/alfresco-global.properties.sample @@ -14,20 +14,6 @@ #db.username=alfresco #db.password=alfresco -# -# External locations -#------------- -#jodconverter.officeHome=/usr/lib64/libreoffice -#jodconverter.portNumbers=8101 -#jodconverter.enabled=true -#img.root=./ImageMagick - -# -# Windows specific environment variables (should not be set on unix) for ImageMagick -# -#img.coders=${img.root}/modules/coders -#img.config=${img.root}/config - # # Property to control whether schema updates are performed automatically. # Updates must be enabled during upgrades as, apart from the static upgrade scripts, diff --git a/repository/src/main/resources/alfresco/bootstrap-context.xml b/repository/src/main/resources/alfresco/bootstrap-context.xml index 4f1d43c597..d47197fa22 100644 --- a/repository/src/main/resources/alfresco/bootstrap-context.xml +++ b/repository/src/main/resources/alfresco/bootstrap-context.xml @@ -284,33 +284,7 @@ - - - - true - - - - - - - true - - - - - - - - - - - - - - diff --git a/repository/src/main/resources/alfresco/content-services-context.xml b/repository/src/main/resources/alfresco/content-services-context.xml index c0f47fa10a..3bdfbac6a3 100644 --- a/repository/src/main/resources/alfresco/content-services-context.xml +++ b/repository/src/main/resources/alfresco/content-services-context.xml @@ -152,20 +152,12 @@ - - - ${policy.content.update.ignoreEmpty} - - - - - @@ -283,17 +275,6 @@ - - - - image/jpeg - image/tiff - image/png - - - - @@ -319,49 +300,14 @@ - - - - - - - - - - + - - - - - - - - - - - - - - org.alfresco.repo.content.transform.TransformerConfig - - - - - - - - - - - - org.alfresco.repo.content.transform.TransformerSelector - - + + @@ -406,273 +352,5 @@ - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - Tika - - - ${tika.url} - - - ${tika.startupRetryPeriodSeconds} - - - - - - MiscellaneousTransformers - - - ${transform.misc.url} - - - ${transform.misc.startupRetryPeriodSeconds} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${content.transformer.PdfBox.extractBookmarksText} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - transformer.worker.JodConverter - - - - org.alfresco.repo.content.transform.ContentTransformerWorker - - - - - - - - - - - - - - - - - - - - - - - - - - transformer.worker.ImageMagick - - - - org.alfresco.repo.content.transform.ContentTransformerWorker - - - - - - - - - - - - - - - - - transformer.worker.subsys.alfresco-pdf-renderer - - - - org.alfresco.repo.content.transform.ContentTransformerWorker - - - - - - - - - - - - - - - - - - - diff --git a/repository/src/main/resources/alfresco/extension/ghostscript-pdf-rendering-context.xml.sample b/repository/src/main/resources/alfresco/extension/ghostscript-pdf-rendering-context.xml.sample deleted file mode 100644 index 70f3f8cde5..0000000000 --- a/repository/src/main/resources/alfresco/extension/ghostscript-pdf-rendering-context.xml.sample +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - ${gs.exe} - -version - - - - 127 - - - - - - - - - - cmd - /C - ${gs.exe} -dNOPAUSE -dSAFER -dBATCH -sDEVICE=png16m -dFirstPage=1 -dLastPage=1 ${resolution_opts} ${antialias_opts} "-sOutputFile=${target}" "${source}" 2> NUL - - - - - sh - -c - ${gs.exe} -dNOPAUSE -dSAFER -dBATCH -sDEVICE=png16m -dFirstPage=1 -dLastPage=1 ${resolution_opts} ${antialias_opts} "-sOutputFile=${target}" "${source}" 2> /dev/null - - - - - sh - -c - ${gs.exe} -dNOPAUSE -dSAFER -dBATCH -sDEVICE=png16m -dFirstPage=1 -dLastPage=1 ${resolution_opts} ${antialias_opts} "-sOutputFile=${target}" "${source}" 2> /dev/null - - - - - - true - - - - -r72 - -dTextAlphaBits=4 -dGraphicsAlphaBits=4 - - - - - - - - - - - application/pdf - - - image/png - - - - - - - - - - - - - - - diff --git a/repository/src/main/resources/alfresco/extension/pdfminer-transform-context.xml.sample b/repository/src/main/resources/alfresco/extension/pdfminer-transform-context.xml.sample deleted file mode 100644 index c995ef6f26..0000000000 --- a/repository/src/main/resources/alfresco/extension/pdfminer-transform-context.xml.sample +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - application/pdf - - - - - - - - - - - - - - - application/pdf - text/plain - - - - - - - - - - - - - - - - - ${python.exe} - ${pdf2txt.py} - - - - - - - 1 - - - - - - - - - - ${python.exe} - ${pdf2txt.py} - -V - -o - ${target} - ${source} - - - - - - 1 - - - - - - - - application/pdf - - - text/plain - - - - - - - diff --git a/repository/src/main/resources/alfresco/extension/video-thumbnail-context.xml.sample b/repository/src/main/resources/alfresco/extension/video-thumbnail-context.xml.sample deleted file mode 100644 index 30c8e48f4b..0000000000 --- a/repository/src/main/resources/alfresco/extension/video-thumbnail-context.xml.sample +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - ${ffmpeg.exe} - -version - - - - 127 - - - - - - - - - - cmd - /C - ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} "${target}" 2> NUL - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null - - - - - - true - - - - -y - -ss 10 - -f image2 -vframes 1 - - - - - - - - - - - - - - - - - - - - - - - - - image/jpeg - - - - - - - - - - - - - - - - - - - - -f flv -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 - - - - - - - - - - - - - - - - - - - - - - -f mp4 -ar 44100 -ab 96k -vcodec libx264 -crf 25 -g 250 -r 25 - medium - - - - - - - - - - - - - - - - - - - - - -f mp3 -ar 44100 -ab 128k - - - - - - - - - - diff --git a/repository/src/main/resources/alfresco/extension/video-transformation-context.xml.sample b/repository/src/main/resources/alfresco/extension/video-transformation-context.xml.sample deleted file mode 100644 index 7c557e2285..0000000000 --- a/repository/src/main/resources/alfresco/extension/video-transformation-context.xml.sample +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - ${ffmpeg.exe} - -version - - - - 127 - - - - - - - - - - cmd - /C - ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} "${target}" 2> NUL - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null - - - - - - true - - - - -y - - -f flv - - - - - - - - - - - - - - - - ${ffmpeg.exe} - -version - - - - 127 - - - - - - - - - - cmd - /C - - ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} -fpre "${ffmpeg.base}\share\ffmpeg\libx264-${vpre}.ffpreset" "${target}" 2> NUL - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} -vpre ${vpre} '${target}' 2> /dev/null - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} -vpre ${vpre} '${target}' 2> /dev/null - - - - - - true - - - - -y - - -f mp4 -ar 44100 -ab 96k -vcodec libx264 -crf 25 -g 250 -r 25 - medium - - - - - - - - - - - - - - - - ${ffmpeg.exe} - -version - - - - 127 - - - - - - - - - - cmd - /C - ${ffmpeg.exe} ${opts} ${infile_opts} -i "${source}" ${outfile_opts} "${target}" 2> NUL - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null - - - - - sh - -c - ${ffmpeg.exe} ${opts} ${infile_opts} -i '${source}' ${outfile_opts} '${target}' 2> /dev/null - - - - - - true - - - - -y - - -f mp3 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/repository/src/main/resources/alfresco/extension/xpdf-transform-context.xml.sample b/repository/src/main/resources/alfresco/extension/xpdf-transform-context.xml.sample deleted file mode 100644 index 890f3f6e4e..0000000000 --- a/repository/src/main/resources/alfresco/extension/xpdf-transform-context.xml.sample +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ${pdftotext.root}/pdftotext -enc UTF-8 ${source} ${target} - - - ${pdftotext.root}/pdftotext.exe -enc UTF-8 ${source} ${target} - - - - - - - - - - - - - - - - - chmod 775 ${pdftotext.root}/pdftotext - - - - cmd.exe /C dir - - - - - - - - - - - - - - - application/pdf - - - text/plain - - - - - - - - - - - - transformer.worker.PdfToTextTool - - - - org.alfresco.repo.content.transform.ContentTransformerWorker - - - - - - - - - - - - - - - - - - - - application/pdf - - - - - \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/messages/system-messages.properties b/repository/src/main/resources/alfresco/messages/system-messages.properties index 10b7b5afc7..8ca6e11ff6 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_cs.properties b/repository/src/main/resources/alfresco/messages/system-messages_cs.properties index 99569635c5..fb436a1764 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages_cs.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_cs.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=P\u0159ipojil se \u010dlen system.cluster.drop_invalidating_caches.member_left=Odpojil se \u010dlen clusteru: odstran\u011bn\u00ed zneplatn\u011bn\u00ed mezipam\u011bti. system.cluster.drop_invalidating_caches.disabled=\u010clenov\u00e9 clusteru se zm\u011bnili, ale odstran\u011bn\u00ed mezipam\u011bti je zak\u00e1z\u00e1no (\u017e\u00e1dn\u00fd efekt). -# OpenOffice -system.openoffice.info.connection_verified=Bylo nav\u00e1z\u00e1no p\u0159ipojen\u00ed k\u00a0OpenOffice. -system.openoffice.err.connection_failed=\u00davodn\u00ed p\u0159ipojen\u00ed k\u00a0OpenOffice se nepoda\u0159ilo nav\u00e1zat. -system.openoffice.err.connection_lost=P\u0159ipojen\u00ed k\u00a0OpenOffice bylo p\u0159eru\u0161eno. -system.openoffice.err.connection_remade=P\u0159ipojen\u00ed k\u00a0OpenOffice bylo znovu nav\u00e1z\u00e1no. - # Locks system.locks.err.failed_to_acquire_lock=Nepoda\u0159ilo se z\u00edskat z\u00e1mek ''{0}'' za pou\u017eit\u00ed tokenu ''{1}''. system.locks.err.lock_resource_missing=Nepoda\u0159ila se manipulace se z\u00e1mkem ''{0}'' za pou\u017eit\u00ed tokenu ''{1}''. Prost\u0159edky pro z\u00e1mek ji\u017e neexistuj\u00ed. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_da.properties b/repository/src/main/resources/alfresco/messages/system-messages_da.properties index 37edbd40a7..c0c5a50a6f 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages_da.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_da.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Klyngemedlem tiltr\u00e5dt system.cluster.drop_invalidating_caches.member_left=Klyngemedlem fratr\u00e5dte: ugyldige cachelagre slettes. system.cluster.drop_invalidating_caches.disabled=Klyngemedlemmer blev \u00e6ndret, men sletning af cachelagre er deaktiveret (der sker ikke noget). -# OpenOffice -system.openoffice.info.connection_verified=Forbindelsen til OpenOffice er oprettet. -system.openoffice.err.connection_failed=Det var ikke muligt at oprette en forbindelse til OpenOffice. -system.openoffice.err.connection_lost=Forbindelsen til OpenOffice blev afbrudt. -system.openoffice.err.connection_remade=Forbindelsen til OpenOffice er oprettet igen. - # Locks system.locks.err.failed_to_acquire_lock=L\u00e5sen ''{0}'' kunne ikke hentes med tokenet ''{1}''. system.locks.err.lock_resource_missing=L\u00e5sen ''{0}'' kunne ikke manipuleres med tokenet ''{1}''. L\u00e5seressourcen findes ikke l\u00e6ngere. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_de.properties b/repository/src/main/resources/alfresco/messages/system-messages_de.properties index fd5c4cce58..bba5471b94 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_de.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_de.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_es.properties b/repository/src/main/resources/alfresco/messages/system-messages_es.properties index 20ec67a90f..af07a341bf 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_es.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_es.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_fi.properties b/repository/src/main/resources/alfresco/messages/system-messages_fi.properties index 9fb5ca092b..254ae89ae3 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages_fi.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_fi.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Klusterin j\u00e4sen liitt system.cluster.drop_invalidating_caches.member_left=Klusterin j\u00e4sen poistui: mit\u00e4t\u00f6intiv\u00e4limuistit tyhjennet\u00e4\u00e4n. system.cluster.drop_invalidating_caches.disabled=Klusterin j\u00e4senet muuttuivat, mutta v\u00e4limuistin tyhjennys ei ole k\u00e4yt\u00f6ss\u00e4 (ei tee mit\u00e4\u00e4n). -# OpenOffice -system.openoffice.info.connection_verified=OpenOffice-yhteys on muodostettu. -system.openoffice.err.connection_failed=Alkuper\u00e4isen OpenOffice-yhteyden luominen ei onnistu. -system.openoffice.err.connection_lost=OpenOffice-yhteys on katkennut. -system.openoffice.err.connection_remade=OpenOffice-yhteys muodostettiin uudelleen. - # Locks system.locks.err.failed_to_acquire_lock=Lukituksen {0} hankkiminen tunnuksella {1} ep\u00e4onnistui. system.locks.err.lock_resource_missing=Lukituksen {0} k\u00e4sittely tunnuksella {1} ep\u00e4onnistui. Lukitusresurssia ei ole en\u00e4\u00e4 olemassa. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_fr.properties b/repository/src/main/resources/alfresco/messages/system-messages_fr.properties index 7106989cf0..ba83dd216d 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_fr.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_fr.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_it.properties b/repository/src/main/resources/alfresco/messages/system-messages_it.properties index 24ae4b2320..89e9a1c9fc 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_it.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_it.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_ja.properties b/repository/src/main/resources/alfresco/messages/system-messages_ja.properties index a4014e382e..afac1ebcc7 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_ja.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_ja.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_nb.properties b/repository/src/main/resources/alfresco/messages/system-messages_nb.properties index 092d4b23ca..f5fd7de6fc 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_nb.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_nb.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_nl.properties b/repository/src/main/resources/alfresco/messages/system-messages_nl.properties index 282ae4ef52..a9e5b18cd5 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_nl.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_nl.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_pl.properties b/repository/src/main/resources/alfresco/messages/system-messages_pl.properties index 1c95427226..0a146b5676 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages_pl.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_pl.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Do\u0142\u0105czono elemen system.cluster.drop_invalidating_caches.member_left=Od\u0142\u0105czono element klastra: porzucanie uniewa\u017cniaj\u0105cej pami\u0119ci podr\u0119cznej. system.cluster.drop_invalidating_caches.disabled=Elementy klastra zosta\u0142y zmienione, ale porzucanie pami\u0119ci podr\u0119cznej jest wy\u0142\u0105czone (nic si\u0119 nie dzieje). -# OpenOffice -system.openoffice.info.connection_verified=Ustanowiono po\u0142\u0105czenie z OpenOffice. -system.openoffice.err.connection_failed=Nie mo\u017cna ustanowi\u0107 pocz\u0105tkowego po\u0142\u0105czenia z OpenOffice. -system.openoffice.err.connection_lost=Po\u0142\u0105czenie z OpenOffice zosta\u0142o przerwane. -system.openoffice.err.connection_remade=Po\u0142\u0105czenie z OpenOffice zosta\u0142o ponownie ustanowione. - # Locks system.locks.err.failed_to_acquire_lock=Nie uda\u0142o si\u0119 uzyska\u0107 blokady ''{0}'' za pomoc\u0105 tokenu ''{1}''. system.locks.err.lock_resource_missing=Nie mo\u017cna manipulowa\u0107 blokad\u0105 ''{0}'' za pomoc\u0105 tokenu ''{1}''. Zas\u00f3b blokady ju\u017c nie istnieje. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_pt_BR.properties b/repository/src/main/resources/alfresco/messages/system-messages_pt_BR.properties index 94e94e074c..ea2f90f78d 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages_pt_BR.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_pt_BR.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_ru.properties b/repository/src/main/resources/alfresco/messages/system-messages_ru.properties index 067285aae2..0a2092ac92 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_ru.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_ru.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_sv.properties b/repository/src/main/resources/alfresco/messages/system-messages_sv.properties index f8e46056a7..e3a29b134d 100644 --- a/repository/src/main/resources/alfresco/messages/system-messages_sv.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_sv.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Klustermedlem gick med: sl system.cluster.drop_invalidating_caches.member_left=Klustermedlem l\u00e4mnade: sl\u00e4pper cachar som ogiltigg\u00f6r. system.cluster.drop_invalidating_caches.disabled=Klustermedlemmar \u00e4ndrade men sl\u00e4pp av cache \u00e4r avaktiverad (g\u00f6r ingenting). -# OpenOffice -system.openoffice.info.connection_verified=Anslutningen till OpenOffice har skapats. -system.openoffice.err.connection_failed=En initial OpenOffice-anslutning kunde inte uppr\u00e4ttas. -system.openoffice.err.connection_lost=OpenOffice-anslutningen har g\u00e5tt f\u00f6rlorad. -system.openoffice.err.connection_remade=OpenOffice-anslutningen \u00e5terskapades. - # Locks system.locks.err.failed_to_acquire_lock=Misslyckades att h\u00e4mta l\u00e5s ''{0}'' genom att anv\u00e4nda token ''{1}''. system.locks.err.lock_resource_missing=Misslyckades att manipulera l\u00e5s ''{0}'' genom att anv\u00e4nda token ''{1}''. L\u00e5sresursen finns inte l\u00e4ngre. diff --git a/repository/src/main/resources/alfresco/messages/system-messages_zh_CN.properties b/repository/src/main/resources/alfresco/messages/system-messages_zh_CN.properties index 221776f174..5c2fe67e6d 100755 --- a/repository/src/main/resources/alfresco/messages/system-messages_zh_CN.properties +++ b/repository/src/main/resources/alfresco/messages/system-messages_zh_CN.properties @@ -57,12 +57,6 @@ system.cluster.drop_invalidating_caches.member_joined=Cluster member joined: dro system.cluster.drop_invalidating_caches.member_left=Cluster member left: dropping invalidating caches. system.cluster.drop_invalidating_caches.disabled=Cluster members changed but cache dropping is disabled (doing nothing). -# OpenOffice -system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. -system.openoffice.err.connection_lost=The OpenOffice connection has been lost. -system.openoffice.err.connection_remade=The OpenOffice connection was re-established. - # Locks system.locks.err.failed_to_acquire_lock=Failed to get lock ''{0}'' using token ''{1}''. system.locks.err.lock_resource_missing=Failed to manipulate lock ''{0}'' using token ''{1}''. The lock resource no longer exists. diff --git a/repository/src/main/resources/alfresco/public-services-security-context.xml b/repository/src/main/resources/alfresco/public-services-security-context.xml index 00f8c6c5e8..a0f20a0ff6 100644 --- a/repository/src/main/resources/alfresco/public-services-security-context.xml +++ b/repository/src/main/resources/alfresco/public-services-security-context.xml @@ -494,9 +494,6 @@ org.alfresco.service.cmr.repository.ContentService.getReader=ACL_NODE.0.sys:base.ReadContent org.alfresco.service.cmr.repository.ContentService.getWriter=ACL_NODE.0.sys:base.WriteContent org.alfresco.service.cmr.repository.ContentService.getDirectAccessUrl=ACL_NODE.0.sys:base.ReadContent - org.alfresco.service.cmr.repository.ContentTransformService.getTransformer=ACL_ALLOW - org.alfresco.service.cmr.repository.ContentTransformService.getMaxSourceSizeBytes=ACL_ALLOW - org.alfresco.service.cmr.repository.ContentTransformService.transform=ACL_ALLOW org.alfresco.service.cmr.repository.ContentService.getTempWriter=ACL_ALLOW org.alfresco.service.cmr.repository.ContentService.*=ACL_DENY
    diff --git a/repository/src/main/resources/alfresco/rendition-services2-context.xml b/repository/src/main/resources/alfresco/rendition-services2-context.xml index 4280e29e6f..855919c574 100644 --- a/repository/src/main/resources/alfresco/rendition-services2-context.xml +++ b/repository/src/main/resources/alfresco/rendition-services2-context.xml @@ -76,46 +76,17 @@ - - - - - - - + + - - - - - - - + - - - - - - - - - - - - - - - - - - - + @@ -133,12 +104,7 @@ - - - - - - + @@ -154,13 +120,6 @@ - - - - - - - diff --git a/repository/src/main/resources/alfresco/repository.properties b/repository/src/main/resources/alfresco/repository.properties index d9e7e5f6dc..612c630853 100644 --- a/repository/src/main/resources/alfresco/repository.properties +++ b/repository/src/main/resources/alfresco/repository.properties @@ -465,18 +465,6 @@ monitor.rmi.service.enabled=false # false for WebSphere clusters. mbean.server.locateExistingServerIfPossible=true -# External executable locations -img.root=./ImageMagick -img.dyn=${img.root}/lib -img.exe=${img.root}/bin/convert - -# Legacy imageMagick transformer url to T-Engine to service transform requests via http. Disabled by default. -img.url= - -# When img.url is set, this value indicates the amount of time to wait after a connection failure -# before retrying the connection to allow a docker container to (re)start. -img.startupRetryPeriodSeconds=60 - # Rendition Service 2 renditionService2.enabled=true @@ -522,15 +510,6 @@ content.metadata.async.embed.enabled=true # The default timeout for metadata mapping extracters content.metadataExtracter.default.timeoutMs=20000 -# Legacy tika and misc transformer url to T-Engines to service transform requests via http. Disabled by default. -tika.url= -transform.misc.url= - -# When the legacy tika and misc transformer .url is set, this value indicates the amount of time to wait after a connection failure -# before retrying the connection to allow a docker container to (re)start. -tika.startupRetryPeriodSeconds=60 -transform.misc.startupRetryPeriodSeconds=60 - # Local transformer urls to T-engines to service transform requests via http. Enabled by default. localTransform.core-aio.url=http://localhost:8090/ @@ -538,16 +517,6 @@ localTransform.core-aio.url=http://localhost:8090/ # before retrying the connection to allow a docker container to (re)start. localTransform.core-aio.startupRetryPeriodSeconds=60 -# -content.metadataExtracter.pdf.maxDocumentSizeMB=10 -content.metadataExtracter.pdf.maxConcurrentExtractionsCount=5 - -# The default overwrite policy for PdfBoxMetadataExtracter -content.metadataExtracter.pdf.overwritePolicy=PRAGMATIC - -#True if bookmarks content should be extracted for PDFBox -content.transformer.PdfBox.extractBookmarksText=true - # Property to enable upgrade from 2.1-A V2.1-A.fixes.to.schema=0 #V2.1-A.fixes.to.schema=82 @@ -1019,9 +988,6 @@ local.transform.service.enabled=true local.transform.service.cronExpression=4 30 0/1 * * ? local.transform.service.initialAndOnError.cronExpression=0/10 * * * * ? -# Used to disable transforms that extend AbstractContentTransformer2 -legacy.transform.service.enabled=true - # # Check that the declared mimetype (of the Node) is the same as the derived # mimetype of the content (via Tika) before a transformation takes place. @@ -1047,6 +1013,10 @@ transformer.strict.mimetype.check.whitelist.mimetypes=application/eps;applicatio # content.transformer.retryOn.different.mimetype=true +# Debug and Log buffer sizes +transformer.debug.entries=0 +transformer.log.entries=50 + # # Lock timeout configuration # diff --git a/repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter-context.xml b/repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter-context.xml deleted file mode 100644 index b726fb1df8..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter-context.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - ${jodconverter.url} - - - ${jodconverter.officeHome} - - - ${jodconverter.maxTasksPerProcess} - - - ${jodconverter.taskExecutionTimeout} - - - ${jodconverter.taskQueueTimeout} - - - ${jodconverter.connectTimeout} - - - ${jodconverter.portNumbers} - - - ${jodconverter.templateProfileDir} - - - ${jodconverter.enabled} - - - ${ooo.exe} - - - ${ooo.port} - - - ${ooo.enabled} - - - - - - - - - - - - - classpath:alfresco/mimetype/jodconverter-document-formats.json - - - - - - - - LibreOffice - - - ${jodconverter.url} - - - ${jodconverter.startupRetryPeriodSeconds} - - - - - - diff --git a/repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter.properties b/repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter.properties deleted file mode 100644 index df812c19b9..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter.properties +++ /dev/null @@ -1,54 +0,0 @@ -# External executable locations - -# This property determines whether the jodConverter services are enabled. -# Allowed values are 'true' or 'false'. -jodconverter.enabled=true - -# The property jodconverter.officeHome is used to locate LibreOffice's 'soffice.bin' executable file. -# -# For Mac OS X this should be the directory that contains "MacOS/soffice.bin" -# So it should be like: /Applications/OpenOffice.org.app/Contents -# -# For other OSes this should be the directory that contains "program/soffice.bin" -# Debian/Ubuntu it should be like: /usr/lib64/libreoffice -# Fedora it should be like: /opt/openoffice.org3 -# Windows it should be like: C:/Alfresco/libreoffice -jodconverter.officeHome=/usr/lib64/libreoffice - -# Remote server (or docker container) url used to service jodconverter requests. -jodconverter.url= - -# When jodconverter.url is set, this value indicates the amount of time to wait after a connection failure -# before retrying the connection to allow a docker container to (re)start. -jodconverter.startupRetryPeriodSeconds=60 - -# 1 or more unique port numbers can be specified. They must be comma-separated if there are more than -# one, like so: -#jodconverter.portNumbers=2002, 2003, 2004 -# Note that it is by specifying multiple port numbers that one can create a pool of n instances of OOo -# These port numbers must be available for use. -jodconverter.portNumbers=2022 - -# The maximum number of OOo-related tasks to perform before a process restart -jodconverter.maxTasksPerProcess=200 - -# timeouts are in milliseconds -jodconverter.taskExecutionTimeout=120000 -jodconverter.taskQueueTimeout=30000 - -jodconverter.connectTimeout=25000 - -# OpenOffice user template profile to be used by the JOD started OpenOffice process. -# Among other settings, the profile contains values set in Tools|Options via the UI -# This includes the temporary directory: Tools|Options|openOffice.org|Temporary Files -# -# If blank, a default profile is created. The user profile is recreated on each restart from the template. -# May be set to an existing user's profile such as: C:\Users\\AppData\Roaming\OpenOffice.org\3 - -jodconverter.templateProfileDir= - -# Default values for the old ooo.direct transformer that was used by Community. Now replaced by jodconverter. -# However we don't want to force community users to change all their configuration. -ooo.exe= -ooo.enabled= -ooo.port= diff --git a/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers-context.xml b/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers-context.xml index 0f17696462..b9b9cbc1e0 100644 --- a/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers-context.xml +++ b/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers-context.xml @@ -2,64 +2,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -70,22 +20,14 @@ - - - - - - + + - - - - - - + + \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers.properties b/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers.properties deleted file mode 100644 index fbf93dcb04..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/Transformers/default/transformers.properties +++ /dev/null @@ -1,726 +0,0 @@ -# Debug and Log buffer sizes -# ========================== -transformer.debug.entries=0 -transformer.log.entries=50 - -transformer.strict.mimetype.check.whitelist.mimetypes=application/eps;application/postscript;application/illustrator;application/pdf;application/x-tar;application/x-gtar;application/acp;application/zip;application/vnd.stardivision.math;application/x-tika-msoffice - -# Base setting for all transformers -# ================================= -content.transformer.default.priority=100 -content.transformer.default.thresholdCount=3 -content.transformer.default.time=0 -content.transformer.default.count=100000 -content.transformer.default.errorTime=120000 -content.transformer.default.timeoutMs=120000 -content.transformer.default.readLimitTimeMs=-1 -content.transformer.default.maxSourceSizeKBytes=-1 -content.transformer.default.readLimitKBytes=-1 -content.transformer.default.pageLimit=-1 -content.transformer.default.maxPages=-1 - -# Transformer specific settings -# ============================= - -content.transformer.Archive.extensions.*.txt.priority=50 -content.transformer.Archive.extensions.bin.txt.supported=false - -content.transformer.BinaryPassThrough.priority=20 - -# Text -# ---- -content.transformer.TikaAuto.priority=120 -content.transformer.TikaAuto.extensions.bin.txt.supported=false - -content.transformer.Office.priority=130 - -content.transformer.OutlookMsg.priority=125 - -content.transformer.OOXML.priority=130 - -content.transformer.Poi.priority=130 - -content.transformer.TextMining.priority=130 -content.transformer.TextMining.extensions.doc.txt.priority=50 - -content.transformer.HtmlParser.extensions.html.txt.priority=50 - -# Image -# ----- -content.transformer.ImageMagick.extensions.png.png.priority=50 -content.transformer.alfresco-pdf-renderer.extensions.pdf.png.priority=50 -content.transformer.alfresco-pdf-renderer.extensions.ai.png.priority=50 - -content.transformer.alfresco-pdf-renderer.ImageMagick.available=false -content.transformer.alfresco-pdf-renderer.ImageMagick.pipeline=alfresco-pdf-renderer|png|ImageMagick - -# This transformer was called transformer.complex.OOXML.Image, but now the first stage -# is any transformer to allow failover when there is no embedded thumbnail. -content.transformer.complex.Any.Image.pipeline=*|jpg|ImageMagick -content.transformer.complex.Any.Image.priority=400 - -content.transformer.complex.Text.Image.pipeline=*|pdf|complex.PDF.Image -content.transformer.complex.Text.Image.priority=350 -content.transformer.complex.Text.Image.extensions.dita.*.supported=true -content.transformer.complex.Text.Image.extensions.xml.*.supported=true - -content.transformer.OOXMLThumbnail.extensions.dotx.jpg.priority=50 -content.transformer.OOXMLThumbnail.extensions.potx.jpg.priority=50 - -content.transformer.iWorksQuicklooks.extensions.key.jpg.priority=50 -content.transformer.iWorksQuicklooks.extensions.pages.jpg.priority=50 -content.transformer.iWorksQuicklooks.extensions.numbers.jpg.priority=50 -content.transformer.iWorksQuicklooks.extensions.key.pdf.priority=50 -content.transformer.iWorksQuicklooks.extensions.pages.pdf.priority=50 -content.transformer.iWorksQuicklooks.extensions.numbers.pdf.priority=50 - -content.transformer.complex.iWorks.Image.pipeline=iWorksQuicklooks|jpg|ImageMagick -content.transformer.complex.iWorks.Image.priority=400 -content.transformer.complex.iWorks.Image.extensions.key.png.priority=50 -content.transformer.complex.iWorks.Image.extensions.numbers.png.priority=50 -content.transformer.complex.iWorks.Image.extensions.pages.png.priority=50 - -content.transformer.complex.OutlookMsg2Image.pipeline=OutlookMsg|txt|* -content.transformer.complex.OutlookMsg2Image.priority=450 -content.transformer.complex.OutlookMsg2Image.extensions.msg.png.priority=395 - - -# PDF -# --- -content.transformer.PdfBox.priority=110 -content.transformer.PdfBox.extensions.pdf.txt.priority=50 -content.transformer.PdfBox.extensions.pdf.txt.maxSourceSizeKBytes=25600 - -content.transformer.PdfBox.TextToPdf.extensions.csv.pdf.supported=true -content.transformer.PdfBox.TextToPdf.extensions.dita.pdf.supported=true -content.transformer.PdfBox.TextToPdf.extensions.xml.pdf.supported=true -content.transformer.PdfBox.TextToPdf.maxSourceSizeKBytes=10240 - -content.transformer.TikaAuto.extensions.pdf.txt.maxSourceSizeKBytes=25600 - -# EML to PDF -content.transformer.complex.Rfc822ToPdf.pipeline=RFC822|txt|* -content.transformer.complex.Rfc822ToPdf.extensions.*.pdf.supported=true - -# Archive Zip to PDF -content.transformer.complex.ArchiveToPdf.pipeline=Archive|txt|* -content.transformer.complex.ArchiveToPdf.extensions.*.pdf.supported=true - -# Supports the same transformations as the previous version by using either a single -# alfresco-pdf-renderer transformation to png or a combination with ImageMagick via png. -# Adobe Illustrator (ai) files are, in fact, PDF files -content.transformer.complex.PDF.Image.failover=alfresco-pdf-renderer|alfresco-pdf-renderer.ImageMagick -content.transformer.complex.PDF.Image.priority=60 -content.transformer.complex.PDF.Image.extensions.ai.png.supported=true -content.transformer.complex.PDF.Image.extensions.ai.eps.supported=true -content.transformer.complex.PDF.Image.extensions.ai.jp2.supported=true -content.transformer.complex.PDF.Image.extensions.ai.psd.supported=true -content.transformer.complex.PDF.Image.extensions.ai.ppj.supported=true -content.transformer.complex.PDF.Image.extensions.ai.cgm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.gif.supported=true -content.transformer.complex.PDF.Image.extensions.ai.ief.supported=true -content.transformer.complex.PDF.Image.extensions.ai.bmp.supported=true -content.transformer.complex.PDF.Image.extensions.ai.jpg.supported=true -content.transformer.complex.PDF.Image.extensions.ai.pbm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.pgm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.pnm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.ppm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.ras.supported=true -content.transformer.complex.PDF.Image.extensions.ai.tiff.supported=true -content.transformer.complex.PDF.Image.extensions.ai.xbm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.xpm.supported=true -content.transformer.complex.PDF.Image.extensions.ai.xwd.supported=true -content.transformer.complex.PDF.Image.extensions.ai.bin.supported=true -content.transformer.complex.PDF.Image.extensions.ai.dwt.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.png.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.eps.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.jp2.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.psd.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.ppj.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.cgm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.gif.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.ief.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.bmp.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.jpg.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.pbm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.pgm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.pnm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.ppm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.ras.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.tiff.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.xbm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.xpm.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.xwd.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.bin.supported=true -content.transformer.complex.PDF.Image.extensions.pdf.dwt.supported=true -content.transformer.complex.PDF.Image.extensions.ai.jpg.priority=50 -content.transformer.complex.PDF.Image.extensions.ai.gif.priority=50 -content.transformer.complex.PDF.Image.extensions.pdf.jpg.priority=50 -content.transformer.complex.PDF.Image.extensions.pdf.gif.priority=50 - -# JodConverter -# ------------ -content.transformer.JodConverter.priority=110 -content.transformer.JodConverter.extensions.*.xlsm.supported=false -content.transformer.JodConverter.extensions.*.pptm.supported=false -content.transformer.JodConverter.extensions.*.sldm.supported=false -content.transformer.JodConverter.extensions.*.xltx.supported=false -content.transformer.JodConverter.extensions.*.docx.supported=false -content.transformer.JodConverter.extensions.*.potx.supported=false -content.transformer.JodConverter.extensions.*.xlsx.supported=false -content.transformer.JodConverter.extensions.*.pptx.supported=false -content.transformer.JodConverter.extensions.*.xlam.supported=false -content.transformer.JodConverter.extensions.*.docm.supported=false -content.transformer.JodConverter.extensions.*.xltm.supported=false -content.transformer.JodConverter.extensions.*.dotx.supported=false -content.transformer.JodConverter.extensions.*.xlsb.supported=false -content.transformer.JodConverter.extensions.*.sldx.supported=false -content.transformer.JodConverter.extensions.*.ppsm.supported=false -content.transformer.JodConverter.extensions.*.txt.supported=false -content.transformer.JodConverter.extensions.*.potm.supported=false -content.transformer.JodConverter.extensions.*.ppam.supported=false -content.transformer.JodConverter.extensions.*.dotm.supported=false -content.transformer.JodConverter.extensions.*.ppsx.supported=false -content.transformer.JodConverter.extensions.html.pdf.supported=false -content.transformer.JodConverter.extensions.xlsm.pdf.maxSourceSizeKBytes=1536 -content.transformer.JodConverter.extensions.pptm.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.xls.pdf.maxSourceSizeKBytes=10240 -content.transformer.JodConverter.extensions.sldm.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.xltx.pdf.maxSourceSizeKBytes=1536 -content.transformer.JodConverter.extensions.potx.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.docx.pdf.maxSourceSizeKBytes=768 -content.transformer.JodConverter.extensions.xlsx.pdf.maxSourceSizeKBytes=1536 -content.transformer.JodConverter.extensions.pptx.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.xlam.pdf.maxSourceSizeKBytes=1536 -content.transformer.JodConverter.extensions.ppt.pdf.maxSourceSizeKBytes=6144 -content.transformer.JodConverter.extensions.docm.pdf.maxSourceSizeKBytes=768 -content.transformer.JodConverter.extensions.xltm.pdf.maxSourceSizeKBytes=1536 -content.transformer.JodConverter.extensions.dotx.pdf.maxSourceSizeKBytes=768 -content.transformer.JodConverter.extensions.xlsb.pdf.maxSourceSizeKBytes=1536 -content.transformer.JodConverter.extensions.sldx.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.ppsm.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.potm.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.txt.pdf.maxSourceSizeKBytes=5120 -content.transformer.JodConverter.extensions.ppam.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.dotm.pdf.maxSourceSizeKBytes=768 -content.transformer.JodConverter.extensions.doc.pdf.maxSourceSizeKBytes=10240 -content.transformer.JodConverter.extensions.vsd.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.vsdx.pdf.maxSourceSizeKBytes=4096 -content.transformer.JodConverter.extensions.ppsx.pdf.maxSourceSizeKBytes=4096 - -content.transformer.JodConverter.Html2Pdf.pipeline=JodConverter|odt|JodConverter -content.transformer.JodConverter.Html2Pdf.extensions.html.pdf.supported=true -content.transformer.JodConverter.Html2Pdf.extensions.html.pdf.priority=50 - -# This transformer exists because OpenOffice and LibreOffice have a problem -# going directly from HTML to PDF. Going via ODT appears a much better option. -# For example tags hang the soffice process. ALF-14035 -content.transformer.JodConverter.2Pdf.available=false -content.transformer.JodConverter.2Pdf.failover=JodConverter|JodConverter.Html2Pdf -content.transformer.JodConverter.2Pdf.priority=150 -content.transformer.JodConverter.2Pdf.extensions.*.pdf.supported=true - -content.transformer.complex.JodConverter.Image.pipeline=JodConverter.2Pdf|pdf|complex.PDF.Image -content.transformer.complex.JodConverter.Image.priority=250 - -content.transformer.complex.JodConverter.PdfBox.pipeline=JodConverter.2Pdf|pdf|PdfBox -content.transformer.complex.JodConverter.PdfBox.priority=150 -content.transformer.complex.JodConverter.PdfBox.extensions.xlsm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.pptm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.xls.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.sldm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.xltx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.docx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.potx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.xlsx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.pptx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.xlam.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.ppt.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.docm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.xltm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.dotx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.sldx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.ppsm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.txt.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.ppam.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.dotm.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.doc.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.ppsx.txt.supported=false -content.transformer.complex.JodConverter.PdfBox.extensions.xlsb.txt.maxSourceSizeKBytes=1024 -content.transformer.complex.JodConverter.PdfBox.extensions.potm.txt.maxSourceSizeKBytes=1024 - -# Remote -# ------ - -# Remote alfresco node -content.transformer.remote.alfresco.priority=30 - -# Remote transformation server -content.transformer.remoteServer.priority=40 -content.transformer.remoteServer.extensions.*.*.supported=false -content.transformer.remoteServer.extensions.*.txt.supported=false -content.transformer.remoteServer.extensions.bmp.bmp.supported=true -content.transformer.remoteServer.extensions.bmp.cgm.supported=true -content.transformer.remoteServer.extensions.bmp.dwt.supported=true -content.transformer.remoteServer.extensions.bmp.gif.supported=true -content.transformer.remoteServer.extensions.bmp.ief.supported=true -content.transformer.remoteServer.extensions.bmp.jp2.supported=true -content.transformer.remoteServer.extensions.bmp.jpg.supported=true -content.transformer.remoteServer.extensions.bmp.pbm.supported=true -content.transformer.remoteServer.extensions.bmp.pgm.supported=true -content.transformer.remoteServer.extensions.bmp.png.supported=true -content.transformer.remoteServer.extensions.bmp.pnm.supported=true -content.transformer.remoteServer.extensions.bmp.ppj.supported=true -content.transformer.remoteServer.extensions.bmp.ppm.supported=true -content.transformer.remoteServer.extensions.bmp.psd.supported=true -content.transformer.remoteServer.extensions.bmp.ras.supported=true -content.transformer.remoteServer.extensions.bmp.tiff.supported=true -content.transformer.remoteServer.extensions.bmp.xbm.supported=true -content.transformer.remoteServer.extensions.bmp.xpm.supported=true -content.transformer.remoteServer.extensions.bmp.xwd.supported=true -content.transformer.remoteServer.extensions.cgm.bmp.supported=true -content.transformer.remoteServer.extensions.cgm.cgm.supported=true -content.transformer.remoteServer.extensions.cgm.dwt.supported=true -content.transformer.remoteServer.extensions.cgm.gif.supported=true -content.transformer.remoteServer.extensions.cgm.ief.supported=true -content.transformer.remoteServer.extensions.cgm.jp2.supported=true -content.transformer.remoteServer.extensions.cgm.jpg.supported=true -content.transformer.remoteServer.extensions.cgm.pbm.supported=true -content.transformer.remoteServer.extensions.cgm.pgm.supported=true -content.transformer.remoteServer.extensions.cgm.png.supported=true -content.transformer.remoteServer.extensions.cgm.pnm.supported=true -content.transformer.remoteServer.extensions.cgm.ppj.supported=true -content.transformer.remoteServer.extensions.cgm.ppm.supported=true -content.transformer.remoteServer.extensions.cgm.psd.supported=true -content.transformer.remoteServer.extensions.cgm.ras.supported=true -content.transformer.remoteServer.extensions.cgm.tiff.supported=true -content.transformer.remoteServer.extensions.cgm.xbm.supported=true -content.transformer.remoteServer.extensions.cgm.xpm.supported=true -content.transformer.remoteServer.extensions.cgm.xwd.supported=true -content.transformer.remoteServer.extensions.doc.gif.supported=true -content.transformer.remoteServer.extensions.doc.jpg.supported=true -content.transformer.remoteServer.extensions.doc.pdf.supported=true -content.transformer.remoteServer.extensions.doc.png.supported=true -content.transformer.remoteServer.extensions.doc.swf.supported=true -content.transformer.remoteServer.extensions.docm.gif.supported=true -content.transformer.remoteServer.extensions.docm.jpg.supported=true -content.transformer.remoteServer.extensions.docm.pdf.supported=true -content.transformer.remoteServer.extensions.docm.png.supported=true -content.transformer.remoteServer.extensions.docm.swf.supported=true -content.transformer.remoteServer.extensions.docx.gif.supported=true -content.transformer.remoteServer.extensions.docx.jpg.supported=true -content.transformer.remoteServer.extensions.docx.pdf.supported=true -content.transformer.remoteServer.extensions.docx.png.supported=true -content.transformer.remoteServer.extensions.docx.swf.supported=true -content.transformer.remoteServer.extensions.dotm.gif.supported=true -content.transformer.remoteServer.extensions.dotm.jpg.supported=true -content.transformer.remoteServer.extensions.dotm.pdf.supported=true -content.transformer.remoteServer.extensions.dotm.png.supported=true -content.transformer.remoteServer.extensions.dotm.swf.supported=true -content.transformer.remoteServer.extensions.dotx.gif.supported=true -content.transformer.remoteServer.extensions.dotx.jpg.supported=true -content.transformer.remoteServer.extensions.dotx.pdf.supported=true -content.transformer.remoteServer.extensions.dotx.png.supported=true -content.transformer.remoteServer.extensions.dotx.swf.supported=true -content.transformer.remoteServer.extensions.dwt.bmp.supported=true -content.transformer.remoteServer.extensions.dwt.cgm.supported=true -content.transformer.remoteServer.extensions.dwt.dwt.supported=true -content.transformer.remoteServer.extensions.dwt.gif.supported=true -content.transformer.remoteServer.extensions.dwt.ief.supported=true -content.transformer.remoteServer.extensions.dwt.jp2.supported=true -content.transformer.remoteServer.extensions.dwt.jpg.supported=true -content.transformer.remoteServer.extensions.dwt.pbm.supported=true -content.transformer.remoteServer.extensions.dwt.pgm.supported=true -content.transformer.remoteServer.extensions.dwt.png.supported=true -content.transformer.remoteServer.extensions.dwt.pnm.supported=true -content.transformer.remoteServer.extensions.dwt.ppj.supported=true -content.transformer.remoteServer.extensions.dwt.ppm.supported=true -content.transformer.remoteServer.extensions.dwt.psd.supported=true -content.transformer.remoteServer.extensions.dwt.ras.supported=true -content.transformer.remoteServer.extensions.dwt.tiff.supported=true -content.transformer.remoteServer.extensions.dwt.xbm.supported=true -content.transformer.remoteServer.extensions.dwt.xpm.supported=true -content.transformer.remoteServer.extensions.dwt.xwd.supported=true -content.transformer.remoteServer.extensions.gif.bmp.supported=true -content.transformer.remoteServer.extensions.gif.cgm.supported=true -content.transformer.remoteServer.extensions.gif.dwt.supported=true -content.transformer.remoteServer.extensions.gif.gif.supported=true -content.transformer.remoteServer.extensions.gif.ief.supported=true -content.transformer.remoteServer.extensions.gif.jp2.supported=true -content.transformer.remoteServer.extensions.gif.jpg.supported=true -content.transformer.remoteServer.extensions.gif.pbm.supported=true -content.transformer.remoteServer.extensions.gif.pgm.supported=true -content.transformer.remoteServer.extensions.gif.png.supported=true -content.transformer.remoteServer.extensions.gif.pnm.supported=true -content.transformer.remoteServer.extensions.gif.ppj.supported=true -content.transformer.remoteServer.extensions.gif.ppm.supported=true -content.transformer.remoteServer.extensions.gif.psd.supported=true -content.transformer.remoteServer.extensions.gif.ras.supported=true -content.transformer.remoteServer.extensions.gif.tiff.supported=true -content.transformer.remoteServer.extensions.gif.xbm.supported=true -content.transformer.remoteServer.extensions.gif.xpm.supported=true -content.transformer.remoteServer.extensions.gif.xwd.supported=true -content.transformer.remoteServer.extensions.ief.bmp.supported=true -content.transformer.remoteServer.extensions.ief.cgm.supported=true -content.transformer.remoteServer.extensions.ief.dwt.supported=true -content.transformer.remoteServer.extensions.ief.gif.supported=true -content.transformer.remoteServer.extensions.ief.ief.supported=true -content.transformer.remoteServer.extensions.ief.jp2.supported=true -content.transformer.remoteServer.extensions.ief.jpg.supported=true -content.transformer.remoteServer.extensions.ief.pbm.supported=true -content.transformer.remoteServer.extensions.ief.pgm.supported=true -content.transformer.remoteServer.extensions.ief.png.supported=true -content.transformer.remoteServer.extensions.ief.pnm.supported=true -content.transformer.remoteServer.extensions.ief.ppj.supported=true -content.transformer.remoteServer.extensions.ief.ppm.supported=true -content.transformer.remoteServer.extensions.ief.psd.supported=true -content.transformer.remoteServer.extensions.ief.ras.supported=true -content.transformer.remoteServer.extensions.ief.tiff.supported=true -content.transformer.remoteServer.extensions.ief.xbm.supported=true -content.transformer.remoteServer.extensions.ief.xpm.supported=true -content.transformer.remoteServer.extensions.ief.xwd.supported=true -content.transformer.remoteServer.extensions.jp2.bmp.supported=true -content.transformer.remoteServer.extensions.jp2.cgm.supported=true -content.transformer.remoteServer.extensions.jp2.dwt.supported=true -content.transformer.remoteServer.extensions.jp2.gif.supported=true -content.transformer.remoteServer.extensions.jp2.ief.supported=true -content.transformer.remoteServer.extensions.jp2.jp2.supported=true -content.transformer.remoteServer.extensions.jp2.jpg.supported=true -content.transformer.remoteServer.extensions.jp2.pbm.supported=true -content.transformer.remoteServer.extensions.jp2.pgm.supported=true -content.transformer.remoteServer.extensions.jp2.png.supported=true -content.transformer.remoteServer.extensions.jp2.pnm.supported=true -content.transformer.remoteServer.extensions.jp2.ppj.supported=true -content.transformer.remoteServer.extensions.jp2.ppm.supported=true -content.transformer.remoteServer.extensions.jp2.psd.supported=true -content.transformer.remoteServer.extensions.jp2.ras.supported=true -content.transformer.remoteServer.extensions.jp2.tiff.supported=true -content.transformer.remoteServer.extensions.jp2.xbm.supported=true -content.transformer.remoteServer.extensions.jp2.xpm.supported=true -content.transformer.remoteServer.extensions.jp2.xwd.supported=true -content.transformer.remoteServer.extensions.jpg.bmp.supported=true -content.transformer.remoteServer.extensions.jpg.cgm.supported=true -content.transformer.remoteServer.extensions.jpg.dwt.supported=true -content.transformer.remoteServer.extensions.jpg.gif.supported=true -content.transformer.remoteServer.extensions.jpg.ief.supported=true -content.transformer.remoteServer.extensions.jpg.jp2.supported=true -content.transformer.remoteServer.extensions.jpg.jpg.supported=true -content.transformer.remoteServer.extensions.jpg.pbm.supported=true -content.transformer.remoteServer.extensions.jpg.pgm.supported=true -content.transformer.remoteServer.extensions.jpg.png.supported=true -content.transformer.remoteServer.extensions.jpg.pnm.supported=true -content.transformer.remoteServer.extensions.jpg.ppj.supported=true -content.transformer.remoteServer.extensions.jpg.ppm.supported=true -content.transformer.remoteServer.extensions.jpg.psd.supported=true -content.transformer.remoteServer.extensions.jpg.ras.supported=true -content.transformer.remoteServer.extensions.jpg.tiff.supported=true -content.transformer.remoteServer.extensions.jpg.xbm.supported=true -content.transformer.remoteServer.extensions.jpg.xpm.supported=true -content.transformer.remoteServer.extensions.jpg.xwd.supported=true -content.transformer.remoteServer.extensions.pbm.bmp.supported=true -content.transformer.remoteServer.extensions.pbm.cgm.supported=true -content.transformer.remoteServer.extensions.pbm.dwt.supported=true -content.transformer.remoteServer.extensions.pbm.gif.supported=true -content.transformer.remoteServer.extensions.pbm.ief.supported=true -content.transformer.remoteServer.extensions.pbm.jp2.supported=true -content.transformer.remoteServer.extensions.pbm.jpg.supported=true -content.transformer.remoteServer.extensions.pbm.pbm.supported=true -content.transformer.remoteServer.extensions.pbm.pgm.supported=true -content.transformer.remoteServer.extensions.pbm.png.supported=true -content.transformer.remoteServer.extensions.pbm.pnm.supported=true -content.transformer.remoteServer.extensions.pbm.ppj.supported=true -content.transformer.remoteServer.extensions.pbm.ppm.supported=true -content.transformer.remoteServer.extensions.pbm.psd.supported=true -content.transformer.remoteServer.extensions.pbm.ras.supported=true -content.transformer.remoteServer.extensions.pbm.tiff.supported=true -content.transformer.remoteServer.extensions.pbm.xbm.supported=true -content.transformer.remoteServer.extensions.pbm.xpm.supported=true -content.transformer.remoteServer.extensions.pbm.xwd.supported=true -content.transformer.remoteServer.extensions.pdf.gif.supported=true -content.transformer.remoteServer.extensions.pdf.jpg.supported=true -content.transformer.remoteServer.extensions.pdf.png.supported=true -content.transformer.remoteServer.extensions.pdf.swf.supported=true -content.transformer.remoteServer.extensions.pgm.bmp.supported=true -content.transformer.remoteServer.extensions.pgm.cgm.supported=true -content.transformer.remoteServer.extensions.pgm.dwt.supported=true -content.transformer.remoteServer.extensions.pgm.gif.supported=true -content.transformer.remoteServer.extensions.pgm.ief.supported=true -content.transformer.remoteServer.extensions.pgm.jp2.supported=true -content.transformer.remoteServer.extensions.pgm.jpg.supported=true -content.transformer.remoteServer.extensions.pgm.pbm.supported=true -content.transformer.remoteServer.extensions.pgm.pgm.supported=true -content.transformer.remoteServer.extensions.pgm.png.supported=true -content.transformer.remoteServer.extensions.pgm.pnm.supported=true -content.transformer.remoteServer.extensions.pgm.ppj.supported=true -content.transformer.remoteServer.extensions.pgm.ppm.supported=true -content.transformer.remoteServer.extensions.pgm.psd.supported=true -content.transformer.remoteServer.extensions.pgm.ras.supported=true -content.transformer.remoteServer.extensions.pgm.tiff.supported=true -content.transformer.remoteServer.extensions.pgm.xbm.supported=true -content.transformer.remoteServer.extensions.pgm.xpm.supported=true -content.transformer.remoteServer.extensions.pgm.xwd.supported=true -content.transformer.remoteServer.extensions.png.bmp.supported=true -content.transformer.remoteServer.extensions.png.cgm.supported=true -content.transformer.remoteServer.extensions.png.dwt.supported=true -content.transformer.remoteServer.extensions.png.gif.supported=true -content.transformer.remoteServer.extensions.png.ief.supported=true -content.transformer.remoteServer.extensions.png.jp2.supported=true -content.transformer.remoteServer.extensions.png.jpg.supported=true -content.transformer.remoteServer.extensions.png.pbm.supported=true -content.transformer.remoteServer.extensions.png.pgm.supported=true -content.transformer.remoteServer.extensions.png.png.supported=true -content.transformer.remoteServer.extensions.png.pnm.supported=true -content.transformer.remoteServer.extensions.png.ppj.supported=true -content.transformer.remoteServer.extensions.png.ppm.supported=true -content.transformer.remoteServer.extensions.png.psd.supported=true -content.transformer.remoteServer.extensions.png.ras.supported=true -content.transformer.remoteServer.extensions.png.tiff.supported=true -content.transformer.remoteServer.extensions.png.xbm.supported=true -content.transformer.remoteServer.extensions.png.xpm.supported=true -content.transformer.remoteServer.extensions.png.xwd.supported=true -content.transformer.remoteServer.extensions.pnm.bmp.supported=true -content.transformer.remoteServer.extensions.pnm.cgm.supported=true -content.transformer.remoteServer.extensions.pnm.dwt.supported=true -content.transformer.remoteServer.extensions.pnm.gif.supported=true -content.transformer.remoteServer.extensions.pnm.ief.supported=true -content.transformer.remoteServer.extensions.pnm.jp2.supported=true -content.transformer.remoteServer.extensions.pnm.jpg.supported=true -content.transformer.remoteServer.extensions.pnm.pbm.supported=true -content.transformer.remoteServer.extensions.pnm.pgm.supported=true -content.transformer.remoteServer.extensions.pnm.png.supported=true -content.transformer.remoteServer.extensions.pnm.pnm.supported=true -content.transformer.remoteServer.extensions.pnm.ppj.supported=true -content.transformer.remoteServer.extensions.pnm.ppm.supported=true -content.transformer.remoteServer.extensions.pnm.psd.supported=true -content.transformer.remoteServer.extensions.pnm.ras.supported=true -content.transformer.remoteServer.extensions.pnm.tiff.supported=true -content.transformer.remoteServer.extensions.pnm.xbm.supported=true -content.transformer.remoteServer.extensions.pnm.xpm.supported=true -content.transformer.remoteServer.extensions.pnm.xwd.supported=true -content.transformer.remoteServer.extensions.potm.gif.supported=true -content.transformer.remoteServer.extensions.potm.jpg.supported=true -content.transformer.remoteServer.extensions.potm.pdf.supported=true -content.transformer.remoteServer.extensions.potm.png.supported=true -content.transformer.remoteServer.extensions.potm.swf.supported=true -content.transformer.remoteServer.extensions.potx.gif.supported=true -content.transformer.remoteServer.extensions.potx.jpg.supported=true -content.transformer.remoteServer.extensions.potx.pdf.supported=true -content.transformer.remoteServer.extensions.potx.png.supported=true -content.transformer.remoteServer.extensions.potx.swf.supported=true -content.transformer.remoteServer.extensions.ppam.gif.supported=true -content.transformer.remoteServer.extensions.ppam.jpg.supported=true -content.transformer.remoteServer.extensions.ppam.pdf.supported=true -content.transformer.remoteServer.extensions.ppam.png.supported=true -content.transformer.remoteServer.extensions.ppam.swf.supported=true -content.transformer.remoteServer.extensions.ppj.bmp.supported=true -content.transformer.remoteServer.extensions.ppj.cgm.supported=true -content.transformer.remoteServer.extensions.ppj.dwt.supported=true -content.transformer.remoteServer.extensions.ppj.gif.supported=true -content.transformer.remoteServer.extensions.ppj.ief.supported=true -content.transformer.remoteServer.extensions.ppj.jp2.supported=true -content.transformer.remoteServer.extensions.ppj.jpg.supported=true -content.transformer.remoteServer.extensions.ppj.pbm.supported=true -content.transformer.remoteServer.extensions.ppj.pgm.supported=true -content.transformer.remoteServer.extensions.ppj.png.supported=true -content.transformer.remoteServer.extensions.ppj.pnm.supported=true -content.transformer.remoteServer.extensions.ppj.ppj.supported=true -content.transformer.remoteServer.extensions.ppj.ppm.supported=true -content.transformer.remoteServer.extensions.ppj.psd.supported=true -content.transformer.remoteServer.extensions.ppj.ras.supported=true -content.transformer.remoteServer.extensions.ppj.tiff.supported=true -content.transformer.remoteServer.extensions.ppj.xbm.supported=true -content.transformer.remoteServer.extensions.ppj.xpm.supported=true -content.transformer.remoteServer.extensions.ppj.xwd.supported=true -content.transformer.remoteServer.extensions.ppm.bmp.supported=true -content.transformer.remoteServer.extensions.ppm.cgm.supported=true -content.transformer.remoteServer.extensions.ppm.dwt.supported=true -content.transformer.remoteServer.extensions.ppm.gif.supported=true -content.transformer.remoteServer.extensions.ppm.ief.supported=true -content.transformer.remoteServer.extensions.ppm.jp2.supported=true -content.transformer.remoteServer.extensions.ppm.jpg.supported=true -content.transformer.remoteServer.extensions.ppm.pbm.supported=true -content.transformer.remoteServer.extensions.ppm.pgm.supported=true -content.transformer.remoteServer.extensions.ppm.png.supported=true -content.transformer.remoteServer.extensions.ppm.pnm.supported=true -content.transformer.remoteServer.extensions.ppm.ppj.supported=true -content.transformer.remoteServer.extensions.ppm.ppm.supported=true -content.transformer.remoteServer.extensions.ppm.psd.supported=true -content.transformer.remoteServer.extensions.ppm.ras.supported=true -content.transformer.remoteServer.extensions.ppm.tiff.supported=true -content.transformer.remoteServer.extensions.ppm.xbm.supported=true -content.transformer.remoteServer.extensions.ppm.xpm.supported=true -content.transformer.remoteServer.extensions.ppm.xwd.supported=true -content.transformer.remoteServer.extensions.ppsm.gif.supported=true -content.transformer.remoteServer.extensions.ppsm.jpg.supported=true -content.transformer.remoteServer.extensions.ppsm.pdf.supported=true -content.transformer.remoteServer.extensions.ppsm.png.supported=true -content.transformer.remoteServer.extensions.ppsm.swf.supported=true -content.transformer.remoteServer.extensions.ppsx.gif.supported=true -content.transformer.remoteServer.extensions.ppsx.jpg.supported=true -content.transformer.remoteServer.extensions.ppsx.pdf.supported=true -content.transformer.remoteServer.extensions.ppsx.png.supported=true -content.transformer.remoteServer.extensions.ppsx.swf.supported=true -content.transformer.remoteServer.extensions.ppt.gif.supported=true -content.transformer.remoteServer.extensions.ppt.jpg.supported=true -content.transformer.remoteServer.extensions.ppt.pdf.supported=true -content.transformer.remoteServer.extensions.ppt.png.supported=true -content.transformer.remoteServer.extensions.ppt.swf.supported=true -content.transformer.remoteServer.extensions.pptm.gif.supported=true -content.transformer.remoteServer.extensions.pptm.jpg.supported=true -content.transformer.remoteServer.extensions.pptm.pdf.supported=true -content.transformer.remoteServer.extensions.pptm.png.supported=true -content.transformer.remoteServer.extensions.pptm.swf.supported=true -content.transformer.remoteServer.extensions.pptx.gif.supported=true -content.transformer.remoteServer.extensions.pptx.jpg.supported=true -content.transformer.remoteServer.extensions.pptx.pdf.supported=true -content.transformer.remoteServer.extensions.pptx.png.supported=true -content.transformer.remoteServer.extensions.pptx.swf.supported=true -content.transformer.remoteServer.extensions.psd.bmp.supported=true -content.transformer.remoteServer.extensions.psd.cgm.supported=true -content.transformer.remoteServer.extensions.psd.dwt.supported=true -content.transformer.remoteServer.extensions.psd.gif.supported=true -content.transformer.remoteServer.extensions.psd.ief.supported=true -content.transformer.remoteServer.extensions.psd.jp2.supported=true -content.transformer.remoteServer.extensions.psd.jpg.supported=true -content.transformer.remoteServer.extensions.psd.pbm.supported=true -content.transformer.remoteServer.extensions.psd.pgm.supported=true -content.transformer.remoteServer.extensions.psd.png.supported=true -content.transformer.remoteServer.extensions.psd.pnm.supported=true -content.transformer.remoteServer.extensions.psd.ppj.supported=true -content.transformer.remoteServer.extensions.psd.ppm.supported=true -content.transformer.remoteServer.extensions.psd.psd.supported=true -content.transformer.remoteServer.extensions.psd.ras.supported=true -content.transformer.remoteServer.extensions.psd.tiff.supported=true -content.transformer.remoteServer.extensions.psd.xbm.supported=true -content.transformer.remoteServer.extensions.psd.xpm.supported=true -content.transformer.remoteServer.extensions.psd.xwd.supported=true -content.transformer.remoteServer.extensions.ras.bmp.supported=true -content.transformer.remoteServer.extensions.ras.cgm.supported=true -content.transformer.remoteServer.extensions.ras.dwt.supported=true -content.transformer.remoteServer.extensions.ras.gif.supported=true -content.transformer.remoteServer.extensions.ras.ief.supported=true -content.transformer.remoteServer.extensions.ras.jp2.supported=true -content.transformer.remoteServer.extensions.ras.jpg.supported=true -content.transformer.remoteServer.extensions.ras.pbm.supported=true -content.transformer.remoteServer.extensions.ras.pgm.supported=true -content.transformer.remoteServer.extensions.ras.png.supported=true -content.transformer.remoteServer.extensions.ras.pnm.supported=true -content.transformer.remoteServer.extensions.ras.ppj.supported=true -content.transformer.remoteServer.extensions.ras.ppm.supported=true -content.transformer.remoteServer.extensions.ras.psd.supported=true -content.transformer.remoteServer.extensions.ras.ras.supported=true -content.transformer.remoteServer.extensions.ras.tiff.supported=true -content.transformer.remoteServer.extensions.ras.xbm.supported=true -content.transformer.remoteServer.extensions.ras.xpm.supported=true -content.transformer.remoteServer.extensions.ras.xwd.supported=true -content.transformer.remoteServer.extensions.tiff.bmp.supported=true -content.transformer.remoteServer.extensions.tiff.cgm.supported=true -content.transformer.remoteServer.extensions.tiff.dwt.supported=true -content.transformer.remoteServer.extensions.tiff.gif.supported=true -content.transformer.remoteServer.extensions.tiff.ief.supported=true -content.transformer.remoteServer.extensions.tiff.jp2.supported=true -content.transformer.remoteServer.extensions.tiff.jpg.supported=true -content.transformer.remoteServer.extensions.tiff.pbm.supported=true -content.transformer.remoteServer.extensions.tiff.pgm.supported=true -content.transformer.remoteServer.extensions.tiff.png.supported=true -content.transformer.remoteServer.extensions.tiff.pnm.supported=true -content.transformer.remoteServer.extensions.tiff.ppj.supported=true -content.transformer.remoteServer.extensions.tiff.ppm.supported=true -content.transformer.remoteServer.extensions.tiff.psd.supported=true -content.transformer.remoteServer.extensions.tiff.ras.supported=true -content.transformer.remoteServer.extensions.tiff.tiff.supported=true -content.transformer.remoteServer.extensions.tiff.xbm.supported=true -content.transformer.remoteServer.extensions.tiff.xpm.supported=true -content.transformer.remoteServer.extensions.tiff.xwd.supported=true -content.transformer.remoteServer.extensions.xbm.bmp.supported=true -content.transformer.remoteServer.extensions.xbm.cgm.supported=true -content.transformer.remoteServer.extensions.xbm.dwt.supported=true -content.transformer.remoteServer.extensions.xbm.gif.supported=true -content.transformer.remoteServer.extensions.xbm.ief.supported=true -content.transformer.remoteServer.extensions.xbm.jp2.supported=true -content.transformer.remoteServer.extensions.xbm.jpg.supported=true -content.transformer.remoteServer.extensions.xbm.pbm.supported=true -content.transformer.remoteServer.extensions.xbm.pgm.supported=true -content.transformer.remoteServer.extensions.xbm.png.supported=true -content.transformer.remoteServer.extensions.xbm.pnm.supported=true -content.transformer.remoteServer.extensions.xbm.ppj.supported=true -content.transformer.remoteServer.extensions.xbm.ppm.supported=true -content.transformer.remoteServer.extensions.xbm.psd.supported=true -content.transformer.remoteServer.extensions.xbm.ras.supported=true -content.transformer.remoteServer.extensions.xbm.tiff.supported=true -content.transformer.remoteServer.extensions.xbm.xbm.supported=true -content.transformer.remoteServer.extensions.xbm.xpm.supported=true -content.transformer.remoteServer.extensions.xbm.xwd.supported=true -content.transformer.remoteServer.extensions.xlam.gif.supported=true -content.transformer.remoteServer.extensions.xlam.jpg.supported=true -content.transformer.remoteServer.extensions.xlam.pdf.supported=true -content.transformer.remoteServer.extensions.xlam.png.supported=true -content.transformer.remoteServer.extensions.xlam.swf.supported=true -content.transformer.remoteServer.extensions.xls.gif.supported=true -content.transformer.remoteServer.extensions.xls.jpg.supported=true -content.transformer.remoteServer.extensions.xls.pdf.supported=true -content.transformer.remoteServer.extensions.xls.png.supported=true -content.transformer.remoteServer.extensions.xls.swf.supported=true -content.transformer.remoteServer.extensions.xlsb.gif.supported=true -content.transformer.remoteServer.extensions.xlsb.jpg.supported=true -content.transformer.remoteServer.extensions.xlsb.pdf.supported=true -content.transformer.remoteServer.extensions.xlsb.png.supported=true -content.transformer.remoteServer.extensions.xlsb.swf.supported=true -content.transformer.remoteServer.extensions.xlsm.gif.supported=true -content.transformer.remoteServer.extensions.xlsm.jpg.supported=true -content.transformer.remoteServer.extensions.xlsm.pdf.supported=true -content.transformer.remoteServer.extensions.xlsm.png.supported=true -content.transformer.remoteServer.extensions.xlsm.swf.supported=true -content.transformer.remoteServer.extensions.xlsx.gif.supported=true -content.transformer.remoteServer.extensions.xlsx.jpg.supported=true -content.transformer.remoteServer.extensions.xlsx.pdf.supported=true -content.transformer.remoteServer.extensions.xlsx.png.supported=true -content.transformer.remoteServer.extensions.xlsx.swf.supported=true -content.transformer.remoteServer.extensions.xltm.gif.supported=true -content.transformer.remoteServer.extensions.xltm.jpg.supported=true -content.transformer.remoteServer.extensions.xltm.pdf.supported=true -content.transformer.remoteServer.extensions.xltm.png.supported=true -content.transformer.remoteServer.extensions.xltm.swf.supported=true -content.transformer.remoteServer.extensions.xltx.gif.supported=true -content.transformer.remoteServer.extensions.xltx.jpg.supported=true -content.transformer.remoteServer.extensions.xltx.pdf.supported=true -content.transformer.remoteServer.extensions.xltx.png.supported=true -content.transformer.remoteServer.extensions.xltx.swf.supported=true -content.transformer.remoteServer.extensions.xpm.bmp.supported=true -content.transformer.remoteServer.extensions.xpm.cgm.supported=true -content.transformer.remoteServer.extensions.xpm.dwt.supported=true -content.transformer.remoteServer.extensions.xpm.gif.supported=true -content.transformer.remoteServer.extensions.xpm.ief.supported=true -content.transformer.remoteServer.extensions.xpm.jp2.supported=true -content.transformer.remoteServer.extensions.xpm.jpg.supported=true -content.transformer.remoteServer.extensions.xpm.pbm.supported=true -content.transformer.remoteServer.extensions.xpm.pgm.supported=true -content.transformer.remoteServer.extensions.xpm.png.supported=true -content.transformer.remoteServer.extensions.xpm.pnm.supported=true -content.transformer.remoteServer.extensions.xpm.ppj.supported=true -content.transformer.remoteServer.extensions.xpm.ppm.supported=true -content.transformer.remoteServer.extensions.xpm.psd.supported=true -content.transformer.remoteServer.extensions.xpm.ras.supported=true -content.transformer.remoteServer.extensions.xpm.tiff.supported=true -content.transformer.remoteServer.extensions.xpm.xbm.supported=true -content.transformer.remoteServer.extensions.xpm.xpm.supported=true -content.transformer.remoteServer.extensions.xpm.xwd.supported=true -content.transformer.remoteServer.extensions.xwd.bmp.supported=true -content.transformer.remoteServer.extensions.xwd.cgm.supported=true -content.transformer.remoteServer.extensions.xwd.dwt.supported=true -content.transformer.remoteServer.extensions.xwd.gif.supported=true -content.transformer.remoteServer.extensions.xwd.ief.supported=true -content.transformer.remoteServer.extensions.xwd.jp2.supported=true -content.transformer.remoteServer.extensions.xwd.jpg.supported=true -content.transformer.remoteServer.extensions.xwd.pbm.supported=true -content.transformer.remoteServer.extensions.xwd.pgm.supported=true -content.transformer.remoteServer.extensions.xwd.png.supported=true -content.transformer.remoteServer.extensions.xwd.pnm.supported=true -content.transformer.remoteServer.extensions.xwd.ppj.supported=true -content.transformer.remoteServer.extensions.xwd.ppm.supported=true -content.transformer.remoteServer.extensions.xwd.psd.supported=true -content.transformer.remoteServer.extensions.xwd.ras.supported=true -content.transformer.remoteServer.extensions.xwd.tiff.supported=true -content.transformer.remoteServer.extensions.xwd.xbm.supported=true -content.transformer.remoteServer.extensions.xwd.xpm.supported=true -content.transformer.remoteServer.extensions.xwd.xwd.supported=true diff --git a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform-context.xml b/repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform-context.xml deleted file mode 100644 index 3db0808a54..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform-context.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - Alfresco-PDF-Renderer - - - ${alfresco-pdf-renderer.url} - - - ${alfresco-pdf-renderer.startupRetryPeriodSeconds} - - - - - - - - - - ${alfresco-pdf-renderer.exe} - SPLIT:${options} - ${source} - ${target} - - - - - - - - - - - - 1 - - - - - - - - - - ${alfresco-pdf-renderer.exe} - --version - - - - - - - - - - - - - ${alfresco-pdf-renderer.root} - - - - - - - - - - ${alfresco-pdf-renderer.root} - - - - - - \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform.properties b/repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform.properties deleted file mode 100644 index 73a4523dca..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform.properties +++ /dev/null @@ -1,10 +0,0 @@ -# External executable locations -alfresco-pdf-renderer.root=. -alfresco-pdf-renderer.exe=${alfresco-pdf-renderer.root}/alfresco-pdf-renderer - -# Remote server (or docker container) url used to service alfresco-pdf-renderer requests. -alfresco-pdf-renderer.url= - -# When alfresco-pdf-renderer.url is set, this value indicates the amount of time to wait after a connection failure -# before retrying the connection to allow a docker container to (re)start. -alfresco-pdf-renderer.startupRetryPeriodSeconds=60 diff --git a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform-context.xml b/repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform-context.xml deleted file mode 100644 index 9e98320965..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform-context.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - ImageMagick - - - ${img.url} - - - ${img.startupRetryPeriodSeconds} - - - - - - - - - - ${img.exe} - ${source} - SPLIT:${options} - -strip - -quiet - ${target} - - - - - - - - - - - - - 1,2,255,400,405,410,415,420,425,430,435,440,450,455,460,465,470,475,480,485,490,495,499,700,705,710,715,720,725,730,735,740,750,755,760,765,770,775,780,785,790,795,799 - - - - - - - - - - ${img.exe} - -version - - - - - - - - - - - - - - ${img.root} - - - ${img.coders} - - - ${img.config} - - - ${img.dyn} - - - ${img.dyn} - - - - - - - - - - ${img.root} - - - ${img.dyn} - - - ${img.dyn} - - - - - - \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform.properties b/repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform.properties deleted file mode 100644 index 0c0512e3be..0000000000 --- a/repository/src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform.properties +++ /dev/null @@ -1,6 +0,0 @@ -# External executable locations -img.root=./ImageMagick -img.dyn=${img.root}/lib -img.exe=${img.root}/bin/convert -img.coders=${img.root}/modules/coders -img.config=${img.root}/config diff --git a/repository/src/test/java/org/alfresco/AppContext04TestSuite.java b/repository/src/test/java/org/alfresco/AppContext04TestSuite.java index 8c077fb738..52c936b170 100644 --- a/repository/src/test/java/org/alfresco/AppContext04TestSuite.java +++ b/repository/src/test/java/org/alfresco/AppContext04TestSuite.java @@ -88,9 +88,6 @@ import org.junit.runners.Suite; org.alfresco.repo.module.ModuleComponentHelperTest.class, org.alfresco.repo.node.getchildren.GetChildrenCannedQueryTest.class, - // the following test fails locally - on windows - org.alfresco.repo.content.transform.DifferrentMimeTypeTest.class, - org.alfresco.repo.attributes.PropTablesCleanupJobIntegrationTest.class, org.alfresco.service.ServiceRegistryTest.class, diff --git a/repository/src/test/java/org/alfresco/AppContext06TestSuite.java b/repository/src/test/java/org/alfresco/AppContext06TestSuite.java index 15f6a41842..c11a07821d 100644 --- a/repository/src/test/java/org/alfresco/AppContext06TestSuite.java +++ b/repository/src/test/java/org/alfresco/AppContext06TestSuite.java @@ -54,11 +54,7 @@ import org.junit.runners.Suite; org.alfresco.repo.rendition2.RenditionService2IntegrationTest.class, org.alfresco.repo.rendition2.LocalTransformServiceRegistryIntegrationTest.class, org.alfresco.repo.rendition2.LocalTransformClientIntegrationTest.class, - org.alfresco.repo.rendition2.LegacyTransformServiceRegistryIntegrationTest.class, - org.alfresco.repo.rendition2.LegacyTransformClientIntegrationTest.class, org.alfresco.repo.rendition2.LocalRenditionTest.class, - org.alfresco.repo.rendition2.LegacyRenditionTest.class, - org.alfresco.repo.rendition2.LegacyLocalRenditionTest.class, org.alfresco.repo.rendition2.NoneRenditionTest.class, org.alfresco.repo.solr.SOLRTrackingComponentTest.class, diff --git a/repository/src/test/java/org/alfresco/MiscContextTestSuite.java b/repository/src/test/java/org/alfresco/MiscContextTestSuite.java index 321810b85f..b47874cfd3 100644 --- a/repository/src/test/java/org/alfresco/MiscContextTestSuite.java +++ b/repository/src/test/java/org/alfresco/MiscContextTestSuite.java @@ -46,32 +46,6 @@ import org.springframework.context.ApplicationContext; // Minimum context [classpath:alfresco/minimal-context.xml] // ---------------------------------------------------------------------- - // Limits - org.alfresco.repo.content.transform.AbstractContentTransformerLimitsTest.class, - - // Transform tests - org.alfresco.repo.content.transform.BinaryPassThroughContentTransformerTest.class, - org.alfresco.repo.content.transform.ComplexContentTransformerTest.class, - org.alfresco.repo.content.transform.ContentTransformerRegistryTest.class, - org.alfresco.repo.content.transform.HtmlParserContentTransformerTest.class, - org.alfresco.repo.content.transform.MailContentTransformerTest.class, - org.alfresco.repo.content.transform.EMLTransformerTest.class, - org.alfresco.repo.content.transform.MediaWikiContentTransformerTest.class, - org.alfresco.repo.content.transform.OpenOfficeContentTransformerTest.class, - // Requires a transformer to be installed in the system - //org.alfresco.repo.content.transform.PdfBoxContentTransformerTest.class, - org.alfresco.repo.content.transform.PoiContentTransformerTest.class, - org.alfresco.repo.content.transform.PoiHssfContentTransformerTest.class, - org.alfresco.repo.content.transform.PoiOOXMLContentTransformerTest.class, - org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerTest.class, - org.alfresco.repo.content.transform.StringExtractingContentTransformerTest.class, - org.alfresco.repo.content.transform.TextMiningContentTransformerTest.class, - org.alfresco.repo.content.transform.TextToPdfContentTransformerTest.class, - org.alfresco.repo.content.transform.TikaAutoContentTransformerTest.class, - org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerTest.class, - org.alfresco.repo.content.transform.AppleIWorksContentTransformerTest.class, - org.alfresco.repo.content.transform.ArchiveContentTransformerTest.class, - // Metadata tests - replaced with simplified tests in LocalRenditionTest and ServiceRenditionTest org.alfresco.repo.content.metadata.RFC822MetadataExtracterTest.class, org.alfresco.repo.content.metadata.MappingMetadataExtracterTest.class, diff --git a/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTagMappingTest.java b/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTagMappingTest.java index 559bad289c..a3e7cfd4fe 100644 --- a/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTagMappingTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTagMappingTest.java @@ -72,7 +72,6 @@ import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.GUID; import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.RedundantTests; -import org.apache.tika.metadata.Metadata; import org.junit.experimental.categories.Category; import org.springframework.context.ConfigurableApplicationContext; @@ -306,8 +305,8 @@ public class ContentMetadataExtracterTagMappingTest extends TestCase super(Sets.newHashSet(MimetypeMap.MIMETYPE_IMAGE_JPEG)); Properties mappingProperties = new Properties(); // TODO move to new keyword once tika is upgraded - mappingProperties.put(Metadata.KEYWORDS, ContentModel.PROP_TAGS.toString()); - mappingProperties.put(Metadata.DESCRIPTION, ContentModel.PROP_DESCRIPTION.toString()); + mappingProperties.put("Keywords", ContentModel.PROP_TAGS.toString()); + mappingProperties.put("description", ContentModel.PROP_DESCRIPTION.toString()); setMappingProperties(mappingProperties); } @@ -336,7 +335,7 @@ public class ContentMetadataExtracterTagMappingTest extends TestCase // Add some test keywords to those actually extracted from the file including a nodeRef List keywords = new ArrayList(Arrays.asList( new String[] { existingTagNodeRef, TAG_2, TAG_3, TAG_NONEXISTENT_NODEREF })); - Serializable extractedKeywords = rawMap.get(Metadata.KEYWORDS); + Serializable extractedKeywords = rawMap.get("Keywords"); if (extractedKeywords != null && extractedKeywords instanceof String) { keywords.add((String) extractedKeywords); @@ -345,7 +344,7 @@ public class ContentMetadataExtracterTagMappingTest extends TestCase { keywords.addAll((Collection) extractedKeywords); } - putRawValue(Metadata.KEYWORDS, (Serializable) keywords, rawMap); + putRawValue("Keywords", (Serializable) keywords, rawMap); return rawMap; } } diff --git a/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java b/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java index ea7c779831..934fdf3ebc 100644 --- a/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java +++ b/repository/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java @@ -76,8 +76,7 @@ import java.util.Properties; import java.util.Set; /** - * Test of the ActionExecuter for extracting metadata. Note: This test makes - * assumptions about the PDF test data for PdfBoxExtracter. + * Test of the ActionExecuter for extracting metadata. * * @author Jesper Steen Møller */ diff --git a/repository/src/test/java/org/alfresco/repo/content/AbstractJodConverterBasedTest.java b/repository/src/test/java/org/alfresco/repo/content/AbstractJodConverterBasedTest.java deleted file mode 100644 index 99b8382314..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/AbstractJodConverterBasedTest.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content; - -import java.io.File; -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.transform.AbstractContentTransformerTest; -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.rendition2.SynchronousTransformClient; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.cmr.thumbnail.ThumbnailService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.springframework.context.ApplicationContext; - -/** - * @deprecated The JodConverterMetadataExtracter has not been in use since 6.0.1 and the transformer is also deprecated. - * - * @author Neil McErlean - * @since 3.3 - */ -@Ignore("This is an abstract class so don't instaniate it or run it in Junit") -@Deprecated -public abstract class AbstractJodConverterBasedTest -{ - private static Log log = LogFactory.getLog(AbstractJodConverterBasedTest.class); - - protected static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - - protected static ServiceRegistry serviceRegistry; - protected static TransactionService transactionService; - protected static NodeService nodeService; - protected static ContentService contentService; - protected static ThumbnailService thumbnailService; - private static Repository repositoryHelper; - - private static ChildApplicationContextFactory oooJodcSubsystem; - - protected NodeRef contentNodeRef; - protected LinkedList nodesToDeleteAfterTest = new LinkedList(); - - - /** - * This test relies upon customised OpenOffice.org subsystems being available. - * The OOoDirect subsystem (usually enabled by default) is disabled and the - * OOoJodconverter subsystem (usually disabled by default) is enabled. - * @throws Exception - */ - @BeforeClass - public static void initServicesAndRestartOOoSubsystems() throws Exception - { - if (log.isDebugEnabled()) - { - log.debug("initServicesAndRestartOOoSubsystems"); - } - - repositoryHelper = (Repository) ctx.getBean("repositoryHelper"); - serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - contentService = serviceRegistry.getContentService(); - nodeService = serviceRegistry.getNodeService(); - thumbnailService = serviceRegistry.getThumbnailService(); - transactionService = serviceRegistry.getTransactionService(); - - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - - oooJodcSubsystem = (ChildApplicationContextFactory) ctx.getBean("OOoJodconverter"); - - // Stop the OOoJodconverter subsystem and restart it with test settings i.e. enabled. - // Also a pool of 3 JodConverter instances, just for fun. - if (log.isDebugEnabled()) - { - log.debug("Enabling OOoJodconverter"); - } - oooJodcSubsystem.stop(); - oooJodcSubsystem.setProperty("jodconverter.enabled", "true"); - oooJodcSubsystem.setProperty("jodconverter.portNumbers", "2022, 2023, 2024"); - oooJodcSubsystem.start(); - } - - /** - * Returns true if OpenOffice-based transformations are currently known to - * be available, else false. - */ - protected boolean isOpenOfficeAvailable() - { - SynchronousTransformClient synchronousTransformClient = serviceRegistry.getSynchronousTransformClient(); - return synchronousTransformClient.isSupported(MimetypeMap.MIMETYPE_WORD, -1, null, - MimetypeMap.MIMETYPE_PDF, Collections.emptyMap(), null, null); - } - - @Before - public void createTemporaryNodeRefs() throws Exception - { - // Create a content node which will serve as test data for our transformations. - RetryingTransactionCallback makeNodeCallback = new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - if (log.isDebugEnabled()) - { - log.debug("Creating temporary NodeRefs for testing."); - } - - final NodeRef companyHome = repositoryHelper.getCompanyHome(); - // Create a folder - Map folderProps = new HashMap(); - folderProps.put(ContentModel.PROP_NAME, this.getClass().getSimpleName() + System.currentTimeMillis()); - - NodeRef folderNodeRef = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, - ContentModel.ASSOC_CONTAINS, ContentModel.TYPE_FOLDER, folderProps).getChildRef(); - nodesToDeleteAfterTest.add(folderNodeRef); - - // Add some content. - File origFile = AbstractContentTransformerTest.loadQuickTestFile("doc"); - - Map props = new HashMap(); - props.put(ContentModel.PROP_NAME, "original." + "doc"); - NodeRef node = nodeService.createNode( - folderNodeRef, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "original.doc"), - ContentModel.TYPE_CONTENT, - props).getChildRef(); - - ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_WORD); - writer.setEncoding("UTF-8"); - writer.putContent(origFile); - - return node; - } - }; - contentNodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(makeNodeCallback); - this.nodesToDeleteAfterTest.add(contentNodeRef); - } - - @After - public void deleteTemporaryNodeRefs() - { - // Tidy up the test nodes we created - RetryingTransactionCallback deleteNodeCallback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Delete them in reverse order. - for (Iterator iter = nodesToDeleteAfterTest.descendingIterator(); iter.hasNext(); ) - { - NodeRef nextNodeToDelete = iter.next(); - - if (nodeService.exists(nextNodeToDelete)) - { - if (log.isDebugEnabled()) - { - log.debug("Deleting temporary node " + nextNodeToDelete); - } - nodeService.deleteNode(nextNodeToDelete); - } - } - - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(deleteNodeCallback); - } - - @AfterClass - public static void stopOOoSubsystems() throws Exception - { - // Put the OOoJodconverter subsystem back to its install settings (disabled). - if (log.isDebugEnabled()) - { - log.debug("Disabling OOoJodconverter"); - } - oooJodcSubsystem.stop(); - oooJodcSubsystem.setProperty("jodconverter.enabled", "false"); - oooJodcSubsystem.start(); - - oooJodcSubsystem.stop(); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/JodConverterSharedInstanceTest.java b/repository/src/test/java/org/alfresco/repo/content/JodConverterSharedInstanceTest.java deleted file mode 100644 index f4d7f46bdf..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/JodConverterSharedInstanceTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.MockitoAnnotations; - -import java.io.File; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests methods added to JodConverterSharedInstance that try to use the replaced oooDirect settings. - * @author Alan Davis - */ -public class JodConverterSharedInstanceTest -{ - public static final String LIBREOFFICE = "libreoffice"; - public static final String PROGRAM = "program"; - public static final String ELSEWHERE = "elsewhere"; - public static final String SOFFICE_BIN = "soffice.bin"; - public static final String SOFFICE_EXE = "soffice.exe"; - - private static final File OFFICE_HOME_DIR = new File(LIBREOFFICE); - private static final File PROGRAM_DIR = new File(OFFICE_HOME_DIR, PROGRAM); - private static final File ELSEWHERE_DIR = new File(OFFICE_HOME_DIR, ELSEWHERE); - - private static final String OFFICE_HOME = OFFICE_HOME_DIR.getPath(); - private static final String PROGRAM_BIN = new File( PROGRAM_DIR, SOFFICE_BIN).getPath(); - private static final String PROGRAM_EXE = new File( PROGRAM_DIR, SOFFICE_EXE).getPath(); - private static final String ELSEWHERE_BIN = new File( ELSEWHERE_DIR, SOFFICE_BIN).getPath(); - private static final String NO_OFFICE_HOME_BIN = new File(new File(PROGRAM), SOFFICE_BIN).getPath(); - private static final String JUST_SOFFICE_BIN = new File( SOFFICE_BIN).getPath(); - - - private JodConverterSharedInstance instance; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - instance = new JodConverterSharedInstance(); - } - - @Test - public void setupTest() - { - String SLASH = File.separator; - assertEquals(LIBREOFFICE, OFFICE_HOME); - assertEquals(LIBREOFFICE + SLASH + PROGRAM + SLASH + SOFFICE_EXE, PROGRAM_EXE); - assertEquals(LIBREOFFICE + SLASH + PROGRAM + SLASH + SOFFICE_BIN, PROGRAM_BIN); - assertEquals(LIBREOFFICE + SLASH + ELSEWHERE + SLASH + SOFFICE_BIN, ELSEWHERE_BIN); - assertEquals( PROGRAM + SLASH + SOFFICE_BIN, NO_OFFICE_HOME_BIN); - assertEquals( SOFFICE_BIN, JUST_SOFFICE_BIN); - assertNotEquals(PROGRAM_BIN, PROGRAM_EXE); - } - - @Test - public void officeHomeTest() - { - // Only jodconverter.officehome - instance.setOfficeHome(OFFICE_HOME); - instance.setDeprecatedOooExe(null); - assertEquals(OFFICE_HOME, instance.getOfficeHome()); - - // Use ooo.exe - instance.setOfficeHome(null); - instance.setDeprecatedOooExe(PROGRAM_BIN); - assertEquals(OFFICE_HOME, instance.getOfficeHome()); - - // jodconverter.officehome wins - instance.setOfficeHome(OFFICE_HOME); - instance.setDeprecatedOooExe(PROGRAM_EXE); - assertEquals(OFFICE_HOME, instance.getOfficeHome()); - - // ooo.exe has no parent - instance.setOfficeHome(null); - instance.setDeprecatedOooExe(JUST_SOFFICE_BIN); - assertEquals("", instance.getOfficeHome()); - - // ooo.exe parent is not "program" - instance.setOfficeHome(null); - instance.setDeprecatedOooExe(ELSEWHERE_BIN); - assertEquals("", instance.getOfficeHome()); - - // ooo.exe has a parent "program" directory but no grandparent - instance.setOfficeHome(null); - instance.setDeprecatedOooExe(NO_OFFICE_HOME_BIN); - assertEquals("", instance.getOfficeHome()); - } - - @Test - public void enabledTest() - { - // If ooo.enabled is true the JodConverter will be enabled, otherwise the jodconverter.enabled value is used. - // Community set properties via alfresco-global.properties. - // Enterprise may do the same but may also reset jodconverter.enabled them via the Admin console. - // In the case of Enterprise it is very unlikely that ooo.enabled will be set to true. - - // Only jodconverter.enabled - instance = new JodConverterSharedInstance(); - instance.setEnabled("true"); - instance.setDeprecatedOooEnabled(null); - assertTrue(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("true"); - assertTrue(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("false"); - instance.setDeprecatedOooEnabled(null); - assertFalse(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("false"); - assertFalse(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("any value other than true"); - instance.setDeprecatedOooEnabled(null); - assertFalse(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled(""); - instance.setDeprecatedOooEnabled(null); - assertFalse(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled(null); - instance.setDeprecatedOooEnabled(null); - assertFalse(instance.isEnabled()); - - // Use ooo.enabled - instance = new JodConverterSharedInstance(); - instance.setEnabled(null); - instance.setDeprecatedOooEnabled("true"); - assertTrue(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled(null); - instance.setDeprecatedOooEnabled("false"); - assertFalse(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setDeprecatedOooEnabled("true"); - assertTrue(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setDeprecatedOooEnabled("false"); - assertFalse(instance.isEnabled()); - - // Check jodconverter.enabled is used if ooo.enabled is false - Original Enterprise setup - instance = new JodConverterSharedInstance(); - instance.setEnabled("true"); - instance.setDeprecatedOooEnabled("false"); - assertTrue(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("false"); - instance.setDeprecatedOooEnabled("false"); - assertFalse(instance.isEnabled()); - - // Check jodconverter.enabled is ignored if ooo.enabled is true - Original Community setup - instance = new JodConverterSharedInstance(); - instance.setEnabled("true"); - instance.setDeprecatedOooEnabled("true"); - assertTrue(instance.isEnabled()); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("false"); - instance.setDeprecatedOooEnabled("true"); - assertTrue(instance.isEnabled()); - - // Check reset of jodconverter.enabled turns off isAvailable - instance = new JodConverterSharedInstance(); - instance.setEnabled("true"); - instance.isAvailable = true; // Normally set to true after running afterPropertiesSet() - instance.setEnabled("true"); - assertTrue(instance.isAvailable); - instance.setEnabled("false"); - assertFalse(instance.isAvailable); - - instance = new JodConverterSharedInstance(); - instance.setEnabled("true"); - instance.setDeprecatedOooEnabled("false"); // Extra line compare with previous - instance.isAvailable = true; - instance.setEnabled("true"); - assertTrue(instance.isAvailable); - instance.setEnabled("false"); - assertFalse(instance.isAvailable); - } - - @Test - public void portNumbersTest() - { - // ooo.port or jodconverter.portNumber is used depending on the setting of enabled properties. - // If jodconverter.enabled is true jodconverter.portNumber is used. - // If jodconverter.enabled is false and ooo.enabled is true ooo.port is used. - // If jodconverter.enabled is false and ooo.enabled is true ooo.port is used. - - // jodconverter.enabled=true use jodconverter.portNumber - instance.setEnabled("true"); - instance.setPortNumbers("8001,8002,8003"); - instance.setDeprecatedOooPort("8001"); - assertArrayEquals(new int[] {8001, 8002, 8003}, instance.getPortNumbers()); - - // jodconverter.enabled=true and ooo.enabled=true use jodconverter.portNumber - instance.setDeprecatedOooEnabled("true"); - assertArrayEquals(new int[] {8001, 8002, 8003}, instance.getPortNumbers()); - - // jodconverter.enabled=false and ooo.enabled=true use ooo.port - instance.setEnabled("false"); - assertArrayEquals(new int[] {8001}, instance.getPortNumbers()); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerLimitsTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerLimitsTest.java deleted file mode 100644 index 6f3269f732..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerLimitsTest.java +++ /dev/null @@ -1,574 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.MiscContextTestSuite; -import org.alfresco.repo.content.AbstractContentReader; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.ApplicationContext; - -/** - * Test methods that control limits in {@link AbstractContentTransformerLimits} - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class AbstractContentTransformerLimitsTest -{ - private static final String A = MimetypeMap.MIMETYPE_XML; - private static final String B = MimetypeMap.MIMETYPE_HTML; - private static final String C = MimetypeMap.MIMETYPE_PDF; - - private AbstractContentTransformerLimits transformer; - private TransformationOptionLimits limits; - private Map> mimetypeLimits; - private TransformationOptions options; - - @Before - public void setUp() throws Exception - { - ApplicationContext ctx = MiscContextTestSuite.getMinimalContext(); - ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - MimetypeService mimetypeService = serviceRegistry.getMimetypeService(); - TransformerDebug transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); - TransformerConfig transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); - - transformer = new AbstractContentTransformer2() - { - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - return false; - } - - @Override - protected void transformInternal(ContentReader reader, ContentWriter writer, - TransformationOptions options) throws Exception - { - } - }; - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.setBeanName("transformer.test"+System.currentTimeMillis()%100000); - - limits = new TransformationOptionLimits(); - options = new TransformationOptions(); - } - - private void addMimetypeLimits(String source, String target, TransformationOptionLimits limits) - { - if (mimetypeLimits == null) - { - mimetypeLimits = new HashMap>(); - } - - Map targetLimits = mimetypeLimits.get(source); - if (targetLimits == null) - { - targetLimits = new HashMap(); - mimetypeLimits.put(source, targetLimits); - } - - targetLimits.put(target, limits); - } - - @Test - public void testTimeoutMs() throws Exception - { - long value = 1234; - transformer.setTimeoutMs(value); - transformer.register(); - long actual = transformer.getTimeoutMs(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testReadLimitTimeMs() throws Exception - { - long value = 1234; - transformer.setReadLimitTimeMs(value); - transformer.register(); - long actual = transformer.getReadLimitTimeMs(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testMaxSourceSizeKBytes() throws Exception - { - long value = 1234; - transformer.setMaxSourceSizeKBytes(value); - transformer.register(); - long actual = transformer.getMaxSourceSizeKBytes(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testReadLimitKBytes() throws Exception - { - long value = 1234; - transformer.setReadLimitKBytes(value); - transformer.register(); - long actual = transformer.getReadLimitKBytes(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testMaxPages() throws Exception - { - int value = 1234; - transformer.setMaxPages(value); - transformer.register(); - int actual = transformer.getMaxPages(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testPageLimit() throws Exception - { - int value = 1234; - transformer.setPageLimit(value); - transformer.register(); - int actual = transformer.getPageLimit(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testMimetypeLimit() throws Exception - { - long value = 1234; - limits.setMaxSourceSizeKBytes(value); - addMimetypeLimits(A, B, limits); - - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - long actual = transformer.getLimits(A, B, options).getMaxSourceSizeKBytes(); - assertEquals("Getter did not return set value", value, actual); - - actual = transformer.getLimits(A, C, options).getMaxSourceSizeKBytes(); - assertEquals("Other values should not be set", -1, actual); - } - - @Test - public void testMimetypeLimitTargetWildcard() throws Exception - { - long value = 1234; - limits.setMaxSourceSizeKBytes(value); - addMimetypeLimits(A, "*", limits); - - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - long actual = transformer.getLimits(A, B, options).getMaxSourceSizeKBytes(); - assertEquals("Getter did not return set value", value, actual); - - actual = transformer.getLimits(B, A, options).getMaxSourceSizeKBytes(); - assertEquals("Other values should not be set", -1, actual); - } - - @Test - public void testMimetypeLimitSourceWildcard() throws Exception - { - long value = 1234; - limits.setMaxSourceSizeKBytes(value); - addMimetypeLimits("*", B, limits); - - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - long actual = transformer.getLimits(A, B, options).getMaxSourceSizeKBytes(); - assertEquals("Getter did not return set value", value, actual); - - actual = transformer.getLimits(B, A, options).getMaxSourceSizeKBytes(); - assertEquals("Other values should not be set", -1, actual); - } - - @Test - public void testPassedInOptions() throws Exception - { - long value = 1234; - limits.setMaxSourceSizeKBytes(value+1); - addMimetypeLimits(A, B, limits); - - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - long actual = transformer.getLimits(A, B, options).getMaxSourceSizeKBytes(); - assertEquals("Getter did not return set value", value+1, actual); - - options.setMaxSourceSizeKBytes(value); - actual = transformer.getLimits(A, B, options).getMaxSourceSizeKBytes(); - assertEquals("Getter did not return set value", value, actual); - } - - @Test - public void testGetMaxSourceSizeKBytes() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - // Set limit for A to B mimetypes and test - limits.setMaxSourceSizeKBytes(kValue); - addMimetypeLimits(A, B, limits); - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - - assertEquals("Expected to have set value returned", kValue, - transformer.getMaxSourceSizeKBytes(A, B, options)); - - // With a mimetype that does not have any specific limits - assertEquals("Expected to have -1 (unlimited) returned", -1, - transformer.getMaxSourceSizeKBytes(C, B, options)); - } - - @Test - // Combination using just transformer limit to start with - public void testGetMaxSourceSizeKBytesCombination() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - // Check for combinations with transformer limits - - transformer.setMaxSourceSizeKBytes(kValue); - transformer.register(); - assertEquals("Expected to have transformer set value returned", kValue, - transformer.getMaxSourceSizeKBytes(A, B, options)); - } - - @Test - // Combination where mimetype limit is used - public void testGetMaxSourceSizeKBytesCombinationMimetypeUsed() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - transformer.setMaxSourceSizeKBytes(kValue+1); - limits.setMaxSourceSizeKBytes(kValue); - addMimetypeLimits(A, B, limits); - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - assertEquals("Expected to have transformer set value returned", kValue, - transformer.getMaxSourceSizeKBytes(A, B, options)); - } - - @Test - // Check no limit when page limit set on a transformer that does not support page limit - // maxSourceSizeKbytes value should be ignored if a page limit is in use - public void testGetMaxSourceSizeKBytesPageSupportsNot() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - transformer.setPageLimitsSupported(false); - transformer.setMaxSourceSizeKBytes(kValue); - limits.setMaxSourceSizeKBytes(kValue+1); - limits.setPageLimit(1); - addMimetypeLimits(A, B, limits); - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - assertEquals("Expected to ignore the page limit as the transformer does not support it", kValue+1, - transformer.getMaxSourceSizeKBytes(A, B, options)); - } - - @Test - // Check no limit when page limit set on a transformer that does support page limit - // maxSourceSizeKbytes value should be ignored if a page limit is in use - public void testGetMaxSourceSizeKBytesPageSupports() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - transformer.setPageLimitsSupported(true); - transformer.setMaxSourceSizeKBytes(kValue); - limits.setMaxSourceSizeKBytes(kValue+1); - limits.setPageLimit(1); - addMimetypeLimits(A, B, limits); - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - assertEquals("Expected to have -1 (unlimited) returned when there are page limits", -1, - transformer.getMaxSourceSizeKBytes(A, B, options)); - } - - @Test - // Using limit on a mimetype - public void testIsTransformableSizeMimetype() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - // Set limit for A to B mimetypes and test - limits.setMaxSourceSizeKBytes(kValue); - addMimetypeLimits(A, B, limits); - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - - assertTrue("Size is less than limit so should have been ok", - transformer.isTransformableSize(A, byteValue-1, B, options)); - assertTrue("Size is equal to limit so should have been ok", - transformer.isTransformableSize(A, byteValue, B, options)); - assertFalse("Size is greater than limit so should have failed", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - // With a mimetype that does not have any specific limits - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(C, byteValue+1, B, options)); - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, C, options)); - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(C, byteValue+1, C, options)); - } - - @Test - // Using limit on transformer as a whole - public void testIsTransformableSizeTrans() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - transformer.setMaxSourceSizeKBytes(kValue); - transformer.register(); - assertTrue("Size is equal to limit so should have been ok", - transformer.isTransformableSize(A, byteValue, B, options)); - assertFalse("Size is greater than limit so should have failed", - transformer.isTransformableSize(A, byteValue+1, B, options)); - } - - @Test - // Combination where mimetype limit is used - public void testIsTransformableSizeCombinationMimetypeUsed() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - // Not set mimetype limits yet - assertTrue("No limits so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - transformer.setMaxSourceSizeKBytes(kValue+1); - limits.setMaxSourceSizeKBytes(kValue); - addMimetypeLimits(A, B, limits); - transformer.setMimetypeLimits(mimetypeLimits); - transformer.register(); - assertTrue("Size is equal to limit so should have been ok", - transformer.isTransformableSize(A, byteValue, B, options)); - assertFalse("Size is greater than limit so should have failed", - transformer.isTransformableSize(A, byteValue+1, B, options)); - } - - @Test - public void testIsTransformableSizeWithPageLimit() throws Exception - { - long kValue = 12; - long byteValue = kValue*1024; - - transformer.setMaxSourceSizeKBytes(kValue); - transformer.setPageLimitsSupported(true); - transformer.register(); - - // Test works as normal before setting the pageLimit - assertTrue("Size is less than limit so should have been ok", - transformer.isTransformableSize(A, byteValue-1, B, options)); - assertTrue("Size is equal to limit so should have been ok", - transformer.isTransformableSize(A, byteValue, B, options)); - assertFalse("Size is greater than limit so should not have failed", - transformer.isTransformableSize(A, byteValue+1, B, options)); - - // test with pageLimit set - options.getLimits().setPageLimit(1); - assertTrue("Size is greater than limit BUT pageLimit is set so should have been ok", - transformer.isTransformableSize(A, byteValue+1, B, options)); - } - - @Test - public void testSetReaderLimits() throws Exception - { - AbstractContentReader reader = new DummyAbstractContentReader(0, 0); - - long value = 1234; - transformer.setTimeoutMs(value); - transformer.register(); - - assertEquals("Limit should not have been set in the reader", null, reader.getLimits()); - - transformer.setReaderLimits(reader, null, options); - assertEquals("Limit should have been set in the reader", value, reader.getLimits().getTimeoutMs()); - - options.setTimeoutMs(--value); - transformer.setReaderLimits(reader, null, options); - assertEquals("Limit should have been set in the reader", value, reader.getLimits().getTimeoutMs()); - } - - /** - * A dummy AbstractContentReader that returns a given number of bytes - * (all 'a') very slowly. There is a configurable delay returning each byte. - * Used to test timeouts and read limits. - */ - private static class DummyAbstractContentReader extends AbstractContentReader - { - final long size; - final long msPerByte; - - /** - * @param size of the dummy data - * @param msPerByte milliseconds between byte reads - */ - public DummyAbstractContentReader(long size, long msPerByte) - { - super("a"); - this.size = size; - this.msPerByte = msPerByte; - } - - /** - * @return Returns an instance of the this class - */ - @Override - protected ContentReader createReader() throws ContentIOException - { - return new DummyAbstractContentReader(size, msPerByte); - } - - @Override - protected ReadableByteChannel getDirectReadableChannel() throws ContentIOException - { - InputStream is = new InputStream() - { - long read = 0; - long start = 0; - - @Override - public int read() throws IOException - { - if (read >= size) - return -1; - - read++; - - if (msPerByte > 0) - { - long elapse = System.currentTimeMillis() - start; - if (read == 1) - { - start = elapse; - } - else - { - // On Windows it is possible to just wait 1 ms per byte but this - // does not work on linux hence (end up with a full read taking - // 40 seconds rather than 5) the need to wait if elapse time - // is too fast. - long delay = (read * msPerByte) - elapse; - if (delay > 0) - { - try - { - Thread.sleep(delay); - } - catch (InterruptedException e) - { - // ignore - } - } - } - } - - return 'a'; - } - - // Just a way to tell AbstractContentReader not to wrap the ChannelInputStream - // in a BufferedInputStream - @Override - public boolean markSupported() - { - return true; - } - }; - return Channels.newChannel(is); - } - - public boolean exists() - { - return true; - } - - public long getLastModified() - { - return 0L; - } - - public long getSize() - { - return size; - } - }; -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java index 730ad544fa..36c3dd2191 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * 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 @@ -25,42 +25,19 @@ */ package org.alfresco.repo.content.transform; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; -import java.util.TreeSet; - import junit.framework.TestCase; - -import org.alfresco.MiscContextTestSuite; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.TempFileProvider; -import org.alfresco.util.exec.RuntimeExec; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationContext; import org.springframework.util.ResourceUtils; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + /** - * Provides a base set of tests for testing - * {@link org.alfresco.repo.content.transform.ContentTransformer} - * implementations. + * Now only contains methods to load quick files * * @author Derek Hulley * @@ -69,67 +46,7 @@ import org.springframework.util.ResourceUtils; @Deprecated public abstract class AbstractContentTransformerTest extends TestCase { - protected static String QUICK_CONTENT = "The quick brown fox jumps over the lazy dog"; - private static String[] QUICK_WORDS = new String[] { - "quick", "brown", "fox", "jumps", "lazy", "dog"}; - private static Log logger = LogFactory.getLog(AbstractContentTransformerTest.class); - - /** - * This context will be fetched each time, but almost always - * will have been cached by {@link ApplicationContextHelper} - */ - protected ApplicationContext ctx; - - protected ServiceRegistry serviceRegistry; - protected MimetypeService mimetypeService; - protected TransformerDebug transformerDebug; - protected TransformerConfig transformerConfig; - - /** - * Fetches a transformer to test for a given transformation. The transformer - * does not have to be reliable for the given format - if it isn't - * then it will be ignored. - * - * @param sourceMimetype the sourceMimetype to be tested - * @param targetMimetype the targetMimetype to be tested - * @return Returns the ContentTranslators that will be tested by - * the methods implemented in this class. A null return value is - * acceptable if the source and target mimetypes are not of interest. - */ - protected abstract ContentTransformer getTransformer(String sourceMimetype, String targetMimetype); - - /** - * Ensures that the temp locations are cleaned out before the tests start - */ - @Override - protected void setUp() throws Exception - { - // Grab a suitably configured context - ctx = MiscContextTestSuite.getMinimalContext(); - - // Grab other useful beans - serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - mimetypeService = serviceRegistry.getMimetypeService(); - transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); - transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); - - // perform a little cleaning up - long now = System.currentTimeMillis(); - TempFileProvider.TempFileCleanerJob.removeFiles(now); - } - - /** - * Check that all objects are present - */ - public void testSetUp() throws Exception - { - assertNotNull("MimetypeMap not present", mimetypeService); - // check that the quick resources are available - File sourceFile = AbstractContentTransformerTest.loadQuickTestFile("txt"); - assertNotNull(sourceFile); - } - /** * Helper method to load one of the "The quick brown fox" files from the * classpath. @@ -180,281 +97,4 @@ public abstract class AbstractContentTransformerTest extends TestCase { return loadNamedQuickTestFile("quick."+extension); } - - /** - * For the given mime type, returns one or more quick* - * files to be tested. - * By default this is just quick + the default extension. - * However, you can override this if you need special - * rules, eg quickOld.foo, quickMid.foo and quickNew.foo - * for differing versions of the file format. - */ - protected String[] getQuickFilenames(String sourceMimetype) { - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - return new String[] { - "quick." + sourceExtension - }; - } - - /** - * Writes the supplied text out to a temporary file, and opens - * a content reader onto it. - */ - protected static ContentReader buildContentReader(String text, Charset encoding) - throws IOException - { - File tmpFile = TempFileProvider.createTempFile("AlfrescoTest_", ".txt"); - FileOutputStream out = new FileOutputStream(tmpFile); - OutputStreamWriter wout = new OutputStreamWriter(out, encoding); - wout.write(text); - wout.close(); - out.close(); - - ContentReader reader = new FileContentReader(tmpFile); - reader.setEncoding(encoding.displayName()); - reader.setMimetype("text/plain"); - return reader; - } - - /** - * Tests the full range of transformations available on the - * {@link #getTransformer(String, String) transformer} subject to the - * {@link org.alfresco.util.test.QuickFileTest available test files} - * and the {@link ContentTransformer#getReliability(String, String) reliability} of - * the {@link #getTransformer(String, String) transformer} itself. - *

    - * Each transformation is repeated several times, with a transformer being - * {@link #getTransformer(String, String) requested} for each transformation. In the - * case where optimizations are being done around the selection of the most - * appropriate transformer, different transformers could be used during the iteration - * process. - *

    - * Results for the transformations are dumped to a temporary file named - * AbstractContentTransformerTest-results-1234.txt. - */ - public void testAllConversions() throws Exception - { - StringBuilder sb = new StringBuilder(2048); - sb.append("Mimetype Conversion Tests \n") - .append("========================= \n") - .append(" Date: ").append(new Date()).append("\n") - .append("\n"); - - // get all mimetypes - Set mimetypes = new TreeSet(mimetypeService.getMimetypes()); - for (String sourceMimetype : mimetypes) - { - // attempt to get a source file for each mimetype - String[] quickFiles = getQuickFilenames(sourceMimetype); - sb.append(" Source Files: "); - for (String quickFile: quickFiles) - { - sb.append(quickFile); - sb.append(' '); - } - sb.append("\n"); - - - for (String quickFile : quickFiles) - { - String sourceExtension = quickFile.substring(quickFile.lastIndexOf('.')+1); - - // attempt to convert to every other mimetype - for (String targetMimetype : mimetypes) - { - if (sourceMimetype.equals(targetMimetype)) - { - // Don't test like-to-like transformations - continue; - } - if (!doTestTransformation(quickFile, sourceMimetype, targetMimetype)) - { - continue; - } - ContentWriter targetWriter = null; - // construct a reader onto the source file - String targetExtension = mimetypeService.getExtension(targetMimetype); - - // must we test the transformation? - ContentTransformer transformer = getTransformer(sourceMimetype, targetMimetype); - if (transformer == null || transformer.isTransformable(sourceMimetype, -1, targetMimetype, null) == false) - { - // no transformer - continue; - } - - if (isTransformationExcluded(sourceExtension, targetExtension)) - { - continue; - } - - // dump - sb.append(" Target Extension: ").append(targetExtension); - sb.append(" <").append(transformer.getClass().getSimpleName()).append(">"); - - // is there a test file for this conversion? - File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(quickFile); - if (sourceFile == null) - { - sb.append(" \n"); - continue; // no test file available for that extension - } - ContentReader sourceReader = new FileContentReader(sourceFile); - - // perform the transformation several times so that we get a good idea of performance - int count = 0; - long before = System.currentTimeMillis(); - Set transformerClasses = new HashSet(2); - for (int i = 0; i < 5; i++) - { - // get the transformer repeatedly as it might be different each time around - transformer = getTransformer(sourceMimetype, targetMimetype); - // must we report on this class? - if (!transformerClasses.contains(transformer.getClass().getName())) - { - transformerClasses.add(transformer.getClass().getName()); - sb.append(" <").append(transformer.getClass().getSimpleName()).append(">"); - } - - // make a writer for the target file - File targetFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_" + sourceExtension + "_", - "." + targetExtension); - targetWriter = new FileContentWriter(targetFile); - - // do the transformation - sourceReader.setMimetype(sourceMimetype); - targetWriter.setMimetype(targetMimetype); - transformer.transform(sourceReader.getReader(), targetWriter); - - // if the target format is any type of text, then it must contain the 'quick' phrase - if (isQuickPhraseExpected(targetMimetype)) - { - ContentReader targetReader = targetWriter.getReader(); - String checkContent = targetReader.getContentString(); - assertTrue("Quick phrase not present in document converted to text: \n" + - " transformer: " + transformer + "\n" + - " source: " + sourceReader + "\n" + - " target: " + targetWriter, - checkContent.contains(QUICK_CONTENT)); - - // Let subclasses do extra checks if they want - additionalContentCheck(sourceMimetype, targetMimetype, checkContent); - } - else if (isQuickWordsExpected(targetMimetype)) - { - ContentReader targetReader = targetWriter.getReader(); - String checkContent = targetReader.getContentString(); - // essentially check that FTS indexing can use the conversion properly - for (int word = 0; word < QUICK_WORDS.length; word++) - { - assertTrue("Quick phrase word not present in document converted to text: \n" + - " transformer: " + transformer + "\n" + - " source: " + sourceReader + "\n" + - " target: " + targetWriter + "\n" + - " word: " + word, - checkContent.contains(QUICK_WORDS[word])); - } - } - // increment count - count++; - } - long after = System.currentTimeMillis(); - double average = (double) (after - before) / (double) count; - - // dump - sb.append(String.format(" average %10.0f ms", average)).append("\n"); - - if (logger.isDebugEnabled()) - { - logger.debug("Transformation performed " + count + " time: " + - sourceMimetype + " --> " + targetMimetype + "\n" + - " source: " + sourceReader + "\n" + - " target: " + targetWriter + "\n" + - " transformer: " + getTransformer(sourceMimetype, targetMimetype)); - } - } - } - } - - // dump to file - File outputFile = TempFileProvider.createTempFile("AbstractContentTransformerTest-results-", ".txt"); - ContentWriter outputWriter = new FileContentWriter(outputFile); - outputWriter.setEncoding("UTF8"); - outputWriter.putContent(sb.toString()); - } - - /** - * Allows a subclass to skip selected transformations. - * @param quickFile name - * @param sourceMimetype of the quickFile - * @param targetMimetype of the transformation - * @return false to skip the transformation. - */ - protected boolean doTestTransformation(String quickFile, String sourceMimetype, String targetMimetype) - { - return false; - } - - /** - * Allows implementations to do some extra checks on the - * results of the content as found by - * {@link #testAllConversions()} - */ - protected void additionalContentCheck(String sourceMimetype, String targetMimetype, String contents) {} - - /** - * This method is an extension point for enabling/disabling an assertion that the "quick brown fox" - * phrase is present in the transformed content. - * By default, the phrase is expected in all text/plain outputs. - * - * @param targetMimetype mimetype of the target of the transformation - * @return true if phrase is expected else false. - */ - protected boolean isQuickPhraseExpected(String targetMimetype) - { - return targetMimetype.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN); - } - - /** - * This method is an extension point for enabling/disabling an assertion that the "quick brown fox" - * words are each present in the transformed content. - * By default, the words in the phrase are expected in all text/* outputs. - * - * @param targetMimetype mimetype of the target of the transformation - * @return true if each word is expected else false. - */ - protected boolean isQuickWordsExpected(String targetMimetype) - { - return targetMimetype.startsWith(StringExtractingContentTransformer.PREFIX_TEXT); - } - - /** - * This method is an extension point for excluding certain transformations in a subclass. - * The default implementation returns false for all mime type pairs. - * - * @param sourceExtension String - * @param targetExtension String - * @return boolean - */ - protected boolean isTransformationExcluded(String sourceExtension, String targetExtension) - { - return false; - } - - // TODO externalise ? Review as part of "fast & reliable tests" (and also testing a "reference deployment" that includes LibreOffice/OpenOffice) - private boolean failTestIfOOWorkerUnavailable = false; - - /** - * This method is currently used to skip certain tests if LibreOffice/OpenOffice is not available (eg. on build machines). - * - * @return - * @throws InterruptedException - */ - protected boolean isOpenOfficeWorkerAvailable() throws InterruptedException - { - ChildApplicationContextFactory jodconverterSubsystem = (ChildApplicationContextFactory) ctx.getBean("OOoJodconverter"); - JodContentTransformer jodContentTransformer = (JodContentTransformer)jodconverterSubsystem.getApplicationContext().getBean("transformer.worker.JodConverter"); - return jodContentTransformer.isAvailable(); - } } diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/AppleIWorksContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/AppleIWorksContentTransformerTest.java deleted file mode 100644 index 37531b6687..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/AppleIWorksContentTransformerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Test case for {@link AppleIWorksContentTransformer} content transformer. - * - * @author Neil Mc Erlean - * @since 4.0 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class AppleIWorksContentTransformerTest extends AbstractContentTransformerTest -{ - private AppleIWorksContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new AppleIWorksContentTransformer(); - - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - @Override - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_NUMBERS, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_PAGES, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions())); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/ArchiveContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/ArchiveContentTransformerTest.java deleted file mode 100644 index 55565ef544..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/ArchiveContentTransformerTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - - * 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.repo.rendition2.SynchronousTransformClient; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * Test class for ArchiveContentTransformer. - * - * @see org.alfresco.repo.content.transform.ArchiveContentTransformer - * - * @author Neil McErlean - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ArchiveContentTransformerTest extends AbstractContentTransformerTest -{ - private ArchiveContentTransformer transformer; - - private ContentTransformerRegistry registry; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new ArchiveContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - - registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry"); - } - - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_ZIP, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable("application/x-tar", -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - - // TODO should this work ? - //assertTrue(transformer.isTransformable("application/x-gtar", -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - } - - @Override - protected boolean isQuickPhraseExpected(String targetMimetype) - { - // The Zip transformer produces names of the entries, not their contents. - return false; - } - - @Override - protected boolean isQuickWordsExpected(String targetMimetype) - { - // The Zip transformer produces names of the entries, not their contents. - return false; - } - - public void testRecursing() throws Exception - { - ContentWriter writer; - String contents; - - // Bean off, no options - transformer.setIncludeContents("FALSE"); - - writer = getTestWriter(); - transformer.transform(getTestReader(), writer); - contents = writer.getReader().getContentString(); - testHasFiles(contents); - testNested(contents, false); - - - // Bean on, no options - transformer.setIncludeContents("TRUE"); - - writer = getTestWriter(); - transformer.transform(getTestReader(), writer); - contents = writer.getReader().getContentString(); - testHasFiles(contents); - testNested(contents, true); - - - // Bean off, Transformation Options off - TransformationOptions options = new TransformationOptions(); - transformer.setIncludeContents("FALSE"); - - writer = getTestWriter(); - transformer.transform(getTestReader(), writer, options); - contents = writer.getReader().getContentString(); - testHasFiles(contents); - testNested(contents, false); - - - // Bean on, Transformation Options off - transformer.setIncludeContents("T"); - - writer = getTestWriter(); - transformer.transform(getTestReader(), writer, options); - contents = writer.getReader().getContentString(); - testHasFiles(contents); - testNested(contents, true); - - - // Bean off, Transformation Options on - options win - options.setIncludeEmbedded(true); - transformer.setIncludeContents("FALSE"); - - writer = getTestWriter(); - transformer.transform(getTestReader(), writer, options); - contents = writer.getReader().getContentString(); - testHasFiles(contents); - testNested(contents, true); - - - // Bean on, Transformation Options on - transformer.setIncludeContents("YeS"); - - writer = getTestWriter(); - transformer.transform(getTestReader(), writer, options); - contents = writer.getReader().getContentString(); - testHasFiles(contents); - testNested(contents, true); - } - private ContentReader getTestReader() throws IOException { - ContentReader sourceReader = new FileContentReader( - loadQuickTestFile("zip") - ); - sourceReader.setMimetype(MimetypeMap.MIMETYPE_ZIP); - return sourceReader; - } - private ContentWriter getTestWriter() throws IOException { - ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile("test", ".txt")); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - return writer; - } - private void testHasFiles(String contents) - { - assertTrue("Files not found in " + contents, - contents.contains("quick.txt")); - assertTrue("Files not found in " + contents, - contents.contains("quick.doc")); - assertTrue("Files not found in " + contents, - contents.contains("subfolder/quick.jpg")); - } - private void testNested(String contents, boolean shouldHaveRecursed) - { - assertEquals( - "Recursion was " + shouldHaveRecursed + - " but content was " + contents, - shouldHaveRecursed, - contents.contains("The quick brown fox jumps over the lazy dog") - ); - assertEquals( - "Recursion was " + shouldHaveRecursed + - " but content was " + contents, - shouldHaveRecursed, - contents.contains("Le renard brun rapide saute par-dessus le chien paresseux") - ); - } - - public void testArchiveToPdf() throws Exception - { - String sourceMimetype = MimetypeMap.MIMETYPE_ZIP; - String targetMimetype = MimetypeMap.MIMETYPE_PDF; - - // force Transformers subsystem to start (this will also load the ContentTransformerRegistry - including complex/dynamic pipelines) - // note: a call to contentService.getTransformer would also do this .. even if transformer cannot be found (returned as null) - ChildApplicationContextFactory transformersSubsystem = (ChildApplicationContextFactory) ctx.getBean("Transformers"); - transformersSubsystem.start(); - - assertNotNull(registry.getTransformer("transformer.complex.ArchiveToPdf")); - - // note: txt -> pdf currently uses OpenOffice/LibreOffice - if (! isOpenOfficeWorkerAvailable()) - { - // no connection - System.err.println("ooWorker not available - skipping testArchiveToPdf !!"); - return; - } - - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - ContentTransformer transformer = serviceRegistry.getContentService().getTransformer(sourceMimetype, targetMimetype); - assertNotNull(transformer); - - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - - File zipSourceFile = loadQuickTestFile("zip"); - ContentReader sourceReader = new FileContentReader(zipSourceFile); - - // make a writer for the target file - File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_" - + getName() + "_" + sourceExtension + "_", "." + targetExtension); - ContentWriter targetWriter = new FileContentWriter(targetFile); - - // do the transformation - sourceReader.setMimetype(sourceMimetype); - targetWriter.setMimetype(targetMimetype); - transformer.transform(sourceReader.getReader(), targetWriter); - - ContentReader targetReader = new FileContentReader(targetFile); - assertTrue(targetReader.getSize() > 0); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/BinaryPassThroughContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/BinaryPassThroughContentTransformerTest.java deleted file mode 100644 index ecc9118c35..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/BinaryPassThroughContentTransformerTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * @see org.alfresco.repo.content.transform.BinaryPassThroughContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class BinaryPassThroughContentTransformerTest extends AbstractContentTransformerTest -{ - private BinaryPassThroughContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new BinaryPassThroughContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - TransformationOptions options = new TransformationOptions(); - boolean reliability = false; - - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, options); - assertFalse("Mimetype should not be supported", reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_XML, -1, MimetypeMap.MIMETYPE_XML, options); - assertFalse("Mimetype should not be supported", reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_WORD, options); - assertTrue("Mimetype should be supported", reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_EXCEL, options); - assertTrue("Mimetype should be supported", reliability); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/ComplexContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/ComplexContentTransformerTest.java deleted file mode 100644 index 60e425d320..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/ComplexContentTransformerTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Tests a transformation from Powerpoint->PDF->Text. - * - * @see org.alfresco.repo.content.transform.ComplexContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ComplexContentTransformerTest extends AbstractContentTransformerTest -{ - private ComplexContentTransformer transformer; - private boolean isAvailable; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - ContentTransformer unoTransformer = (ContentTransformer) ctx.getBean("transformer.JodConverter"); - ContentTransformer pdfBoxTransformer = (ContentTransformer) ctx.getBean("transformer.PdfBox"); - // make sure that they are working for this test - if (unoTransformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()) == false) - { - isAvailable = false; - return; - } - else if (pdfBoxTransformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()) == false) - { - isAvailable = false; - return; - } - else - { - isAvailable = true; - } - - transformer = new ComplexContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - // set the transformer list - List transformers = new ArrayList(2); - transformers.add(unoTransformer); - transformers.add(pdfBoxTransformer); - transformer.setTransformers(transformers); - // set the intermediate mimetypes - List intermediateMimetypes = Collections.singletonList(MimetypeMap.MIMETYPE_PDF); - transformer.setIntermediateMimetypes(intermediateMimetypes); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testReliability() throws Exception - { - if (!isAvailable) - { - return; - } - boolean reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()); - assertEquals("Mimetype should not be supported", false, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/ContentTransformerRegistryTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/ContentTransformerRegistryTest.java deleted file mode 100644 index 8b6b3522e9..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/ContentTransformerRegistryTest.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.junit.Assert; - -import java.util.Collections; -import java.util.List; - -import static org.alfresco.repo.content.MimetypeMap.MIMETYPE_TEXT_PLAIN; - -/** - * @see org.alfresco.repo.content.transform.ContentTransformerRegistry - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ContentTransformerRegistryTest extends AbstractContentTransformerTest -{ - private static final String A = MIMETYPE_TEXT_PLAIN; - private static final String B = MimetypeMap.MIMETYPE_XML; - private static final String C = MimetypeMap.MIMETYPE_WORD; - private static final String D = MimetypeMap.MIMETYPE_HTML; - - private static final TransformationOptions OPTIONS = new TransformationOptions(); - - /** a real registry with real transformers */ - private ContentTransformerRegistry registry; - /** a fake registry with fake transformers */ - private ContentTransformerRegistry dummyRegistry; - - private ContentReader reader; - private ContentWriter writer; - - private DummyTransformer ad20; - private DummyTransformer ad30; - private DummyTransformer ad10; - private DummyTransformer ad25a; - private DummyTransformer ad25b; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry"); - - reader = new FileContentReader(TempFileProvider.createTempFile(getName(), ".txt")); - reader.setMimetype(A); - writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt")); - writer.setMimetype(D); - - byte[] bytes = new byte[256]; - for (int i = 0; i < 256; i++) - { - bytes[i] = (byte)i; - } - // create the dummyRegistry - TransformerSelectorImpl transformerSelector = new TransformerSelectorImpl(); - transformerSelector.setTransformerConfig(transformerConfig); - transformerSelector.setContentTransformerRegistry(dummyRegistry); - dummyRegistry = new ContentTransformerRegistry(transformerSelector); - transformerSelector.setContentTransformerRegistry(dummyRegistry); - dummyRegistry.setTransformerDebug(transformerDebug); - // create some dummy transformers for reliability tests - new DummyTransformer(mimetypeService, "transformer.testAB10a", transformerDebug, transformerConfig, dummyRegistry, A, B, 10L); - new DummyTransformer(mimetypeService, "transformer.testAB10b", transformerDebug, transformerConfig, dummyRegistry, A, B, 10L); - new DummyTransformer(mimetypeService, "transformer.testAC10a", transformerDebug, transformerConfig, dummyRegistry, A, C, 10L); - new DummyTransformer(mimetypeService, "transformer.testAC10b", transformerDebug, transformerConfig, dummyRegistry, A, C, 10L); - new DummyTransformer(mimetypeService, "transformer.testBC10", transformerDebug, transformerConfig, dummyRegistry, B, C, 10L); - // create some dummy transformers for speed tests - ad20 = new DummyTransformer(mimetypeService, "transformer.testAD20", transformerDebug, transformerConfig, dummyRegistry, A, D, 20L); - ad30 = new DummyTransformer(mimetypeService, "transformer.testAD30", transformerDebug, transformerConfig, dummyRegistry, A, D, 30L); - ad10 = new DummyTransformer(mimetypeService, "transformer.testAD10", transformerDebug, transformerConfig, dummyRegistry, A, D, 10L); // the fast one - ad25a = new DummyTransformer(mimetypeService, "transformer.testAD25a", transformerDebug, transformerConfig, dummyRegistry, A, D, 25L); - ad25b = new DummyTransformer(mimetypeService, "transformer.testAD25b", transformerDebug, transformerConfig, dummyRegistry, A, D, 25L); - } - - /** - * Checks that required objects are present - */ - public void testSetUp() throws Exception - { - super.testSetUp(); - assertNotNull(registry); - } - - /** - * @return Returns the transformer provided by the real registry - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return registry.getTransformer(sourceMimetype, -1, targetMimetype, options); - } - - public void testGetTransformerEnabledDisabled() throws Exception - { - TransformationOptions options = new TransformationOptions(); - - Assert.assertNotNull(registry.getTransformer(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options)); - try - { - registry.setEnabled(false); - Assert.assertNull(registry.getTransformer(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options)); - } - finally - { - registry.setEnabled(true); - } - Assert.assertNotNull(registry.getTransformer(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options)); - } - - public void testGetActiveTransformersEnabledDisabled() throws Exception - { - TransformationOptions options = new TransformationOptions(); - - Assert.assertFalse(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty()); - try - { - registry.setEnabled(false); - Assert.assertTrue(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty()); - } - finally - { - registry.setEnabled(true); - } - Assert.assertFalse(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty()); - } - - public void testNullRetrieval() throws Exception - { - ContentTransformer transformer = null; - transformer = dummyRegistry.getTransformer(C, -1, B, OPTIONS); - assertNull("No transformer expected", transformer); - transformer = dummyRegistry.getTransformer(C, -1, A, OPTIONS); - assertNull("No transformer expected", transformer); - transformer = dummyRegistry.getTransformer(B, -1, A, OPTIONS); - assertNull("No transformer expected", transformer); - } - - public void testSimpleRetrieval() throws Exception - { - ContentTransformer transformer = null; - // B -> C expect true - transformer = dummyRegistry.getTransformer(B, -1, C, OPTIONS); - //transformer = dummyRegistry.getTransformer(B, C, OPTIONS); - assertNotNull("No transformer found", transformer); - assertTrue("Incorrect reliability", transformer.isTransformable(B, -1, C, OPTIONS)); - assertFalse("Incorrect reliability", transformer.isTransformable(C, -1, B, OPTIONS)); - } - - /** - * Force some equally reliant transformers to do some work and develop - * different average transformation times. Check that the registry - * copes with the new averages after a reset. - */ - public void testPerformanceRetrieval() throws Exception - { - // Until the threshold (3) is reached by each transformer with the same priority it will - // be tried that many times in the order defined. 20, 30, 10, 25a, 25b - for (int i=1; i<=3; i++) - { - long expectedTime = i == 1 ? 0L : 20L; - ContentTransformer transformer1 = dummyRegistry.getTransformer(A, -1, D, OPTIONS); - assertEquals(i+" incorrect transformation time", expectedTime, transformer1.getTransformationTime(A, D)); - ad20.transformInternal(null, null, null); - - expectedTime = i == 1 ? 0L : 30L; - transformer1 = dummyRegistry.getTransformer(A, -1, D, OPTIONS); - assertEquals(i+" incorrect transformation time", expectedTime, transformer1.getTransformationTime(A, D)); - ad30.transformInternal(null, null, null); - - ad10.transformInternal(null, null, null); - ad25a.transformInternal(null, null, null); - ad25b.transformInternal(null, null, null); - } - - // Now the average times are set up, it should find the fastest one - - // A -> D expect 1.0, 10ms - ContentTransformer transformer1 = dummyRegistry.getTransformer(A, -1, D, OPTIONS); - assertTrue("Incorrect reliability", transformer1.isTransformable(A, -1, D, OPTIONS)); - assertFalse("Incorrect reliability", transformer1.isTransformable(D, -1, A, OPTIONS)); - assertEquals("Incorrect transformation time", 10L, transformer1.getTransformationTime(A, D)); - - // A -> D has 10, 20, 25, 25, 30 - List activeTransformers = dummyRegistry.getActiveTransformers(A, -1, D, OPTIONS); - assertEquals("Not all found", 5, activeTransformers.size()); - assertEquals("Incorrect order", 10L, activeTransformers.get(0).getTransformationTime(A, D)); - assertEquals("Incorrect order", 20L, activeTransformers.get(1).getTransformationTime(A, D)); - assertEquals("Incorrect order", 25L, activeTransformers.get(2).getTransformationTime(A, D)); - assertEquals("Incorrect order", 25L, activeTransformers.get(3).getTransformationTime(A, D)); - assertEquals("Incorrect order", 30L, activeTransformers.get(4).getTransformationTime(A, D)); - - // Disable two of them, and re-test - ((DummyTransformer)activeTransformers.get(2)).disable(); - ((DummyTransformer)activeTransformers.get(4)).disable(); - - activeTransformers = dummyRegistry.getActiveTransformers(A, -1, D, OPTIONS); - assertEquals("Not all found", 3, activeTransformers.size()); - assertEquals("Incorrect order", 10L, activeTransformers.get(0).getTransformationTime(A, D)); - assertEquals("Incorrect order", 20L, activeTransformers.get(1).getTransformationTime(A, D)); - assertEquals("Incorrect order", 25L, activeTransformers.get(2).getTransformationTime(A, D)); - } - - public void testScoredRetrieval() throws Exception - { - ContentTransformer transformer = null; - // A -> B expect 0.6 - transformer = dummyRegistry.getTransformer(A, -1, B, OPTIONS); - assertNotNull("No transformer found", transformer); - assertTrue("Incorrect reliability", transformer.isTransformable(A, -1, B, OPTIONS)); - assertFalse("Incorrect reliability", transformer.isTransformable(B, -1, A, OPTIONS)); - // A -> C expect 1.0 - transformer = dummyRegistry.getTransformer(A, -1, C, OPTIONS); - assertNotNull("No transformer found", transformer); - assertTrue("Incorrect reliability", transformer.isTransformable(A, -1, C, OPTIONS)); - assertFalse("Incorrect reliability", transformer.isTransformable(C, -1, A, OPTIONS)); - } - - /** - * Set an explicit, and bizarre, transformation. Check that it is used. - * - */ - public void testExplicitTransformation() - { - AbstractContentTransformer2 dummyTransformer = new DummyTransformer( - mimetypeService, - "transformer.testExplicit", - transformerDebug, transformerConfig, - dummyRegistry, MimetypeMap.MIMETYPE_FLASH, MimetypeMap.MIMETYPE_EXCEL, 12345); - // set an explicit transformation - ExplictTransformationDetails key = - new ExplictTransformationDetails( - MimetypeMap.MIMETYPE_FLASH, - MimetypeMap.MIMETYPE_EXCEL); - dummyTransformer.setExplicitTransformations(Collections.singletonList(key)); - // register again - dummyTransformer.register(); - - // get the appropriate transformer for the bizarre mapping - ContentTransformer checkTransformer = dummyRegistry.getTransformer(MimetypeMap.MIMETYPE_FLASH, -1, MimetypeMap.MIMETYPE_EXCEL, OPTIONS); - - assertNotNull("No explicit transformer found", checkTransformer); - assertTrue("Expected explicit transformer", dummyTransformer == checkTransformer); - } - - /** - * Dummy transformer that does no transformation and scores exactly as it is - * told to in the constructor. It enables the tests to be sure of what to expect. - */ - private static class DummyTransformer extends AbstractContentTransformer2 - { - private String sourceMimetype; - private String targetMimetype; - private long transformationTime; - private boolean disable = false; - - public DummyTransformer( - MimetypeService mimetypeService, - String name, - TransformerDebug transformerDebug, TransformerConfig transformerConfig, - ContentTransformerRegistry registry, String sourceMimetype, String targetMimetype, long transformationTime) - { - super.setMimetypeService(mimetypeService); - super.setTransformerDebug(transformerDebug); - super.setTransformerConfig(transformerConfig); - super.setRegistry(registry); - this.sourceMimetype = sourceMimetype; - this.targetMimetype = targetMimetype; - this.transformationTime = transformationTime; - setRegisterTransformer(true); - setBeanName(name+'.'+System.currentTimeMillis()%100000); - - // register - register(); - } - - protected void disable() - { - disable = true; - } - - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) - { - if (disable) { - return false; - } - - if (this.sourceMimetype.equals(sourceMimetype) - && this.targetMimetype.equals(targetMimetype)) - { - return true; - } - else - { - return false; - } - } - - /** - * Just notches up some average times - */ - public void transformInternal( - ContentReader reader, - ContentWriter writer, - TransformationOptions options) throws Exception - { - // just update the transformation time - super.recordTime(sourceMimetype, targetMimetype, transformationTime); - } - } - - @Override - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - // TODO Auto-generated method stub - return null; - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/DifferrentMimeTypeTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/DifferrentMimeTypeTest.java deleted file mode 100644 index d196d914fa..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/DifferrentMimeTypeTest.java +++ /dev/null @@ -1,517 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.springframework.context.ApplicationContext; - -import junit.framework.TestCase; - - -/** - * Tests that ContentTransformers only correctly process source nodes if the - * mimetype of the node matches the content. This is the opposite of what this - * test class was originally written to prove for MNT-11015. The current version - * was reworked for MNT-16381. - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class DifferrentMimeTypeTest extends TestCase -{ - private static Log log = LogFactory.getLog(DifferrentMimeTypeTest.class); - - private AbstractContentTransformer2 contentTransformer; - private TransformationOptions options; - private ServiceRegistry serviceRegistry; - private MimetypeService mimetypeService; - private TransformerDebug transformerDebug; - private TransformerConfig transformerConfig; - private ContentTransformerRegistry registry; - private static Repository repositoryHelper; - private File testFile; - private TransactionService transactionService; - private NodeRef contentNodeRef; - private NodeService nodeService; - private LinkedList nodesToDeleteAfterTest = new LinkedList<>(); - private ContentService contentService; - - private int NEITHER = 0; - private int RETRY = 1; - private int STRICT = 2; - private static boolean SUCCESS = true; - private static boolean FAILURE = false; - - @Before - public void setUp() throws Exception - { - ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - mimetypeService = serviceRegistry.getMimetypeService(); - transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); - transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); - registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry"); - transactionService = serviceRegistry.getTransactionService(); - repositoryHelper = (Repository) ctx.getBean("repositoryHelper"); - nodeService = serviceRegistry.getNodeService(); - contentService = serviceRegistry.getContentService(); - - assertNotNull("MimetypeMap not present", this.mimetypeService); - assertNotNull("ServiceRegistry not present", serviceRegistry); - assertNotNull("TransformerDebug not present", transformerDebug); - assertNotNull("TransformerConfig not present", transformerConfig); - assertNotNull("transactionService not present", transactionService); - assertNotNull("repositoryHelper not present", repositoryHelper); - assertNotNull("nodeService not present", nodeService); - assertNotNull("contentService not present", contentService); - } - - // The file has the correct declared and detected mimetypes, - // so can be processed by all approaches - - public void testMimetypesCorrects() throws IOException - { - testTransformToJPeg("quick.gif", - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - NEITHER, SUCCESS); - } - - public void testMimetypesCorrectsRetry() throws IOException - { - testTransformToJPeg("quick.gif", - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - RETRY, SUCCESS); - } - - public void testMimetypesCorrectsStrict() throws IOException - { - testTransformToJPeg("quick.gif", - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - STRICT, SUCCESS); - } - - public void testMimetypesCorrectsRetryStrict() throws IOException - { - testTransformToJPeg("quick.gif", - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_GIF, - RETRY|STRICT, SUCCESS); - } - - // The file has the wrong extension (it is a .png rather than .docx) - // so can only be processed by the RETRY approach. If strict the transform - // should have been discarded before a retry could be tried. - - public void testWrongExtension() throws IOException - { - testTransformToJPeg("quick-differentMimetype.docx", - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_IMAGE_PNG, - NEITHER, FAILURE); - } - - public void testWrongExtensionRetry() throws IOException - { - testTransformToJPeg("quick-differentMimetype.docx", - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_IMAGE_PNG, - RETRY, SUCCESS); - } - - public void testWrongExtensionStrict() throws IOException - { - testTransformToJPeg("quick-differentMimetype.docx", - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_IMAGE_PNG, - STRICT, FAILURE); - } - - public void testWrongExtensionStrictRetry() throws IOException - { - testTransformToJPeg("quick-differentMimetype.docx", - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, - MimetypeMap.MIMETYPE_IMAGE_PNG, - RETRY|STRICT, FAILURE); - } - - // The file has the correct extension and content, but the content is incorrectly detected - // as .pdf. As .ai to .pdf is in the white list and has the same format as pdf all 3 can - // only process the file. - - public void testDetectedInWhiteList() throws IOException - { - // The transformer can read the file as a pdf and does not know the node had the wrong mimetype. - testTransformToJPeg("quickCS5.ai", - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_PDF, - NEITHER, SUCCESS); - } - - public void testDetectedInWhiteListRetry() throws IOException - { - // Same as testDetectedInWhiteList, so did not use the retry - testTransformToJPeg("quickCS5.ai", - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_PDF, - RETRY, SUCCESS); - } - - public void testDetectedInWhiteListStrict() throws IOException - { - // Works because ai to pdf is in the white list, so we pass it to the transformer and it can read pdf. - testTransformToJPeg("quickCS5.ai", - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_PDF, - STRICT, SUCCESS); - } - - public void testDetectedInWhiteListRetryStrict() throws IOException - { - // Works in the same way as testDetectedInWhiteListStrict. - testTransformToJPeg("quickCS5.ai", - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_PDF, - RETRY|STRICT, SUCCESS); - } - - // The file has the correct extension and content, but has the wrong declared mimetype. - // As .ai to .doc is not in the white list a strict check will fail. - - public void testDetectedNotInWhiteList() throws IOException - { - // The transformer for .ai to .jpg can do nothing with .doc files, so fails - testTransformToJPeg("quick.doc", - MimetypeMap.MIMETYPE_WORD, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_WORD, - NEITHER, FAILURE); - } - - public void testDetectedNotInWhiteListRetry() throws IOException - { - // The retry fails without soffice (which is not available on Bamboo) - testTransformToJPeg("quick.doc", - MimetypeMap.MIMETYPE_WORD, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_WORD, - RETRY, FAILURE); - } - - public void testDetectedNotInWhiteListStrict() throws IOException - { - // ai to doc not in white list - testTransformToJPeg("quick.doc", - MimetypeMap.MIMETYPE_WORD, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_WORD, - STRICT, FAILURE); - } - - public void testDetectedNotInWhiteListRetryStrict() throws IOException - { - // ai to doc not in white list - testTransformToJPeg("quick.doc", - MimetypeMap.MIMETYPE_WORD, - MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR, - MimetypeMap.MIMETYPE_WORD, - RETRY|STRICT, FAILURE); - } - - /** - * Method tries to transform a quick file to a JPeg, setting the declared source Mimetype. - * @param quickname name of the quickfile. - * @param extensionMimetype the expected mimetype of the quick file from the extension - * (this might be wrong - checked). - * @param declaredMimetype source mimetype to be set on the node - * (this may be wrong - simply used). - * @param detectedMimetype the expected mimetype detected from the content - * (this might be wrong - checked). - * @param approach indicates that the initial transform should be using - * STRICT mimetype checking, - * RETRY with another transformer if the declared and derived mimetypes - * don't match, or - * NEITHER if it should uses the original approach with no - * retries and no strict checking. - * @param expectSuccess indicates if the transform is expected to work. - * @throws IOException if the quick file cannot be loaded. - */ - private void testTransformToJPeg(String quickname, String extensionMimetype, - String declaredMimetype, String detectedMimetype, int approach, - boolean expectSuccess) throws IOException - { - boolean retry = (approach&RETRY) != 0; - boolean strict = (approach&STRICT) != 0; - - testFile = AbstractContentTransformerTest.loadNamedQuickTestFile(quickname); - options = new TransformationOptions(); - createContentNodeRef(); - - String fileName = testFile.getName(); - String actualExtensionMimetype = mimetypeService.guessMimetype(fileName); - assertEquals("The "+quickname+" extension indicates a mimetype of "+actualExtensionMimetype+ - " rather than "+extensionMimetype, extensionMimetype, actualExtensionMimetype); - - String targetMimeType = MimetypeMap.MIMETYPE_IMAGE_JPEG; - String outputFileExtension = mimetypeService.getExtension(targetMimeType); - - AuthenticationUtil.RunAsWork createTargetWork = new AuthenticationUtil.RunAsWork() - { - @Override - public ContentReader doWork() throws Exception - { - return contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT); - } - }; - ContentReader contentReader = AuthenticationUtil.runAs(createTargetWork, AuthenticationUtil.getSystemUserName()); - contentReader.setMimetype(declaredMimetype); - String actualDetectedMimetype = mimetypeService.getMimetypeIfNotMatches(contentReader); - if (actualDetectedMimetype != null) - { - assertEquals("The mimetype detected from the content was "+actualDetectedMimetype+ - " rather than "+detectedMimetype, detectedMimetype, actualDetectedMimetype); - } - - long size = contentReader.getSize(); - contentTransformer = (AbstractContentTransformer2)registry.getTransformer(declaredMimetype, size, targetMimeType, options); - assertNotNull("Transformer not found", contentTransformer); - boolean originalRetry = (Boolean)contentTransformer.getRetryTransformOnDifferentMimeType(); - boolean originalStrict = contentTransformer.getStrictMimeTypeCheck(); - assertTrue("Content Transformations should be 'retry' by default", originalRetry); - assertTrue("Content Transformations should be 'strict' by default", originalStrict); - - contentTransformer.setRetryTransformOnDifferentMimeType(retry); - contentTransformer.setStrictMimeTypeCheck(strict); - File outputFile = createATempFileForTheDifferentMimeTypeTest(outputFileExtension); - try - { - ContentWriter outputWriter = new FileContentWriter(outputFile); - outputWriter.setMimetype(targetMimeType); - contentTransformer.transform(contentReader.getReader(), outputWriter, options); - if (!expectSuccess) - { - if (strict) - { - fail("The contentTransformer should have failed with an UnsupportedTransformationException"); - } - else - { - fail("The contentTransformer should have failed with a ContentIOException"); - } - } - // After successful transformation image size should be grater than 0 - assertTrue("File transformation failed. Output file size is '0'", outputWriter.getSize() > 0); - } - catch (ContentIOException e) - { - if (expectSuccess) - { - fail("The contentTransformer should NOT have failed with an ContentIOException "+e); - e.printStackTrace(); - } - } - catch (UnsupportedTransformationException e) - { - if (expectSuccess) - { - fail("The contentTransformer should NOT have failed with an UnsupportedTransformationException "+e); - e.printStackTrace(); - } - if (strict) - { - validateErrorMessage(fileName, declaredMimetype, detectedMimetype, e); - } - } - finally - { - contentTransformer.setRetryTransformOnDifferentMimeType(originalRetry); - contentTransformer.setStrictMimeTypeCheck(originalStrict); - outputFile.deleteOnExit(); - } - } - - private void validateErrorMessage(String fileName, String declaredMimetype, String detectedMimetype, - UnsupportedTransformationException e) - { - String message = e.getMessage(); - assertTrue("Message should contain the original filename (" + fileName + ")", message.contains(fileName)); - assertTrue("Message should contain the declared source mimetype (" + declaredMimetype + ")", - message.contains(declaredMimetype)); - assertTrue("Message should contain the detected source mimetype (" + detectedMimetype + ")", - message.contains(detectedMimetype)); - } - - private File createATempFileForTheDifferentMimeTypeTest(String outputFileExtension) - { - return TempFileProvider.createTempFile("DifferentMimeTypeTest-results-", "." + outputFileExtension); - } - - private void createContentNodeRef() - { - AuthenticationUtil.RunAsWork createTargetWork = new AuthenticationUtil.RunAsWork() - { - @Override - public NodeRef doWork() throws Exception - { - if (log.isDebugEnabled()) - { - log.debug("Creating temporary NodeRefs for testing."); - } - - final NodeRef companyHome = repositoryHelper.getCompanyHome(); - // Create a folder - Map folderProps = new HashMap<>(); - folderProps.put(ContentModel.PROP_NAME, this.getClass().getSimpleName() + System.currentTimeMillis()); - NodeRef folderNodeRef = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, - ContentModel.ASSOC_CONTAINS, ContentModel.TYPE_FOLDER, folderProps).getChildRef(); - - // Mark folder for removing after test - nodesToDeleteAfterTest.add(folderNodeRef); - - String fileName = testFile.getName(); - Map props = new HashMap<>(); - props.put(ContentModel.PROP_NAME, fileName); - - NodeRef node = nodeService.createNode( - folderNodeRef, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName), - ContentModel.TYPE_CONTENT, - props).getChildRef(); - - // Make sure the error message contains the file name. Without this it is null. - nodeService.setProperty(node, ContentModel.PROP_NAME, fileName); - options.setSourceNodeRef(node); - - // node should be removed after tests - nodesToDeleteAfterTest.add(node); - - ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true); - String targetMimeType = mimetypeService.guessMimetype(fileName); - - writer.setMimetype(targetMimeType); - writer.setEncoding("UTF-8"); - writer.putContent(testFile); - - return node; - } - }; - - contentNodeRef = AuthenticationUtil.runAs(createTargetWork, AuthenticationUtil.getSystemUserName()); - nodesToDeleteAfterTest.add(contentNodeRef); - } - - //MNT-16381 related: make sure we match a mime-type with known type aliases and don't dismiss documents as having non-matching type<->actual content - public void testTypeAliasesMatch() throws Exception - { - File testFile = AbstractContentTransformerTest.loadNamedQuickTestFile("quick.xml"); - ContentReader sourceReader = new FileContentReader(testFile); - sourceReader.setMimetype(MimetypeMap.MIMETYPE_XML); // "text/xml" - // Detected mimetype is "application/xml" - assertNull(mimetypeService.getMimetypeIfNotMatches(sourceReader)); - - testFile = AbstractContentTransformerTest.loadNamedQuickTestFile("quick.bmp"); - sourceReader = new FileContentReader(testFile); - sourceReader.setMimetype("image/bmp"); - // Detected mimetype is "image/x-ms-bmp" - assertNull(mimetypeService.getMimetypeIfNotMatches(sourceReader)); - } - - @After - public void deleteTemporaryNodeRefsAndTempFiles() - { - // Tidy up the test nodes we created - RetryingTransactionHelper.RetryingTransactionCallback deleteNodeCallback = new RetryingTransactionHelper.RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - // Delete them in reverse order. - for (Iterator iter = nodesToDeleteAfterTest.descendingIterator(); iter.hasNext(); ) - { - NodeRef nextNodeToDelete = iter.next(); - - if (nodeService.exists(nextNodeToDelete)) - { - if (log.isDebugEnabled()) - { - log.debug("Deleting temporary node " + nextNodeToDelete); - } - nodeService.deleteNode(nextNodeToDelete); - } - } - return null; - } - }; - transactionService.getRetryingTransactionHelper().doInTransaction(deleteNodeCallback); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/EMLTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/EMLTransformerTest.java deleted file mode 100644 index 9571b3f70b..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/EMLTransformerTest.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * 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 . - * #L% - */ - -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.repo.rendition2.SynchronousTransformClient; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -import java.io.File; -import java.util.Collections; - -/** - * @see org.alfresco.repo.content.transform.EMLTransformer - * - * @author Jamal Kaabi-Mofrad - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class EMLTransformerTest extends AbstractContentTransformerTest -{ - private static final String QUICK_EML_CONTENT = "Gym class featuring a brown fox and lazy dog"; - - private static final String QUICK_EML_CONTENT_SPANISH_UNICODE = "El r\u00E1pido zorro marr\u00F3n salta sobre el perro perezoso"; - - private static final String QUICK_EML_WITH_ATTACHMENT_CONTENT = "Mail with attachment content"; - - private static final String QUICK_EML_ATTACHMENT_CONTENT = "File attachment content"; - - private static final String QUICK_EML_ALTERNATIVE_CONTENT = "alternative plain text"; - - private static final String QUICK_EML_NESTED_ALTERNATIVE_CONTENT = "nested alternative plain text"; - - private static final String HTML_SPACE_SPECIAL_CHAR = " "; - - private EMLTransformer transformer; - - private ContentTransformerRegistry registry; - private SynchronousTransformClient synchronousTransformClient; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new EMLTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - RemoteTransformerClient remoteTransformerClient = new RemoteTransformerClient("miscRemoteTransformerClient", "http://localhost:8090/"); - transformer.setRemoteTransformerClient(remoteTransformerClient); - - registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry"); - synchronousTransformClient = (SynchronousTransformClient) ctx.getBean("synchronousTransformClient"); - } - - @Override - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_RFC822, - new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_RFC822, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, - new TransformationOptions())); - } - - /** - * Test transforming a valid eml file to text - */ - public void testRFC822ToText() throws Exception - { - File emlSourceFile = loadQuickTestFile("eml"); - File txtTargetFile = TempFileProvider.createTempFile("test", ".txt"); - ContentReader reader = new FileContentReader(emlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - assertTrue(reader2.getContentString().contains(QUICK_EML_CONTENT)); - } - - /** - * Test transforming a valid eml file to pdf using complex transformer ("Rfc822ToPdf") - eg. for HTML5 preview - */ - public void testRFC822ToPdf() throws Exception - { - String sourceMimetype = MimetypeMap.MIMETYPE_RFC822; - String targetMimetype = MimetypeMap.MIMETYPE_PDF; - - // force Transformers subsystem to start (this will also load the ContentTransformerRegistry - including complex/dynamic pipelines) - // note: a call to contentService.getTransformer would also do this .. even if transformer cannot be found (returned as null) - ChildApplicationContextFactory transformersSubsystem = (ChildApplicationContextFactory) ctx.getBean("Transformers"); - transformersSubsystem.start(); - - assertNotNull(registry.getTransformer("transformer.complex.Rfc822ToPdf")); - - // note: txt -> pdf currently uses OpenOffice/LibreOffice - if (! isOpenOfficeWorkerAvailable()) - { - // no connection - System.err.println("ooWorker available - skipping testRFC822ToPdf !!"); - return; - } - - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - assertTrue(synchronousTransformClient.isSupported(sourceMimetype, -1, null, targetMimetype, Collections.emptyMap(), null, null)); - - String sourceExtension = mimetypeService.getExtension(sourceMimetype); - String targetExtension = mimetypeService.getExtension(targetMimetype); - - File emlSourceFile = loadQuickTestFile("eml"); - ContentReader sourceReader = new FileContentReader(emlSourceFile); - - // make a writer for the target file - File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_" - + getName() + "_" + sourceExtension + "_", "." + targetExtension); - ContentWriter targetWriter = new FileContentWriter(targetFile); - - // do the transformation - sourceReader.setMimetype(sourceMimetype); - targetWriter.setMimetype(targetMimetype); - synchronousTransformClient.transform(sourceReader, targetWriter, Collections.emptyMap(), null, null); - - ContentReader targetReader = new FileContentReader(targetFile); - assertTrue(targetReader.getSize() > 0); - } - - /** - * Test transforming a non-ascii eml file to text - */ - public void testNonAsciiRFC822ToText() throws Exception - { - File emlSourceFile = loadQuickTestFile("spanish.eml"); - File txtTargetFile = TempFileProvider.createTempFile("test2", ".txt"); - ContentReader reader = new FileContentReader(emlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - String contentStr = reader2.getContentString(); - assertTrue(contentStr.contains(QUICK_EML_CONTENT_SPANISH_UNICODE)); - } - - /** - * Test transforming a valid eml with an attachment to text; attachment should be ignored - */ - public void testRFC822WithAttachmentToText() throws Exception - { - File emlSourceFile = loadQuickTestFile("attachment.eml"); - File txtTargetFile = TempFileProvider.createTempFile("test3", ".txt"); - ContentReader reader = new FileContentReader(emlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - String contentStr = reader2.getContentString(); - assertTrue(contentStr.contains(QUICK_EML_WITH_ATTACHMENT_CONTENT)); - assertTrue(!contentStr.contains(QUICK_EML_ATTACHMENT_CONTENT)); - } - - /** - * Test transforming a valid eml with minetype multipart/alternative to text - */ - public void testRFC822AlternativeToText() throws Exception - { - File emlSourceFile = loadQuickTestFile("alternative.eml"); - File txtTargetFile = TempFileProvider.createTempFile("test4", ".txt"); - ContentReader reader = new FileContentReader(emlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - String contentStr = reader2.getContentString(); - assertTrue(contentStr.contains(QUICK_EML_ALTERNATIVE_CONTENT)); - } - - /** - * Test transforming a valid eml with nested mimetype multipart/alternative to text - */ - public void testRFC822NestedAlternativeToText() throws Exception - { - File emlSourceFile = loadQuickTestFile("nested.alternative.eml"); - File txtTargetFile = TempFileProvider.createTempFile("test5", ".txt"); - ContentReader reader = new FileContentReader(emlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - String contentStr = reader2.getContentString(); - assertTrue(contentStr.contains(QUICK_EML_NESTED_ALTERNATIVE_CONTENT)); - } - - /** - * Test transforming a valid eml with a html part containing html special characters to text - */ - public void testHtmlSpecialCharsToText() throws Exception - { - File emlSourceFile = loadQuickTestFile("htmlChars.eml"); - File txtTargetFile = TempFileProvider.createTempFile("test6", ".txt"); - ContentReader reader = new FileContentReader(emlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - String contentStr = reader2.getContentString(); - assertTrue(!contentStr.contains(HTML_SPACE_SPECIAL_CHAR)); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/FailoverContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/FailoverContentTransformerTest.java deleted file mode 100644 index a1f44e5963..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/FailoverContentTransformerTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.ApplicationContextHelper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * Tests the FailoverContentTransformer. - * - * @see org.alfresco.repo.content.transform.FailoverContentTransformer - * - * @author Neil McErlean - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class FailoverContentTransformerTest extends AbstractContentTransformerTest -{ - private static final String sourceMimeType = MimetypeMap.MIMETYPE_PDF; - private static final String targetMimeType = MimetypeMap.MIMETYPE_IMAGE_PNG; - - private static ApplicationContext failoverAppContext = - new ClassPathXmlApplicationContext(new String[] {"classpath:org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml"}, - ApplicationContextHelper.getApplicationContext()); - - private FailoverContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - ApplicationContextHelper.getApplicationContext(); - - transformer = (FailoverContentTransformer) failoverAppContext.getBean("transformer.failover.Test-FailThenSucceed"); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testReliability() throws Exception - { - // The MIME types here are rather arbitrary - - boolean reliability = transformer.isTransformable(sourceMimeType, -1, targetMimeType, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - } -} - -/** - * This dummy class is used only for test purposes within this source file. - * - * @author Neil McErlean - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -class DummyTestContentTransformer extends AbstractContentTransformer2 implements BeanNameAware -{ - private static Log logger = LogFactory.getLog(DummyTestContentTransformer.class); - - /** Bean name for logging */ - private String springBeanName; - private boolean alwaysFail; - - public void setAlwaysFail(boolean value) - { - this.alwaysFail = value; - } - - @Override - protected void transformInternal(ContentReader reader, - ContentWriter writer, TransformationOptions options) - throws Exception - { - // Do not actually perform any transformation. The test above is only interested in whether - // an exception is thrown and handled. - if (logger.isInfoEnabled()) - { - logger.info(springBeanName + " is attempting a transformation"); - } - - reader.getContentString(); - - if (alwaysFail) - { - throw new AlfrescoRuntimeException("Test code intentionally failed method call."); - } - else - { - return; - } - } - - @Override - public boolean isTransformableMimetype(String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - // We'll arbitrarily claim to be able to transform PDF to PNG - return (MimetypeMap.MIMETYPE_PDF.equals(sourceMimetype) && - MimetypeMap.MIMETYPE_IMAGE_PNG.equals(targetMimetype)); - } - - public void setBeanName(String name) - { - this.springBeanName = name; - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/FailoverUnsupportedSubtransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/FailoverUnsupportedSubtransformerTest.java deleted file mode 100644 index d3526d2141..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/FailoverUnsupportedSubtransformerTest.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.TempFileProvider; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * Test for the MNT-9257: html2pdf transformer is being triggered incorrectly for password protected MS files - * - * @see org.alfresco.repo.content.transform.FailoverContentTransformer - * - * @author Viachaslau Tsikhanovich - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class FailoverUnsupportedSubtransformerTest extends AbstractContentTransformerTest -{ - private static final String sourceMimeType = MimetypeMap.MIMETYPE_EXCEL; - private static final String targetMimeType = MimetypeMap.MIMETYPE_PDF; - - private static ApplicationContext failoverAppContext = - new ClassPathXmlApplicationContext(new String[] {"classpath:org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml"}, - ApplicationContextHelper.getApplicationContext()); - - private TestFailoverContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - ApplicationContextHelper.getApplicationContext(); - - transformer = (TestFailoverContentTransformer) failoverAppContext.getBean("transformer.failover.Test-PasswordProtectedMSExcel2Pdf"); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.getTriggered().setValue(false); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testReliability() throws Exception - { - // The MIME types here are rather arbitrary - - boolean reliability = transformer.isTransformable(sourceMimeType, -1, targetMimeType, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - } - - @Override - public void testAllConversions() throws Exception - { - // skip - } - - - public void testExcelToPdfConversion() throws Exception - { - String[] quickFiles = getQuickFilenames(sourceMimeType); - for (String quickFile : quickFiles) - { - String sourceExtension = quickFile.substring(quickFile.lastIndexOf('.') + 1); - - // is there a test file for this conversion? - File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(quickFile); - if (sourceFile == null) - { - continue; // no test file available for that extension - } - ContentReader sourceReader = new FileContentReader(sourceFile); - - // make a writer for the target file - File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_" + getName() + "_" + sourceExtension + "_", ".pdf"); - ContentWriter targetWriter = new FileContentWriter(targetFile); - - // do the transformation - sourceReader.setMimetype(sourceMimeType); - targetWriter.setMimetype(targetMimeType); - try - { - transformer.transform(sourceReader.getReader(), targetWriter); - } - catch (ContentIOException e) - { - // all transformers expected to fail for password protected MS office document - } - - if (transformer.getTriggered().getValue()) - { - org.junit.Assert.fail("final AbstractContentTransformer2.transform was called for html2pdf"); - } - } - } - -} - -/** - * To share with DummyTestComplexSubtransformer to detect if html2pdf was triggered - */ -@Deprecated -class TestHtml2PdfTriggeredFlag -{ - private boolean value; - - public boolean getValue() - { - return value; - } - - public void setValue(boolean value) - { - this.value = value; - } -} - -@Deprecated -class TestFailoverContentTransformer extends FailoverContentTransformer -{ - private TestHtml2PdfTriggeredFlag triggered; - - public void setTriggered(TestHtml2PdfTriggeredFlag triggered) - { - this.triggered = triggered; - } - - public TestHtml2PdfTriggeredFlag getTriggered() - { - return triggered; - } -} - -/** - * This dummy class is used only for test purposes within this source file. - */ -@Deprecated -class DummyTestComplexSubtransformer extends ComplexContentTransformer -{ - - private TestHtml2PdfTriggeredFlag triggered; - - public void setTriggered(TestHtml2PdfTriggeredFlag triggered) - { - this.triggered = triggered; - } - - - @Override - protected void checkTransformable(ContentReader reader, ContentWriter writer, TransformationOptions options) - { - // checkTransformable is called only from AbstractContentTransformer2.transform - // that is final and cannot be overridden - triggered.setValue(true); - - super.checkTransformable(reader, writer, options); - } - - @Override - public void transformInternal(ContentReader reader, - ContentWriter writer, TransformationOptions options) - throws Exception - { - triggered.setValue(true); - - reader.getContentString(); - - // alwaysFail - throw new AlfrescoRuntimeException("Test code intentionally failed method call."); - } - -} - -/** - * This dummy class is used only for test purposes within this source file. - * - * Supported source mimetype can be set - */ -@Deprecated -class DummyAnyToPDFTestSubtransformer extends DummyTestContentTransformer -{ - @Override - public boolean isTransformableMimetype(String sourceMimetype, - String targetMimetype, TransformationOptions options) - { - // We'll arbitrarily claim to be able to transform PDF to PNG - return MimetypeMap.MIMETYPE_PDF.equals(targetMimetype); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/HtmlParserContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/HtmlParserContentTransformerTest.java deleted file mode 100644 index 690620727a..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/HtmlParserContentTransformerTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.ByteArrayInputStream; -import java.io.File; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * @see org.alfresco.repo.content.transform.HtmlParserContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class HtmlParserContentTransformerTest extends AbstractContentTransformerTest -{ - private HtmlParserContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - transformer = new HtmlParserContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testSetUp() throws Exception - { - assertNotNull(transformer); - } - - public void checkIsTransformable() throws Exception - { - // check reliability - boolean reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_HTML, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()); - assertTrue(reliability); // plain text to plain text is supported - - // check other way around - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions()); - assertFalse(reliability); // plain text to plain text is not supported - } - - /** - * Checks that we correctly handle text in different encodings, - * no matter if the encoding is specified on the Content Property - * or in a meta tag within the HTML itself. (ALF-10466) - * - * On Windows, org.htmlparser.beans.StringBean.carriageReturn() appends a new system dependent new line - * so we must be careful when checking the returned text - */ - public void testEncodingHandling() throws Exception - { - final String NEWLINE = System.getProperty ("line.separator"); - final String TITLE = "Testing!"; - final String TEXT_P1 = "This is some text in English"; - final String TEXT_P2 = "This is more text in English"; - final String TEXT_P3 = "C'est en Fran\u00e7ais et Espa\u00f1ol"; - String partA = "" + TITLE + "" + NEWLINE; - String partB = "

    " + TEXT_P1 + "

    " + NEWLINE + - "

    " + TEXT_P2 + "

    " + NEWLINE + - "

    " + TEXT_P3 + "

    " + NEWLINE; - String partC = ""; - final String expected = TITLE + NEWLINE + TEXT_P1 + NEWLINE + TEXT_P2 + NEWLINE + TEXT_P3 + NEWLINE; - - ContentWriter content; - ContentWriter dest; - File tmpS = null; - File tmpD = null; - - try - { - // Content set to ISO 8859-1 - tmpS = File.createTempFile("test", ".html"); - content = new FileContentWriter(tmpS); - content.setEncoding("ISO-8859-1"); - content.setMimetype(MimetypeMap.MIMETYPE_HTML); - content.putContent(partA+partB+partC); - - tmpD = File.createTempFile("test", ".txt"); - dest = new FileContentWriter(tmpD); - dest.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(content.getReader(), dest); - - assertEquals(expected, dest.getReader().getContentString()); - tmpS.delete(); - tmpD.delete(); - - - // Content set to UTF-8 - tmpS = File.createTempFile("test", ".html"); - content = new FileContentWriter(tmpS); - content.setEncoding("UTF-8"); - content.setMimetype(MimetypeMap.MIMETYPE_HTML); - content.putContent(partA+partB+partC); - - tmpD = File.createTempFile("test", ".txt"); - dest = new FileContentWriter(tmpD); - dest.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(content.getReader(), dest); - assertEquals(expected, dest.getReader().getContentString()); - tmpS.delete(); - tmpD.delete(); - - - // Content set to UTF-16 - tmpS = File.createTempFile("test", ".html"); - content = new FileContentWriter(tmpS); - content.setEncoding("UTF-16"); - content.setMimetype(MimetypeMap.MIMETYPE_HTML); - content.putContent(partA+partB+partC); - - tmpD = File.createTempFile("test", ".txt"); - dest = new FileContentWriter(tmpD); - dest.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(content.getReader(), dest); - assertEquals(expected, dest.getReader().getContentString()); - tmpS.delete(); - tmpD.delete(); - - // Note - since HTML Parser 2.0 META tags specifying the - // document encoding will ONLY be respected if the original - // content type was set to ISO-8859-1. - // - // This means there is now only one test which we can perform - // to ensure that this now-limited overriding of the encoding - // takes effect. - - // Content set to ISO 8859-1, meta set to UTF-8 - tmpS = File.createTempFile("test", ".html"); - content = new FileContentWriter(tmpS); - content.setMimetype(MimetypeMap.MIMETYPE_HTML); - String str = partA+ - "" + - partB+partC; - content.putContent(new ByteArrayInputStream(str.getBytes("UTF-8"))); - content.setEncoding("ISO-8859-1"); - - tmpD = File.createTempFile("test", ".txt"); - dest = new FileContentWriter(tmpD); - dest.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(content.getReader(), dest); - assertEquals(expected, dest.getReader().getContentString()); - tmpS.delete(); - tmpD.delete(); - - - // Note - we can't test UTF-16 with only a meta encoding, - // because without that the parser won't know about the - // 2 byte format so won't be able to identify the meta tag - } - finally - { - if (tmpS != null && tmpS.exists()) tmpS.delete(); - if (tmpD != null && tmpD.exists()) tmpD.delete(); - } - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/JodContentTransformerOOoTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/JodContentTransformerOOoTest.java deleted file mode 100644 index 2a4c37c9b0..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/JodContentTransformerOOoTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.junit.Assert.assertNotNull; - -import org.alfresco.repo.content.AbstractJodConverterBasedTest; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.thumbnail.ThumbnailDefinition; -import org.alfresco.repo.thumbnail.ThumbnailRegistry; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Test; - -/** - * - * @author Neil McErlean - * @since 3.2 SP1 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class JodContentTransformerOOoTest extends AbstractJodConverterBasedTest -{ - private static Log log = LogFactory.getLog(JodContentTransformerOOoTest.class); - - /** - * This test method tests the built-in thumbnail transformations - all for a Word source document. - * This will include transformations doc-pdf-png and doc-pdf-swf. ALF-2070 - */ - @Test - public void thumbnailTransformationsUsingJodConverter() - { - // If OpenOffice is not available then we will ignore this test (by passing it). - // This is because not all the build servers have OOo installed. - if (!isOpenOfficeAvailable()) - { - System.out.println("Did not run " + this.getClass().getSimpleName() + ".thumbnailTransformationsUsingJodConverter" + - " because OOo is not available."); - return; - } - - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - ThumbnailRegistry thumbnailRegistry = thumbnailService.getThumbnailRegistry(); - for (ThumbnailDefinition thumbDef : thumbnailRegistry.getThumbnailDefinitions()) - { - if (log.isDebugEnabled()) - { - log.debug("Testing thumbnail definition " + thumbDef.getName()); - } - - NodeRef thumbnail = thumbnailService.createThumbnail(contentNodeRef, ContentModel.PROP_CONTENT, - thumbDef.getMimetype(), thumbDef.getTransformationOptions(), thumbDef.getName()); - - assertNotNull("Thumbnail was unexpectedly null.", thumbnail); - } - - return null; - } - }); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/LegacyTransformerDebugTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/LegacyTransformerDebugTest.java deleted file mode 100644 index b7fc4b9c2b..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/LegacyTransformerDebugTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.rendition2.SynchronousTransformClient; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.NodeService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.util.Arrays; -import java.util.List; -import java.util.StringJoiner; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.alfresco.repo.content.transform.TransformerDebugLogTest.assertDebugEntriesEquals; -import static org.alfresco.repo.content.transform.TransformerLogTest.stripDateStamp; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.junit.Assert.assertArrayEquals; -import static org.mockito.Mockito.when; - -/** - * Test class for LegacyTransformerDebugTest. - * - * @author Alan Davis - */ -@Deprecated -public class LegacyTransformerDebugTest -{ - @Mock - private NodeService nodeService; - - @Mock - private MimetypeService mimetypeService; - - @Mock - private ContentTransformerRegistry transformerRegistry; - - @Mock - private TransformerConfig transformerConfig; - - @Mock - private SynchronousTransformClient synchronousTransformClient; - - @Mock - private AbstractContentTransformerLimits transformer1; - - @Mock - private AbstractContentTransformerLimits transformer2; - - @Mock - private AbstractContentTransformerLimits transformer3; - - @Mock - private AbstractContentTransformerLimits transformer4; - - private LegacyTransformerDebug transformerDebug; - - private TransformerLog log; - - private TransformerDebugLog debug; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - log = new TransformerLog(); - debug = new TransformerDebugLog(); - - when(transformerConfig.getProperty("transformer.log.entries")).thenReturn("10"); - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("10"); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "text/plain", "txt"); - - when(transformer1.getName()).thenReturn("transformer1"); - when(transformer2.getName()).thenReturn("transformer2"); - when(transformer3.getName()).thenReturn("transformer3"); - when(transformer4.getName()).thenReturn("transformer4"); - - transformerDebug = new LegacyTransformerDebug(); - transformerDebug.setNodeService(nodeService); - transformerDebug.setMimetypeService(mimetypeService); - transformerDebug.setTransformerRegistry(transformerRegistry); - transformerDebug.setTransformerConfig(transformerConfig); - transformerDebug.setTransformerLog(log); - transformerDebug.setTransformerDebugLog(debug); - transformerDebug.setSynchronousTransformClient(synchronousTransformClient); - - log.setTransformerDebug(transformerDebug); - log.setTransformerConfig(transformerConfig); - - debug.setTransformerDebug(transformerDebug); - debug.setTransformerConfig(transformerConfig); - } - - // Replaces any transformer reference numbers N.N.N with "0" before checking - private String[] unnumbered(String actual[]) - { - for (int i = actual.length-1; i >= 0; i--) - { - StringJoiner sj = new StringJoiner("\n"); - String[] bits = actual[i].split("\n"); - for (String bit: bits) - { - Pattern p = Pattern.compile("^[0-9.]*"); - Matcher m = p.matcher(bit); - bit = m.replaceFirst("0"); - sj.add(bit); - } - actual[i] = sj.toString(); - } - return actual; - } - - // Replaces any times with " NN ms" before checking - private String[] untimed(String[] actual) - { - for (int i = actual.length-1; i >= 0; i--) - { - actual[i] = actual[i].replaceAll(" \\d+ ms", " NN ms"); - } - return actual; - } - - @Test - public void alf18373Test() - { - long sourceSize = 1024*1024*3/2; - - transformerDebug.pushAvailable("sourceUrl", "application/pdf", "text/plain", null, null); - - transformerDebug.unavailableTransformer(transformer1, "application/pdf", "text/plain", 50); - transformerDebug.unavailableTransformer(transformer2, "application/pdf", "text/plain", 0); - transformerDebug.unavailableTransformer(transformer3, "application/pdf", "text/plain", 50); - transformerDebug.unavailableTransformer(transformer4, "application/pdf", "text/plain", 50); - - List transformers = Arrays.asList(new ContentTransformer[] {}); - - transformerDebug.availableTransformers(transformers, sourceSize, null, null, "ContentService.transform(...)"); - - transformerDebug.popAvailable(); - - assertDebugEntriesEquals(new String[] { - "0 pdf txt 1.5 MB ContentService.transform(...) NO transformers\n"+ - "0 --a) [---] Legacy:transformer1<> > 50 KB\n"+ - "0 --b) [---] Legacy:transformer3<> > 50 KB\n"+ - "0 --c) [---] Legacy:transformer4<> > 50 KB\n"+ - "0 Finished in NN ms Just checking if a transformer is available"}, unnumbered(untimed(debug.getEntries(10)))); - assertArrayEquals(new String[] { - "0 pdf txt WARN 1.5 MB NN ms No transformers as file is > 50 KB"}, unnumbered(untimed(stripDateStamp(log.getEntries(10))))); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/MailContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/MailContentTransformerTest.java deleted file mode 100644 index 2b2f9e3849..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/MailContentTransformerTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * @see org.alfresco.repo.content.transform.MailContentTransformer - * - * @author Kevin Roast - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class MailContentTransformerTest extends AbstractContentTransformerTest -{ - private MailContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new MailContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_OUTLOOK_MSG, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OUTLOOK_MSG, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - } - - /** - * Test transforming a valid msg file to text - */ - public void testMsgToText() throws Exception - { - File msgSourceFile = loadQuickTestFile("msg"); - File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-1", ".txt"); - ContentReader reader = new FileContentReader(msgSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - assertTrue(reader2.getContentString().contains(QUICK_CONTENT)); - } - - /** - * Test transforming a valid unicode msg file to text - */ - public void testUnicodeMsgToText() throws Exception - { - File msgSourceFile = loadQuickTestFile("unicode.msg"); - File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-2", ".txt"); - ContentReader reader = new FileContentReader(msgSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - assertTrue(reader2.getContentString().contains(QUICK_CONTENT)); - } - - /** - * Test transforming a chinese non-unicode msg file to - * text - */ - public void testNonUnicodeChineseMsgToText() throws Exception - { - File msgSourceFile = loadQuickTestFile("chinese.msg"); - File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-2", ".txt"); - ContentReader reader = new FileContentReader(msgSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG); - ContentWriter writer = new FileContentWriter(txtTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - transformer.transform(reader, writer); - - ContentReader reader2 = new FileContentReader(txtTargetFile); - reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Check the quick text - String text = reader2.getContentString(); - assertTrue(text.contains(QUICK_CONTENT)); - - // Now check the non quick parts came out ok - assertTrue(text.contains("(\u5f35\u6bd3\u502b)")); - assertTrue(text.contains("\u683c\u5f0f\u6e2c\u8a66 )")); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java deleted file mode 100644 index 980c42bc70..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * @see org.alfresco.repo.content.transform.MediaWikiContentTransformer - * - * @author Roy Wetherall - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class MediaWikiContentTransformerTest extends AbstractContentTransformerTest -{ - private MediaWikiContentTransformer transformer; - - private static final String WIKI_TEXT = - "== This is a title ==\n" + - "\n" + - "'''This is bold''' and some ''italics on the same line''\n" + - "\n" + - "Here is a link to the main page .... [[Main Page]]\n" + - "\n" + - "*and\n" + - "*what\n" + - "*about\n" + - "*a list\n" + - "\n" + - " Some indented text that should apear different\n" + - "\n" + - "What about an external link [http://www.alfresco.com Alfresco]\n" + - "\n" + - "This markup should be ignored [[Main Page]]\n" + - "\n" + - "----\n" + - "\n" + - "Lets put some text at the end :)\n"; - - - @Override - public void setUp() throws Exception - { - super.setUp(); - transformer = new MediaWikiContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - } - - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testSetUp() throws Exception - { - assertNotNull(transformer); - } - - public void testIsTransformable() throws Exception - { - // check reliability - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_HTML, -1, MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI, new TransformationOptions())); - } - - public void testMediaWikiToHTML() throws Exception - { - File input = TempFileProvider.createTempFile("mediaWikiTest", ".mw"); - FileOutputStream fos = new FileOutputStream(input); - fos.write(WIKI_TEXT.getBytes()); - fos.close(); - - File output = TempFileProvider.createTempFile("mediaWikiTest", ".htm"); - - ContentReader contentReader = new FileContentReader(input); - contentReader.setMimetype(MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI); - contentReader.setEncoding("UTF-8"); - - ContentWriter contentWriter = new FileContentWriter(output); - contentWriter.setMimetype(MimetypeMap.MIMETYPE_HTML); - contentWriter.setEncoding("UTF-8"); - - transformer.transform(contentReader, contentWriter); - - String line = null; - BufferedReader reader = new BufferedReader(new FileReader(output)); - while ((line = reader.readLine()) != null) - { - System.out.println(line); - } - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/OOXMLThumbnailContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/OOXMLThumbnailContentTransformerTest.java deleted file mode 100644 index 2d907046a7..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/OOXMLThumbnailContentTransformerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * Test case for {@link OOXMLThumbnailContentTransformer} content transformer. - * - * @author Nick Burch - * @since 4.0.1 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class OOXMLThumbnailContentTransformerTest extends AbstractContentTransformerTest -{ - private ContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new OOXMLThumbnailContentTransformer(); - - // Ugly cast just to set the MimetypeService - ((ContentTransformerHelper)transformer).setMimetypeService(mimetypeService); - } - - @Override - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - // Does support Thumbnails - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions())); - - // Unlike iWorks, it doesn't handle PDF previews - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, MimetypeMap.MIMETYPE_PDF, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, MimetypeMap.MIMETYPE_PDF, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, MimetypeMap.MIMETYPE_PDF, new TransformationOptions())); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/OpenOfficeContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/OpenOfficeContentTransformerTest.java deleted file mode 100644 index 952e33558b..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/OpenOfficeContentTransformerTest.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.net.URL; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.junit.Ignore; - -/** - * We no longer use ooo.direct in Community. This test class now is connnected up to the JODConverter which was moved - * from the Enterprise Edition. - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class OpenOfficeContentTransformerTest extends AbstractContentTransformerTest -{ - private static String MIMETYPE_RUBBISH = "text/rubbish"; - - private ContentTransformerWorker worker; - private ProxyContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - this.worker = (ContentTransformerWorker) ctx.getBean("transformer.worker.JodConverter"); - RemoteTransformerClient remoteTransformerClient = new RemoteTransformerClient("miscRemoteTransformerClient", "http://localhost:8090/"); - worker.setRemoteTransformerClient(remoteTransformerClient); - transformer = new ProxyContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.setWorker(this.worker); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testSetUp() throws Exception - { - super.testSetUp(); - assertNotNull(mimetypeService); - } - - public void testReliability() throws Exception - { - if (!isOpenOfficeWorkerAvailable()) - { - // no connection - System.err.println("ooWorker not available - skipping testReliability !!"); - return; - } - boolean reliability = transformer.isTransformable(MIMETYPE_RUBBISH, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()); - assertEquals("Mimetype should not be supported", false, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_RUBBISH, new TransformationOptions()); - assertEquals("Mimetype should not be supported", false, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_XHTML, new TransformationOptions()); - assertEquals("Mimetype should not be supported", false, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_WORD, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - } - - /** - * Test what is up with HTML to PDF - */ - public void testHtmlToPdf() throws Exception - { - if (!isOpenOfficeWorkerAvailable()) - { - // no connection - System.err.println("ooWorker not available - skipping testHtmlToPdf !!"); - return; - } - File htmlSourceFile = loadQuickTestFile("html"); - File pdfTargetFile = TempFileProvider.createTempFile(getName() + "-target-", ".pdf"); - ContentReader reader = new FileContentReader(htmlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_HTML); - ContentWriter writer = new FileContentWriter(pdfTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_PDF); - - transformer.transform(reader, writer); - } - - /** - * ALF-219. Transforamtion from .html to .pdf for empty file. - * @throws Exception - */ - // The test was never run and fails on remote transformer - public void ignoreTestEmptyHtmlToEmptyPdf() throws Exception - { - if (!isOpenOfficeWorkerAvailable()) - { - // no connection - System.err.println("ooWorker not available - skipping testEmptyHtmlToEmptyPdf !!"); - return; - } - URL url = this.getClass().getClassLoader().getResource("misc/empty.html"); - assertNotNull("URL was unexpectedly null", url); - - File htmlSourceFile = new File(url.getFile()); - assertTrue("Test file does not exist.", htmlSourceFile.exists()); - - File pdfTargetFile = TempFileProvider.createTempFile(getName() + "-target-", ".pdf"); - - ContentReader reader = new FileContentReader(htmlSourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_HTML); - ContentWriter writer = new FileContentWriter(pdfTargetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_PDF); - - transformer.transform(reader, writer); - } - - /** - * Some transformations fail intermittently within OOo on our test server. - * Rather than exclude these transformations from product code, where they - * may work (e.g. due to different OOo version installed), they are excluded - * from this test. - */ - @Override - protected boolean isTransformationExcluded(String sourceExtension, String targetExtension) - { - return ((sourceExtension.equals("doc") && targetExtension.equals("docx")) || - (sourceExtension.equals("doc") && targetExtension.equals("html")) || - (sourceExtension.equals("doc") && targetExtension.equals("odt")) || - (sourceExtension.equals("doc") && targetExtension.equals("rtf")) || - (sourceExtension.equals("doc") && targetExtension.equals("sxw")) || - (sourceExtension.equals("doc") && targetExtension.equals("txt")) || - (sourceExtension.equals("docx") && targetExtension.equals("sxw")) || - (sourceExtension.equals("html") && targetExtension.equals("docx")) || - (sourceExtension.equals("odp") && targetExtension.equals("pptx")) || - (sourceExtension.equals("ods") && targetExtension.equals("html")) || - (sourceExtension.equals("ods") && targetExtension.equals("sxc")) || - (sourceExtension.equals("ods") && targetExtension.equals("xlsx")) || - (sourceExtension.equals("ods") && targetExtension.equals("xls")) || - (sourceExtension.equals("odt") && targetExtension.equals("docx")) || - (sourceExtension.equals("odt") && targetExtension.equals("txt")) || - (sourceExtension.equals("ppt") && targetExtension.equals("html")) || - (sourceExtension.equals("ppt") && targetExtension.equals("pptx")) || - (sourceExtension.equals("sxc") && targetExtension.equals("xlsx")) || - (sourceExtension.equals("sxi") && targetExtension.equals("odp")) || - (sourceExtension.equals("sxi") && targetExtension.equals("pptx")) || - (sourceExtension.equals("sxw") && targetExtension.equals("docx")) || - (sourceExtension.equals("txt") && targetExtension.equals("docx")) || - (sourceExtension.equals("txt") && targetExtension.equals("html")) || - (sourceExtension.equals("txt") && targetExtension.equals("odt")) || - (sourceExtension.equals("txt") && targetExtension.equals("pdf")) || - (sourceExtension.equals("txt") && targetExtension.equals("rtf")) || - (sourceExtension.equals("txt") && targetExtension.equals("sxw")) || - (sourceExtension.equals("wpd") && targetExtension.equals("docx")) || - (sourceExtension.equals("xls") && targetExtension.equals("ods")) || - (sourceExtension.equals("xls") && targetExtension.equals("pdf")) || - (sourceExtension.equals("xls") && targetExtension.equals("sxc")) || - (sourceExtension.equals("xls") && targetExtension.equals("xlsx")) || - - (sourceExtension.equals("txt") && targetExtension.equals("doc")) || - - (sourceExtension.equals("pptx") && targetExtension.equals("html"))); - } - -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/PdfBoxContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/PdfBoxContentTransformerTest.java deleted file mode 100644 index a9741a1de2..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/PdfBoxContentTransformerTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.content.metadata.MediaTypeDisablingDocumentSelector; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * @see org.alfresco.repo.content.transform.PdfBoxContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PdfBoxContentTransformerTest extends AbstractContentTransformerTest -{ - private PdfBoxContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new PdfBoxContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - - // Disable parsing of embedded images - MediaTypeDisablingDocumentSelector selector = new MediaTypeDisablingDocumentSelector(); - selector.setDisabledMediaTypes(Arrays.asList( - MimetypeMap.MIMETYPE_IMAGE_JPEG, - MimetypeMap.MIMETYPE_IMAGE_TIFF, - MimetypeMap.MIMETYPE_IMAGE_PNG)); - transformer.setDocumentSelector(selector); - transformer.afterPropertiesSet(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - } - - /** - * Added to test a single transform that appeared to have problems. - * Commented out once issue was fixed, but left in the code to help with - * future issues. - * @throws Exception - */ - public void testPdfToTextConversions() throws Exception - { - final String sourceMimetype = MimetypeMap.MIMETYPE_PDF; - final String targetMimetype = MimetypeMap.MIMETYPE_TEXT_PLAIN; - int transforms = 100; - final String filename = "svn-book.pdf"; - - final CountDownLatch doneSignal = new CountDownLatch(transforms); - - int threadCount = 8; - final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount); - long time = System.currentTimeMillis(); - for (int i=0; i 0 ? "average="+(time/transforms)+" ms" : "")+" threads="+threadCount+" transforms="+transforms; - System.out.println(message); - - if (!okay) - { - // Before the changes to PDFBox, this would fail having only done about 50 transforms. - // After the change, this takes about 55 seconds - fail("********** Transforms did not finish ********** "+message); - } - } - - private void pdfToTextTransform(String filename, String sourceMimetype, String targetMimetype) throws IOException - { - ContentWriter targetWriter = null; - String sourceExtension = filename.substring(filename.lastIndexOf('.') + 1); - String targetExtension = mimetypeService.getExtension(targetMimetype); - - File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(filename); - ContentReader sourceReader = new FileContentReader(sourceFile); - - AbstractContentTransformer2 transformer = (AbstractContentTransformer2) getTransformer( - sourceMimetype, targetMimetype); - - // make a writer for the target file - File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_" - + getName() + "_" + sourceExtension + "_", "." + targetExtension); - targetWriter = new FileContentWriter(targetFile); - - // do the transformation - sourceReader.setMimetype(sourceMimetype); - targetWriter.setMimetype(targetMimetype); - transformer.transform(sourceReader.getReader(), targetWriter); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/PoiContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/PoiContentTransformerTest.java deleted file mode 100644 index 48530284a2..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/PoiContentTransformerTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * @see org.alfresco.repo.content.transform.PoiContentTransformer - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PoiContentTransformerTest extends AbstractContentTransformerTest -{ - private PoiContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new PoiContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_WORD, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_PPT, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PPT, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_OUTLOOK_MSG, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OUTLOOK_MSG, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OUTLOOK_MSG, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OUTLOOK_MSG, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - // Doesn't claim excel - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/PoiHssfContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/PoiHssfContentTransformerTest.java deleted file mode 100644 index 17b8461173..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/PoiHssfContentTransformerTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.io.InputStream; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * @see org.alfresco.repo.content.transform.PoiHssfContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PoiHssfContentTransformerTest extends TikaPoweredContentTransformerTest -{ - private PoiHssfContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new PoiHssfContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - @Override - protected String[] getQuickFilenames(String sourceMimetype) { - return new String[] { - "quick.xls", "quick.xlsx" - }; - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_EXCEL, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_TEXT_CSV, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - } - - public void testCsvOutput() throws Exception - { - File sourceFile = AbstractContentTransformerTest.loadQuickTestFile("xls"); - ContentReader sourceReader = new FileContentReader(sourceFile); - - File targetFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_xls_", - ".csv"); - ContentWriter targetWriter = new FileContentWriter(targetFile); - - sourceReader.setMimetype(MimetypeMap.MIMETYPE_EXCEL); - targetWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_CSV); - transformer.transform(sourceReader, targetWriter); - - ContentReader targetReader = targetWriter.getReader(); - String checkContent = targetReader.getContentString(); - - additionalContentCheck( - MimetypeMap.MIMETYPE_EXCEL, - MimetypeMap.MIMETYPE_TEXT_CSV, - checkContent - ); - } - - @Override - protected void additionalContentCheck(String sourceMimetype, - String targetMimetype, String contents) { - if(targetMimetype.equals(MimetypeMap.MIMETYPE_TEXT_CSV)) { - assertTrue( - "Content not properly CSV'd", - contents.contains("1,2,2") - ); - assertTrue( - "Content not properly CSV'd", - contents.contains("\"The\",\"quick\",\"brown\",\"fox\"") - ); - } else if(targetMimetype.equals(MimetypeMap.MIMETYPE_XML)) { - // First check we got the usual bits - super.additionalContentCheck(sourceMimetype, targetMimetype, contents); - - // Now check tables came out correctly - assertTrue( - "Content lacks XHTML table tags:\n" + contents, - contents.contains("") - ); - assertTrue( - "Content lacks XHTML table tags:\n" + contents, - contents.contains("") - ); - assertTrue( - "Content lacks XHTML table tags:\n" + contents, - contents.contains("") - ); - assertTrue( - "Content lacks XHTML table tags:\n" + contents, - contents.contains("") - ); - } else { - super.additionalContentCheck(sourceMimetype, targetMimetype, contents); - } - } - - @Override - protected boolean isQuickPhraseExpected(String targetMimetype) { - if(targetMimetype.equals(MimetypeMap.MIMETYPE_TEXT_CSV)) { - return true; - } - return super.isQuickPhraseExpected(targetMimetype); - } - - /** - * Tests a specific failure in the library - */ - public void xxtestBugFixAR114() throws Exception - { - File tempFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_", - ".xls"); - FileContentWriter writer = new FileContentWriter(tempFile); - writer.setMimetype(MimetypeMap.MIMETYPE_EXCEL); - // get the test resource and write it (Excel) - InputStream is = getClass().getClassLoader().getResourceAsStream("Plan270904b.xls"); - assertNotNull("Test resource not found: Plan270904b.xls"); - writer.putContent(is); - - // get the source of the transformation - ContentReader reader = writer.getReader(); - - // make a new location of the transform output (plain text) - tempFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_", - ".txt"); - writer = new FileContentWriter(tempFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // transform it - transformer.transform(reader, writer); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/PoiOOXMLContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/PoiOOXMLContentTransformerTest.java deleted file mode 100644 index 5a2cb1c30d..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/PoiOOXMLContentTransformerTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.util.concurrent.TimeoutException; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; - -/** - * @see org.alfresco.repo.content.transform.PoiOOXMLContentTransformer - * - * @author Nick Burch - * @author Dmitry Velichkevich - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class PoiOOXMLContentTransformerTest extends AbstractContentTransformerTest -{ - private static final int SMALL_TIMEOUT = 30; - - private static final int ADDITIONAL_PROCESSING_TIME = 1500; - - - private static final String ENCODING_UTF_8 = "UTF-8"; - - private static final String TEST_PPTX_FILE_NAME = "quickImg2.pptx"; - - - private ContentService contentService; - - private PoiOOXMLContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new PoiOOXMLContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - - contentService = serviceRegistry.getContentService(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - } - - /** - * MNT-12043: CLONE - Upload of PPTX causes very high memory usage leading to system instability - * - * @throws Exception - */ - public void testMnt12043() throws Exception - { - transformer.setMimetypeService(mimetypeService); - transformer.setAdditionalThreadTimout(0); - configureExtractorLimits(transformer, SMALL_TIMEOUT); - - File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(TEST_PPTX_FILE_NAME); - ContentReader sourceReader = new FileContentReader(sourceFile) - { - @Override - public void setLimits(TransformationOptionLimits limits) - { - // Test without content reader input stream timeout limits - } - }; - sourceReader.setMimetype(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION); - - ContentWriter tempWriter = AuthenticationUtil.runAs(new RunAsWork() - { - @Override - public ContentWriter doWork() throws Exception - { - ContentWriter result = contentService.getTempWriter(); - result.setEncoding(ENCODING_UTF_8); - result.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - return result; - } - }, AuthenticationUtil.getAdminUserName()); - - long startTime = System.currentTimeMillis(); - - try - { - transformer.transform(sourceReader, tempWriter); - // should not get here unless transform is too fast - long transformationTime = System.currentTimeMillis() - startTime; - fail("Content transformation took " + transformationTime + " ms, but should have failed with a timeout at " + SMALL_TIMEOUT + " ms"); - } - catch (ContentIOException e) - { - long transformationTime = System.currentTimeMillis() - startTime; - assertTrue((TimeoutException.class.getName() + " exception is expected as the cause of transformation failure"), e.getCause() instanceof TimeoutException); - // Not sure we can have the following assert as we may have introduced an intermittent test failure. Already seen a time of 1009ms - assertTrue(("Failed content transformation took " + transformationTime + " ms, but should have failed with a timeout at " + SMALL_TIMEOUT + " ms"), - transformationTime <= (SMALL_TIMEOUT + ADDITIONAL_PROCESSING_TIME)); - } - - assertFalse("Readable channel was not closed after transformation attempt!", sourceReader.isChannelOpen()); - assertFalse("Writable channel was not closed after transformation attempt!", tempWriter.isChannelOpen()); - } - - /** - * Configures timeout for given transformer - * - * @param transformer - {@link PoiOOXMLContentTransformer} instance - * @param timeout - {@link Long} value which specifies timeout for transformer - */ - private void configureExtractorLimits(PoiOOXMLContentTransformer transformer, final long timeout) - { - transformer.setTransformerConfig(new TransformerConfigImpl() - { - @Override - public TransformationOptionLimits getLimits(ContentTransformer transformer, String sourceMimetype, String targetMimetype, String use) - { - TransformationOptionLimits result = new TransformationOptionLimits(); - result.setTimeoutMs(timeout); - return result; - } - - @Override - public TransformerStatistics getStatistics(ContentTransformer transformer, String sourceMimetype, String targetMimetype, boolean createNew) - { - return transformerConfig.getStatistics(transformer, sourceMimetype, targetMimetype, createNew); - } - - @Override - public boolean isSupportedTransformation(ContentTransformer transformer, String sourceMimetype, String targetMimetype, TransformationOptions options) - { - return transformerConfig.isSupportedTransformation(transformer, sourceMimetype, targetMimetype, options); - } - }); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java deleted file mode 100644 index 43b1e0a213..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.MiscContextTestSuite; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.util.BaseAlfrescoTestCase; -import org.alfresco.util.TempFileProvider; -import org.alfresco.util.exec.RuntimeExec; - -/** - * @see org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class RuntimeExecutableContentTransformerTest extends BaseAlfrescoTestCase -{ - private ContentTransformer transformer; - - @Override - protected void setUpContext() { - // We use a smaller context - ctx = MiscContextTestSuite.getMinimalContext(); - } - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - RuntimeExecutableContentTransformerWorker worker = new RuntimeExecutableContentTransformerWorker(); - // the command to execute - RuntimeExec transformCommand = new RuntimeExec(); - Map commandMap = new HashMap(5); - commandMap.put("Mac OS X", "mv -f ${source} ${target}"); - commandMap.put("Linux", "mv -f ${source} ${target}"); - commandMap.put(".*", "cmd /c copy /Y \"${source}\" \"${target}\""); - transformCommand.setCommandMap(commandMap); - transformCommand.setErrorCodes("1, 2"); - worker.setTransformCommand(transformCommand); - worker.setMimetypeService(serviceRegistry.getMimetypeService()); - // set the explicit transformations - List explicitTranformations = new ArrayList(1); - explicitTranformations.add( - new ExplictTransformationDetails(MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_XML)); - worker.setExplicitTransformations(explicitTranformations); - - // initialise so that it doesn't score 0 - worker.afterPropertiesSet(); - - TransformerDebug transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); - TransformerConfig transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); - - ProxyContentTransformer transformer = new ProxyContentTransformer(); - transformer.setMimetypeService(serviceRegistry.getMimetypeService()); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.setWorker(worker); - this.transformer = transformer; - } - - public void testCopyCommand() throws Exception - { - String content = ""; - // create the source - File sourceFile = TempFileProvider.createTempFile(getName() + "_", ".txt"); - ContentWriter tempWriter = new FileContentWriter(sourceFile); - tempWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - tempWriter.putContent(content); - ContentReader reader = tempWriter.getReader(); - // create the target - File targetFile = TempFileProvider.createTempFile(getName() + "_", ".xml"); - ContentWriter writer = new FileContentWriter(targetFile); - writer.setMimetype(MimetypeMap.MIMETYPE_XML); - - // do the transformation - transformer.transform(reader, writer); // no options on the copy - - // make sure that the content was copied over - ContentReader checkReader = writer.getReader(); - String checkContent = checkReader.getContentString(); - assertEquals("Content not copied", content, checkContent); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/StringExtractingContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/StringExtractingContentTransformerTest.java deleted file mode 100644 index ddc2d83ff5..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/StringExtractingContentTransformerTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.util.Random; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * @see org.alfresco.repo.content.transform.StringExtractingContentTransformer - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class StringExtractingContentTransformerTest extends AbstractContentTransformerTest -{ - private static final String SOME_CONTENT; - static - { - // force the content to be encoded in a particular way, independently of the source file encoding - try - { - SOME_CONTENT = new String("azAz10!�$%^&*()\t\r\n".getBytes("UTF-8"), "MacDingbat"); - } - catch (UnsupportedEncodingException e) - { - throw new AlfrescoRuntimeException("Encoding not recognised", e); - } - } - - private StringExtractingContentTransformer transformer; - /** the final destination of transformations */ - private ContentWriter targetWriter; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new StringExtractingContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - targetWriter = new FileContentWriter(getTempFile()); - targetWriter.setMimetype("text/plain"); - targetWriter.setEncoding("UTF-8"); - transformer.afterPropertiesSet(); - } - - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testSetUp() throws Exception - { - assertNotNull(transformer); - } - - /** - * @return Returns a new temp file - */ - private File getTempFile() - { - return TempFileProvider.createTempFile(getName(), ".txt"); - } - - /** - * Writes some content using the mimetype and encoding specified. - * - * @param mimetype String - * @param encoding String - * @return Returns a reader onto the newly written content - */ - private ContentReader writeContent(String mimetype, String encoding) - { - ContentWriter writer = new FileContentWriter(getTempFile()); - writer.setMimetype(mimetype); - writer.setEncoding(encoding); - // put content - writer.putContent(SOME_CONTENT); - // return a reader onto the new content - return writer.getReader(); - } - - public void testDirectTransform() throws Exception - { - ContentReader reader = writeContent("text/plain", "MacDingbat"); - - // check transformability - assertTrue(transformer.isTransformable(reader.getMimetype(), -1, targetWriter.getMimetype(), new TransformationOptions())); - - // transform - transformer.transform(reader, targetWriter); - - // get a reader onto the transformed content and check - ContentReader checkReader = targetWriter.getReader(); - String checkContent = checkReader.getContentString(); - assertEquals("Content check failed", SOME_CONTENT, checkContent); - } - - public void testInterTextTransform() throws Exception - { - ContentReader reader = writeContent("text/xml", "MacDingbat"); - - // check transformability - assertTrue(transformer.isTransformable(reader.getMimetype(), -1, targetWriter.getMimetype(), new TransformationOptions())); - - // transform - transformer.transform(reader, targetWriter); - - // get a reader onto the transformed content and check - ContentReader checkReader = targetWriter.getReader(); - String checkContent = checkReader.getContentString(); - assertEquals("Content check failed", SOME_CONTENT, checkContent); - } - - /** - * Generate a large file and then transform it using the text extractor. - * We are not creating super-large file (1GB) in order to test the transform - * as it takes too long to create the file in the first place. Rather, - * this test can be used during profiling to ensure that memory is not - * being consumed. - */ - public void testLargeFileStreaming() throws Exception - { - File sourceFile = TempFileProvider.createTempFile(getName(), ".txt"); - - int chars = 1000000; // a million characters should do the trick - Random random = new Random(); - - Writer charWriter = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(sourceFile))); - for (int i = 0; i < chars; i++) - { - char next = (char)(random.nextDouble() * 93D + 32D); - charWriter.write(next); - } - charWriter.close(); - - // get a reader and a writer - ContentReader reader = new FileContentReader(sourceFile); - reader.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - File outputFile = TempFileProvider.createTempFile(getName(), ".txt"); - ContentWriter writer = new FileContentWriter(outputFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // transform - transformer.transform(reader, writer); - - // delete files - sourceFile.delete(); - outputFile.delete(); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TextMiningContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TextMiningContentTransformerTest.java deleted file mode 100644 index db3714e7e6..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TextMiningContentTransformerTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.io.InputStream; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; - -/** - * @see org.alfresco.repo.content.transform.TextMiningContentTransformer - * Note - Is actually POI (soon to be Tika), and not the - * old and unsupported Text Mining library! - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TextMiningContentTransformerTest extends AbstractContentTransformerTest -{ - private TextMiningContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new TextMiningContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - @Override - protected String[] getQuickFilenames(String sourceMimetype) { - return new String[] { - "quick.doc", "quick95.doc", "quick6.doc" - }; - } - - public void testIsTransformable() throws Exception - { - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_WORD, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - } - - /** - * Tests a specific failure in the library - */ - public void testBugFixAR1() throws Exception - { - File tempFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_", - ".doc"); - FileContentWriter writer = new FileContentWriter(tempFile); - writer.setMimetype(MimetypeMap.MIMETYPE_WORD); - // get the test resource and write it (MS Word) - InputStream is = getClass().getClassLoader().getResourceAsStream("farmers_markets_list_2003.doc"); - assertNotNull("Test resource not found: farmers_markets_list_2003.doc"); - writer.putContent(is); - - // get the source of the transformation - ContentReader reader = writer.getReader(); - - // make a new location of the transform output (plain text) - tempFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_", - ".txt"); - writer = new FileContentWriter(tempFile); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // transform it - transformer.transform(reader, writer); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TextToPdfContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TextToPdfContentTransformerTest.java deleted file mode 100644 index 49c6de21ab..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TextToPdfContentTransformerTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.nio.charset.Charset; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.util.TempFileProvider; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.text.PDFTextStripper; - -/** - * @see org.alfresco.repo.content.transform.TextToPdfContentTransformer - * - * @author Derek Hulley - * @since 2.1.0 - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TextToPdfContentTransformerTest extends AbstractContentTransformerTest -{ - private TextToPdfContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - transformer = new TextToPdfContentTransformer(); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.setStandardFont("Times-Roman"); - transformer.setFontSize(20); - transformer.setBeanName("transformer.test"+System.currentTimeMillis()%100000); - transformer.afterPropertiesSet(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - @Override - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testReliability() throws Exception - { - transformer.setPageLimit(-1); - transformer.register(); - - boolean reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()); - assertEquals("Mimetype should not be supported", false, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_XML, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - } - - /** - * Tests that we can produce PDFs from a variety of different - * source encodings. - * TODO Re-enable this test once we've fixed ALF-2534 - */ - public void DISABLEDtestUnicodeTextAndEncodings() throws Exception - { - String allAscii = "This is a simple set of text\n" + - "It is all nice and dull\n"; - String european = "En français où les choses sont accentués\n" + - "En español, así"; - - for(String text : new String[] {allAscii, european}) - { - for(String encoding : new String[] {"ISO-8859-1", "UTF-8", "UTF-16"}) - { - // Newlines etc may be different, so zap them - String checkText = clean(text); - - transformTextAndCheck(text, encoding, checkText); - } - } - } - - public void testUnlimitedPages() throws Exception - { - transformTextAndCheckPageLength(-1); - } - - public void testLimitedTo1Page() throws Exception - { - transformTextAndCheckPageLength(1); - } - - public void testLimitedTo2Pages() throws Exception - { - transformTextAndCheckPageLength(2); - } - - public void testLimitedTo50Pages() throws Exception - { - transformTextAndCheckPageLength(50); - } - - private void transformTextAndCheckPageLength(int pageLimit) throws IOException - { - transformer.setPageLimit(pageLimit); - transformer.register(); - - int pageLength = 32; - int lines = (pageLength+10) * ((pageLimit > 0) ? pageLimit : 1); - StringBuilder sb = new StringBuilder(); - String checkText = null; - int cutoff = pageLimit * pageLength; - for (int i=1; i<=lines; i++) - { - sb.append(i); - sb.append(" I must not talk in class or feed my homework to my cat.\n"); - if (i == cutoff) - checkText = sb.toString(); - } - sb.append("\nBart\n"); - String text = sb.toString(); - checkText = (checkText == null) ? clean(text) : clean(checkText); - - transformTextAndCheck(text, "UTF-8", checkText); - } - - private void transformTextAndCheck(String text, String encoding, String checkText) - throws IOException - { - // Get a reader for the text - ContentReader reader = buildContentReader(text, Charset.forName(encoding)); - - // And a temp writer - File out = TempFileProvider.createTempFile("AlfrescoTest_", ".pdf"); - ContentWriter writer = new FileContentWriter(out); - writer.setMimetype("application/pdf"); - - // Transform to PDF - transformer.transform(reader, writer); - - // Read back in the PDF and check it - PDDocument doc = PDDocument.load(out); - PDFTextStripper textStripper = new PDFTextStripper(); - StringWriter textWriter = new StringWriter(); - textStripper.writeText(doc, textWriter); - doc.close(); - - String roundTrip = clean(textWriter.toString()); - - assertEquals( - "Incorrect text in PDF when starting from text in " + encoding, - checkText, roundTrip - ); - } - - private String clean(String text) - { - text = text.replaceAll("\\s+\\r", ""); - text = text.replaceAll("\\s+\\n", ""); - text = text.replaceAll("\\r", ""); - text = text.replaceAll("\\n", ""); - return text; - } - - public void testSetUp() throws Exception - { - transformer.setPageLimit(-1); - transformer.register(); - - super.testSetUp(); - } - - public void testAllConversions() throws Exception - { - transformer.setPageLimit(-1); - transformer.register(); - - super.testAllConversions(); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TikaAutoContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TikaAutoContentTransformerTest.java deleted file mode 100644 index b1aa675f3d..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TikaAutoContentTransformerTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.apache.tika.config.TikaConfig; - -/** - * Most of the work for testing the Tika Auto-Detect transformer - * is automatically done by {@link AbstractContentTransformerTest} - * - * @see org.alfresco.repo.content.transform.TikaAutoContentTransformer - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TikaAutoContentTransformerTest extends TikaPoweredContentTransformerTest -{ - private TikaAutoContentTransformer transformer; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - TikaConfig config = (TikaConfig)ctx.getBean("tikaConfig"); - transformer = new TikaAutoContentTransformer( config ); - transformer.setMimetypeService(mimetypeService); - transformer.setTransformerDebug(transformerDebug); - transformer.setTransformerConfig(transformerConfig); - transformer.afterPropertiesSet(); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - /** - * Ensure we picked up a mixture of content - * types from Tika - */ - public void testIsTransformable() throws Exception - { - // Excel (but this isn't normally used) - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_EXCEL, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - // Word - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_WORD, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - // PDF - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_PDF, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_PDF, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - // Open Office - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - - // We don't do images - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_IMAGE_JPEG, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_IMAGE_JPEG, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_IMAGE_JPEG, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - // Ditto music - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_MP3, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_MP3, -1, MimetypeMap.MIMETYPE_HTML, new TransformationOptions())); - assertFalse(transformer.isTransformable(MimetypeMap.MIMETYPE_MP3, -1, MimetypeMap.MIMETYPE_XML, new TransformationOptions())); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TikaPoweredContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TikaPoweredContentTransformerTest.java deleted file mode 100644 index 1d995e68dc..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TikaPoweredContentTransformerTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.content.MimetypeMap; - -/** - * Parent test for Tika powered transformer tests - * - * @author Nick Burch - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public abstract class TikaPoweredContentTransformerTest extends AbstractContentTransformerTest -{ - protected boolean isQuickPhraseExpected(String targetMimetype) - { - return ( - targetMimetype.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN) || - targetMimetype.equals(MimetypeMap.MIMETYPE_HTML) || - targetMimetype.equals(MimetypeMap.MIMETYPE_XML) - ); - } - protected boolean isQuickWordsExpected(String targetMimetype) - { - return ( - targetMimetype.startsWith(StringExtractingContentTransformer.PREFIX_TEXT) || - targetMimetype.equals(MimetypeMap.MIMETYPE_HTML) || - targetMimetype.equals(MimetypeMap.MIMETYPE_XML) - ); - } - - /** - * Tests for html vs xml vs plain text - */ - protected void additionalContentCheck(String sourceMimetype, String targetMimetype, String contents) - { - if(targetMimetype.equals(MimetypeMap.MIMETYPE_XML)) - { - // Look for header and footer to confirm it was translated - assertTrue( - "XML header not found", - contents.contains("") - ); - } - else if(targetMimetype.equals(MimetypeMap.MIMETYPE_HTML)) - { - // Look for header and footer to confirm it was translated - assertFalse( - "XML header found but shouldn't be there for HTML", - contents.contains("") - ); - assertTrue( - "Expanded HTML title not found", - contents.contains("") - ); - } - else if(targetMimetype.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN)) - { - // Ensure it really is plain text not xml/html - assertFalse( - "XML header found but shouldn't be there for Plain Text", - contents.contains("") - ); - } - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigDynamicTransformersTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigDynamicTransformersTest.java deleted file mode 100644 index adb855dc18..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigDynamicTransformersTest.java +++ /dev/null @@ -1,488 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockProperties; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -import java.util.Properties; - -import org.alfresco.repo.rendition2.LegacySynchronousTransformClient; -import org.alfresco.service.cmr.module.ModuleDetails; -import org.alfresco.service.cmr.module.ModuleService; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.descriptor.Descriptor; -import org.alfresco.service.descriptor.DescriptorService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Tests the TransformerConfigDynamicTransformers class. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigDynamicTransformersTest -{ - @Mock - private TransformerConfig transformerConfig; - - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - @Mock - private LegacySynchronousTransformClient legacySynchronousTransformClient; - - @Mock - private LegacyTransformerDebug transformerDebug; - - @Mock - ModuleService moduleService; - - @Mock - ModuleDetails moduleDetails; - - @Mock - DescriptorService descriptorService; - - @Mock - Descriptor descriptor; - - ContentTransformerRegistry transformerRegistry; - - private ContentTransformer transformer1; - private ContentTransformer transformer2; - private ContentTransformer transformer3; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - transformer1 = new DummyContentTransformer("transformer.transformer1"); - transformer2 = new DummyContentTransformer("transformer.transformer2"); - transformer3 = new DummyContentTransformer("transformer.transformer3"); - - transformerRegistry = new ContentTransformerRegistry(null); - - transformerRegistry.addComponentTransformer(transformer1); - transformerRegistry.addComponentTransformer(transformer2); - transformerRegistry.addComponentTransformer(transformer3); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png", - "text/plain", "txt"); - - assertEquals(3, transformerRegistry.getAllTransformers().size()); - assertEquals(0, transformerRegistry.getTransformers().size()); - } - - @Test - // Simple pipeline - public void pipelineTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "transformer1|pdf|transformer2|png|transformer3"); - - assertEquals(0, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - - assertEquals(4, transformerRegistry.getAllTransformers().size()); - assertEquals(1, transformerRegistry.getTransformers().size()); - - // Throws an exception if it does not exist - ContentTransformer trans = transformerRegistry.getTransformer("transformer.transformerA"); - - // Check the pipeline - ComplexContentTransformer transformer = (ComplexContentTransformer)trans; - assertEquals(2, transformer.getIntermediateMimetypes().size()); - assertEquals("application/pdf", transformer.getIntermediateMimetypes().get(0)); - assertEquals("image/png", transformer.getIntermediateMimetypes().get(1)); - - assertEquals(3, transformer.getIntermediateTransformers().size()); - assertEquals("transformer.transformer1", transformer.getIntermediateTransformers().get(0).getName()); - assertEquals("transformer.transformer2", transformer.getIntermediateTransformers().get(1).getName()); - assertEquals("transformer.transformer3", transformer.getIntermediateTransformers().get(2).getName()); - - // - transformer.isTransformable("application/pdf", -1, "text/txt", new TransformationOptions()); - } - - @Test - // Pipeline - too few components in the value - public void pipelineTooFewCompsTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "transformer1|pdf"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Pipeline - final transformer is missing - public void pipelineMissingFinalTransformerTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "transformer1|pdf|transformer2|png"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Pipeline - transformer name is in use - public void pipelineTransformerAlreadyExistsTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer3.pipeline", "transformer1|pdf|transformer2"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Pipeline with wildcard mimetype - public void pipelineWildcardMimetypeTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "transformer1|*|transformer2|png|transformer3"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - @Test - // Pipeline with wildcard transformer - public void pipelineWildcardTransformerTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "transformer1|pdf|*|png|transformer3"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - @Test - // Pipeline with an unknown sub transformer - public void pipelineBadSubtransformerTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "unknown1|pdf|unknown2|png|unknown3"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Sets available=false - public void pipelineUnavailableTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.pipeline", "transformer1|pdf|transformer2|png|transformer3", - "content.transformer.transformerA.available", "false"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - assertEquals(4, transformerRegistry.getAllTransformers().size()); - assertEquals(0, transformerRegistry.getTransformers().size()); // << note 0 rather than 1 - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - // -------------------------------------------------------------- - - @Test - // Simple failover - public void failoverTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|transformer2|transformer3"); - - assertEquals(0, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - - assertEquals(4, transformerRegistry.getAllTransformers().size()); - assertEquals(1, transformerRegistry.getTransformers().size()); - - // Throws an exception if it does not exist - transformerRegistry.getTransformer("transformer.transformerA"); - } - - @Test - // Failover - too few components in the value - public void failoverTooFewCompsTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Failover - transformer name is in use - public void failoverTransformerAlreadyExistsTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer3.failover", "transformer1|transformer2"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Failover with wildcard transformer - public void failoverWildcardTransformerTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|*|transformer3"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - @Test - // Failover with an unknown sub transformer - public void failoverBadSubtransformerTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "unknown1|unknown2|unknown3"); - - assertEquals(1, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null).getErrorCount()); - } - - @Test - // Failover sets available=false - public void failoverUnavailableTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|transformer2|transformer3", - "content.transformer.transformerA.available", "false"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - assertEquals(4, transformerRegistry.getAllTransformers().size()); - assertEquals(0, transformerRegistry.getTransformers().size()); // << note 0 rather than 1 - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - @Test - // Dynamic transformer that references other dynamic transformers - public void referenceDynamicTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|transformerB", - "content.transformer.transformerB.failover", "transformer1|transformerC", - "content.transformer.transformerC.failover", "transformer1|transformerD", - "content.transformer.transformerD.failover", "transformer1|transformerE", - "content.transformer.transformerE.failover", "transformer1|transformer1"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - assertEquals(5, transformerRegistry.getTransformers().size()); - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - @Test - // Dynamic transformer that references other dynamic transformers and form a loop - public void referrenceDynamicLoopTest() - { - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|transformerB", - "content.transformer.transformerB.failover", "transformer1|transformer1", - "content.transformer.transformerC.failover", "transformer1|transformerD", - "content.transformer.transformerD.failover", "transformer1|transformerE", - "content.transformer.transformerE.failover", "transformer1|transformerC"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, null); - - assertEquals(2, transformerRegistry.getTransformers().size()); - - transformerRegistry.getTransformer("transformer.transformerA"); - } - - private void entrerpriseTransformer(String edition) - { - when(descriptorService.getServerDescriptor()).thenReturn(descriptor); - when(descriptor.getEdition()).thenReturn(edition); - - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|transformer2|transformer3", - "content.transformer.transformerA.edition", "Enterprise"); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, descriptorService, null); - } - - private void ampTransformer(String moduleId) - { - when(moduleService.getModule("testAmp")).thenReturn(moduleDetails); - - mockProperties(transformerProperties, - "content.transformer.transformerA.failover", "transformer1|transformer2|transformer3", - "content.transformer.transformerA.amp", moduleId); - - new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, moduleService, null, null); - } - - @Test - // Test that enterprise transformers are not available to community. - public void communityTest() - { - entrerpriseTransformer("Community"); - - assertEquals(3, transformerRegistry.getAllTransformers().size()); - } - - @Test - // Test that enterprise transformers are available to enterprise. - public void enterpriseTest() - { - entrerpriseTransformer("Enterprise"); - - assertEquals(4, transformerRegistry.getAllTransformers().size()); - } - @Test - // Test that enterprise transformers are not available to community. - public void noAmpTest() - { - ampTransformer("AmpNotInstalled"); - - assertEquals(3, transformerRegistry.getAllTransformers().size()); - } - - @Test - // Test that enterprise transformers are available to enterprise. - public void ampTest() - { - ampTransformer("testAmp"); - - assertEquals(4, transformerRegistry.getAllTransformers().size()); - } - - // for MNT-16381 - - @Test - public void failoverPropertyFFTest() - { - internalPropertyTest(false, false, false); - } - - @Test - public void failoverPropertyFTTest() - { - internalPropertyTest(false, false, true); - } - - @Test - public void failoverPropertyTFTest() - { - internalPropertyTest(false, true, false); - } - - @Test - public void failoverPropertyTTTest() - { - internalPropertyTest(false, true, true); - } - - @Test - public void pipelinePropertyFFTest() - { - internalPropertyTest(true, false, false); - } - - @Test - public void pipelinePropertyFTTest() - { - internalPropertyTest(true, false, true); - } - - @Test - public void pipelinePropertyTFTest() - { - internalPropertyTest(true, true, false); - } - - @Test - public void pipelinePropertyTTTest() - { - internalPropertyTest(true, true, true); - } - - private void internalPropertyTest(boolean pipeline, boolean expectedRetry, boolean expectedCheck) - { - String[] transformerNamesAndValues = pipeline - ? new String[] {"content.transformer.transformerA.pipeline", "transformer1|pdf|transformer2"} - : new String[] {"content.transformer.transformerA.failover", "transformer1|transformer2|transformer3"}; - - Properties properties = new Properties(); - if (expectedRetry) - { - properties.setProperty("content.transformer.retryOn.different.mimetype", "true"); - } - if (expectedCheck) - { - properties.setProperty("transformer.strict.mimetype.check", "true"); - } - - mockProperties(transformerProperties, transformerNamesAndValues); - - assertEquals(0, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, - transformerRegistry, transformerDebug, null, null, properties).getErrorCount()); - - // Throws an exception if it does not exist - AbstractContentTransformer2 transformer = (AbstractContentTransformer2)transformerRegistry.getTransformer("transformer.transformerA"); - assertEquals("retryTransformOnDifferentMimeType was not set", expectedRetry, transformer.getRetryTransformOnDifferentMimeType()); - assertEquals("strictMimetypeCheck was not set", expectedCheck, transformer.getStrictMimeTypeCheck()); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigImplTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigImplTest.java deleted file mode 100644 index 8e6f052848..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigImplTest.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockProperties; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeSet; - -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.springframework.context.ApplicationContext; - -/** - * Test class for TransformerConfigImpl. This class generally calls onto - * secondary classes to handle the request, so most test simply check that - * the real method is called. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigImplTest -{ - @Mock - private ApplicationContext applicationContext; - - @Mock - private MimetypeService mimetypeService; - - @Mock - private ContentTransformerRegistry transformerRegistry; - - @Mock - private TransformerLog transformerLog; - - @Mock - private TransformerDebugLog transformerDebugLog; - - @Mock - private ChildApplicationContextFactory subsystem; - - @Mock - private TransformerProperties transformerProperties; - - @Mock - private TransformationOptions options; - - @Mock - private - ContentTransformer transformer1; - - private TransformerConfigImpl config; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - Properties globalProperties = new Properties(); - - config = new TransformerConfigImpl() - { - @Override - synchronized ChildApplicationContextFactory getSubsystem() - { - return subsystem; - } - }; - config.setApplicationContext(applicationContext); - config.setMimetypeService(mimetypeService); - config.setContentTransformerRegistry(transformerRegistry); - config.setTransformerLog(transformerLog); - config.setTransformerDebugLog(transformerDebugLog); - config.setGlobalProperties(globalProperties); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png"); - - finishSetup(); - } - - private void finishSetup() - { - when(transformer1.getName()).thenReturn("transformer.abc"); - when(transformerRegistry.getTransformer("transformer.abc")).thenReturn(transformer1); - when(transformer1.getComments(false)).thenReturn(""); - - config.initialise(); - } - - /** - * Mock up the responses from the subsystem so that it returns all the supplied - * property names and values. - * @param subsystem to mock the return values - * @param namesAndValues a sequence of property names and values. - * @throws IllegalStateException if there is not a value for every property - */ - public static void mockProperties(ChildApplicationContextFactory subsystem, String... namesAndValues) - { - if (namesAndValues.length % 2 != 0) - { - // Not using IllegalArgumentException as this is thrown by classes under test - throw new java.lang.IllegalStateException("There should be a value for every property"); - } - - final Set propertyNames = new TreeSet(); - for (int i=0; i < namesAndValues.length; i+=2) - { - propertyNames.add(namesAndValues[i]); - when(subsystem.getProperty(namesAndValues[i])).thenReturn(namesAndValues[i+1]); - } - when(subsystem.getPropertyNames()).thenReturn(propertyNames); - } - - @Test - public void getPropertyTest() - { - when(subsystem.getProperty("abc")).thenReturn("xyz"); - String actual = config.getProperty("abc"); - assertEquals("xyz", actual); - } - - @Test - public void getPropertiesTest() - { - when(transformerLog.getPropertyName()).thenReturn("transformer.log.entries"); - when(transformerDebugLog.getPropertyName()).thenReturn("transformer.debug.entries"); - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("transformer.log.entries=0 # default=50"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = config.getProperties(false); - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "transformer.log.entries=0 # default=50\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Miscellaneous settings\n" + - "# ======================\n" + - "# transformer.strict.mimetype.check.whitelist.mimetypes=application/eps;application/postscript;application/illustrator;application/pdf;application/x-tar;application/x-gtar;application/acp;application/zip;application/vnd.stardivision.math;application/x-tika-msoffice\n", - actual); - } - - @Test - public void setPropertiesTest() - { - config.setProperties("transformer.debug.entries=56\ntransformer.log.entries=76"); - Map expected = new HashMap(); - expected.put("transformer.debug.entries", "56"); - expected.put("transformer.log.entries", "76"); - verify(subsystem).setProperties(expected); - } - - @Test - public void removePropertiesTest() - { - mockProperties(subsystem, "content.transformer.abc.extensions.pdf.png.maxPages", "23"); - finishSetup(); - - config.removeProperties("content.transformer.abc.extensions.pdf.png.maxPages"); - Set expected = new HashSet(); - expected.add("content.transformer.abc.extensions.pdf.png.maxPages"); - verify(subsystem).removeProperties(expected); - } - - @Test - public void getStatisticsTest() - { - TransformerStatistics actual = config.getStatistics(transformer1, "application/pdf", "image/png", true); - actual.recordTime(100); - actual.recordTime(200); - actual = config.getStatistics(transformer1, "application/pdf", "image/png", false); - assertEquals(150, actual.getAverageTime()); - } - - @Test - public void getLimitsTest() - { - mockProperties(subsystem, "content.transformer.abc.extensions.pdf.png.maxPages", "23"); - finishSetup(); - - TransformationOptionLimits actual = config.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(23, actual.getMaxPages()); - } - - @Test - public void isSupportedTransformationTest() - { - mockProperties(subsystem, "content.transformer.abc.extensions.pdf.png.suppoprted", "true"); - finishSetup(); - - assertTrue(config.isSupportedTransformation(transformer1, "application/pdf", "image/png", options)); - } - - @Test - public void getPriorityTest() - { - mockProperties(subsystem, - "content.transformer.default.priority", "22", - "content.transformer.abc.extensions.pdf.png.priority", "67"); - finishSetup(); - - assertEquals(67, config.getPriority(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getPriorityBadTest() - { - mockProperties(subsystem, - "content.transformer.default.priority", "22", - "content.transformer.abc.extensions.pdf.png.priority", "bad"); - finishSetup(); - - assertEquals(22, config.getPriority(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getThresholdCountTest() - { - mockProperties(subsystem, - "content.transformer.default.thresholdCount", "22", - "content.transformer.abc.extensions.pdf.png.thresholdCount", "67"); - finishSetup(); - - assertEquals(67, config.getThresholdCount(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getThresholdCountBadTest() - { - mockProperties(subsystem, - "content.transformer.default.thresholdCount", "22", - "content.transformer.abc.extensions.pdf.png.thresholdCount", "bad"); - finishSetup(); - - assertEquals(22, config.getThresholdCount(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getErrorTimeTest() - { - mockProperties(subsystem, - "content.transformer.default.errorTime", "22", - "content.transformer.abc.extensions.pdf.png.errorTime", "67"); - finishSetup(); - - assertEquals(67, config.getErrorTime(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getErrorTimeBadTest() - { - mockProperties(subsystem, - "content.transformer.default.errorTime", "22", - "content.transformer.abc.extensions.pdf.png.errorTime", "bad"); - finishSetup(); - - assertEquals(22, config.getErrorTime(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getInitialAverageTimeTest() - { - mockProperties(subsystem, - "content.transformer.default.time", "22", - "content.transformer.abc.extensions.pdf.png.time", "67"); - finishSetup(); - - assertEquals(67, config.getInitialAverageTime(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getInitialAverageTimeBadTest() - { - mockProperties(subsystem, - "content.transformer.default.time", "22", - "content.transformer.abc.extensions.pdf.png.time", "bad"); - finishSetup(); - - assertEquals(22, config.getInitialAverageTime(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getInitialCountTest() - { - mockProperties(subsystem, - "content.transformer.default.count", "22", - "content.transformer.abc.extensions.pdf.png.count", "67"); - finishSetup(); - - assertEquals(67, config.getInitialCount(transformer1, "application/pdf", "image/png")); - } - - @Test - public void getInitialCountBadTest() - { - mockProperties(subsystem, - "content.transformer.default.count", "22", - "content.transformer.abc.extensions.pdf.png.count", "bad"); - finishSetup(); - - assertEquals(22, config.getInitialCount(transformer1, "application/pdf", "image/png")); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigLimitsTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigLimitsTest.java deleted file mode 100644 index ac609e391e..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigLimitsTest.java +++ /dev/null @@ -1,412 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockProperties; -import static org.junit.Assert.assertEquals; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptionLimits; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for TransformerConfigLimits. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigLimitsTest -{ - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - private ContentTransformer transformer1; - private ContentTransformer transformer2; - - private TransformerConfigLimits extractor; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - transformer1 = new DummyContentTransformer("transformer.transformer1"); - transformer2 = new DummyContentTransformer("transformer.transformer2"); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png", - "text/plain", "txt"); - } - - @Test - // A value is specified for a transformer and mimetypes - public void transformerMimetypesTest() - { - mockProperties(transformerProperties, "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "10"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified for a transformer - public void transformerTest() - { - mockProperties(transformerProperties, "content.transformer.transformer1.maxSourceSizeKBytes", "10"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified as a transformer default with mimetypes - public void defaultMimetypesTest() - { - mockProperties(transformerProperties, "content.transformer.default.extensions.pdf.png.maxSourceSizeKBytes", "10"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified as a transformer default without mimetypes - public void defaultTest() - { - mockProperties(transformerProperties, "content.transformer.default.maxSourceSizeKBytes", "10"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - } - - // --------------------------------------- - - @Test - // Checks that transformer defaults are combined to construct mimetype specific values - public void transformerDefaultsUsedInMimetypesTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "10", - "content.transformer.transformer1.timeoutMs", "10000"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - assertEquals(10000L, limits.getTimeoutMs()); - } - - @Test - // Checks that transformer mimetype values override transformer defaults even if unlimited. - // This was new in 4.2. Prior to this they would have been combined, because of the need to - // always specify them in the spring configuration, which was removed in 4.2. - public void dontCombineTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "-1", - "content.transformer.transformer1.maxSourceSizeKBytes", "20"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(-1, limits.getMaxSourceSizeKBytes()); - } - - @Test - // Checks that system wide defaults (and system wide mimetype defaults) have been used to construct - // transformer specific values. - public void systemWideDefaultsUsedInTransformersTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "10", - "content.transformer.transformer1.maxSourceSizeKBytes", "15", - "content.transformer.default.timeoutMs", "120000", - "content.transformer.default.extensions.txt.png.pageLimit", "1"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits pdfToPngLimits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, pdfToPngLimits.getMaxSourceSizeKBytes()); - assertEquals(120000L, pdfToPngLimits.getTimeoutMs()); - assertEquals(-1, pdfToPngLimits.getPageLimit()); - - TransformationOptionLimits txtToPngLimits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(15, txtToPngLimits.getMaxSourceSizeKBytes()); - assertEquals(120000L, txtToPngLimits.getTimeoutMs()); - assertEquals(1, txtToPngLimits.getPageLimit()); - } - - @Test - // Checks wildcard usage at the transformer level - public void transformerWildcardTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.extensions.*.png.maxSourceSizeKBytes", "10"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - } - - @Test - // Checks wildcard usage at the system wide level - public void systemWideWildcardTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.maxSourceSizeKBytes", "15", - "content.transformer.default.timeoutMs", "120000", - "content.transformer.default.extensions.txt.*.pageLimit", "1"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits txtToPngLimits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(15, txtToPngLimits.getMaxSourceSizeKBytes()); - assertEquals(120000L, txtToPngLimits.getTimeoutMs()); - assertEquals(1, txtToPngLimits.getPageLimit()); - } - - // MNT-14295 With Java 7 the order in which properties were supplied changed from - // what happen with Java 6 and happens with 8. When combined with a bug to do with - // always clearing the max value when setting a limit or the limit when setting - // the max value, the initial map of TransformerConfigLimits would be different. - // Java 7 was used as the runtime for 4.2 and the 5.0 but Java 8 became the default - // from 5.0.1. - // None of the other unit tests in this class failed as a none of them provided - // both max and limit values. - @Test - public void propertyOrderJava7Test() - { - mockProperties(transformerProperties, - "content.transformer.default.timeoutMs", "120000", - "content.transformer.default.readLimitTimeMs", "-1"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(120000L, limits.getTimeoutMs()); - assertEquals(-1L, limits.getReadLimitTimeMs()); - } - - @Test - public void propertyOrderJava8or6Test() - { - mockProperties(transformerProperties, - "content.transformer.default.timeoutMs", "-1", - "content.transformer.default.readLimitTimeMs", "120000"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(-1L, limits.getTimeoutMs()); - assertEquals(120000L, limits.getReadLimitTimeMs()); - } - - @Test - public void bothMaxAndLimitSetIgnoreLimitTest() - { - mockProperties(transformerProperties, - "content.transformer.default.readLimitTimeMs", "990000", - "content.transformer.default.timeoutMs", "120000"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(120000L, limits.getTimeoutMs()); - assertEquals(-1L, limits.getReadLimitTimeMs()); - } - - @Test - public void bothMaxAndLimitSetIgnoreMaxTest() - { - mockProperties(transformerProperties, - "content.transformer.default.readLimitTimeMs", "120000", - "content.transformer.default.timeoutMs", "990000"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(-1L, limits.getTimeoutMs()); - assertEquals(120000L, limits.getReadLimitTimeMs()); - } - - // --------------------------------------- - - @Test - // A value is specified for a transformer, mimetypes and use - public void transformerMimetypesUseTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "10", - "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes.use.index", "20"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index"); - assertEquals(20, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified for a transformer and use - public void transformerUseTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer2.maxSourceSizeKBytes", "10", - "content.transformer.transformer1.maxSourceSizeKBytes.use.index", "20", - // The following is ignored when "index" is specified, as the 'use' property is transformer wide. - "content.transformer.transformer1.maxSourceSizeKBytes", "30"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(30, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index"); - assertEquals(20, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "index"); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified as a transformer default with mimetypes and use - public void defaultMimetypesUseTest() - { - mockProperties(transformerProperties, - "content.transformer.default.extensions.pdf.png.maxSourceSizeKBytes", "10", - "content.transformer.default.extensions.pdf.png.maxSourceSizeKBytes.use.index", "20", - // The following is ignored when "index" is specified, as the 'use' property is system wide. - "content.transformer.transformer2.maxSourceSizeKBytes", "30"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "doclib"); - assertEquals(30, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "index"); - assertEquals(20, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified as a transformer default without mimetypes but with a use - public void defaultUseTest() - { - mockProperties(transformerProperties, - "content.transformer.default.maxSourceSizeKBytes", "10", - "content.transformer.default.maxSourceSizeKBytes.use.index", "20"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index"); - assertEquals(20, limits.getMaxSourceSizeKBytes()); - } - - @Test - // A value is specified as a transformer default without mimetypes but with a use - public void defaultUseTest2() - { - mockProperties(transformerProperties, - "content.transformer.default.maxSourceSizeKBytes", "10", - "content.transformer.default.maxSourceSizeKBytes.use.index", "20", - // The following is ignored when "index" is specified, as the 'use' property is system wide. - "content.transformer.transformer2.maxSourceSizeKBytes", "30"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null); - assertEquals(10, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer2, "application/pdf", "image/png", null); - assertEquals(30, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index"); - assertEquals(20, limits.getMaxSourceSizeKBytes()); - - limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "index"); - assertEquals(20, limits.getMaxSourceSizeKBytes()); - } - - @Test - // Checks limit does not change if use param is specified but not specifically set - public void useUnsetTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.pageLimit", "76"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits transformerDefaultLimits = extractor.getLimits(transformer1, null, null, null); - TransformationOptionLimits transformerDoclibLimits = extractor.getLimits(transformer1, null, null, "doclib"); - assertEquals(76, transformerDefaultLimits.getPageLimit()); - assertEquals(76, transformerDoclibLimits.getPageLimit()); - } - - @Test - // Checks limit does not change if use param is specified but not specifically set - public void useSetTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.pageLimit.use.doclib", "22", - "content.transformer.transformer1.pageLimit", "76"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits transformerDefaultLimits = extractor.getLimits(transformer1, null, null, null); - TransformationOptionLimits transformerDoclibLimits = extractor.getLimits(transformer1, null, null, "doclib"); - assertEquals(76, transformerDefaultLimits.getPageLimit()); - assertEquals(22, transformerDoclibLimits.getPageLimit()); - } - - @Test - // Checks wildcard usage at the system wide level - public void systemWideWildcardUseTest() - { - mockProperties(transformerProperties, - "content.transformer.default.extensions.txt.*.pageLimit", "1", - "content.transformer.default.extensions.txt.*.pageLimit.use.index", "2", - "content.transformer.default.extensions.pdf.*.pageLimit.use.index", "3", - "content.transformer.default.extensions.pdf.txt.pageLimit.use.index", "4"); - - extractor = new TransformerConfigLimits(transformerProperties, mimetypeService); - TransformationOptionLimits txtToPngLimits = extractor.getLimits(transformer1, "text/plain", "image/png", null); - assertEquals(1, txtToPngLimits.getPageLimit()); - - txtToPngLimits = extractor.getLimits(transformer1, "text/plain", "image/png", "index"); - assertEquals(2, txtToPngLimits.getPageLimit()); - - TransformationOptionLimits pdfToPngLimits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index"); - assertEquals(3, pdfToPngLimits.getPageLimit()); - - TransformationOptionLimits pdfToTxtLimits = extractor.getLimits(transformer1, "application/pdf", "text/plain", "index"); - assertEquals(4, pdfToTxtLimits.getPageLimit()); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImplTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImplTest.java index 8dcc192dec..f288196104 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImplTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigMBeanImplTest.java @@ -25,44 +25,31 @@ */ package org.alfresco.repo.content.transform; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - import org.alfresco.service.cmr.repository.MimetypeService; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + /** * Test class for TransformerConfigMBeanImpl. * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated public class TransformerConfigMBeanImplTest { @Mock - private ContentTransformerRegistry transformerRegistry; - - @Mock - private LegacyTransformerDebug transformerDebug; - - @Mock - private TransformerConfig transformerConfig; + private AdminUiTransformerDebug transformerDebug; @Mock private MimetypeService mimetypeService; @@ -99,9 +86,7 @@ public class TransformerConfigMBeanImplTest MockitoAnnotations.initMocks(this); mbean = new TransformerConfigMBeanImpl(); - mbean.setContentTransformerRegistry(transformerRegistry); mbean.setTransformerDebug(transformerDebug); - mbean.setTransformerConfig(transformerConfig); mbean.setMimetypeService(mimetypeService); mbean.setTransformerLog(transformerLog); mbean.setTransformerDebugLog(transformerDebugLog); @@ -112,6 +97,33 @@ public class TransformerConfigMBeanImplTest "text/plain", "txt"); } + /** + * Mock up the responses from the mimetypeService so that it: + * a) returns all the supplied mimetypes + * b) returns the extension given the mimetype + * c) returns the mimetype given the extension. + * @param mimetypeService mimetype service + * @param mimetypesAndExtensions sequence of mimetypes and extenstions. + * @throws IllegalStateException if there is not an extension for every mimetype + */ + public static void mockMimetypes(MimetypeService mimetypeService, String... mimetypesAndExtensions) + { + if (mimetypesAndExtensions.length % 2 != 0) + { + // Not using IllegalArgumentException as this is thrown by classes under test + throw new java.lang.IllegalStateException("There should be an extension for every mimetype"); + } + + final Set allMimetypes = new HashSet(); + for (int i=0; i < mimetypesAndExtensions.length; i+=2) + { + allMimetypes.add(mimetypesAndExtensions[i]); + when(mimetypeService.getExtension(mimetypesAndExtensions[i])).thenReturn(mimetypesAndExtensions[i+1]); + when(mimetypeService.getMimetype(mimetypesAndExtensions[i+1])).thenReturn(mimetypesAndExtensions[i]); + } + when(mimetypeService.getMimetypes()).thenReturn(new ArrayList(allMimetypes)); + } + @Test public void getExtensionsAndMimetypesTest() { @@ -128,154 +140,40 @@ public class TransformerConfigMBeanImplTest public void getTransformationsByExtensionTest() { setupForGetTransformationsByExtension(); - assertEquals("One result", mbean.getTransformationsByExtension("pdf", "png", null)); + assertEquals("One result", mbean.getTransformationsByExtension("pdf", "png")); } @Test public void getTransformationsByExtensionUpperCaseTest() { setupForGetTransformationsByExtension(); - assertEquals("One result", mbean.getTransformationsByExtension("PDF", "PNG", null)); + assertEquals("One result", mbean.getTransformationsByExtension("PDF", "PNG")); } @Test public void getTransformationsByExtensionNullSourceTest() { setupForGetTransformationsByExtension(); - assertEquals("Lots of results to png", mbean.getTransformationsByExtension(null, "PNG", null)); + assertEquals("Lots of results to png", mbean.getTransformationsByExtension(null, "PNG")); } @Test public void getTransformationsByExtensionNullTargetTest() { setupForGetTransformationsByExtension(); - assertEquals("Lots of results from pdf", mbean.getTransformationsByExtension("pdf", null, null)); + assertEquals("Lots of results from pdf", mbean.getTransformationsByExtension("pdf", null)); } private void setupForGetTransformationsByExtension() { - when(transformerDebug.transformationsByExtension("pdf", "png", true, true, false, null)).thenReturn("One result"); - when(transformerDebug.transformationsByExtension(null, "png", true, true, false, null)).thenReturn("Lots of results to png"); - when(transformerDebug.transformationsByExtension("pdf", null, true, true, false, null)).thenReturn("Lots of results from pdf"); - } - - @Test - public void getTransformationStatisticsTransformer1FromToTest() - { - setupForGetTransformationStatistics(); - // Should not be a transformer summary as there might be other transforms and the - // totals would not add up - assertEquals( - "transformer.transformer1 pdf png count=10 errors=0 averageTime=200 ms", - mbean.getTransformationStatistics("transformer1", "pdf", "png")); - } - - @Test - public void getTransformationStatisticsTransformer1AllTest() - { - setupForGetTransformationStatistics(); - // Should be transformer summaries as all transforms were requested and the - // totals will add up - assertEquals( - "transformer.transformer1 * * count=30 errors=0 averageTime=133 ms\n" + - "transformer.transformer1 pdf png count=10 errors=0 averageTime=200 ms\n" + - "transformer.transformer1 txt png count=20 errors=0 averageTime=100 ms", - mbean.getTransformationStatistics("transformer1", null, null)); - } - - @Test - public void getTransformationStatisticsFromToTest() - { - setupForGetTransformationStatistics(); - // Should be an overall summary as the transformer is not specified - // Should not be a transformer summary as there 'might' be other transforms and the - // totals would not add up - assertEquals( - "SUMMARY pdf png count=10 errors=0 averageTime=200 ms\n" + - "SUMMARY txt png count=24 errors=0 averageTime=234 ms\n" + - "\n" + - "transformer.transformer1 pdf png count=10 errors=0 averageTime=200 ms\n" + - "transformer.transformer1 txt png count=20 errors=0 averageTime=100 ms\n" + - "\n" + - "transformer.transformer2 txt png count=4 errors=0 averageTime=654 ms", - mbean.getTransformationStatistics(null, null, "png")); - } - - @Test - public void getTransformationStatisticsAllTest() - { - setupForGetTransformationStatistics(); - // Should be an overall summary as the transformer is not specified - // Should be a transformer1 summary but not for transformer2 as it only has done txt->png - assertEquals( - "SUMMARY * * count=34 errors=0 averageTime=222 ms\n" + - "SUMMARY pdf png count=10 errors=0 averageTime=200 ms\n" + - "SUMMARY txt png count=24 errors=0 averageTime=234 ms\n" + - "\n" + - "transformer.transformer1 * * count=30 errors=0 averageTime=133 ms\n" + - "transformer.transformer1 pdf png count=10 errors=0 averageTime=200 ms\n" + - "transformer.transformer1 txt png count=20 errors=0 averageTime=100 ms\n" + - "\n" + - "transformer.transformer2 txt png count=4 errors=0 averageTime=654 ms", - mbean.getTransformationStatistics(null, null, null)); - } - - @Test - public void getTransformationStatisticsNoneTest() - { - setupForGetTransformationStatistics(); - assertEquals( - "No transformations to report", - mbean.getTransformationStatistics("transformer1", "png", "pdf")); - } - - @SuppressWarnings("unchecked") - private void setupForGetTransformationStatistics() - { - ContentTransformer transformer1 = (ContentTransformer) new DummyContentTransformer("transformer.transformer1"); - ContentTransformer transformer2 = (ContentTransformer) new DummyContentTransformer("transformer.transformer2"); - - Collection transformerList1=Arrays.asList(new ContentTransformer[] {transformer1}); - when(transformerDebug.sortTransformersByName("transformer.transformer1")).thenReturn( - transformerList1); - Collection transformerList2=Arrays.asList(new ContentTransformer[] {transformer1, transformer2}); - when(transformerDebug.sortTransformersByName(null)).thenReturn( - transformerList2); - - when(transformerDebug.getSourceMimetypes("pdf")).thenReturn(Collections.singletonList("application/pdf")); - when(transformerDebug.getSourceMimetypes("png")).thenReturn(Collections.singletonList("image/png")); - when(transformerDebug.getSourceMimetypes("txt")).thenReturn(Collections.singletonList("text/plain")); - when(transformerDebug.getSourceMimetypes(null)).thenReturn(Arrays.asList(new String[] {"application/pdf", "image/png", "text/plain"})); - - when(transformerDebug.getTargetMimetypes(any(), eq("pdf"), (Collection) any())).thenReturn(Collections.singletonList("application/pdf")); - when(transformerDebug.getTargetMimetypes(any(), eq("png"), (Collection) any())).thenReturn(Collections.singletonList("image/png")); - when(transformerDebug.getTargetMimetypes(any(), eq("txt"), (Collection) any())).thenReturn(Collections.singletonList("text/plain")); - when(transformerDebug.getTargetMimetypes(any(), (String)eq(null), (Collection) any())).thenReturn(Arrays.asList(new String[] {"application/pdf", "image/png", "text/plain"})); - - when(transformerConfig.getStatistics(null, null, null, false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "*", "*", null, null, 130000, 222, 34)); - when(transformerConfig.getStatistics(null, "application/pdf", "image/png", false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "application/pdf", "image/png", null, null, 130001, 200, 10)); - when(transformerConfig.getStatistics(null, "text/plain", "image/png", false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "text/plain", "image/png", null, null, 130002, 234, 24)); - - when(transformerConfig.getStatistics(transformer1, "application/pdf", "image/png", false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "application/pdf", "image/png", transformer1, null, 120000, 200, 10)); - when(transformerConfig.getStatistics(transformer1, "text/plain", "image/png", false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "text/plain", "image/png", transformer1, null, 120001, 100, 20)); - when(transformerConfig.getStatistics(transformer1, null, null, false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "*", "*", transformer1, null, 120002, 133, 30)); - - when(transformerConfig.getStatistics(transformer2, "text/plain", "image/png", false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "text/plain", "image/png", transformer2, null, 120003, 654, 4)); - when(transformerConfig.getStatistics(transformer2, null, null, false)).thenReturn( - new TransformerStatisticsImpl(mimetypeService, "*", "*", transformer2, null, 120004, 654, 4)); + when(transformerDebug.transformationsByExtension("pdf", "png", true)).thenReturn("One result"); + when(transformerDebug.transformationsByExtension(null, "png", true)).thenReturn("Lots of results to png"); + when(transformerDebug.transformationsByExtension("pdf", null, true)).thenReturn("Lots of results from pdf"); } @Test public void getTransformationLogTest() { -// when(transformerLog.getEntries(5)).thenReturn(new String[] {"test message 1", "test message 2"}); logEntries.add("test message 1"); logEntries.add("test message 2"); assertArrayEquals(new String[] {"test message 1", "test message 2"}, mbean.getTransformationLog(5)); @@ -284,14 +182,12 @@ public class TransformerConfigMBeanImplTest @Test public void getTransformationLogZeroTest() { -// when(transformerLog.getEntries(5)).thenReturn(new String[0]); assertArrayEquals(new String[] {"No transformations to report"}, mbean.getTransformationLog(5)); } @Test public void getTransformationDebugLogTest() { -// when(transformerDebugLog.getEntries(5)).thenReturn(new String[] {"test message 1", "test message 2"}); logEntries.add("test message 1"); logEntries.add("test message 2"); assertArrayEquals(new String[] {"test message 1", "test message 2"}, mbean.getTransformationDebugLog(5)); @@ -300,56 +196,20 @@ public class TransformerConfigMBeanImplTest @Test public void getTransformationDebugLogZeroTest() { -// when(transformerDebugLog.getEntries(5)).thenReturn(new String[0]); assertArrayEquals(new String[] {"No transformations to report"}, mbean.getTransformationDebugLog(5)); } - @Test - public void getPropertiesTest() - { - when(transformerConfig.getProperties(false)).thenReturn("some properties"); - assertEquals("some properties", mbean.getProperties(true)); - } - - @Test - public void setPropertiesTest() - { - when(transformerConfig.setProperties("abc")).thenReturn(12); - assertEquals("Properties added or changed: 12", mbean.setProperties("abc")); - } - - @Test - public void setPropertiesDataProblemTest() - { - when(transformerConfig.setProperties("abc=12\nabc=1")).thenThrow(new IllegalArgumentException("abc has been specified more than once")); - assertEquals("abc has been specified more than once", mbean.setProperties("abc=12\nabc=1")); - } - - @Test - public void removePropertiesTest() - { - when(transformerConfig.removeProperties("abc")).thenReturn(1); - assertEquals("Properties removed: 1", mbean.removeProperties("abc")); - } - - @Test - public void removePropertiesDataProblemTest() - { - when(transformerConfig.removeProperties("abc")).thenThrow(new IllegalArgumentException("Unexpected property: abc Does not exist")); - assertEquals("Unexpected property: abc Does not exist", mbean.removeProperties("abc")); - } - @Test public void testTransformAnyTransformerTest() { - when(transformerDebug.testTransform("pdf", "png", null)).thenReturn("debug output"); - assertEquals("debug output", mbean.testTransform("String", "pdf", "png", null)); + when(transformerDebug.testTransform("pdf", "png")).thenReturn("debug output"); + assertEquals("debug output", mbean.testTransform("pdf", "png")); } @Test public void testTransformAnyTransformerBadExtensionTest() { - when(transformerDebug.testTransform("bad", "png", null)).thenThrow(new IllegalArgumentException("Unknown source extension: bad")); - assertEquals("Unknown source extension: bad", mbean.testTransform(null, "bad", "png", null)); + when(transformerDebug.testTransform("bad", "png")).thenThrow(new IllegalArgumentException("Unknown source extension: bad")); + assertEquals("Unknown source extension: bad", mbean.testTransform("bad", "png")); } } diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigPropertyTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigPropertyTest.java deleted file mode 100644 index cd3776a6cd..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigPropertyTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.alfresco.repo.content.transform.TransformerConfig.BLACKLIST; -import static org.alfresco.repo.content.transform.TransformerConfig.PRIORITY; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockProperties; -import static org.junit.Assert.assertEquals; - -import java.math.BigInteger; - -import org.alfresco.service.cmr.repository.MalformedNodeRefException; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for TransformerConfigProperty. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigPropertyTest -{ - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - private TransformerConfigProperty extractor; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png"); - } - - @Test - public void simpleTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.priority", "87"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), null, null); - assertEquals("transformer default priority", 87, actual); - } - - @Test - public void getSystemWideDefaultTest() - { - mockProperties(transformerProperties, "content.transformer.default.priority", "87"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt(null, null, null); - assertEquals("default priority", 87, actual); - } - - @Test - public void getSystemWideDefaultWithAnyTest() - { - // Same as getSystemWideDefaultTest except getInt uses ANY rather than null - mockProperties(transformerProperties, "content.transformer.default.priority", "87"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt(null, ANY, ANY); - assertEquals("default priority", 87, actual); - } - - @Test - public void useSystemWideDefaultTest() - { - mockProperties(transformerProperties, "content.transformer.default.priority", "87"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), null, null); - assertEquals("default priority", 87, actual); - } - - @Test - public void useNonExistentSystemWideDefaultTest() - { - mockProperties(transformerProperties); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), null, null); - assertEquals("default priority", 55, actual); - } - - @Test - public void mimetypesTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.mimetypes.application/pdf.image/png.priority", "87"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - assertEquals("transformer default priority", 87, actual); - } - - @Test - public void extensionsTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.priority", "87"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - int actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - assertEquals("transformer default priority", 87, actual); - } - - @Test - public void multiplePropertiesTest() - { - mockProperties(transformerProperties, - "content.transformer.default.priority", "11", - "content.transformer.abc.extensions.pdf.png.priority", "22", - "content.transformer.abc.xyz.extensions.pdf.png.priority", "33"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - - int actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.qaz"), "application/pdf", "image/png"); - assertEquals("default", 11, actual); - actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png"); - assertEquals("abc", 22, actual); - actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - assertEquals("abc.xyz", 33, actual); - } - - @Test - public void longTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.priority", "1234567890"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - long actual = extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - assertEquals("transformer default priority", 1234567890L, actual); - } - - @Test(expected=NumberFormatException.class) - public void badIntTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.priority", - Long.toString(((long)Integer.MAX_VALUE)+1)); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - } - - @Test(expected=NumberFormatException.class) - public void badIntAbcTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.priority", "abc"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - extractor.getInt((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - } - - @Test(expected=NumberFormatException.class) - public void badLongTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.priority", - new BigInteger(""+Long.MAX_VALUE).add(BigInteger.ONE).toString()); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - extractor.getLong((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - } - - @Test(expected=NumberFormatException.class) - public void badLongAbcTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.priority", "abc"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, PRIORITY, "55"); - extractor.getLong((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - } - - @Test - public void goodNodeRefTest() - { - // ".+://.+/.+" - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.blacklist", "abc://mno/xyz"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, BLACKLIST, "abc/mno/xyz"); - String actual = extractor.getNodeRefs((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png").toString(); - assertEquals("blacklist", "[abc://mno/xyz]", actual); - } - - @Test - public void goodNodeRefListTest() - { - // ".+://.+/.+" - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.blacklist", "abc://mno/xyz, ,a://m/x,b://n/y"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, BLACKLIST, "abc://mno/xyz, ,a://m/x,b://n/y"); - String actual = extractor.getNodeRefs((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png").toString(); - assertEquals("blacklist", "[abc://mno/xyz, a://m/x, b://n/y]", actual); - } - - @Test(expected=MalformedNodeRefException.class) - public void badNodeRefTest() - { - mockProperties(transformerProperties, "content.transformer.abc.xyz.extensions.pdf.png.blacklist", "abc"); - - extractor = new TransformerConfigProperty(transformerProperties, mimetypeService, BLACKLIST, "abc"); - extractor.getNodeRefs((ContentTransformer) new DummyContentTransformer("transformer.abc.xyz"), "application/pdf", "image/png"); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigStatisticsTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigStatisticsTest.java deleted file mode 100644 index 6f53150ced..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigStatisticsTest.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for TransformerConfigStatistics. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigStatisticsTest -{ - @Mock - private TransformerConfigImpl transformerConfig; - - @Mock - private MimetypeService mimetypeService; - - private ContentTransformer transformer1; - - private TransformerConfigStatistics stats; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - stats = new TransformerConfigStatistics(transformerConfig, mimetypeService); - - transformer1 = new DummyContentTransformer("transformer.transformer1"); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png", - "text/plain", "txt"); - } - - @Test - public void createTest() - { - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - assertTrue(statistics != null); - assertEquals(0L, statistics.getAverageTime()); - assertEquals(0L, statistics.getCount()); - assertEquals(0L, statistics.getErrorCount()); - assertEquals("pdf", statistics.getSourceExt()); - assertEquals("png", statistics.getTargetExt()); - assertEquals("transformer.transformer1", statistics.getTransformerName()); - } - - @Test - public void createSetAverageTimeTest() - { - when(transformerConfig.getInitialAverageTime(transformer1, "application/pdf", "image/png")).thenReturn(12345L); - when(transformerConfig.getInitialCount(transformer1, "application/pdf", "image/png")).thenReturn(123); - - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - assertTrue(statistics != null); - assertEquals(12345L, statistics.getAverageTime()); - assertEquals(123L, statistics.getCount()); - } - - @Test - public void create0CountOnSetAverageTimeTest() - { - // getInitialCount should be defaulted to 0 if the average time is set and there is no default - when(transformerConfig.getInitialAverageTime(transformer1, "application/pdf", "image/png")).thenReturn(12345L); - - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - assertTrue(statistics != null); - assertEquals(12345L, statistics.getAverageTime()); - assertEquals(0L, statistics.getCount()); - } - - @Test - public void createSetErrorTimeTest() - { - when(transformerConfig.getErrorTime(transformer1, "application/pdf", "image/png")).thenReturn(12345L); - - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - statistics.recordError(100L); // 100 does not get used if errorTime is set - - assertEquals(12345L, statistics.getAverageTime()); - assertEquals(1L, statistics.getCount()); - assertEquals(1L, statistics.getErrorCount()); - } - - @Test - public void createNoSetErrorTimeTest() - { - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - statistics.recordError(100L); - - assertEquals(100L, statistics.getAverageTime()); - assertEquals(1L, statistics.getCount()); - assertEquals(1L, statistics.getErrorCount()); - } - - @Test - public void mayCreateButExistsTest() - { - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - statistics.recordTime(100L); - - // Call again (with createNew=true) and then make sure it is the same object returned - statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - assertEquals(100L, statistics.getAverageTime()); - } - - @Test - public void mayNotCreateButExistsTest() - { - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - statistics.recordTime(100L); - - // Call again (with createNew=false) and then make sure it is the same object returned - statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", false); - assertEquals(100L, statistics.getAverageTime()); - } - - @Test - public void doesNotExistTest() - { - assertEquals(null, stats.getStatistics(transformer1, "application/pdf", "image/png", false)); - } - - @Test - // i.e. the system wide summary - public void nullTransformerTest() - { - TransformerStatistics statistics = stats.getStatistics(null, "application/pdf", "image/png", true); - assertEquals("SUMMARY", statistics.getTransformerName()); - } - - @Test - public void nullMimetypesTest() - { - TransformerStatistics statistics = stats.getStatistics(transformer1, null, null, true); - assertEquals("transformer.transformer1", statistics.getTransformerName()); - assertEquals("*", statistics.getSourceExt()); - assertEquals("*", statistics.getTargetExt()); - } - - @Test - public void createSummaryTooTest() - { - // Same as createTest() - TransformerStatistics statistics = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - - // The summary for the transformer should also have been created - statistics = stats.getStatistics(transformer1, "*", "*", false); - assertTrue(statistics != null); - assertEquals(0L, statistics.getAverageTime()); - assertEquals(0L, statistics.getCount()); - assertEquals(0L, statistics.getErrorCount()); - assertEquals("*", statistics.getSourceExt()); // pdf in createTest - assertEquals("*", statistics.getTargetExt()); // png in createTest - assertEquals("transformer.transformer1", statistics.getTransformerName()); - } - - @Test - // check the transformer summary gets reused - public void transformerSummaryTest() - { - // Create pdf->png and summary from transformer1 - TransformerStatistics pdfToPng = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - TransformerStatistics summary = stats.getStatistics(transformer1, "*", "*", false); - - // Create txt->png for transformer1 - TransformerStatistics txtToPng = stats.getStatistics(transformer1, "text/plain", "image/png", true); - - pdfToPng.recordTime(100); - txtToPng.recordTime(200); - - assertEquals(2, summary.getCount()); - assertEquals(150L, summary.getAverageTime()); - } - - @Test - // check the system wide statistics gather up values - public void systemWideSummaryTest() - { - TransformerStatistics transformer1PdfToPng = stats.getStatistics(transformer1, "application/pdf", "image/png", true); - TransformerStatistics transformer1TxtToPng = stats.getStatistics(transformer1, "text/plain", "image/png", true); - - ContentTransformer transformer2 = new DummyContentTransformer("transformer.transformer2"); - TransformerStatistics transformer2PdfToPng = stats.getStatistics(transformer2, "application/pdf", "image/png", true); - TransformerStatistics transformer2TxtToPdf = stats.getStatistics(transformer2, "text/plain", "application/pdf", true); - - TransformerStatistics summaryPdfToPng = stats.getStatistics(null, "application/pdf", "image/png", true); - TransformerStatistics summaryTxtToPng = stats.getStatistics(null, "text/plain", "image/png", true); - TransformerStatistics summaryTxtToPdf = stats.getStatistics(null, "text/plain", "application/pdf", true); - TransformerStatistics summary = stats.getStatistics(null, "*", "*", false); - - // Run a few transforms - recordTime(summaryPdfToPng, transformer1PdfToPng, 100); - recordTime(summaryPdfToPng, transformer1PdfToPng, 100); - recordTime(summaryPdfToPng, transformer2PdfToPng, 400); - - recordTime(summaryTxtToPng, transformer1TxtToPng, 200); - - recordTime(summaryTxtToPdf, transformer2TxtToPdf, 400); - - // Check summaries - assertEquals(5, summary.getCount()); - assertEquals(3, summaryPdfToPng.getCount()); - assertEquals(1, summaryTxtToPng.getCount()); - assertEquals(1, summaryTxtToPdf.getCount()); - - assertEquals(200L, summaryPdfToPng.getAverageTime()); - assertEquals(200L, summaryTxtToPng.getAverageTime()); - assertEquals(400L, summaryTxtToPdf.getAverageTime()); - assertEquals(240L, summary.getAverageTime()); // 100+100+400+200+400 = 1200 - } - - // Calls both transformer and summary recordTime() methods in the same way - // AbstractContentTransformer2.recordTime(String, String, long) would do for - // a top level transformation - private void recordTime(TransformerStatistics summaryAToB, TransformerStatistics transformerAToB, long time) - { - transformerAToB.recordTime(time); - summaryAToB.recordTime(time); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigSupportedTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigSupportedTest.java deleted file mode 100644 index e610e726f7..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigSupportedTest.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockProperties; -import static org.junit.Assert.assertEquals; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for TransformerConfigSupported. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerConfigSupportedTest -{ - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - @Mock - private TransformationOptions options; - - private TransformerConfigSupported extractor; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png", - "text/xml", "xml"); - } - - @Test - public void supportedTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.pdf.png.supported", "true"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", true, supported); - - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "image/png", "text/xml", options); - assertEquals("xyz supported", false, supported); - } - - @Test - public void unsupportedTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.pdf.png.supported", "false"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", false, supported); - - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "image/png", "text/xml", options); - assertEquals("xyz supported", true, supported); - } - - @Test - public void mixedCaseTrueTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.pdf.png.supported", "tRUE"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", true, supported); - } - - @Test - public void unsupportedMimetypesTest() - { - mockProperties(transformerProperties, "content.transformer.abc.mimetypes.application/pdf.image/png.supported", "false"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", false, supported); - } - - @Test - public void badValueIsUnsupportedTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.pdf.png.supported", "bad"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", false, supported); - } - - @Test - public void otherMimetypesTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.png.pdf.supported", "false"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", true, supported); - } - - @Test - public void supportedByDefaultTest() - { - mockProperties(transformerProperties); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", true, supported); - } - - @Test - public void multipleTest() - { - mockProperties(transformerProperties, - "content.transformer.abc.extensions.pdf.png.supported", "false", - "content.transformer.def.extensions.pdf.png.supported", "true", - "content.transformer.xyz.extensions.pdf.png.supported", "false"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("abc supported", false, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.def"), "application/pdf", "image/png", options); - assertEquals("def supported", true, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.xyz"), "application/pdf", "image/png", options); - assertEquals("xyz supported", false, supported); - } - - @Test - public void withoutDefaultTest() - { - mockProperties(transformerProperties, - "content.transformer.abc.extensions.pdf.*.supported", "false", - "content.transformer.abc.extensions.pdf.png.supported", "true"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "application/pdf", options); - assertEquals("abc supported", false, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("def supported", true, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "image/png", "text/xml", options); - assertEquals("xyz supported", false, supported); // << not the same in withDefaultTest - } - - @Test - public void withDefaultTest() - { - mockProperties(transformerProperties, - "content.transformer.abc.extensions.*.*.supported", "true", // << not the same in withoutDefaultTest - "content.transformer.abc.extensions.pdf.*.supported", "false", - "content.transformer.abc.extensions.pdf.png.supported", "true"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "application/pdf", options); - assertEquals("abc supported", false, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("def supported", true, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "image/png", "text/xml", options); - assertEquals("xyz supported", true, supported); // << not the same in withoutDefaultTest - } - - @Test - public void withoutDefaultNegatedTest() - { - mockProperties(transformerProperties, - "content.transformer.abc.extensions.pdf.*.supported", "true", - "content.transformer.abc.extensions.pdf.png.supported", "false"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "application/pdf", options); - assertEquals("abc supported", true, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("def supported", false, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "image/png", "text/xml", options); - assertEquals("xyz supported", false, supported); - } - - @Test - public void withDefaultNegatedTest() - { - mockProperties(transformerProperties, - "content.transformer.abc.extensions.*.*.supported", "false", - "content.transformer.abc.extensions.pdf.*.supported", "true", - "content.transformer.abc.extensions.pdf.png.supported", "false"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "application/pdf", options); - assertEquals("abc supported", true, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("def supported", false, supported); - supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "image/png", "text/xml", options); - assertEquals("xyz supported", false, supported); - } - - @Test - public void bothUnsupportedAndSupportedTest() - { - // mimetypes should win if both are supplied - mockProperties(transformerProperties, - "content.transformer.abc.extensions.pdf.png.supported", "false", - "content.transformer.abc.mimetypes.application/pdf.image/png.supported", "true"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - boolean supported = extractor.isSupportedTransformation((ContentTransformer) new DummyContentTransformer("transformer.abc"), "application/pdf", "image/png", options); - assertEquals("supported", true, supported); - } - - @Test - public void supportedWildcardMimetypeTest() - { - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png", - "image/x-raw-adobe", "dng", - "image/x-raw-hasselblad", "3fr", - "image/x-raw-fuji", "raf", - "image/x-raw-canon", "cr2", - "image/x-raw-kodak", "k25", - "text/xml", "xml"); - mockProperties(transformerProperties, "content.transformer.abc.mimetypes.image/x-raw*.application/pdf.supported", "true"); - - extractor = new TransformerConfigSupported(transformerProperties, mimetypeService); - ContentTransformer transformer = (ContentTransformer) new DummyContentTransformer("transformer.abc"); - boolean supported = extractor.isSupportedTransformation(transformer, "image/png", "application/pdf", options); - assertEquals("png supported", false, supported); - - supported = extractor.isSupportedTransformation(transformer, "image/x-raw-adobe", "application/pdf", options); - assertEquals("dng supported", true, supported); - supported = extractor.isSupportedTransformation(transformer, "image/x-raw-hasselblad", "application/pdf", options); - assertEquals("3fr supported", true, supported); - supported = extractor.isSupportedTransformation(transformer, "image/x-raw-fuji", "application/pdf", options); - assertEquals("raf supported", true, supported); - supported = extractor.isSupportedTransformation(transformer, "image/x-raw-canon", "application/pdf", options); - assertEquals("cr2 supported", true, supported); - supported = extractor.isSupportedTransformation(transformer, "image/x-raw-kodak", "application/pdf", options); - assertEquals("k25 supported", true, supported); - - supported = extractor.isSupportedTransformation(transformer, "text/xml", "application/pdf", options); - assertEquals("txt supported", false, supported); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigTestSuite.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigTestSuite.java index 3ba0fe830d..1ad493937e 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigTestSuite.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerConfigTestSuite.java @@ -37,27 +37,14 @@ import org.junit.runners.Suite.SuiteClasses; */ @RunWith(Suite.class) @SuiteClasses({ - TransformerConfigStatisticsTest.class, - TransformerConfigLimitsTest.class, - TransformerConfigSupportedTest.class, - TransformerConfigPropertyTest.class, - TransformerPropertyNameExtractorTest.class, - TransformerPropertyGetterTest.class, - TransformerPropertySetterTest.class, - TransformerConfigDynamicTransformersTest.class, - LogAdapterTest.class, LogTeeTest.class, TransformerLoggerTest.class, TransformerLogTest.class, TransformerDebugLogTest.class, - LegacyTransformerDebugTest.class, - - TransformerConfigImplTest.class, - TransformerConfigMBeanImplTest.class, - TransformerSelectorImplTest.class}) + TransformerConfigMBeanImplTest.class}) /** * Test classes in the Transformers subsystem diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerDebugLogTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerDebugLogTest.java index 8a24feeef9..c81460c9cf 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerDebugLogTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerDebugLogTest.java @@ -25,18 +25,16 @@ */ package org.alfresco.repo.content.transform; -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import java.util.Date; -import java.util.Deque; -import java.util.concurrent.atomic.AtomicInteger; - import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.Properties; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + /** * Test class for TransformerDebugLog. * @@ -48,7 +46,7 @@ public class TransformerDebugLogTest private TransformerDebug transformerDebug; @Mock - private TransformerConfig transformerConfig; + private Properties properties; private TransformerDebugLog log; @@ -59,7 +57,7 @@ public class TransformerDebugLogTest log = new TransformerDebugLog(); log.setTransformerDebug(transformerDebug); - log.setTransformerConfig(transformerConfig); + log.setProperties(properties); } static void assertDebugEntriesEquals(String[] expected, String[] actual) @@ -91,7 +89,7 @@ public class TransformerDebugLogTest @Test public void oneTest() { - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("3"); + when(properties.getProperty("transformer.debug.entries")).thenReturn("3"); log.debug("56 one"); log.debug("56 Finished in 23 ms"); @@ -101,7 +99,7 @@ public class TransformerDebugLogTest @Test public void incompleteTest() { - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("3"); + when(properties.getProperty("transformer.debug.entries")).thenReturn("3"); log.debug("56 one"); assertDebugEntriesEquals(new String[] {"56 one\n <<-- INCOMPLETE -->>"}, log.getEntries(10)); @@ -110,7 +108,7 @@ public class TransformerDebugLogTest @Test public void nullEntryTest() { - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("3"); + when(properties.getProperty("transformer.debug.entries")).thenReturn("3"); log.debug(null); assertDebugEntriesEquals(new String[] {}, log.getEntries(10)); @@ -119,7 +117,7 @@ public class TransformerDebugLogTest @Test public void zeroLengthIdEntryTest() { - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("3"); + when(properties.getProperty("transformer.debug.entries")).thenReturn("3"); log.debug("one"); // as the 1st char is not a digit the id is taken to be "" assertDebugEntriesEquals(new String[] {"one\n <<-- INCOMPLETE -->>"}, log.getEntries(10)); @@ -128,7 +126,7 @@ public class TransformerDebugLogTest @Test public void twoAndAHalfTest() { - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("3"); + when(properties.getProperty("transformer.debug.entries")).thenReturn("3"); log.debug("56 one"); log.debug("56 Finished in 23 ms"); log.debug("57 one"); @@ -150,7 +148,7 @@ public class TransformerDebugLogTest { // The sequence will still be based on the first entry of each request, // but subsequent debug may be out of order. - when(transformerConfig.getProperty("transformer.debug.entries")).thenReturn("3"); + when(properties.getProperty("transformer.debug.entries")).thenReturn("3"); log.debug("56 one"); log.debug("57 one"); log.debug("56 Finished in 23 ms"); diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLogTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLogTest.java index 339e8fba22..5b435bcfe5 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLogTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLogTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.mockito.Mockito.when; import java.util.Date; +import java.util.Properties; import org.junit.Before; import org.junit.Test; @@ -46,7 +47,7 @@ public class TransformerLogTest private TransformerDebug transformerDebug; @Mock - private TransformerConfig transformerConfig; + private Properties properties; private TransformerLog log; @@ -57,7 +58,7 @@ public class TransformerLogTest log = new TransformerLog(); log.setTransformerDebug(transformerDebug); - log.setTransformerConfig(transformerConfig); + log.setProperties(properties); } static String[] stripDateStamp(String[] actual) @@ -84,7 +85,7 @@ public class TransformerLogTest @Test public void oneEntryTest() { - when(transformerConfig.getProperty("transformer.log.entries")).thenReturn("3"); + when(properties.getProperty("transformer.log.entries")).thenReturn("3"); log.debug("one"); assertLogEntriesEquals(new String[] {"one"}, log.getEntries(10)); @@ -93,7 +94,7 @@ public class TransformerLogTest @Test public void fiveEntryTest() { - when(transformerConfig.getProperty("transformer.log.entries")).thenReturn("3"); + when(properties.getProperty("transformer.log.entries")).thenReturn("3"); log.debug("one"); log.debug("two"); diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLoggerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLoggerTest.java index 7906c8c608..d06bb445ef 100644 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLoggerTest.java +++ b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerLoggerTest.java @@ -44,17 +44,13 @@ import org.mockito.MockitoAnnotations; * Test class for TransformerLogger. * * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. */ -@Deprecated public class TransformerLoggerTest { @Mock private TransformerDebug transformerDebug; - @Mock - private TransformerConfig transformerConfig; + private Properties properties = new Properties(); private TransformerLogger log; @@ -62,12 +58,12 @@ public class TransformerLoggerTest public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - log = newLogger(new AtomicInteger(1), transformerDebug, transformerConfig); + + log = newLogger(new AtomicInteger(1), transformerDebug, properties); } private TransformerLogger newLogger(final AtomicInteger numberOfMessagesToAdd, - TransformerDebug transformerDebug, TransformerConfig transformerConfig) + TransformerDebug transformerDebug, Properties properties) { TransformerLogger log = new TransformerLogger() { @@ -109,53 +105,10 @@ public class TransformerLoggerTest } }; log.setTransformerDebug(transformerDebug); - log.setTransformerConfig(transformerConfig); + log.setProperties(properties); return log; } - @Test - public void propertyExistsTest() - { - when(transformerConfig.getProperty("property.name")).thenReturn("5"); - assertEquals("property.name=5 # default=0", log.getPropertyAndValue(null)); - } - - @Test - public void propertyExistsAndDefaultSetTest() - { - when(transformerConfig.getProperty("property.name")).thenReturn("5"); - Properties properties = new Properties(); - properties.setProperty("property.name", "23"); - assertEquals("property.name=5 # default=23", log.getPropertyAndValue(properties)); - } - - @Test - public void propertyDoesNotExistTest() - { - assertEquals("# property.name=0", log.getPropertyAndValue(null)); - } - - @Test - public void propertyNegativeTest() - { - when(transformerConfig.getProperty("property.name")).thenReturn("-2"); - assertEquals("# property.name=0", log.getPropertyAndValue(null)); - } - - @Test - public void propertyGreaterThanMax() - { - when(transformerConfig.getProperty("property.name")).thenReturn("1000"); - assertEquals("property.name=176 # default=0", log.getPropertyAndValue(null)); - } - - @Test - public void propertyBadTest() - { - when(transformerConfig.getProperty("property.name")).thenReturn("abc"); - assertEquals("# property.name=0", log.getPropertyAndValue(null)); - } - @Test public void isDebugEnabled0EntriesTest() { @@ -166,7 +119,7 @@ public class TransformerLoggerTest @Test public void isDebugEnabled5EntriesTest() { - when(transformerConfig.getProperty("property.name")).thenReturn("5"); + properties.setProperty("property.name", "5"); assertTrue(log.isDebugEnabled()); } @@ -174,14 +127,14 @@ public class TransformerLoggerTest public void isDebugEnabledHasStringBuilderTest() { when(transformerDebug.getStringBuilder()).thenReturn(new StringBuilder()); - when(transformerConfig.getProperty("property.name")).thenReturn("5"); + properties.setProperty("property.name", "5"); assertFalse(log.isDebugEnabled()); } @Test public void noEntriesTest() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); assertArrayEquals(new String[] {}, log.getEntries(10)); } @@ -194,7 +147,7 @@ public class TransformerLoggerTest @Test public void oneEntryTest() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); log.debug("one"); assertArrayEquals(new String[] {"one"}, log.getEntries(10)); @@ -204,7 +157,7 @@ public class TransformerLoggerTest // newest entry first public void fiveEntryTest() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); log.debug("one"); log.debug("two"); @@ -219,7 +172,7 @@ public class TransformerLoggerTest // <= 0 indicates return all public void limit0Test() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); log.debug("one"); log.debug("two"); @@ -233,7 +186,7 @@ public class TransformerLoggerTest // < 0 indicates return all - most current first public void limitAllTest() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); log.debug("one"); log.debug("two"); @@ -246,7 +199,7 @@ public class TransformerLoggerTest // Returns latest public void limit1Test() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); log.debug("one"); log.debug("two"); @@ -258,7 +211,7 @@ public class TransformerLoggerTest @Test public void limitMoreThanEntriesTest() { - when(transformerConfig.getProperty("property.name")).thenReturn("3"); + properties.setProperty("property.name", "3"); log.debug("one"); log.debug("two"); @@ -272,8 +225,8 @@ public class TransformerLoggerTest public void addTwoEntriesTest() { AtomicInteger numberOfMessagesToAdd = new AtomicInteger(2); - log = newLogger(numberOfMessagesToAdd, transformerDebug, transformerConfig); - when(transformerConfig.getProperty("property.name")).thenReturn("5"); + log = newLogger(numberOfMessagesToAdd, transformerDebug, properties); + properties.setProperty("property.name", "5"); log.debug("one"); assertArrayEquals(new String[] {"one", "one"}, log.getEntries(10)); @@ -290,8 +243,8 @@ public class TransformerLoggerTest { // Same as addTwoEntriesTest but without hitting the buffer limit AtomicInteger numberOfMessagesToAdd = new AtomicInteger(2); - log = newLogger(numberOfMessagesToAdd, transformerDebug, transformerConfig); - when(transformerConfig.getProperty("property.name")).thenReturn("10"); + log = newLogger(numberOfMessagesToAdd, transformerDebug, properties); + properties.setProperty("property.name", "10"); log.debug("one"); log.debug("two"); log.debug("three"); diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertiesTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertiesTest.java deleted file mode 100644 index 4a634cd82b..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertiesTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2017 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.util.Properties; -import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -/** - * Test class for TransformerProperties. Currently just that The old oooDirect (OpenOffice) transformer settings - * are aliased to JodConverter settings if they are not set up. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerPropertiesTest -{ - @Mock - private ChildApplicationContextFactory subsystem; - - private TransformerProperties transformerProperties; - private Properties globalProperties; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - globalProperties = new Properties(); - transformerProperties = new TransformerProperties(subsystem, globalProperties); - } - - @Test - public void aliasOpenOfficeToJodTest() - { - when(subsystem.getProperty(Matchers.any())).thenReturn(null); - - // Should be picked up as normal - globalProperties.setProperty("content.transformer.complex.JodConverter.Image.priority", "150"); - - // JodConverter value should override the OpenOffice value - globalProperties.setProperty("content.transformer.complex.OpenOffice.Image.extensions.docx.txt.supported", "true"); - globalProperties.setProperty("content.transformer.complex.JodConverter.Image.extensions.docx.txt.supported", "false"); - - // Should be picked up as a JodConverter value - globalProperties.setProperty("content.transformer.complex.OpenOffice.Image.extensions.xlsb.txt.maxSourceSizeKBytes", "1024"); - - Set propertyNames = transformerProperties.getPropertyNames(); - - assertEquals("The combined settings should be seen as only three entries", 3, propertyNames.size()); - assertTrue(propertyNames.contains("content.transformer.complex.JodConverter.Image.priority")); - assertTrue(propertyNames.contains("content.transformer.complex.JodConverter.Image.extensions.docx.txt.supported")); - assertTrue(propertyNames.contains("content.transformer.complex.JodConverter.Image.extensions.xlsb.txt.maxSourceSizeKBytes")); - - assertEquals("150", transformerProperties.getProperty("content.transformer.complex.JodConverter.Image.priority")); - assertEquals("false", transformerProperties.getProperty("content.transformer.complex.JodConverter.Image.extensions.docx.txt.supported")); - assertEquals("1024", transformerProperties.getProperty("content.transformer.complex.JodConverter.Image.extensions.xlsb.txt.maxSourceSizeKBytes")); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertyGetterTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertyGetterTest.java deleted file mode 100644 index a4c5dd802f..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertyGetterTest.java +++ /dev/null @@ -1,479 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockMimetypes; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.mockProperties; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for TransformerPropertyGetter. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerPropertyGetterTest -{ - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - @Mock - ContentTransformerRegistry transformerRegistry; - - @Mock - TransformerLog transformerLog; - - @Mock - TransformerDebugLog transformerDebugLog; - - private ContentTransformer transformer1; - private ContentTransformer transformer2; - private ContentTransformer transformer3; - - private class DummyContentTransformer2 extends AbstractContentTransformer2 { - private final String name; - - DummyContentTransformer2(String name) - { - this.name = name; - } - - @Override - public String getName() - { - return name; - } - - @Override - protected void transformInternal(ContentReader reader, ContentWriter writer, - TransformationOptions options) throws Exception - { - }}; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - transformer1 = new DummyContentTransformer2("transformer.transformer1"); - transformer2 = new DummyContentTransformer2("transformer.transformer2"); - transformer3 = new DummyContentTransformer2("transformer.transformer3"); - - when(transformerLog.getPropertyName()).thenReturn("transformer.log.entries"); - when(transformerDebugLog.getPropertyName()).thenReturn("transformer.debug.entries"); - - when(transformerProperties.getDefaultProperties()).thenReturn(new Properties()); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png", - "text/plain", "txt"); - } - - public static void mockAllTransformers(ContentTransformerRegistry transformerRegistry, ContentTransformer... transformers) - { - List allTransformers = new ArrayList(); - for (ContentTransformer transformer: transformers) - { - allTransformers.add(transformer); - } - when(transformerRegistry.getAllTransformers()).thenReturn(allTransformers); - } - - @Test - public void logEntriesTest() - { - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n", actual); - } - - @Test - public void miscTest() - { - Properties defaultProperties = new Properties(); - defaultProperties.setProperty("transformer.another", "aValue"); - defaultProperties.setProperty("transformer.yet.another", "77"); - defaultProperties.setProperty("transformer.strict.mimetype.check.whitelist.mimetypes", "application/eps;application/postscript;application/illustrator;application/pdf"); - when(transformerProperties.getDefaultProperties()).thenReturn(defaultProperties); - - mockProperties(transformerProperties, - "transformer.strict.mimetype.check.whitelist.mimetypes", "application/eps;application/postscript;application/illustrator;application/pdf", // same value - "transformer.another", "aNewValue"); // changed value - - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Miscellaneous settings\n" + - "# ======================\n" + - "transformer.another=aNewValue # default=aValue\n" + - "# transformer.strict.mimetype.check.whitelist.mimetypes=application/eps;application/postscript;application/illustrator;application/pdf\n" + - "# transformer.yet.another=77\n", - actual); - } - - @Test - public void defaultTest() - { - mockProperties(transformerProperties, - "content.transformer.default.priority", "100", - "content.transformer.default.count", "0", - "content.transformer.default.maxPages.use.XXX", "88"); - - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Default transformer settings\n" + - "# ============================\n" + - "content.transformer.default.count=0\n" + - "content.transformer.default.maxPages.use.XXX=88\n"+ - "content.transformer.default.priority=100\n", actual); - } - - @Test - public void defaultWithOverridesTest() - { - defaultWithOverridesTest(false, - "# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Default transformer settings\n" + - "# ============================\n" + - "# content.transformer.default.count=0\n" + - "content.transformer.default.maxPages.use.XXX=88 # default=77\n"+ - "content.transformer.default.priority=100 # default=111\n"); - } - - @Test - public void defaultWithOnlyOverridesTest() - { - defaultWithOverridesTest(true, - "# Default transformer settings\n" + - "# ============================\n" + - "content.transformer.default.maxPages.use.XXX=88 # default=77\n"+ - "content.transformer.default.priority=100 # default=111\n"); - } - - private void defaultWithOverridesTest(boolean onlyChanges, String expected) - { - Properties defaultProperties = new Properties(); - defaultProperties.setProperty("content.transformer.default.priority", "111"); - defaultProperties.setProperty("content.transformer.default.count", "0"); - defaultProperties.setProperty("content.transformer.default.maxPages.use.XXX", "77"); - when(transformerProperties.getDefaultProperties()).thenReturn(defaultProperties); - - mockProperties(transformerProperties, - "content.transformer.default.priority", "100", - "content.transformer.default.count", "0", - "content.transformer.default.maxPages.use.XXX", "88"); - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(onlyChanges, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals(expected, actual); - } - - @Test - public void allSuffixesTest() - { - mockProperties(transformerProperties, - "content.transformer.transformer1.timeoutMs", "1", - "content.transformer.transformer1.extensions.pdf.png.readLimitTimeMs", "2", - "content.transformer.transformer1.maxSourceSizeKBytes", "3", - "content.transformer.transformer1.extensions.pdf.png.readLimitKBytes", "4", - "content.transformer.transformer1.maxPages", "5", - "content.transformer.transformer1.extensions.pdf.png.pageLimit", "6", - "content.transformer.transformer1.maxPages.use.index", "12", - "content.transformer.transformer1.maxPages.use.webpreview", "13", - - "content.transformer.transformer1.extensions.pdf.png.supported", "true", - "content.transformer.transformer1.priority", "7", - "content.transformer.transformer1.errorTime", "8", - "content.transformer.transformer2.time", "9", - "content.transformer.transformer2.count", "10", - "content.transformer.transformer1.thresholdCount", "11", - "content.transformer.transformer1.failover", "qwe|qaz", - "content.transformer.transformer1.pipeline", "qwe|pdf|qaz"); - - when(transformerRegistry.getTransformer("transformer.transformer1")).thenReturn(transformer1); - when(transformerRegistry.getTransformer("transformer.transformer2")).thenReturn(transformer2); - when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {transformer1, transformer2})); - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Transformers with configuration settings\n" + - "# ========================================\n" + - "# Commented out settings are hard coded values for information purposes\n" + - "\n" + - "# transformer1\n" + - "# ------------\n" + - "content.transformer.transformer1.pipeline=qwe|pdf|qaz\n" + - "content.transformer.transformer1.errorTime=8\n" + - "content.transformer.transformer1.failover=qwe|qaz\n" + - "content.transformer.transformer1.maxPages=5\n" + - "content.transformer.transformer1.maxPages.use.index=12\n"+ - "content.transformer.transformer1.maxPages.use.webpreview=13\n"+ - "content.transformer.transformer1.maxSourceSizeKBytes=3\n" + - "content.transformer.transformer1.priority=7\n" + - "content.transformer.transformer1.thresholdCount=11\n" + - "content.transformer.transformer1.timeoutMs=1\n" + - "content.transformer.transformer1.extensions.pdf.png.pageLimit=6\n" + - "content.transformer.transformer1.extensions.pdf.png.readLimitKBytes=4\n" + - "content.transformer.transformer1.extensions.pdf.png.readLimitTimeMs=2\n" + - "content.transformer.transformer1.extensions.pdf.png.supported=true\n" + - "\n" + - "# transformer2\n"+ - "# ------------\n" + - "content.transformer.transformer2.count=10\n"+ - "content.transformer.transformer2.time=9\n", actual); - } - - @Test - public void normalTest() - { - normalTest(true); - } - - @Test - // Output for a transformer that may only be used as part of another transformer - public void normalComponentTest() - { - normalTest(false); - } - - private void normalTest(boolean isAvailable) - { - AbstractContentTransformer2 simple = new AbstractContentTransformer2() { - @Override - protected void transformInternal(ContentReader reader, ContentWriter writer, - TransformationOptions options) throws Exception - { - }}; - simple.setBeanName("transformer.exampleSimple"); - - when(transformerRegistry.getAllTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {(ContentTransformer)simple})); - if (isAvailable) - { - when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {(ContentTransformer)simple})); - } - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Transformers without extra configuration settings\n" + - "# =================================================\n" + - "\n" + - "# exampleSimple\n" + - "# -------------\n" + - (isAvailable ? "" : "# content.transformer.exampleSimple.available=false\n"), actual); - } - - @Test - public void complexTest() - { - complexTest(true); - } - - @Test - // Output for a transformer that may only be used as part of another transformer - public void complexComponentTest() - { - complexTest(false); - } - - private void complexTest(boolean isAvailable) - { - ComplexContentTransformer complex = new ComplexContentTransformer(); - complex.setTransformers(Arrays.asList(new ContentTransformer[] {transformer1, transformer2, transformer3})); - complex.setIntermediateMimetypes(Arrays.asList(new String[] {"application/pdf", null})); - complex.setBeanName("transformer.examplePipeline"); - complex.setMimetypeService(mimetypeService); - - if (isAvailable) - { - when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {complex, transformer1, transformer2, transformer3})); - } - else - { - when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {transformer1, transformer2, transformer3})); - } - when(transformerRegistry.getAllTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {complex, transformer1, transformer2, transformer3})); - - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Transformers without extra configuration settings\n" + - "# =================================================\n" + - "\n" + - "# examplePipeline\n" + - "# ---------------\n" + - (isAvailable ? "" : "# content.transformer.examplePipeline.available=false\n") + - "# content.transformer.examplePipeline.pipeline=transformer1|pdf|transformer2||transformer3\n"+ - "\n" + - "# transformer1\n" + - "# ------------\n" + - "\n" + - "# transformer2\n" + - "# ------------\n" + - "\n" + - "# transformer3\n" + - "# ------------\n", actual); - } - - @Test - public void failoverTest() - { - failoverTest(true); - } - - @Test - // Output for a failover transformer that may only be used as part of another transformer - public void failoverComponentTest() - { - failoverTest(false); - } - - private void failoverTest(boolean isAvailable) - { - FailoverContentTransformer failover = new FailoverContentTransformer(); - failover.setTransformers(Arrays.asList(new ContentTransformer[] {transformer1, transformer2})); - failover.setBeanName("transformer.exampleFailover"); - - if (isAvailable) - { - when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {failover, transformer1, transformer2})); - } - else - { - when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {transformer1, transformer2})); - } - when(transformerRegistry.getAllTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {failover, transformer1, transformer2})); - - when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); - when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); - - String actual = new TransformerPropertyGetter(false, transformerProperties, - mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); - - assertEquals("# LOG and DEBUG history sizes\n" + - "# ===========================\n" + - "# Use small values as these logs are held in memory. 0 to disable.\n" + - "# transformer.log.entries=0\n" + - "# transformer.debug.entries=0\n" + - "\n" + - "# Transformers without extra configuration settings\n" + - "# =================================================\n" + - "\n" + - "# exampleFailover\n" + - "# ---------------\n" + - (isAvailable ? "" : "# content.transformer.exampleFailover.available=false\n") + - "# content.transformer.exampleFailover.failover=transformer1|transformer2\n" + - "\n" + - "# transformer1\n" + - "# ------------\n" + - "\n" + - "# transformer2\n" + - "# ------------\n", actual); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertyNameExtractorTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertyNameExtractorTest.java deleted file mode 100644 index 0aefc1c251..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertyNameExtractorTest.java +++ /dev/null @@ -1,721 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.alfresco.repo.content.transform.TransformerConfig.ANY; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicInteger; - -import org.alfresco.service.cmr.repository.MimetypeService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for some of the regex methods and TransformerPropertyNameExtractor in general. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -@SuppressWarnings("deprecation") -public class TransformerPropertyNameExtractorTest -{ - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - private Map map; - - private TestTransformerPropertyNameExtractor extractor; - - private Collection suffixes = Collections.singleton(".suffix"); - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - extractor = new TestTransformerPropertyNameExtractor(); - - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png"); - } - - /** - * Mock up the responses from the subsystem so that it returns all the supplied - * property names and values. - * @param transformerProperties to mock the return values - * @param namesAndValues a sequence of property names and values. - * @throws IllegalStateException if there is not a value for every property - */ - public static void mockProperties(TransformerProperties transformerProperties, String... namesAndValues) - { - if (namesAndValues.length % 2 != 0) - { - // Not using IllegalArgumentException as this is thrown by classes under test - throw new java.lang.IllegalStateException("There should be a value for every property"); - } - - final Set propertyNames = new TreeSet(); - for (int i=0; i < namesAndValues.length; i+=2) - { - String name = namesAndValues[i]; - String value = namesAndValues[i+1]; - if (name.startsWith(TransformerConfig.PREFIX)) - { - propertyNames.add(name); - } - when(transformerProperties.getProperty(name)).thenReturn(value); - } - when(transformerProperties.getPropertyNames()).thenReturn(propertyNames); - } - - /** - * Mock up the responses from the mimetypeService so that it: - * a) returns all the supplied mimetypes - * b) returns the extension given the mimetype - * c) returns the mimetype given the extension. - * @param mimetypeService mimetype service - * @param mimetypesAndExtensions sequence of mimetypes and extenstions. - * @throws IllegalStateException if there is not an extension for every mimetype - */ - public static void mockMimetypes(MimetypeService mimetypeService, String... mimetypesAndExtensions) - { - if (mimetypesAndExtensions.length % 2 != 0) - { - // Not using IllegalArgumentException as this is thrown by classes under test - throw new java.lang.IllegalStateException("There should be an extension for every mimetype"); - } - - final Set allMimetypes = new HashSet(); - for (int i=0; i < mimetypesAndExtensions.length; i+=2) - { - allMimetypes.add(mimetypesAndExtensions[i]); - when(mimetypeService.getExtension(mimetypesAndExtensions[i])).thenReturn(mimetypesAndExtensions[i+1]); - when(mimetypeService.getMimetype(mimetypesAndExtensions[i+1])).thenReturn(mimetypesAndExtensions[i]); - } - when(mimetypeService.getMimetypes()).thenReturn(new ArrayList(allMimetypes)); - } - - /** - * Asserts two List are equal after they are sorted. - * @param msg to be included in the assertEquals call. - * @param expected list - * @param actual list - */ - public void assertEqualsLists(String msg, List expected, List actual) - { - if (expected.size() > 1) - { - Collections.sort(expected); - } - if (actual.size() > 1) - { - Collections.sort(actual); - } - - assertEquals(msg, expected, actual); - } - - @Test - public void textSplitExt() - { - String[][] values = new String[][] - { - {"AAA.BBB", "AAA", "BBB"}, - {"AA\\.BB.CC\\.DD\\.EE", "AA.BB", "CC.DD.EE"}, - }; - - for (String[] args: values) - { - String input = args[0]; - String expectedSource = args[1]; - String expectedTarget = args[2]; - - String[] sourceTarget = extractor.splitExt(input); - assertEquals("length", sourceTarget.length, 2); - assertEquals("source", expectedSource, sourceTarget[0]); - assertEquals("target", expectedTarget, sourceTarget[1]); - } - } - - @Test - public void testPattern() - { - assertTrue( extractor.pattern("ABC").matcher("ABC").matches()); - assertFalse(extractor.pattern("ABC").matcher("x").matches()); - assertFalse(extractor.pattern("ABC").matcher("ABCD").matches()); - assertFalse(extractor.pattern("ABC").matcher("DABC").matches()); - - assertTrue( extractor.pattern("*B").matcher("B").matches()); - assertTrue( extractor.pattern("*B").matcher("xxB").matches()); - assertFalse(extractor.pattern("*B").matcher("xxBx").matches()); - assertFalse(extractor.pattern("B*").matcher("").matches()); - - assertTrue( extractor.pattern("C*").matcher("C").matches()); - assertTrue( extractor.pattern("C*").matcher("CxxB").matches()); - assertFalse(extractor.pattern("C*").matcher("xxBx").matches()); - - assertTrue(extractor.pattern("D*E*F").matcher("DEF").matches()); - assertTrue(extractor.pattern("D*E*F").matcher("DxxExxF").matches()); - assertTrue(extractor.pattern("D*E*F").matcher("D*E*F").matches()); - - assertTrue( extractor.pattern("A+").matcher("A+").matches()); - assertFalse(extractor.pattern("A+").matcher("AA").matches()); - assertFalse(extractor.pattern("A+").matcher("AAA").matches()); - assertFalse(extractor.pattern("A+").matcher("A+A").matches()); - } - - @Test - public void getMatchingExtensionsFromMimetypesTest() - { - mockMimetypes(mimetypeService, - "mimetypeAx", "aExt", - "mimetypeBx", "bExt", - "mimetypeC", "cExt"); - - String[][] data = new String[][] - { - {"*C", "cExt"}, - {"*ypeAx", "aExt"}, - {"mimetype*x", "aExt bExt"}, - {"mimetypeBx", "bExt"}, - {"*mime*", "aExt bExt cExt"}, - {"*", ANY}, // special meaning on its own - {"", null}, - {"bad", null} - }; - - for (String[] entry: data) - { - List expected = entry[1] == null ? Collections.emptyList() : Arrays.asList(entry[1].split(" ")); - List actual = extractor.getMatchingExtensionsFromMimetypes(entry[0], mimetypeService); - assertEqualsLists("getMatchingExtensionsFromMimetypes("+entry[0]+")", expected, actual); - - } - } - - @Test - public void getMatchingExtensionsFromExtensionsTest() - { - mockMimetypes(mimetypeService, - "mimetypeAx", "aExt", - "mimetypeBx", "bExt", - "mimetypeC", "cExt"); - - String[][] data = new String[][] - { - {"c*", "cExt"}, - {"*a*", "aExt"}, - {"a*xt", "aExt"}, - {"*Ext", "aExt bExt cExt"}, - {"*t", "aExt bExt cExt"}, - {"*", ANY}, // special meaning on its own - {"", null}, - {"bad", null} - }; - - for (String[] entry: data) - { - List expected = entry[1] == null ? Collections.emptyList() : Arrays.asList(entry[1].split(" ")); - List actual = extractor.getMatchingExtensionsFromExtensions(entry[0], mimetypeService); - assertEqualsLists("getMatchingExtensionsFromMimetypes("+entry[0]+")", expected, actual); - } - } - - @Test - public void transformerSourceTargetSuffixKeyHashCodeEqualsTest() - { - // Test data - String[][] data = new String[][] - { - {"transformerName", "sourceExt", "targetExt", ".suffix", null}, - {"XXXXXXXXXXXXXXX", "sourceExt", "targetExt", ".suffix", null}, - {"transformerName", "XXXXXXXXX", "targetExt", ".suffix", null}, - {"transformerName", "sourceExt", "XXXXXXXXX", ".suffix", null}, - {"transformerName", "sourceExt", "targetExt", ".XXXXXX", null}, - {"transformerName", "sourceExt", "targetExt", ".suffix", "index"}, - {"XXXXXXXXXXXXXXX", "sourceExt", "targetExt", ".suffix", "index"}, - {"transformerName", "XXXXXXXXX", "targetExt", ".suffix", "index"}, - {"transformerName", "sourceExt", "XXXXXXXXX", ".suffix", "index"}, - {"transformerName", "sourceExt", "targetExt", ".XXXXXX", "index"} - }; - - for (int i=data.length+1; i >= 0; i--) - { - // Check properties are set - Object a = i == data.length+1 ? "" : i == data.length ? null : new TransformerSourceTargetSuffixKey(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4]); - if (a instanceof TransformerSourceTargetSuffixKey) - { - assertEquals(i+" transformerName", ((TransformerSourceTargetSuffixKey)a).transformerName, data[i][0]); - assertEquals(i+" sourceExt", ((TransformerSourceTargetSuffixKey)a).sourceExt, data[i][1]); - assertEquals(i+" targetExt", ((TransformerSourceTargetSuffixKey)a).targetExt, data[i][2]); - assertEquals(i+" suffix", ((TransformerSourceTargetSuffixKey)a).suffix, data[i][3]); - assertEquals(i+" use", ((TransformerSourceTargetSuffixKey)a).use, data[i][4]); - } - - // Try out the hashCode and equals methods - for (int j=data.length+1; j >= 0; j--) - { - Object b = j == data.length+1 ? "" : j == data.length ? null : new TransformerSourceTargetSuffixKey(data[j][0], data[j][1], data[j][2], data[j][3], data[j][4]); - if (a != null) - { - if (i == j) - { - assertTrue( i+" "+j+" equals", a.equals(b)); - assertEquals(i+" "+j+" hashCode", a.hashCode(), b.hashCode()); - } - else - { - assertFalse( i+" "+j+" equals ", a.equals(b)); - if (b != null) - { - assertFalse(i+" "+j+" hashCode", a.hashCode() == b.hashCode()); - } - } - } - } - } - } - - @Test - public void transformerSourceTargetSuffixValueHashCodeEqualsTest() - { - mockMimetypes(mimetypeService, - "sourceMimetype", "sourceExt", - "sourceXXXXXXXX", "sourceXXX", - "targetMimetype", "targetExt", - "targetXXXXXXXX", "targetXXX"); - - // Test data - String[][] data = new String[][] - { - {"transformerName", "sourceExt", "targetExt", ".suffix", null, "value", "sourceMimetype", "targetMimetype"}, - {"XXXXXXXXXXXXXXX", "sourceExt", "targetExt", ".suffix", null, "value", "sourceMimetype", "targetMimetype"}, - {"transformerName", "sourceXXX", "targetExt", ".suffix", null, "value", "sourceXXXXXXXX", "targetMimetype"}, - {"transformerName", "sourceExt", "targetXXX", ".suffix", null, "value", "sourceMimetype", "targetXXXXXXXX"}, - {"transformerName", "sourceExt", "targetExt", ".XXXXXX", null, "value", "sourceMimetype", "targetMimetype"}, - {"transformerName", "sourceExt", "targetExt", ".suffix", null, "XXXXX", "sourceMimetype", "targetMimetype"}, - {"transformerName", "sourceExt", "targetExt", ".suffix", "index", "value", "sourceMimetype", "targetMimetype"}, - {"XXXXXXXXXXXXXXX", "sourceExt", "targetExt", ".suffix", "index", "value", "sourceMimetype", "targetMimetype"}, - {"transformerName", "sourceXXX", "targetExt", ".suffix", "index", "value", "sourceXXXXXXXX", "targetMimetype"}, - {"transformerName", "sourceExt", "targetXXX", ".suffix", "index", "value", "sourceMimetype", "targetXXXXXXXX"}, - {"transformerName", "sourceExt", "targetExt", ".XXXXXX", "index", "value", "sourceMimetype", "targetMimetype"}, - {"transformerName", "sourceExt", "targetExt", ".suffix", "index", "XXXXX", "sourceMimetype", "targetMimetype"} - }; - - for (int i=data.length+1; i >= 0; i--) - { - // Check properties are set - Object a = i == data.length+1 ? "" : i == data.length ? null : new TransformerSourceTargetSuffixValue(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5], mimetypeService); - if (a instanceof TransformerSourceTargetSuffixValue) - { - assertEquals(i+" transformerName", data[i][0], ((TransformerSourceTargetSuffixValue)a).transformerName); - assertEquals(i+" sourceExt", data[i][1], ((TransformerSourceTargetSuffixValue)a).sourceExt); - assertEquals(i+" targetExt", data[i][2], ((TransformerSourceTargetSuffixValue)a).targetExt); - assertEquals(i+" suffix", data[i][3], ((TransformerSourceTargetSuffixValue)a).suffix); - assertEquals(i+" use", data[i][4], ((TransformerSourceTargetSuffixValue)a).use); - - assertEquals(i+" value", data[i][5], ((TransformerSourceTargetSuffixValue)a).value); - assertEquals(i+" sourceMimetype", data[i][6], ((TransformerSourceTargetSuffixValue)a).sourceMimetype); - assertEquals(i+" targetMimetype", data[i][7], ((TransformerSourceTargetSuffixValue)a).targetMimetype); - - assertEquals(i+" key", - new TransformerSourceTargetSuffixKey(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4]), - ((TransformerSourceTargetSuffixValue)a).key()); - } - - // Try out the hashCode and equals methods - for (int j=data.length+1; j >= 0; j--) - { - Object b = j == data.length+1 ? "" : j == data.length ? null : new TransformerSourceTargetSuffixValue(data[j][0], data[j][1], data[j][2], data[j][3], data[j][4], data[j][5], mimetypeService); - if (a != null) - { - if (i == j) - { - assertTrue( i+" "+j+" equals", a.equals(b)); - assertEquals(i+" "+j+" hashCode", a.hashCode(), b.hashCode()); - } - else - { - assertFalse( i+" "+j+" equals ", a.equals(b)); - if (b != null) - { - assertFalse(i+" "+j+" hashCode", a.hashCode() == b.hashCode()); - } - } - } - } - } - } - - @Test - public void transformerSourceTargetSuffixValuetoStringTest() - { - mockMimetypes(mimetypeService, - "sourceMimetype", "sourceExt", - "targetMimetype", "targetExt"); - - // Test data - String[][] data = new String[][] - { - {"transformerName", "sourceExt", "targetExt", ".suffix", null, "value", "transformerName.extensions.sourceExt.targetExt.suffix=value"}, - {"transformerName", "sourceExt", "targetExt", ".suffix", "index", "value", "transformerName.extensions.sourceExt.targetExt.suffix.use.index=value"}, - {"transformerName", ANY, ANY, ".suffix", null, "value", "transformerName.suffix=value"} - }; - - for (int i=data.length-1; i >= 0; i--) - { - // Check properties are set - TransformerSourceTargetSuffixValue a = new TransformerSourceTargetSuffixValue(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5], mimetypeService); - assertEquals(i+" toString", data[i][6], a.toString()); - } - } - - @Test - public void getPropertyTest() - { - mockMimetypes(mimetypeService, - "sourceMimetype", "sourceExt", - "sourceAAAAAAAA", "sourceAAA", - "targetMimetype", "targetExt"); - - // Test data - String[][] data = new String[][] - { - {"transformerName", "sourceExt", "targetExt", ".suffix", null, "value1"}, - {"transformerName", null, null, ".suffix", null, "value2"}, - {"transformerName", ANY, ANY, ".suffix", null, "value2"}, - {"transformerName", "sourceAAA", "targetExt", ".suffix", null, "value3"}, - {"transformerXXXX", null, null, ".suffix", null, null}, - {"transformerName", "sourceExt", "targetExt", ".suffix", "index", "value4"}, - {"transformerName", null, null, ".suffix", "index", "value5"}, - {"transformerName", ANY, ANY, ".suffix", "index", "value5"}, - {"transformerName", "sourceAAA", "targetExt", ".suffix", "index", "value6"}, - {"transformerXXXX", null, null, ".suffix", "index", null} - }; - - // Populate the test Map - Map transformerSourceTargetSuffixValues = - new HashMap(); - for (int i=data.length-1; i >= 0; i--) - { - TransformerSourceTargetSuffixValue keyValue = new TransformerSourceTargetSuffixValue(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], data[i][5], mimetypeService); - transformerSourceTargetSuffixValues.put(keyValue.key(), keyValue); - } - - // Check we can return the values including the last one which was not added so has a null value - for (int i=data.length-1; i >= 0; i--) - { - assertEquals(i+" getProperty", data[i][5], extractor.getProperty(data[i][0], data[i][1], data[i][2], data[i][3], data[i][4], transformerSourceTargetSuffixValues)); - } - } - - @Test - public void transformerWideTest() - { - mockProperties(transformerProperties, "content.transformer.abc.suffix", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("value1", extractor.getProperty("transformer.abc", null, null, ".suffix", null, map)); - } - - @Test - public void excludeSummaryTest() - { - mockProperties(transformerProperties, "content.transformer.abc.suffix", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, false, true, false, transformerProperties, mimetypeService); - - assertEquals(null, extractor.getProperty("transformer.abc", null, null, ".suffix", null, map)); - } - - @Test - public void extensionTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.pdf.png.suffix", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("value1", extractor.getProperty("transformer.abc", "pdf", "png", ".suffix", null, map)); - } - - @Test - public void excludeExtensionsTest() - { - mockProperties(transformerProperties, "content.transformer.abc.extensions.pdf.png.suffix", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, false, false, transformerProperties, mimetypeService); - - assertEquals(null, extractor.getProperty("transformer.abc", "pdf", "png", ".suffix", null, map)); - } - - @Test - public void mimetypeTest() - { - mockProperties(transformerProperties, "content.transformer.abc.mimetypes.application/pdf.image/png.suffix", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("value1", extractor.getProperty("transformer.abc", "pdf", "png", ".suffix", null, map)); - } - - @Test - public void multipleSuffix1Test() - { - suffixes = Arrays.asList(new String[] {".suffix1", ".suffix2", ".suffix3", ".suffix4"}); - mockProperties(transformerProperties, "content.transformer.abc.suffix1", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("value1", extractor.getProperty("transformer.abc", null, null, ".suffix1", null, map)); - } - - @Test - public void multipleSuffix4Test() - { - suffixes = Arrays.asList(new String[] {".suffix1", ".suffix2", ".suffix3", ".suffix4"}); - mockProperties(transformerProperties, "content.transformer.abc.suffix4", "value1"); - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("value1", extractor.getProperty("transformer.abc", null, null, ".suffix4", null, map)); - } - - @Test - public void noPrefixTest() - { - mockProperties(transformerProperties, "the.cat.sat", "on the mat"); - extractor = new TestTransformerPropertyNameExtractor(); - - assertEquals(0, extractor.getTransformerSourceTargetValues(suffixes, true, false, transformerProperties, mimetypeService).size()); - } - - @Test - public void multipleValuesTest() - { - suffixes = TransformerConfig.LIMIT_SUFFIXES; - mockProperties(transformerProperties, - "content.transformer.abc.maxSourceSizeKBytes", "1", - "content.transformer.abc.timeoutMs", "2", - "content.transformer.abc.extensions.pdf.png.maxPages", "3", - "content.transformer.x.y.mimetypes.application/pdf.image/png.maxPages", "4", - "content.transformer.abc.maxSourceSizeKBytes.use.index", "5", - "content.transformer.abc.timeoutMs.use.index", "6", - "content.transformer.abc.extensions.pdf.png.maxPages.use.index", "7", - "content.transformer.x.y.mimetypes.application/pdf.image/png.maxPages.use.index", "8"); - - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("1", extractor.getProperty("transformer.abc", null, null, ".maxSourceSizeKBytes", null, map)); - assertEquals("2", extractor.getProperty("transformer.abc", null, null, ".timeoutMs", null, map)); - assertEquals("3", extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", null, map)); - assertEquals("4", extractor.getProperty("transformer.x.y", "pdf", "png", ".maxPages", null, map)); - assertEquals(null, extractor.getProperty("transformer.abc", null, null, ".maxSourceSizeKBytes", "index", map)); - assertEquals(null, extractor.getProperty("transformer.abc", null, null, ".timeoutMs", "index", map)); - assertEquals(null, extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", "index", map)); - assertEquals(null, extractor.getProperty("transformer.x.y", "pdf", "png", ".maxPages", "index", map)); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, true, transformerProperties, mimetypeService); - - assertEquals("1", extractor.getProperty("transformer.abc", null, null, ".maxSourceSizeKBytes", null, map)); - assertEquals("2", extractor.getProperty("transformer.abc", null, null, ".timeoutMs", null, map)); - assertEquals("3", extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", null, map)); - assertEquals("4", extractor.getProperty("transformer.x.y", "pdf", "png", ".maxPages", null, map)); - assertEquals("5", extractor.getProperty("transformer.abc", null, null, ".maxSourceSizeKBytes", "index", map)); - assertEquals("6", extractor.getProperty("transformer.abc", null, null, ".timeoutMs", "index", map)); - assertEquals("7", extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", "index", map)); - assertEquals("8", extractor.getProperty("transformer.x.y", "pdf", "png", ".maxPages", "index", map)); - } - - @Test - public void wildcardTest() - { - suffixes = TransformerConfig.LIMIT_SUFFIXES; - mockProperties(transformerProperties, - "content.transformer.abc.extensions.p*.*g.maxPages", "value"); - - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("pdf,png to png", 2, map.size()); - assertEquals("value", extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", null, map)); - assertEquals("value", extractor.getProperty("transformer.abc", "png", "png", ".maxPages", null, map)); - } - - @Test - public void mimetypeWinsOverExtensionFirstTest() - { - // Extension property is provided first - suffixes = TransformerConfig.LIMIT_SUFFIXES; - mockProperties(transformerProperties, - "content.transformer.abc.extensions.pdf.png.maxPages", "extension", - "content.transformer.abc.mimetypes.application/pdf.image/png.maxPages", "mimetype"); - - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("mimetype", extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", null, map)); - } - - @Test - public void mimetypeWinsOverExtensionSecondTest() - { - // Extension property is provided second - suffixes = TransformerConfig.LIMIT_SUFFIXES; - mockProperties(transformerProperties, - "content.transformer.abc.mimetypes.application/pdf.image/png.maxPages", "mimetype", - "content.transformer.abc.extensions.pdf.png.maxPages", "extension"); - - extractor = new TestTransformerPropertyNameExtractor(); - - map = extractor.getTransformerSourceTargetValuesMap(suffixes, true, true, false, transformerProperties, mimetypeService); - - assertEquals("mimetype", extractor.getProperty("transformer.abc", "pdf", "png", ".maxPages", null, map)); - } - - @Test - public void callsToHandlePropertyTest() - { - final String[][] data = new String[][] - { // Must sort the property names - {"content.transformer.abc.extensions.pdf.png.suffix", "value2", "transformer.abc", ".extensions.", "pdf", "png", ".suffix", null}, - {"content.transformer.abc.extensions.pdf.png.suffix.use.index", "value2", "transformer.abc", ".extensions.", "pdf", "png", ".suffix", "index"}, - - {"content.transformer.abc.mimetypes.application/pdf.image/png.suffix", "value2", "transformer.abc", ".mimetypes.", "application/pdf", "image/png", ".suffix", null}, - {"content.transformer.abc.mimetypes.application/pdf.image/png.suffix.use.index", "value2", "transformer.abc", ".mimetypes.", "application/pdf", "image/png", ".suffix", "index"}, - - {"content.transformer.abc.suffix", "value1", "transformer.abc", null, null, null, ".suffix", null}, - {"content.transformer.abc.suffix.use.index", "value1", "transformer.abc", null, null, null, ".suffix", "index"}, - - {"xxxx.transformer.abc.extensions.pdf.png.suffix", "value2", null}, - {"xxxx.transformer.abc.extensions.pdf.png.suffix.use.index", "value2", null} - }; - - List properties = new ArrayList(); - final Set suffixes = new HashSet(); - for (String[] entry: data) - { - properties.add(entry[0]); - properties.add(entry[1]); - if (entry.length == 8) - { - suffixes.add(entry[6]); - } - } - mockProperties(transformerProperties, properties.toArray(new String[properties.size()])); - - final AtomicInteger i = new AtomicInteger(0); - extractor = new TestTransformerPropertyNameExtractor() - { - protected void handleProperty(String transformerName, String separator, - String firstExpression, String secondExpression, String suffix, String use, String value, - String propertyName, - Map transformerSourceTargetSuffixValues, MimetypeService mimetypeService) - { - // Ignore non transformer properties - int j; - do - { - j = i.getAndIncrement(); - } while(j < data.length && data[j].length != 8); - - if (j < data.length) - { - assertEquals(j+" transformerName", data[j][2], transformerName); - assertEquals(j+" separator", data[j][3], separator); - assertEquals(j+" firstExpression", data[j][4], firstExpression); - assertEquals(j+" secondExpression", data[j][5], secondExpression); - assertEquals(j+" suffix", data[j][6], suffix); - assertEquals(j+" use", data[j][7], use); - assertEquals(j+" value", data[j][1], value); - assertEquals(j+" propertyName", data[j][0], propertyName); - } - - while(j+1 < data.length && data[j+1].length < 8) - { - j = i.getAndIncrement(); - } - - super.handleProperty(transformerName, separator, firstExpression, secondExpression, suffix, use, value, propertyName, transformerSourceTargetSuffixValues, mimetypeService); - } - }; - - extractor.callGetTransformerSourceTargetValuesMap(suffixes, true, transformerProperties, mimetypeService); - - assertEquals("counter", 8, i.get()); - } -} - -@Deprecated -@SuppressWarnings("deprecation") -class TestTransformerPropertyNameExtractor extends TransformerPropertyNameExtractor -{ - public Collection callGetTransformerSourceTargetValues(Collection suffixes, - boolean includeSummary, TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - return getTransformerSourceTargetValues(suffixes, includeSummary, false, transformerProperties, mimetypeService); - } - - public Map callGetTransformerSourceTargetValuesMap(Collection suffixes, - boolean includeSummary, TransformerProperties transformerProperties, MimetypeService mimetypeService) - { - return getTransformerSourceTargetValuesMap(suffixes, includeSummary, true, true, transformerProperties, mimetypeService); - } -}; - diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertySetterTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertySetterTest.java deleted file mode 100644 index a4feb06b93..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerPropertySetterTest.java +++ /dev/null @@ -1,739 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.junit.Assert.assertEquals; -import static org.alfresco.repo.content.transform.TransformerPropertyNameExtractorTest.*; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.alfresco.service.cmr.repository.ContentIOException; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Tests TransformerPropertySetter. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerPropertySetterTest -{ - @Mock - private TransformerProperties transformerProperties; - - @Mock - private MimetypeService mimetypeService; - - @Mock - private ContentTransformerRegistry transformerRegistry; - - private TransformerPropertySetter setter; - private Properties properties; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - mockAllTransformers(transformerRegistry, "abc", "complex.PDF.Image", "transformer1", "transformer2", "transformer3"); - mockMimetypes(mimetypeService, - "application/pdf", "pdf", - "image/png", "png"); - setter = new TransformerPropertySetter(transformerProperties, mimetypeService, transformerRegistry); - - properties = new Properties(); - when(transformerProperties.getDefaultProperties()).thenReturn(properties); - } - - public static void mockAllTransformers(ContentTransformerRegistry transformerRegistry, String... shortTransformerNames) - { - List allTransformers = new ArrayList(); - for (String shortTransformerName: shortTransformerNames) - { - allTransformers.add(new DummyContentTransformer(TransformerConfig.TRANSFORMER+shortTransformerName)); - } - when(transformerRegistry.getAllTransformers()).thenReturn(allTransformers); - } - - private Map expectedProperties(String... namesAndValues) - { - Map expected = new HashMap(); - String name = null; - for (String string: namesAndValues) - { - if (name == null) - { - name = string; - } - else - { - expected.put(name, string); - name = null; - } - } - return expected; - } - - private Collection expectedNames(String... names) - { - Set expected = new HashSet(); - expected.addAll(Arrays.asList(names)); - return expected; - } - - @Test - public void simpleTest() - { - int count = setter.setProperties("transformer.log.entries=12"); - - verify(transformerProperties).setProperties(expectedProperties("transformer.log.entries", "12")); - assertEquals("Added count", 1, count); - } - - @Test - public void debugLineSplitTest() - { - int count = setter.setProperties( - "transformer.log.entries=12\n" + - "transformer.debug.entries=23"); - - verify(transformerProperties).setProperties(expectedProperties( - "transformer.debug.entries", "23", - "transformer.log.entries", "12")); - assertEquals("Added count", 2, count); - } - - @Test - public void mixedCaseTest() - { - setter.setProperties("Transformer.LOG.entries=12"); - - verify(transformerProperties).setProperties(expectedProperties("Transformer.LOG.entries", "12")); - } - - @Test - public void debugLogSizeTest() - { - setter.setProperties( - "transformer.log.entries=12\n" + - "transformer.debug.entries=-1"); - - verify(transformerProperties).setProperties(expectedProperties( - "transformer.debug.entries", "-1", - "transformer.log.entries", "12")); - } - - @Test - public void mimetypeListTest() - { - setter.setProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes=image/png;application/pdf"); - - verify(transformerProperties).setProperties(expectedProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes", "image/png;application/pdf")); - } - - public void mimetypeListBlankTest() - { - setter.setProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes="); - - verify(transformerProperties).setProperties(expectedProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes", "")); - } - - @Test(expected=IllegalArgumentException.class) - public void mimetypeListUnevenTest() - { - setter.setProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes=image/png"); - } - - @Test(expected=IllegalArgumentException.class) - public void mimetypeListBadDeclaredTypeTest() - { - setter.setProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes=BAD;image/png"); - } - - public void mimetypeListBadDetectedTypeTest() - { - // Tika may detect a mimetype we have not registered, so let it through - setter.setProperties( - "transformer.strict.mimetype.check.whitelist.mimetypes=image/png;BAD"); - } - - @Test(expected=IllegalArgumentException.class) - public void badPropertyNameTest() - { - setter.setProperties("trans.bad=11"); - } - - @Test(expected=IllegalArgumentException.class) - public void duplicateNameTest() - { - setter.setProperties( - "transformer.log.entries=12\n" + - "transformer.log.entries=-1"); - } - - @Test(expected=IllegalArgumentException.class) - public void badIntegerTest() - { - setter.setProperties("transformer.debug.entries=--1"); - } - - @Test(expected=IllegalArgumentException.class) - public void badInteger2Test() - { - setter.setProperties("transformer.debug.entries=1a"); - } - - @Test(expected=IllegalArgumentException.class) - public void noValueEqualsTest() - { - // setProiperties must have an = - setter.setProperties("transformer.debug.entries"); - } - - @Test - public void booleanTest() - { - setter.setProperties("content.transformer.complex.PDF.Image.extensions.pdf.png.supported=TruE"); - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.complex.PDF.Image.extensions.pdf.png.supported", "TruE")); - } - - @Test(expected=IllegalArgumentException.class) - public void badBooleanTest() - { - setter.setProperties("content.transformer.complex.PDF.Image.extensions.pdf.png.supported=yes"); - } - - @Test - public void defaultTransformerTest() - { - setter.setProperties( - "content.transformer.default.priority=100\n"+ - "content.transformer.default.thresholdCount=3\n"+ - "content.transformer.default.time=0\n"+ - "content.transformer.default.count=100000\n"+ - "content.transformer.default.errorTime=120000\n"+ - "content.transformer.default.timeoutMs=120000\n"+ - "content.transformer.default.readLimitTimeMs=-1\n"+ - "content.transformer.default.maxSourceSizeKBytes=-1\n"+ - "content.transformer.default.readLimitKBytes=-1\n"+ - "content.transformer.default.pageLimit=-1\n"+ - "content.transformer.default.maxPages=-1"); - - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.default.priority", "100", - "content.transformer.default.thresholdCount", "3", - "content.transformer.default.time", "0", - "content.transformer.default.count", "100000", - "content.transformer.default.errorTime", "120000", - "content.transformer.default.timeoutMs", "120000", - "content.transformer.default.readLimitTimeMs", "-1", - "content.transformer.default.maxSourceSizeKBytes", "-1", - "content.transformer.default.readLimitKBytes", "-1", - "content.transformer.default.pageLimit", "-1", - "content.transformer.default.maxPages", "-1")); - } - - - @Test - public void defaultUseTransformerTest() - { - setter.setProperties( - "content.transformer.default.maxSourceSizeKBytes.use.doclib=67"); - - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.default.maxSourceSizeKBytes.use.doclib", "67")); - } - - @Test - public void commentAndWhiteSpaceTest() - { - setter.setProperties( - "# hi mum\n"+ - "content.transformer.default.priority=100\n"+ - " content.transformer.default.thresholdCount=3 \n"+ - "\t content.transformer.default.time=0\n"+ - "\t\t \t content.transformer.default.count=100000 # another comment\n"+ - "#\n"+ - " \n"+ - "\n"+ - "content.transformer.default.errorTime=120000\n"); - - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.default.priority", "100", - "content.transformer.default.thresholdCount", "3", - "content.transformer.default.time", "0", - "content.transformer.default.count", "100000", - "content.transformer.default.errorTime", "120000")); - } - - @Test - public void fixJConsolesMissingNewlinesTest() - { - // Variable names based on what JConsole does to newlines and what fixJConsolesMissingNewlines does to spaces - String nl2nl = "@"; - String nl2space = "~"; - String space2nl = "%"; - - String data = - "transformer.log.entries=12"+nl2nl+ - "transformer.log.entries=-1"+nl2space+ - "# a line of comment"+nl2nl+ - "content.transformer.default.priority=100"+nl2space+ - "#"+nl2space+ // Will discard the next property, but this is still best we can do - "content.transformer.default.thresholdCount=3 "+nl2nl+ - "content.transformer.default.time=0 # end of line comment "+nl2nl+ - "content.transformer.default.count=100000 "+nl2space+ - " "+space2nl+"content.transformer.default.errorTime=120000 "+nl2nl+ - "content.transformer.default.timeoutMs=120000 "+nl2nl+ - "content.transformer.default.readLimitTimeMs=-1"; - - // What we paste into JConsole - String original = data.replace(nl2nl, "\n").replace(nl2space, "\n").replace(space2nl, " "); - - // What we get from JConsole - String missingNl = data.replace(nl2nl, " ").replace(nl2space, " ").replace(space2nl, " "); - - // What we expect to recover as a result of this method - String expected = data.replace(nl2nl, "\n").replace(nl2space, " ").replace(space2nl, "\n"); - - // What we do get from fixJConsolesMissingNewlines - String actual = setter.fixJConsolesMissingNewlines(missingNl); - - String indentOriginal = ("\n"+original).replaceAll("\n", "\n "); - assertEquals("Having entered:"+indentOriginal+"\n", expected, actual); - } - - @Test(expected=IllegalArgumentException.class) - public void midNameWhiteSpaceTest() - { - setter.setProperties("transformer. log.entries=12"); - } - - @Test(expected=IllegalArgumentException.class) - public void prefixValueWhiteSpaceTest() - { - setter.setProperties("transformer.log.entries= 12"); - } - - @Test - public void namedTransformerTest() - { - setter.setProperties( - "content.transformer.abc.priority=100\n"+ - "content.transformer.abc.thresholdCount=3\n"+ - "content.transformer.abc.time=0\n"+ - "content.transformer.abc.count=100000\n"+ - "content.transformer.abc.errorTime=120000\n"+ - "content.transformer.abc.timeoutMs=120000\n"+ - "content.transformer.abc.readLimitTimeMs=-1\n"+ - "content.transformer.abc.maxSourceSizeKBytes=-1\n"+ - "content.transformer.abc.readLimitKBytes=-1\n"+ - "content.transformer.abc.pageLimit=-1\n"+ - "content.transformer.abc.maxPages=-1\n"+ - "content.transformer.abc.failover=transformer1|transformer2|transformer3\n"+ - "content.transformer.abc.pipeline=transformer1|pdf|transformer2"); - - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.abc.priority", "100", - "content.transformer.abc.thresholdCount", "3", - "content.transformer.abc.time", "0", - "content.transformer.abc.count", "100000", - "content.transformer.abc.errorTime", "120000", - "content.transformer.abc.timeoutMs", "120000", - "content.transformer.abc.readLimitTimeMs", "-1", - "content.transformer.abc.maxSourceSizeKBytes", "-1", - "content.transformer.abc.readLimitKBytes", "-1", - "content.transformer.abc.pageLimit", "-1", - "content.transformer.abc.maxPages", "-1", - "content.transformer.abc.failover", "transformer1|transformer2|transformer3", - "content.transformer.abc.pipeline", "transformer1|pdf|transformer2")); - } - - @Test - public void simpleExtensionsTest() - { - setter.setProperties("content.transformer.abc.extensions.pdf.png.maxPages=-1"); - } - - @Test - public void namedTransformerExtensionTest() - { - setter.setProperties( - "content.transformer.abc.extensions.pdf.png.priority=100\n"+ - "content.transformer.abc.extensions.pdf.png.thresholdCount=3\n"+ - "content.transformer.abc.extensions.pdf.png.time=0\n"+ - "content.transformer.abc.extensions.pdf.png.count=100000\n"+ - "content.transformer.abc.extensions.pdf.png.errorTime=120000\n"+ - "content.transformer.abc.extensions.pdf.png.timeoutMs=120000\n"+ - "content.transformer.abc.extensions.pdf.png.readLimitTimeMs=-1\n"+ - "content.transformer.abc.extensions.pdf.png.maxSourceSizeKBytes=-1\n"+ - "content.transformer.abc.extensions.pdf.png.readLimitKBytes=-1\n"+ - "content.transformer.abc.extensions.pdf.png.pageLimit=-1\n"+ - "content.transformer.abc.extensions.pdf.png.maxPages=-1\n"+ - "content.transformer.abc.extensions.pdf.png.supported=true"); - - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.abc.extensions.pdf.png.priority", "100", - "content.transformer.abc.extensions.pdf.png.thresholdCount", "3", - "content.transformer.abc.extensions.pdf.png.time", "0", - "content.transformer.abc.extensions.pdf.png.count", "100000", - "content.transformer.abc.extensions.pdf.png.errorTime", "120000", - "content.transformer.abc.extensions.pdf.png.timeoutMs", "120000", - "content.transformer.abc.extensions.pdf.png.readLimitTimeMs", "-1", - "content.transformer.abc.extensions.pdf.png.maxSourceSizeKBytes", "-1", - "content.transformer.abc.extensions.pdf.png.readLimitKBytes", "-1", - "content.transformer.abc.extensions.pdf.png.pageLimit", "-1", - "content.transformer.abc.extensions.pdf.png.maxPages", "-1", - "content.transformer.abc.extensions.pdf.png.supported", "true")); - } - - @Test(expected=IllegalArgumentException.class) - public void badSourceExtensionsTest() - { - setter.setProperties("content.transformer.abc.extensions.bad.png.maxPages=-1"); - } - - @Test(expected=IllegalArgumentException.class) - public void badTargetExtensionsTest() - { - setter.setProperties("content.transformer.abc.extensions.pdf.bad.maxPages=-1"); - } - - @Test - public void simpleMimetypeTest() - { - setter.setProperties("content.transformer.abc.mimetypes.application/pdf.image/png.maxPages=-1"); - } - - @Test - public void namedTransformerMimetypeTest() - { - setter.setProperties( - "content.transformer.abc.mimetypes.application/pdf.image/png.priority=100\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.thresholdCount=3\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.time=0\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.count=100000\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.errorTime=120000\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.timeoutMs=120000\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.readLimitTimeMs=-1\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.maxSourceSizeKBytes=-1\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.readLimitKBytes=-1\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.pageLimit=-1\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.maxPages=-1\n"+ - "content.transformer.abc.mimetypes.application/pdf.image/png.supported=true"); - - verify(transformerProperties).setProperties(expectedProperties( - "content.transformer.abc.mimetypes.application/pdf.image/png.priority", "100", - "content.transformer.abc.mimetypes.application/pdf.image/png.thresholdCount", "3", - "content.transformer.abc.mimetypes.application/pdf.image/png.time", "0", - "content.transformer.abc.mimetypes.application/pdf.image/png.count", "100000", - "content.transformer.abc.mimetypes.application/pdf.image/png.errorTime", "120000", - "content.transformer.abc.mimetypes.application/pdf.image/png.timeoutMs", "120000", - "content.transformer.abc.mimetypes.application/pdf.image/png.readLimitTimeMs", "-1", - "content.transformer.abc.mimetypes.application/pdf.image/png.maxSourceSizeKBytes", "-1", - "content.transformer.abc.mimetypes.application/pdf.image/png.readLimitKBytes", "-1", - "content.transformer.abc.mimetypes.application/pdf.image/png.pageLimit", "-1", - "content.transformer.abc.mimetypes.application/pdf.image/png.maxPages", "-1", - "content.transformer.abc.mimetypes.application/pdf.image/png.supported", "true")); - } - - @Test(expected=IllegalArgumentException.class) - public void badSourceMimetypeTest() - { - setter.setProperties("content.transformer.abc.mimetypes.bad.image/png.maxPages=-1"); - } - - @Test(expected=IllegalArgumentException.class) - public void badTargetMimetypeTest() - { - setter.setProperties("content.transformer.abc.mimetypes.application/pdf.bad.maxPages=-1"); - } - - public void pipelineTest() - { - setter.setProperties("content.transformer.abc.pipeline=transformer1|pdf|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void pipelineWithExtensionsTest() - { - setter.setProperties("content.transformer.abc.extensions.pdf.png.pipeline=transformer1|pdf|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void pipelineWithMimetypesTest() - { - setter.setProperties("content.transformer.abc.mimetypes.application/pdf.image/png.pipeline=transformer1|application/pdf|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void pipelineTooFewTest() - { - setter.setProperties("content.transformer.abc.pipeline=transformer1"); - } - - @Test(expected=IllegalArgumentException.class) - public void pipelineMissingTransformerTest() - { - setter.setProperties("content.transformer.abc.pipeline=transformer1|pdf|transformer2|png"); - } - - @Test(expected=IllegalArgumentException.class) - public void pipelineBadTransformerTest() - { - setter.setProperties("content.transformer.abc.pipeline=transformer1|pdf|bad"); - } - - @Test(expected=IllegalArgumentException.class) - public void pipelineBadExtensionTest() - { - setter.setProperties("content.transformer.abc.pipeline=transformer1|bad|transformer2"); - } - - public void failoverTest() - { - setter.setProperties("content.transformer.abc.failover=transformer1|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void failoverWithExtensionsTest() - { - setter.setProperties("content.transformer.abc.extensions.pdf.png.pipeline=transformer1|pdf|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void failoverWithMimetypeTest() - { - setter.setProperties("content.transformer.abc.mimetypes.application/pdf.image/png.failover=transformer1|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void failoverTooFewTest() - { - setter.setProperties("content.transformer.abc.failover=transformer1"); - } - - @Test(expected=IllegalArgumentException.class) - public void failoverBadTransformerTest() - { - setter.setProperties("content.transformer.abc.failover=transformer1|bad|transformer2"); - } - - @Test(expected=IllegalArgumentException.class) - public void removeUnsetPropetyTest() - { - setter.removeProperties("transformer.log.entries"); - } - - @Test - public void removeSimplePropertyTest() - { - mockProperties(transformerProperties, "transformer.log.entries", "12"); - - int count = setter.removeProperties("transformer.log.entries"); - - verify(transformerProperties).removeProperties(expectedNames("transformer.log.entries")); - assertEquals("Removed count", 1, count); - } - - @Test - // removeProperties optionally has a value - public void removeOptionalValueTest() - { - mockProperties(transformerProperties, "transformer.log.entries", "12"); - - setter.removeProperties("transformer.log.entries=12"); - } - - @Test(expected=IllegalArgumentException.class) - // removeProperties on a default property - public void removeDefaultValueTest() - { - mockProperties(transformerProperties, "transformer.log.entries", "12"); - - properties.setProperty("transformer.log.entries", "10"); - - setter.removeProperties("transformer.log.entries=12"); - } - - @Test - public void dynamicTransformerReferenceTest() - { - setter.setProperties( - "content.transformer.abc.failover=transformer1|xyz\n"+ // Reference the transformer xyz - "content.transformer.xyz.pipeline=transformer1|pdf|transformer2"); // Create the transformer xyz - } - - @Test - public void removeMultiplePropetiesTest() - { - mockProperties(transformerProperties, - "content.transformer.default.priority", "100", - "content.transformer.default.thresholdCount", "3", - "content.transformer.default.time", "0", - "content.transformer.default.count", "100000", - "content.transformer.default.errorTime", "120000"); - - int count = setter.removeProperties( - "# hi mum\n"+ - "content.transformer.default.priority=100\n"+ - " content.transformer.default.thresholdCount=3 \n"+ - "\t content.transformer.default.time=0\n"+ - "\t\t \t content.transformer.default.count=100000 # another comment\n"+ - "#\n"+ - " \n"+ - "\n"+ - "content.transformer.default.errorTime=120000\n"); - - verify(transformerProperties).removeProperties(expectedNames( - "content.transformer.default.priority", - "content.transformer.default.thresholdCount", - "content.transformer.default.time", - "content.transformer.default.count", - "content.transformer.default.errorTime")); - assertEquals("Removed count", 5, count); - } -} - -@Deprecated -class DummyContentTransformer implements ContentTransformer -{ - private final String name; - - DummyContentTransformer(String name) - { - this.name = name; - } - - @Override - public String getName() - { - return name; - } - - @Override - public boolean isTransformable(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - return false; - } - - @Override - public boolean isTransformable(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - return false; - } - - @Override - public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - return false; - } - - @Override - public boolean isTransformableSize(String sourceMimetype, long sourceSize, - String targetMimetype, TransformationOptions options) - { - return false; - } - - @Override - public String getComments(boolean available) - { - return ""; - } - - @Override - public long getMaxSourceSizeKBytes(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - return 0; - } - - @Override - public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, - TransformationOptions options) - { - return false; - } - - @Override - public long getTransformationTime() - { - return 0; - } - - @Override - public long getTransformationTime(String sourceMimetype, String targetMimetype) - { - return 0; - } - - @Override - public void transform(ContentReader reader, ContentWriter writer) throws ContentIOException - { - } - - @Override - public void transform(ContentReader reader, ContentWriter writer, - Map options) throws ContentIOException - { - } - - @Override - public void transform(ContentReader reader, ContentWriter contentWriter, - TransformationOptions options) throws ContentIOException - { - } -}; diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerSelectorImplTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/TransformerSelectorImplTest.java deleted file mode 100644 index b17ae254f3..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/TransformerSelectorImplTest.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Test class for TransformerSelectorImpl. - * - * @author Alan Davis - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class TransformerSelectorImplTest -{ - private static final String PNG = "image/png"; - - private static final String PDF = "application/pdf"; - - @Mock - private TransformerConfig transformerConfig; - - @Mock - private ContentTransformerRegistry contentTransformerRegistry; - - @Mock - private TransformationOptions options; - - @Mock - private DummyContentTransformer transformer1; - - @Mock - private DummyContentTransformer transformer2; - - @Mock - private DummyContentTransformer transformer3; - - @Mock - private DummyContentTransformer transformer4; - - private List allTransformers; - - private TransformerSelectorImpl selector; - - @Before - public void setUp() throws Exception - { - MockitoAnnotations.initMocks(this); - - selector = new TransformerSelectorImpl(); - selector.setTransformerConfig(transformerConfig); - selector.setContentTransformerRegistry(contentTransformerRegistry); - - when(transformer1.getName()).thenReturn("transformer.1"); - when(transformer2.getName()).thenReturn("transformer.2"); - when(transformer3.getName()).thenReturn("transformer.3"); - when(transformer4.getName()).thenReturn("transformer.4"); - - allTransformers = new ArrayList(); - when(contentTransformerRegistry.getTransformers()).thenReturn(allTransformers); - } - - private void mockTransformer(DummyContentTransformer transformer, int priority, String sourceMimetype, String targetMimetype) - { - when(transformerConfig.getPriority(transformer, sourceMimetype, targetMimetype)).thenReturn(priority); - allTransformers.add(transformer); - } - - private void mockTransformer(DummyContentTransformer transformer, int priority, String sourceMimetype, String targetMimetype, - int count, int averageTime, int threshold) - { - mockTransformer(transformer, priority, sourceMimetype, targetMimetype); - when(transformer.isTransformable(sourceMimetype, -1, targetMimetype, options)).thenReturn(true); - when(transformerConfig.getStatistics(transformer, sourceMimetype, targetMimetype, true)).thenReturn(new DummyTransformerStatistics(count, averageTime)); - when(transformerConfig.getThresholdCount(transformer, sourceMimetype, targetMimetype)).thenReturn(threshold); - - } - - private void assertTransformers(String context, List expected, - List actual) - { - String expectedNames = getNames(expected); - String actualNames = getNames(actual); - assertEquals(context, expectedNames, actualNames); - } - - private String getNames(List transformers) - { - StringBuilder sb = new StringBuilder(); - - for (ContentTransformer transformer: transformers) - { - if (sb.length() > 0) - { - sb.append(' '); - } - sb.append(transformer.getName()); - } - return sb.toString(); - } - - private void runMultipleSelections(int[][] data) throws Exception - { - // Run a sequence of selections up to the thresholds and beyond - List expected = null; - for (int i=0; i actual = selector.selectTransformers(PDF, -1, PNG, options); - assertTransformers(i+" multiple", expected, actual); - } - } - - @Test - public void firstRunUnderThresholdTest() - { - // 1 and 4 can do PDF->PNG, same priority (100) and neither have not been run - mockTransformer(transformer1, 100, PDF, PNG, 0, 0, 3); - mockTransformer(transformer2, 100, PDF, PNG); - mockTransformer(transformer3, 100, PDF, PNG); - mockTransformer(transformer4, 100, PDF, PNG, 0, 0, 3); - - List expected = Arrays.asList(new ContentTransformer[] {transformer1, transformer4}); - List actual = selector.selectTransformers(PDF, -1, PNG, options); - - assertTransformers("", expected, actual); - } - - @Test - public void secondRunUnderThresholdOneRunTest() - { - // 1 and 4 can do PDF->PNG, same priority (100) and but 1 has been run - // Should continue to round robin to 2 - mockTransformer(transformer1, 100, PDF, PNG, 1, 23, 3); - mockTransformer(transformer2, 100, PDF, PNG); - mockTransformer(transformer3, 100, PDF, PNG); - mockTransformer(transformer4, 100, PDF, PNG, 0, 0, 3); - - List expected = Arrays.asList(new ContentTransformer[] {transformer4, transformer1}); - List actual = selector.selectTransformers(PDF, -1, PNG, options); - - assertTransformers("", expected, actual); - } - - @Test - public void thirdRunUnderThresholdTwoRunTest() - { - // 1 and 4 can do PDF->PNG, same priority (100) and both have been run, but still under threshold - // Note: If the threshold was not taken into account 4 would be selected - // Should continue to round robin - mockTransformer(transformer1, 100, PDF, PNG, 1, 23, 3); - mockTransformer(transformer2, 100, PDF, PNG); - mockTransformer(transformer3, 100, PDF, PNG); - mockTransformer(transformer4, 100, PDF, PNG, 1, 16, 3); - - List expected = Arrays.asList(new ContentTransformer[] {transformer1, transformer4}); - List actual = selector.selectTransformers(PDF, -1, PNG, options); - - assertTransformers("", expected, actual); - } - - @Test - public void multipleTestSameThreshold() throws Exception - { - int[][] data = new int[][] - { - { 0, 0, 3, 0, 0, 3, 1}, // same as firstRunUnderThresholdTest - { 1, 23, 3, 0, 0, 3, 4}, // same as secondRunUnderThresholdTest - { 1, 23, 3, 1, 16, 3, 1}, // same as thirdRunUnderThresholdTwoRunTest - { 2, 25, 3, 1, 16, 3, 4}, - { 2, 25, 3, 2, 27, 3, 1}, - { 3, 24, 3, 2, 27, 3, 4}, - { 3, 24, 3, 3, 27, 3, 1}, - - // Threshold past for both transformers - 1 was faster - { 4, 25, 3, 3, 27, 3, 1}, - { 5, 22, 3, 3, 27, 3, 1}, - { 6, 21, 3, 3, 27, 3, 1}, - - // 1 is slower than 4 now, so it switches - { 7, 28, 3, 3, 27, 3, 4}, - { 7, 28, 3, 4, 26, 3, 4}, - }; - - runMultipleSelections(data); - } - - @Test - public void multipleTestDifferentThreshold() throws Exception - { - int[][] data = new int[][] - { - { 0, 0, 2, 0, 0, 4, 1}, - { 1, 23, 2, 0, 0, 4, 4}, - { 1, 23, 2, 1, 16, 4, 1}, - - // Threshold past for 1 but not 4 - { 2, 25, 2, 1, 16, 4, 4}, - { 2, 25, 2, 2, 27, 4, 4}, - { 2, 25, 2, 3, 22, 4, 4}, - - // Threshold past for both transformers - { 2, 25, 2, 4, 22, 4, 4}, - { 2, 25, 2, 5, 29, 4, 1}, - { 3, 28, 2, 5, 29, 4, 1}, - - // 1 is slower than 4 now, so it switches - { 4, 30, 2, 5, 29, 4, 4}, - }; - - runMultipleSelections(data); - } - - @Test - public void priorityTest() - { - // 1 and 4 can do PDF->PNG, but 4 is higher priority, even though 1 appears faster - mockTransformer(transformer1, 100, PDF, PNG, 10, 22, 3); - mockTransformer(transformer2, 100, PDF, PNG); - mockTransformer(transformer3, 100, PDF, PNG); - mockTransformer(transformer4, 50, PDF, PNG, 10, 44, 3); - - List expected = Arrays.asList(new ContentTransformer[] {transformer4, transformer1}); - List actual = selector.selectTransformers(PDF, -1, PNG, options); - - assertTransformers("", expected, actual); - } - - @Test - public void priorityAndTimeTest() - { - // 1, 2 and 4 can do PDF->PNG, but 4 is higher priority, even though 1 and 2 appear faster - mockTransformer(transformer1, 100, PDF, PNG, 10, 22, 3); - mockTransformer(transformer2, 100, PDF, PNG, 10, 23, 3); - mockTransformer(transformer3, 100, PDF, PNG); - mockTransformer(transformer4, 50, PDF, PNG, 10, 44, 3); - - List expected = Arrays.asList(new ContentTransformer[] {transformer4, transformer1, transformer2}); - List actual = selector.selectTransformers(PDF, -1, PNG, options); - - assertTransformers("", expected, actual); - } - - @Test - public void priorityAndThresholdTest() - { - // 1, 2 and 4 can do PDF->PNG, but 4 is higher priority, even though 1 and 2 have not reached the threshold - mockTransformer(transformer1, 100, PDF, PNG, 0, 0, 3); - mockTransformer(transformer2, 100, PDF, PNG, 0, 0, 3); - mockTransformer(transformer3, 100, PDF, PNG); - mockTransformer(transformer4, 50, PDF, PNG, 10, 44, 3); - - List expected = Arrays.asList(new ContentTransformer[] {transformer4, transformer1, transformer2}); - List actual = selector.selectTransformers(PDF, -1, PNG, options); - - assertTransformers("", expected, actual); - } -} - -@Deprecated -class DummyTransformerStatistics extends TransformerStatisticsImpl -{ - private final long count; - private final long averageTime; - - public DummyTransformerStatistics(long count, long averageTime) - { - super(null, null, null, null, null, 0L, 0L, 0L); - this.count = count; - this.averageTime = averageTime; - } - - @Override - public long getCount() - { - return count; - } - - @Override - public long getAverageTime() - { - return averageTime; - } -} diff --git a/repository/src/test/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerTest.java b/repository/src/test/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerTest.java deleted file mode 100644 index e13fc80c51..0000000000 --- a/repository/src/test/java/org/alfresco/repo/content/transform/magick/ImageMagickContentTransformerTest.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 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 . - * #L% - */ -package org.alfresco.repo.content.transform.magick; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.content.transform.AbstractContentTransformerTest; -import org.alfresco.repo.content.transform.ContentTransformer; -import org.alfresco.repo.content.transform.ProxyContentTransformer; -import org.alfresco.repo.content.transform.RemoteTransformerClient; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.PagedSourceOptions; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.cmr.repository.TransformationSourceOptions; -import org.alfresco.util.TempFileProvider; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * @see org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerWorker - * - * @author Derek Hulley - * - * @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries. - */ -@Deprecated -public class ImageMagickContentTransformerTest extends AbstractContentTransformerTest -{ - private ProxyContentTransformer transformer; - - @BeforeClass - public static void before() - { - // Use the docker images for transforms (legacy) - System.setProperty("alfresco-pdf-renderer.url", "http://localhost:8090/"); - System.setProperty("img.url", "http://localhost:8090/"); - System.setProperty("jodconverter.url", "http://localhost:8090/"); - System.setProperty("tika.url", "http://localhost:8090/"); - System.setProperty("transform.misc.url", "http://localhost:8090/"); - } - - @AfterClass - public static void after() - { - System.clearProperty("alfresco-pdf-renderer.url"); - System.clearProperty("img.url"); - System.clearProperty("jodconverter.url"); - System.clearProperty("tika.url"); - System.clearProperty("transform.misc.url"); - } - - @Override - public void setUp() throws Exception - { - super.setUp(); - - // Setup a mimetype service that will return a truncated set of mimetypes - MockMimetypeService testMimetypeService = new MockMimetypeService(); - testMimetypeService.setConfigService(((MimetypeMap) mimetypeService).getConfigService()); - testMimetypeService.setContentCharsetFinder(((MimetypeMap) mimetypeService).getContentCharsetFinder()); - testMimetypeService.init(); - this.mimetypeService = testMimetypeService; - - transformer = (ProxyContentTransformer) ctx.getBean("transformer.ImageMagick"); - RemoteTransformerClient remoteTransformerClient = new RemoteTransformerClient("miscRemoteTransformerClient", "http://localhost:8090/"); - transformer.getWorker().setRemoteTransformerClient(remoteTransformerClient); - } - - /** - * @return Returns the same transformer regardless - it is allowed - */ - protected ContentTransformer getTransformer(String sourceMimetype, String targetMimetype) - { - return transformer; - } - - public void testReliability() throws Exception - { - if (!this.transformer.getWorker().isAvailable()) - { - return; - } - boolean reliability = transformer.isTransformable( - MimetypeMap.MIMETYPE_IMAGE_GIF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions()); - assertEquals("Mimetype should not be supported", false, reliability); - reliability = transformer.isTransformable( - MimetypeMap.MIMETYPE_IMAGE_GIF, -1, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions()); - assertEquals("Mimetype should be supported", true, reliability); - } - - protected long transform(String sourceMimetype, String targetMimetype, TransformationOptions options) throws IOException - { - long size = -1; - String[] quickFiles = getQuickFilenames(sourceMimetype); - for (String quickFile : quickFiles) - { - String sourceExtension = quickFile.substring(quickFile.lastIndexOf('.')+1); - String targetExtension = mimetypeService.getExtension(targetMimetype); - - // is there a test file for this conversion? - File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(quickFile); - if (sourceFile == null) - { - continue; // no test file available for that extension - } - ContentReader sourceReader = new FileContentReader(sourceFile); - - // make a writer for the target file - File targetFile = TempFileProvider.createTempFile( - getClass().getSimpleName() + "_" + getName() + "_" + sourceExtension + "_", - "." + targetExtension); - ContentWriter targetWriter = new FileContentWriter(targetFile); - - // do the transformation - sourceReader.setMimetype(sourceMimetype); - targetWriter.setMimetype(targetMimetype); - transformer.transform(sourceReader.getReader(), targetWriter, options); - ContentReader targetReader = targetWriter.getReader(); - size = targetReader.getSize(); - assertTrue(size > 0); - } - return size; - } - - public void testGifToPng() throws Exception - { - ImageTransformationOptions options = new ImageTransformationOptions(); - transform(MimetypeMap.MIMETYPE_IMAGE_GIF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - } - - public void testJpegToPng() throws Exception - { - ImageTransformationOptions options = new ImageTransformationOptions(); - transform(MimetypeMap.MIMETYPE_IMAGE_JPEG, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - } - - public void testDeprecatedCommandOptions() throws Exception - { - // The commandOption should be removed, but is currently needed for custom renditions. - // This test uses it to resize the file. This happens to be one of the standard options. - ImageTransformationOptions options = new ImageTransformationOptions(); - long defaultSize = transform(MimetypeMap.MIMETYPE_IMAGE_JPEG, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - - options.setCommandOptions("-resize 200%"); - long biggerSize = transform(MimetypeMap.MIMETYPE_IMAGE_JPEG, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - - assertTrue("The commandOption appears not to have been used as the file size " + biggerSize + - " is not larger than the default size " + defaultSize, biggerSize > defaultSize); - } - - // This fails with remote transformers - // The thumbnails actually have parameters in real life - public void ignoreTestPageSourceOptions() throws Exception - { - // Test empty source options - ImageTransformationOptions options = new ImageTransformationOptions(); - this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - - // Test first page - options = new ImageTransformationOptions(); - List sourceOptionsList = new ArrayList(); - sourceOptionsList.add(PagedSourceOptions.getPage1Instance()); - options.setSourceOptionsList(sourceOptionsList); - this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - - // Test second page - options = new ImageTransformationOptions(); - sourceOptionsList = new ArrayList(); - PagedSourceOptions sourceOptions = new PagedSourceOptions(); - sourceOptions.setStartPageNumber(2); - sourceOptions.setEndPageNumber(2); - sourceOptionsList.add(sourceOptions); - options.setSourceOptionsList(sourceOptionsList); - this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - - // Test page range invalid for target type - options = new ImageTransformationOptions(); - sourceOptionsList = new ArrayList(); - sourceOptions = new PagedSourceOptions(); - sourceOptions.setStartPageNumber(1); - sourceOptions.setEndPageNumber(2); - sourceOptionsList.add(sourceOptions); - options.setSourceOptionsList(sourceOptionsList); - try { - this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - fail("An exception regarding an invalid page range should have been thrown"); - } - catch (Exception e) - { - // failure expected - } - - // Test page out of range - options = new ImageTransformationOptions(); - sourceOptionsList = new ArrayList(); - sourceOptions = new PagedSourceOptions(); - sourceOptions.setStartPageNumber(3); - sourceOptions.setEndPageNumber(3); - sourceOptionsList.add(sourceOptions); - options.setSourceOptionsList(sourceOptionsList); - try { - this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); - fail("An exception regarding an invalid page range should have been thrown"); - } - catch (Exception e) - { - // failure expected - } - } - - /** - * Mock mimetype service which returns a limited set of mimetypes - * as {@link AbstractContentTransformerTest#testAllConversions()} will - * fail if delegates are not available on the test agent. - * - * @author rgauss - */ - public class MockMimetypeService extends MimetypeMap - { - private List testMimetypes; - - public void init() - { - super.init(); - testMimetypes = new ArrayList(10); - testMimetypes.add(MimetypeMap.MIMETYPE_IMAGE_GIF); - testMimetypes.add(MimetypeMap.MIMETYPE_IMAGE_JPEG); - testMimetypes.add(MimetypeMap.MIMETYPE_IMAGE_PNG); - testMimetypes.add(MimetypeMap.MIMETYPE_IMAGE_TIFF); - testMimetypes.add(MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR); - testMimetypes.add(MimetypeMap.MIMETYPE_APPLICATION_EPS); - testMimetypes.add(MimetypeMap.MIMETYPE_APPLICATION_PHOTOSHOP); - testMimetypes.add(MimetypeMap.MIMETYPE_PDF); - } - - @Override - public List getMimetypes() - { - return testMimetypes; - } - - } -} diff --git a/repository/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java index 95dd1d18fd..047fd9d5cd 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java @@ -2568,7 +2568,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest ContentReader reader = contentService.getReader(newImageRendition, ContentModel.PROP_CONTENT); assertNotNull("Reader to rendered image was null", reader); BufferedImage srcImg = ImageIO.read(reader.getContentInputStream()); - checkTopLeftBottomRight(srcImg, topLeft, bottomRight); + checkTopLeftBottomRight(srcImg, topLeft, bottomRight, "rendered image"); return null; } @@ -2581,16 +2581,16 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest File imageFile = new File(url.getFile()); BufferedImage img = ImageIO.read(url); assertNotNull("image was null", img); - checkTopLeftBottomRight(img, WHITE, BLACK); + checkTopLeftBottomRight(img, WHITE, BLACK, "original image"); return imageFile; } - private static void checkTopLeftBottomRight(BufferedImage img, String topLeft, String bottomRight) + private static void checkTopLeftBottomRight(BufferedImage img, String topLeft, String bottomRight, String srcImage) { - int rgbAtTopLeft = img.getRGB(1, 1); - assertTrue("upper left should be "+topLeft, Integer.toHexString(rgbAtTopLeft).endsWith(topLeft)); - int rgbAtBottomRight = img.getRGB(img.getWidth() - 1, img.getHeight() - 1); - assertTrue("lower right should be "+bottomRight, Integer.toHexString(rgbAtBottomRight).endsWith(bottomRight)); + String rgbAtTopLeft = Integer.toHexString(img.getRGB(1, 1)); + assertTrue("upper left "+ rgbAtTopLeft +" should end with "+topLeft+" "+srcImage, rgbAtTopLeft.endsWith(topLeft)); + String rgbAtBottomRight = Integer.toHexString(img.getRGB(img.getWidth() - 1, img.getHeight() - 1)); + assertTrue("lower right "+ rgbAtBottomRight +" should end with "+bottomRight+" "+srcImage, rgbAtBottomRight.endsWith(bottomRight)); } /** diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/AbstractRenditionIntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/AbstractRenditionIntegrationTest.java index 590e0098f0..783fe33afc 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/AbstractRenditionIntegrationTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/AbstractRenditionIntegrationTest.java @@ -117,9 +117,6 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest @Autowired protected LocalTransformServiceRegistry localTransformServiceRegistry; - @Autowired - protected LegacyTransformServiceRegistry legacyTransformServiceRegistry; - @Autowired protected TransformationOptionsConverter converter; @@ -137,13 +134,6 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest @BeforeClass public static void before() { - // Use the docker images for transforms (legacy) - System.setProperty("alfresco-pdf-renderer.url", "http://localhost:8090/"); - System.setProperty("img.url", "http://localhost:8090/"); - System.setProperty("jodconverter.url", "http://localhost:8090/"); - System.setProperty("tika.url", "http://localhost:8090/"); - System.setProperty("transform.misc.url", "http://localhost:8090/"); - // Use the docker images for transforms (local) System.setProperty("localTransform.core-aio.url", "http://localhost:8090/"); } @@ -152,21 +142,12 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest { System.setProperty("transform.service.enabled", "false"); System.setProperty("local.transform.service.enabled", "false"); - System.setProperty("legacy.transform.service.enabled", "false"); - } - - protected static void legacy() - { - System.setProperty("transform.service.enabled", "false"); - System.setProperty("local.transform.service.enabled", "false"); - System.setProperty("legacy.transform.service.enabled", "true"); } protected static void local() { System.setProperty("transform.service.enabled", "false"); System.setProperty("local.transform.service.enabled", "true"); - System.setProperty("legacy.transform.service.enabled", "false"); // Strict MimetypeCheck System.setProperty("transformer.strict.mimetype.check", "true"); @@ -178,21 +159,12 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest { System.setProperty("transform.service.enabled", "true"); System.setProperty("local.transform.service.enabled", "false"); - System.setProperty("legacy.transform.service.enabled", "false"); } - protected static void legacyLocal() - { - System.setProperty("transform.service.enabled", "false"); - System.setProperty("local.transform.service.enabled", "true"); - System.setProperty("legacy.transform.service.enabled", "true"); - } - - protected static void legacyLocalService() + protected static void localService() { System.setProperty("transform.service.enabled", "true"); System.setProperty("local.transform.service.enabled", "true"); - System.setProperty("legacy.transform.service.enabled", "true"); } @Before @@ -200,22 +172,26 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest { assertTrue("The RenditionService2 needs to be enabled", renditionService2.isEnabled()); - legacyTransformServiceRegistry.setEnabled(Boolean.parseBoolean(System.getProperty("legacy.transform.service.enabled"))); - legacyTransformServiceRegistry.afterPropertiesSet(); - origLocalTransCron = localTransformServiceRegistry.getCronExpression(); localTransformServiceRegistry.setCronExpression(null); - localTransformServiceRegistry.setEnabled(Boolean.parseBoolean(System.getProperty("local.transform.service.enabled"))); + boolean localTransformServiceEnabled = Boolean.parseBoolean(System.getProperty("local.transform.service.enabled")); + localTransformServiceRegistry.setEnabled(localTransformServiceEnabled); localTransformServiceRegistry.afterPropertiesSet(); - origRenditionCron = renditionDefinitionRegistry2.getCronExpression(); - renditionDefinitionRegistry2.setCronExpression(null); - renditionDefinitionRegistry2.setTransformServiceRegistry(transformServiceRegistry); - renditionDefinitionRegistry2.afterPropertiesSet(); + if (transformServiceRegistry instanceof LocalTransformServiceRegistry) + { + ((LocalTransformServiceRegistry)transformServiceRegistry).setEnabled(localTransformServiceEnabled); + } thumbnailRegistry.setTransformServiceRegistry(transformServiceRegistry); thumbnailRegistry.setLocalTransformServiceRegistry(localTransformServiceRegistry); thumbnailRegistry.setConverter(converter); + + origRenditionCron = renditionDefinitionRegistry2.getCronExpression(); + renditionDefinitionRegistry2.setCronExpression(null); + renditionDefinitionRegistry2.setTransformServiceRegistry(transformServiceRegistry); + renditionDefinitionRegistry2.setTransformServiceRegistry(localTransformServiceRegistry); + renditionDefinitionRegistry2.afterPropertiesSet(); } @After @@ -230,17 +206,9 @@ public abstract class AbstractRenditionIntegrationTest extends BaseSpringTest @AfterClass public static void after() { - System.clearProperty("alfresco-pdf-renderer.url"); - System.clearProperty("img.url"); - System.clearProperty("jodconverter.url"); - System.clearProperty("tika.url"); - System.clearProperty("transform.misc.url"); - System.clearProperty("localTransform.core-aio.url"); - System.clearProperty("transform.service.enabled"); System.clearProperty("local.transform.service.enabled"); - System.clearProperty("legacy.transform.service.enabled"); } protected void checkRendition(String testFileName, String renditionName, boolean expectedToPass) diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyLocalRenditionTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/LegacyLocalRenditionTest.java deleted file mode 100644 index 0b0d6dc0bf..0000000000 --- a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyLocalRenditionTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; - -/** - * Repeats quick file rendition tests with local transforms and legacy transformers enabled. - * The Transform Service does not exist for the Community edition. - * Should be the same result as with legacy or local transforms on their own. - * - * @author adavis - */ -@Deprecated -public class LegacyLocalRenditionTest extends AbstractRenditionTest -{ - @BeforeClass - public static void before() - { - AbstractRenditionIntegrationTest.before(); - legacyLocal(); - } - - @AfterClass - public static void after() - { - AbstractRenditionIntegrationTest.after(); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyRenditionTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/LegacyRenditionTest.java deleted file mode 100644 index adaa4ce13d..0000000000 --- a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyRenditionTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.alfresco.util.testing.category.DebugTests; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * Repeats quick file rendition tests with local transforms disabled but legacy transformers enabled. - * The Transform Service does not exist for the Community edition. - * Should be the same result as with local transforms. - * - * @author adavis - */ -public class LegacyRenditionTest extends AbstractRenditionTest -{ - @BeforeClass - public static void before() - { - AbstractRenditionIntegrationTest.before(); - legacy(); - } - - @Override - @Before - public void setUp() throws Exception - { - super.setUp(); - } - - @AfterClass - public static void after() - { - AbstractRenditionIntegrationTest.after(); - } - - @Test - @Override - public void testSelectedMetadataExtracts() throws Exception - { - internalTestSelectedMetadataExtracts(7, 7); - } -} diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/LegacySynchronousTransformClientIntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/LegacySynchronousTransformClientIntegrationTest.java deleted file mode 100644 index 642df80977..0000000000 --- a/repository/src/test/java/org/alfresco/repo/rendition2/LegacySynchronousTransformClientIntegrationTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * Integration tests for {@link LegacyTransformClient} - */ -@Deprecated -public class LegacySynchronousTransformClientIntegrationTest extends LocalSynchronousTransformClientIntegrationTest -{ - @Autowired - protected SynchronousTransformClient legacySynchronousTransformClient; - - @BeforeClass - public static void before() - { - AbstractRenditionIntegrationTest.before(); - legacy(); - } - - @AfterClass - public static void after() - { - AbstractRenditionIntegrationTest.after(); - } - - @Before - public void setUp() throws Exception - { - super.setUp(); - synchronousTransformClient = legacySynchronousTransformClient; - } -} diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyTransformClientIntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/LegacyTransformClientIntegrationTest.java deleted file mode 100644 index adbb50fd6d..0000000000 --- a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyTransformClientIntegrationTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * Integration tests for {@link LegacyTransformClient} - */ -@Deprecated -public class LegacyTransformClientIntegrationTest extends LocalTransformClientIntegrationTest -{ - @Autowired - protected TransformClient legacyTransformClient; - - @BeforeClass - public static void before() - { - AbstractRenditionIntegrationTest.before(); - legacy(); - } - - @AfterClass - public static void after() - { - AbstractRenditionIntegrationTest.after(); - } - - @Before - public void setUp() throws Exception - { - super.setUp(); - transformClient = legacyTransformClient; - } -} diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyTransformServiceRegistryIntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/LegacyTransformServiceRegistryIntegrationTest.java deleted file mode 100644 index ddce1200ca..0000000000 --- a/repository/src/test/java/org/alfresco/repo/rendition2/LegacyTransformServiceRegistryIntegrationTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2018 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 . - * #L% - */ -package org.alfresco.repo.rendition2; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IMAGE_JPEG; - -/** - * Integration tests for {@link LegacyTransformServiceRegistry} - */ -@Deprecated -public class LegacyTransformServiceRegistryIntegrationTest extends LocalTransformServiceRegistryIntegrationTest -{ - @Autowired - private LegacyTransformServiceRegistry legacyTransformServiceRegistry; - - @Before - public void setUp() throws Exception - { - super.setUp(); - transformServiceRegistry = legacyTransformServiceRegistry; - targetMimetype = MIMETYPE_IMAGE_JPEG; - } - - @BeforeClass - public static void before() - { - AbstractRenditionIntegrationTest.before(); - legacy(); - } - - @AfterClass - public static void after() - { - AbstractRenditionIntegrationTest.after(); - } - - @Override - protected void setEnabled(boolean enabled) - { - legacyTransformServiceRegistry.setEnabled(enabled); - legacyTransformServiceRegistry.afterPropertiesSet(); - } - - @Override - protected boolean isEnabled() - { - return legacyTransformServiceRegistry.isEnabled(); - } - - @Test - @Override - public void testIsSupported() - { - // There are no longer any standard transforms with a size limit without a lower priority fallback, - // so this test cannot be codded. - } -} diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/NoneRenditionTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/NoneRenditionTest.java index f845adb1d0..e9841c2d92 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/NoneRenditionTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/NoneRenditionTest.java @@ -34,7 +34,7 @@ import org.junit.experimental.categories.Category; import java.util.Collections; /** - * Repeats quick file rendition tests with local transforms and legacy transformers disabled. + * Repeats quick file rendition tests with local transforms disabled. * The Transform Service does not exist for the Community edition. * * @author adavis diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java index 016f099a08..84bd22c4f0 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java @@ -55,7 +55,7 @@ public class RenditionService2IntegrationTest extends AbstractRenditionIntegrati public static void before() { AbstractRenditionIntegrationTest.before(); - legacyLocal(); + local(); } // PDF transformation diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/TestSynchronousTransformClient.java b/repository/src/test/java/org/alfresco/repo/rendition2/TestSynchronousTransformClient.java index e4538efdf1..ff3210ac86 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/TestSynchronousTransformClient.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/TestSynchronousTransformClient.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2019 Alfresco Software Limited + * Copyright (C) 2005 - 2020 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/TransformationOptionsConverterTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/TransformationOptionsConverterTest.java index 43ce980414..776c86123d 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/TransformationOptionsConverterTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/TransformationOptionsConverterTest.java @@ -25,7 +25,6 @@ */ package org.alfresco.repo.rendition2; -import org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerWorker; import org.alfresco.repo.content.transform.magick.ImageResizeOptions; import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; import org.alfresco.repo.content.transform.swf.SWFTransformationOptions; @@ -81,22 +80,11 @@ public class TransformationOptionsConverterTest private void assertConverterToMapAndBack(TransformationOptions oldOptions, String sourceMimetype, String targetMimetype, String expectedOldOptionsToString, - String expectedArgs, - boolean checkImageMagickContentTransformerWorkerResult) + String expectedArgs) { String sortedOldOptions = getSortedOptions(oldOptions, sourceMimetype, targetMimetype); assertEquals("oldOptions was not set up correctly", expectedOldOptionsToString, oldOptions.toString()); - // This check will need to be removed when the ImageMagickContentTransformerWorker is removed. - // It is really checking that the supplied expectedArgs (just used to check the sortedNewOptions) are correct. - if (checkImageMagickContentTransformerWorkerResult) - { - String[] tEngineArgs = getOptionalTEngineArgs(oldOptions, sourceMimetype, targetMimetype); - String sortedTEngineOptions = getSortedOptions(tEngineArgs)+"timeout=-1 "; - assertEquals("Test error: expectedArgs are not what is generated by ImageMagickContentTransformerWorker", - expectedArgs, sortedTEngineOptions); - } - Map newOptions = converter.getOptions(oldOptions, sourceMimetype, targetMimetype); Map newOptionsWithoutDiscards = discardNoopOptions(newOptions); String sortedNewOptions = getSortedOptions(newOptionsWithoutDiscards); @@ -109,14 +97,6 @@ public class TransformationOptionsConverterTest assertEquals("Having converted twice the map is different", sortedOldOptions, sortedBackToOldOptions); } - // Discards the transformerName, sourceMimetype, sourceExtension and targetMimetype elements which are always in the first 3 elements. - private String[] getOptionalTEngineArgs(TransformationOptions oldOptions, String sourceMimetype, String targetMimetype) - { - String[] args = ImageMagickContentTransformerWorker.getTEngineArgs(oldOptions, sourceMimetype, null, targetMimetype, - "Version: ImageMagick 6.7.5"); - return Arrays.copyOfRange(args, 4*2, args.length); - } - private String getSortedOptions(TransformationOptions options, String sourceMimetype, String targetMimetype) { Map map = converter.getOptions(options, sourceMimetype, targetMimetype); @@ -192,8 +172,8 @@ public class TransformationOptionsConverterTest "resizeHeight=30 " + "resizeWidth=20 " + "startPage=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -205,8 +185,8 @@ public class TransformationOptionsConverterTest assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, resizeOptions=null, autoOrient=true]]", "autoOrient=true " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -218,8 +198,8 @@ public class TransformationOptionsConverterTest assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, resizeOptions=null, autoOrient=false]]", - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -233,8 +213,8 @@ public class TransformationOptionsConverterTest assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_JPEG, "ImageTransformationOptions [commandOptions=, resizeOptions=null, autoOrient=false]]", "alphaRemove=true " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -252,8 +232,8 @@ public class TransformationOptionsConverterTest "[height=-1, width=-1, xOffset=0, yOffset=0, isPercentageCrop=false, gravity=null]} ]", "cropXOffset=0 " + "cropYOffset=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -273,8 +253,8 @@ public class TransformationOptionsConverterTest "cropGravity=North " + "cropXOffset=0 " + "cropYOffset=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -296,8 +276,8 @@ public class TransformationOptionsConverterTest "cropWidth=30 " + "cropXOffset=0 " + "cropYOffset=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -317,8 +297,8 @@ public class TransformationOptionsConverterTest "cropPercentage=true " + "cropXOffset=0 " + "cropYOffset=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -338,8 +318,8 @@ public class TransformationOptionsConverterTest "[height=-1, width=-1, xOffset=20, yOffset=59, isPercentageCrop=false, gravity=null]} ]", "cropXOffset=20 " + "cropYOffset=59 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -355,8 +335,8 @@ public class TransformationOptionsConverterTest "ImageTransformationOptions [commandOptions=, " + "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=true, " + "percentResize=false, resizeToThumbnail=false, allowEnlargement=true], autoOrient=false]]", - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -374,8 +354,8 @@ public class TransformationOptionsConverterTest "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=true, " + "percentResize=false, resizeToThumbnail=false, allowEnlargement=false], autoOrient=false]]", "allowEnlargement=false " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -393,8 +373,8 @@ public class TransformationOptionsConverterTest "resizeOptions=ImageResizeOptions [width=-1, height=-1, maintainAspectRatio=false, " + "percentResize=false, resizeToThumbnail=false, allowEnlargement=true], autoOrient=false]]", "maintainAspectRatio=false " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -414,8 +394,8 @@ public class TransformationOptionsConverterTest "percentResize=false, resizeToThumbnail=false, allowEnlargement=false], autoOrient=false]]", "allowEnlargement=false " + "maintainAspectRatio=false " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -437,8 +417,8 @@ public class TransformationOptionsConverterTest "allowEnlargement=false " + "maintainAspectRatio=false " + "thumbnail=true " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -462,8 +442,8 @@ public class TransformationOptionsConverterTest "maintainAspectRatio=false " + "resizeHeight=15 " + "resizeWidth=18 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -485,8 +465,8 @@ public class TransformationOptionsConverterTest "allowEnlargement=false " + "maintainAspectRatio=false " + "resizePercentage=true " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -505,8 +485,8 @@ public class TransformationOptionsConverterTest "resizeOptions=null, autoOrient=false], " + "sourceOptions={ PagedSourceOptionsPagedSourceOptions {1, 1}} ]", "endPage=0 startPage=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } @Test @@ -525,8 +505,8 @@ public class TransformationOptionsConverterTest "contentWriterNodeRef=null, pageLimit=-1, flashVersion=9, timeoutMs=-1, maxPages=-1, " + "sourceContentProperty=null, targetContentProperty=null, includeEmbedded=null, readLimitTimeMs=-1}", "flashVersion=9 " + - "timeout=-1 ", - false); // SWFTransformationOptions are not used by ImageMagickContentTransformerWorker + "timeout=-1 " + ); // SWFTransformationOptions are not used by ImageMagickContentTransformerWorker } @Test @@ -582,7 +562,7 @@ public class TransformationOptionsConverterTest "resizeHeight=30 " + "resizeWidth=20 " + "startPage=0 " + - "timeout=-1 ", - true); + "timeout=-1 " + ); } } \ No newline at end of file diff --git a/repository/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java b/repository/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java index 9f369eca44..5cebb8acaf 100644 --- a/repository/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java +++ b/repository/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java @@ -50,7 +50,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Date; /** - * Tests for retrieving frozen content from a verioned node + * Tests for getting content readers and writers. * * @author Roy Wetherall */ @@ -110,57 +110,6 @@ public class ContentServiceImplTest extends BaseVersionStoreTest assertEquals(UPDATED_CONTENT, contentReader2.getContentString()); } - @Test - @Deprecated - public void testTransformAndNulls() - { - NodeRef versionableNode = createNewVersionableNode(); - ContentReader contentReader = this.contentService.getReader(versionableNode, ContentModel.PROP_CONTENT); - ContentWriter contentWriter = this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, false); - - // this.nodeService.setProperty(versionableNode, ContentModel.PROP_NAME, "for debugTransformers.txt"); - try - { - this.contentService.transform(new MimetypeMapTest.DummyContentReader(MimetypeMap.MIMETYPE_TEXT_PLAIN), - new MimetypeMapTest.DummyContentWriter(MimetypeMap.MIMETYPE_IMAGE_PNG), - new TransformationOptions(versionableNode,ContentModel.PROP_NAME, null, null)); - } catch (NoTransformerException nte) - { - nte.getMessage().contains("No transformation exists"); - } - - try - { - this.contentService.transform(null, null, new TransformationOptions()); - fail("Should throw exception"); - } - catch (AlfrescoRuntimeException are) - { - are.getMessage().contains("The content reader must be set"); - } - - ContentReader empty = new EmptyContentReader("empty.txt"); - try - { - this.contentService.transform(empty, null, new TransformationOptions()); - fail("Should throw exception"); - } - catch (AlfrescoRuntimeException are) - { - are.getMessage().contains("The content reader mimetype must be set"); - } - - try - { - contentWriter.setMimetype(null); - this.contentService.transform(contentReader, contentWriter, new TransformationOptions()); - fail("Should throw exception"); - } - catch (AlfrescoRuntimeException are) - { - are.getMessage().contains("The content writer mimetype must be set"); - } - } /** * Test getWriter */ @@ -230,40 +179,4 @@ public class ContentServiceImplTest extends BaseVersionStoreTest assertEquals(null, contentService.getDirectAccessUrl(nodeRef, null)); assertEquals(null, contentService.getDirectAccessUrl(nodeRef, expiresAt)); } - -// Commented out as OpenOffice is not on the build machines. -// public void testGetTransformer0() -// { -// ContentTransformer transformer = contentService.getTransformer("test", "application/vnd.ms-excel", 0, -// "application/x-shockwave-flash", new TransformationOptions()); -// assertTrue("Should have found a transformer for 0 bytes", transformer != null); -// } -// -// public void testGetTransformer10K() -// { -// ContentTransformer transformer = contentService.getTransformer("test", "application/vnd.ms-excel", 1024*10, -// "application/x-shockwave-flash", new TransformationOptions()); -// assertTrue("Should have found a transformer for 10 K", transformer != null); -// } -// -// public void testGetTransformer1M() -// { -// ContentTransformer transformer = contentService.getTransformer("test", "application/vnd.ms-excel", 1024*1024, -// "application/x-shockwave-flash", new TransformationOptions()); -// assertTrue("Should have found a transformer for 1M", transformer != null); -// } -// -// public void testGetTransformer10M() -// { -// ContentTransformer transformer = contentService.getTransformer("test", "application/vnd.ms-excel", 1024*1024*10, -// "application/x-shockwave-flash", new TransformationOptions()); -// assertTrue("Should NOT have found a transformer for 10M as the is a 1M limit on xsl mimetype", transformer == null); -// } -// -// public void testGetMaxSourceSizeByes() -// { -// long maxSourceSizeBytes = contentService.getMaxSourceSizeBytes("application/vnd.ms-excel", -// "application/x-shockwave-flash", new TransformationOptions()); -// assertEquals("Should have found a transformer that can handle 1M", 1024*1024, maxSourceSizeBytes); -// } } diff --git a/repository/src/test/resources/alfresco/metadata/ConcurrencyPdfBoxMetadataExtracterTest-SlowPdfBoxMetadataExtracter.properties b/repository/src/test/resources/alfresco/metadata/ConcurrencyPdfBoxMetadataExtracterTest-SlowPdfBoxMetadataExtracter.properties deleted file mode 100644 index 156b5d63a7..0000000000 --- a/repository/src/test/resources/alfresco/metadata/ConcurrencyPdfBoxMetadataExtracterTest-SlowPdfBoxMetadataExtracter.properties +++ /dev/null @@ -1,11 +0,0 @@ -# -# Copied form PdfBoxMetadataExtracter -# -# Namespaces -namespace.prefix.cm=http://www.alfresco.org/model/content/1.0 - -# Mappings -author=cm:author -title=cm:title -subject=cm:description -created=cm:created \ No newline at end of file diff --git a/repository/src/test/resources/log4j.properties b/repository/src/test/resources/log4j.properties index b9510ac529..332062a9fa 100644 --- a/repository/src/test/resources/log4j.properties +++ b/repository/src/test/resources/log4j.properties @@ -225,11 +225,6 @@ log4j.logger.freemarker.runtime= # Metadata extraction log4j.logger.org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter=warn -# Reduces PDFont error level due to ALF-7105 -log4j.logger.org.apache.pdfbox.pdmodel.font.PDSimpleFont=fatal -log4j.logger.org.apache.pdfbox.pdmodel.font.PDFont=fatal -log4j.logger.org.apache.pdfbox.pdmodel.font.PDCIDFont=fatal - # no index support log4j.logger.org.alfresco.repo.search.impl.noindex.NoIndexIndexer=fatal log4j.logger.org.alfresco.repo.search.impl.noindex.NoIndexSearchService=fatal @@ -255,7 +250,6 @@ log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug log4j.logger.org.alfresco.repo.rendition2=debug #log4j.logger.org.alfresco.repo.rendition2.LocalTransformClient=debug -#log4j.logger.org.alfresco.repo.rendition2.LegacyTransformClient=debug #log4j.logger.org.alfresco.repo.rendition.RenditionServiceImpl=debug #log4j.logger.org.alfresco.enterprise.repo.rendition2.RemoteTransformClient=debug log4j.logger.org.alfresco.repo.thumbnail.ThumbnailServiceImplTest=DEBUG diff --git a/repository/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml b/repository/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml deleted file mode 100644 index 280e6eb733..0000000000 --- a/repository/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - true - - - - - - false - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - application/vnd.oasis.opendocument.text - - - - - - - text/html - application/pdf - - - - - - - text/html - application/pdf - - - - - - - - - - - - - - - - diff --git a/repository/src/test/resources/org/alfresco/repo/rendition2/test-transform-context.xml b/repository/src/test/resources/org/alfresco/repo/rendition2/test-transform-context.xml index 866e77805e..8445fe5543 100644 --- a/repository/src/test/resources/org/alfresco/repo/rendition2/test-transform-context.xml +++ b/repository/src/test/resources/org/alfresco/repo/rendition2/test-transform-context.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/repository/src/test/resources/test/alfresco/test-renditions-context.xml b/repository/src/test/resources/test/alfresco/test-renditions-context.xml index 0f83e5eb4a..855d93a1e7 100644 --- a/repository/src/test/resources/test/alfresco/test-renditions-context.xml +++ b/repository/src/test/resources/test/alfresco/test-renditions-context.xml @@ -9,7 +9,7 @@ - +
    1The