diff --git a/l10n.properties b/l10n.properties index fe5e58be8e..49f12fd6ea 100644 --- a/l10n.properties +++ b/l10n.properties @@ -1,7 +1,7 @@ # Branch specific configuration file for localisation scripts -MESSAGE_SEARCH_PATH="src/main/resources/alfresco/messages/action-config*.properties src/main/resources/alfresco/messages/action-service*.properties src/main/resources/alfresco/messages/activiti-engine-messages*.properties src/main/resources/alfresco/messages/activities-service*.properties src/main/resources/alfresco/messages/activity-list*.properties src/main/resources/alfresco/messages/application-model*.properties src/main/resources/alfresco/messages/authentication*.properties src/main/resources/alfresco/messages/bootstrap-content-template-examples*.properties src/main/resources/alfresco/messages/bootstrap-example-javascripts*.properties src/main/resources/alfresco/messages/bootstrap-example-smartfoldertemplates*.properties src/main/resources/alfresco/messages/bootstrap-imapScripts*.properties src/main/resources/alfresco/messages/bootstrap-javascripts*.properties src/main/resources/alfresco/messages/bootstrap-messages*.properties src/main/resources/alfresco/messages/bootstrap-readme-template*.properties src/main/resources/alfresco/messages/bootstrap-spaces*.properties src/main/resources/alfresco/messages/bootstrap-templates*.properties src/main/resources/alfresco/messages/bootstrap-tutorial*.properties src/main/resources/alfresco/messages/bootstrap-webScripts*.properties src/main/resources/alfresco/messages/bootstrap-webScriptsExtensions*.properties src/main/resources/alfresco/messages/bpm-messages*.properties src/main/resources/alfresco/messages/categories*.properties src/main/resources/alfresco/messages/coci-service*.properties src/main/resources/alfresco/messages/content-filter-languages*.properties src/main/resources/alfresco/messages/content-model*.properties src/main/resources/alfresco/messages/copy-service*.properties src/main/resources/alfresco/messages/custommodel-service*.properties src/main/resources/alfresco/messages/discussion-messages*.properties src/main/resources/alfresco/messages/distributionpolicies-model*.properties src/main/resources/alfresco/messages/doclink-service*.properties src/main/resources/alfresco/messages/download-model*.properties src/main/resources/alfresco/messages/email-server-model*.properties src/main/resources/alfresco/messages/email-service*.properties src/main/resources/alfresco/messages/file-folder-service*.properties src/main/resources/alfresco/messages/form-service*.properties src/main/resources/alfresco/messages/forum-model*.properties src/main/resources/alfresco/messages/imap-service*.properties src/main/resources/alfresco/messages/initiate-inplace*.properties src/main/resources/alfresco/messages/invitation-service*.properties src/main/resources/alfresco/messages/lock-service*.properties src/main/resources/alfresco/messages/notification-service*.properties src/main/resources/alfresco/messages/period-provider*.properties src/main/resources/alfresco/messages/permissions-service*.properties src/main/resources/alfresco/messages/publishing-model*.properties src/main/resources/alfresco/messages/publishing-service*.properties src/main/resources/alfresco/messages/quickshare-service*.properties src/main/resources/alfresco/messages/rendition-config*.properties src/main/resources/alfresco/messages/replication*.properties src/main/resources/alfresco/messages/repoadmin-service*.properties src/main/resources/alfresco/messages/reset-password-messages*.properties src/main/resources/alfresco/messages/rule-config*.properties src/main/resources/alfresco/messages/site-model*.properties src/main/resources/alfresco/messages/site-service*.properties src/main/resources/alfresco/messages/slingshot*.properties src/main/resources/alfresco/messages/smartfolder-model*.properties src/main/resources/alfresco/messages/subscription-service*.properties src/main/resources/alfresco/messages/system-messages*.properties src/main/resources/alfresco/messages/system-model*.properties src/main/resources/alfresco/messages/template-service*.properties src/main/resources/alfresco/messages/templates-messages*.properties src/main/resources/alfresco/messages/transfer-model*.properties src/main/resources/alfresco/messages/transfer-service*.properties src/main/resources/alfresco/messages/ui-inplace*.properties src/main/resources/alfresco/messages/webdav-messages*.properties src/main/resources/alfresco/messages/workflow-package-messages*.properties src/main/resources/alfresco/workflow/invitation-moderated-workflow-messages*.properties src/main/resources/alfresco/workflow/invitation-nominated-workflow-messages*.properties src/main/resources/alfresco/workflow/workflow-messages*.properties" +MESSAGE_SEARCH_PATH="src/main/resources/alfresco/messages/action-config*.properties src/main/resources/alfresco/messages/action-service*.properties src/main/resources/alfresco/messages/activiti-engine-messages*.properties src/main/resources/alfresco/messages/activities-service*.properties src/main/resources/alfresco/messages/activity-list*.properties src/main/resources/alfresco/messages/application-model*.properties src/main/resources/alfresco/messages/authentication*.properties src/main/resources/alfresco/messages/bootstrap-content-template-examples*.properties src/main/resources/alfresco/messages/bootstrap-example-javascripts*.properties src/main/resources/alfresco/messages/bootstrap-example-smartfoldertemplates*.properties src/main/resources/alfresco/messages/bootstrap-imapScripts*.properties src/main/resources/alfresco/messages/bootstrap-javascripts*.properties src/main/resources/alfresco/messages/bootstrap-messages*.properties src/main/resources/alfresco/messages/bootstrap-readme-template*.properties src/main/resources/alfresco/messages/bootstrap-spaces*.properties src/main/resources/alfresco/messages/bootstrap-templates*.properties src/main/resources/alfresco/messages/bootstrap-tutorial*.properties src/main/resources/alfresco/messages/bootstrap-webScripts*.properties src/main/resources/alfresco/messages/bootstrap-webScriptsExtensions*.properties src/main/resources/alfresco/messages/bpm-messages*.properties src/main/resources/alfresco/messages/categories*.properties src/main/resources/alfresco/messages/coci-service*.properties src/main/resources/alfresco/messages/content-filter-languages*.properties src/main/resources/alfresco/messages/content-model*.properties src/main/resources/alfresco/messages/copy-service*.properties src/main/resources/alfresco/messages/custommodel-service*.properties src/main/resources/alfresco/messages/discussion-messages*.properties src/main/resources/alfresco/messages/distributionpolicies-model*.properties src/main/resources/alfresco/messages/doclink-service*.properties src/main/resources/alfresco/messages/download-model*.properties src/main/resources/alfresco/messages/email-server-model*.properties src/main/resources/alfresco/messages/email-service*.properties src/main/resources/alfresco/messages/file-folder-service*.properties src/main/resources/alfresco/messages/form-service*.properties src/main/resources/alfresco/messages/forum-model*.properties src/main/resources/alfresco/messages/imap-service*.properties src/main/resources/alfresco/messages/initiate-inplace*.properties src/main/resources/alfresco/messages/invitation-service*.properties src/main/resources/alfresco/messages/lock-service*.properties src/main/resources/alfresco/messages/notification-service*.properties src/main/resources/alfresco/messages/period-provider*.properties src/main/resources/alfresco/messages/permissions-service*.properties src/main/resources/alfresco/messages/quickshare-service*.properties src/main/resources/alfresco/messages/rendition-config*.properties src/main/resources/alfresco/messages/replication*.properties src/main/resources/alfresco/messages/repoadmin-service*.properties src/main/resources/alfresco/messages/reset-password-messages*.properties src/main/resources/alfresco/messages/rule-config*.properties src/main/resources/alfresco/messages/site-model*.properties src/main/resources/alfresco/messages/site-service*.properties src/main/resources/alfresco/messages/slingshot*.properties src/main/resources/alfresco/messages/smartfolder-model*.properties src/main/resources/alfresco/messages/subscription-service*.properties src/main/resources/alfresco/messages/system-messages*.properties src/main/resources/alfresco/messages/system-model*.properties src/main/resources/alfresco/messages/template-service*.properties src/main/resources/alfresco/messages/templates-messages*.properties src/main/resources/alfresco/messages/transfer-model*.properties src/main/resources/alfresco/messages/transfer-service*.properties src/main/resources/alfresco/messages/ui-inplace*.properties src/main/resources/alfresco/messages/webdav-messages*.properties src/main/resources/alfresco/messages/workflow-package-messages*.properties src/main/resources/alfresco/workflow/invitation-moderated-workflow-messages*.properties src/main/resources/alfresco/workflow/invitation-nominated-workflow-messages*.properties src/main/resources/alfresco/workflow/workflow-messages*.properties" -EXCLUDED_FILES="src/main/resources/alfresco/messages/content-service.properties src/main/resources/alfresco/messages/module-messages.properties src/main/resources/alfresco/messages/patch-service.properties src/main/resources/alfresco/messages/repoadmin-interpreter-help.properties src/main/resources/alfresco/messages/schema-update.properties src/main/resources/alfresco/messages/tenant-interpreter-help.properties src/main/resources/alfresco/messages/version-service.properties src/main/resources/alfresco/messages/workflow-interpreter-help.properties src/main/resources/alfresco/alfresco-shared.properties src/main/resources/alfresco/caches.properties src/main/resources/alfresco/repository.properties src/main/resources/alfresco/client/config/repo-clients-apps.properties src/main/resources/alfresco/domain/cache-strategies.properties src/main/resources/alfresco/domain/hibernate-cfg.properties src/main/resources/alfresco/domain/quartz.properties src/main/resources/alfresco/domain/transaction.properties src/main/resources/alfresco/keystore/keystore-passwords.properties src/main/resources/alfresco/keystore/ssl-keystore-passwords.properties src/main/resources/alfresco/keystore/ssl-truststore-passwords.properties src/main/resources/alfresco/metadata/DWGMetadataExtracter.properties src/main/resources/alfresco/metadata/HtmlMetadataExtracter.properties src/main/resources/alfresco/metadata/MailMetadataExtracter.properties src/main/resources/alfresco/metadata/MP3MetadataExtracter.properties src/main/resources/alfresco/metadata/OfficeMetadataExtracter.properties src/main/resources/alfresco/metadata/PdfBoxMetadataExtracter.properties src/main/resources/alfresco/metadata/PoiMetadataExtracter.properties src/main/resources/alfresco/metadata/RFC822MetadataExtracter.properties src/main/resources/alfresco/metadata/TikaAudioMetadataExtracter.properties src/main/resources/alfresco/metadata/TikaAutoMetadataExtracter.properties src/main/resources/alfresco/metadata/TikaSpringConfiguredMetadataExtracter.properties src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties src/main/resources/alfresco/subsystems/Authentication/alfrescoNtlm/alfresco-authentication.properties src/main/resources/alfresco/subsystems/Authentication/external/external-authentication.properties src/main/resources/alfresco/subsystems/Authentication/kerberos/kerberos-authentication.properties src/main/resources/alfresco/subsystems/Authentication/ldap/ldap-authentication.properties src/main/resources/alfresco/subsystems/Authentication/ldap-ad/ldap-ad-authentication.properties src/main/resources/alfresco/subsystems/Authentication/passthru/passthru-authentication-context.properties src/main/resources/alfresco/subsystems/email/InboundSMTP/inboundSMTP.properties src/main/resources/alfresco/subsystems/email/OutboundSMTP/outboundSMTP.properties src/main/resources/alfresco/subsystems/fileServers/default/file-servers.properties src/main/resources/alfresco/subsystems/imap/default/imap-server.properties src/main/resources/alfresco/subsystems/Replication/default/replication.properties src/main/resources/alfresco/subsystems/Search/noindex/common-search.properties src/main/resources/alfresco/subsystems/Search/noindex/noindex-search.properties src/main/resources/alfresco/subsystems/Search/solr/common-search.properties src/main/resources/alfresco/subsystems/Search/solr/solr-backup.properties src/main/resources/alfresco/subsystems/Search/solr/solr-search.properties src/main/resources/alfresco/subsystems/Search/solr/facet/solr-facets-config.properties src/main/resources/alfresco/subsystems/Search/solr4/common-search.properties src/main/resources/alfresco/subsystems/Search/solr4/solr-backup.properties src/main/resources/alfresco/subsystems/Search/solr4/solr-search.properties src/main/resources/alfresco/subsystems/Search/solr6/common-search.properties src/main/resources/alfresco/subsystems/Search/solr6/solr-backup.properties src/main/resources/alfresco/subsystems/Search/solr6/solr-search.properties src/main/resources/alfresco/subsystems/Subscriptions/default/subscription-service.properties src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization.properties src/main/resources/alfresco/subsystems/sysAdmin/default/sysadmin-parameter.properties src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform.properties src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform.properties src/main/resources/alfresco/subsystems/Transformers/default/transformers.properties src/main/resources/org/alfresco/encryption/keystore-parameters.properties src/main/resources/org/alfresco/repo/i18n/testMessages.properties src/main/resources/org/alfresco/repo/module/tool/default-file-mapping.properties src/main/resources/org/alfresco/repo/publishing/facebook/facebook-publishing.properties src/main/resources/org/alfresco/repo/publishing/flickr/flickr-publishing.properties src/main/resources/org/alfresco/repo/publishing/linkedin/linkedin-publishing.properties src/main/resources/org/alfresco/repo/publishing/slideshare/slideshare-publishing.properties src/main/resources/org/alfresco/repo/publishing/twitter/twitter-publishing.properties src/main/resources/org/alfresco/repo/publishing/youtube/youtube-publishing.properties src/main/resources/alfresco/metadata/JodConverterMetadataExtracter.properties src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter.properties" +EXCLUDED_FILES="src/main/resources/alfresco/messages/content-service.properties src/main/resources/alfresco/messages/module-messages.properties src/main/resources/alfresco/messages/patch-service.properties src/main/resources/alfresco/messages/repoadmin-interpreter-help.properties src/main/resources/alfresco/messages/schema-update.properties src/main/resources/alfresco/messages/tenant-interpreter-help.properties src/main/resources/alfresco/messages/version-service.properties src/main/resources/alfresco/messages/workflow-interpreter-help.properties src/main/resources/alfresco/alfresco-shared.properties src/main/resources/alfresco/caches.properties src/main/resources/alfresco/repository.properties src/main/resources/alfresco/client/config/repo-clients-apps.properties src/main/resources/alfresco/domain/cache-strategies.properties src/main/resources/alfresco/domain/hibernate-cfg.properties src/main/resources/alfresco/domain/quartz.properties src/main/resources/alfresco/domain/transaction.properties src/main/resources/alfresco/keystore/keystore-passwords.properties src/main/resources/alfresco/keystore/ssl-keystore-passwords.properties src/main/resources/alfresco/keystore/ssl-truststore-passwords.properties src/main/resources/alfresco/metadata/DWGMetadataExtracter.properties src/main/resources/alfresco/metadata/HtmlMetadataExtracter.properties src/main/resources/alfresco/metadata/MailMetadataExtracter.properties src/main/resources/alfresco/metadata/MP3MetadataExtracter.properties src/main/resources/alfresco/metadata/OfficeMetadataExtracter.properties src/main/resources/alfresco/metadata/PdfBoxMetadataExtracter.properties src/main/resources/alfresco/metadata/PoiMetadataExtracter.properties src/main/resources/alfresco/metadata/RFC822MetadataExtracter.properties src/main/resources/alfresco/metadata/TikaAudioMetadataExtracter.properties src/main/resources/alfresco/metadata/TikaAutoMetadataExtracter.properties src/main/resources/alfresco/metadata/TikaSpringConfiguredMetadataExtracter.properties src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties src/main/resources/alfresco/subsystems/Authentication/alfrescoNtlm/alfresco-authentication.properties src/main/resources/alfresco/subsystems/Authentication/external/external-authentication.properties src/main/resources/alfresco/subsystems/Authentication/kerberos/kerberos-authentication.properties src/main/resources/alfresco/subsystems/Authentication/ldap/ldap-authentication.properties src/main/resources/alfresco/subsystems/Authentication/ldap-ad/ldap-ad-authentication.properties src/main/resources/alfresco/subsystems/Authentication/passthru/passthru-authentication-context.properties src/main/resources/alfresco/subsystems/email/InboundSMTP/inboundSMTP.properties src/main/resources/alfresco/subsystems/email/OutboundSMTP/outboundSMTP.properties src/main/resources/alfresco/subsystems/fileServers/default/file-servers.properties src/main/resources/alfresco/subsystems/imap/default/imap-server.properties src/main/resources/alfresco/subsystems/Replication/default/replication.properties src/main/resources/alfresco/subsystems/Search/noindex/common-search.properties src/main/resources/alfresco/subsystems/Search/noindex/noindex-search.properties src/main/resources/alfresco/subsystems/Search/solr/common-search.properties src/main/resources/alfresco/subsystems/Search/solr/solr-backup.properties src/main/resources/alfresco/subsystems/Search/solr/solr-search.properties src/main/resources/alfresco/subsystems/Search/solr/facet/solr-facets-config.properties src/main/resources/alfresco/subsystems/Search/solr4/common-search.properties src/main/resources/alfresco/subsystems/Search/solr4/solr-backup.properties src/main/resources/alfresco/subsystems/Search/solr4/solr-search.properties src/main/resources/alfresco/subsystems/Search/solr6/common-search.properties src/main/resources/alfresco/subsystems/Search/solr6/solr-backup.properties src/main/resources/alfresco/subsystems/Search/solr6/solr-search.properties src/main/resources/alfresco/subsystems/Subscriptions/default/subscription-service.properties src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization.properties src/main/resources/alfresco/subsystems/sysAdmin/default/sysadmin-parameter.properties src/main/resources/alfresco/subsystems/thirdparty/default/alfresco-pdf-renderer-transform.properties src/main/resources/alfresco/subsystems/thirdparty/default/imagemagick-transform.properties src/main/resources/alfresco/subsystems/Transformers/default/transformers.properties src/main/resources/org/alfresco/encryption/keystore-parameters.properties src/main/resources/org/alfresco/repo/i18n/testMessages.properties src/main/resources/org/alfresco/repo/module/tool/default-file-mapping.properties src/main/resources/alfresco/metadata/JodConverterMetadataExtracter.properties src/main/resources/alfresco/subsystems/OOoJodconverter/default/jodconverter.properties" diff --git a/pom.xml b/pom.xml index 3523bfd5b3..794de0549b 100644 --- a/pom.xml +++ b/pom.xml @@ -567,38 +567,6 @@ ${dependency.webscripts.version} - - - org.springframework.social - spring-social-core - 1.0.3.RELEASE - - - org.springframework.social - spring-social-linkedin - 1.0.0-20110711 - - - org.springframework.social - spring-social-facebook - 1.1.1.RELEASE - - - org.springframework.social - spring-social-facebook-web - 1.1.1.RELEASE - - - org.springframework.social - spring-social-web - 1.1.4.RELEASE - - - org.springframework.social - spring-social-twitter - 1.1.2.RELEASE - - org.apache.chemistry.opencmis diff --git a/src/main/java/org/alfresco/repo/publishing/AbstractChannelType.java b/src/main/java/org/alfresco/repo/publishing/AbstractChannelType.java deleted file mode 100644 index de7469d630..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/AbstractChannelType.java +++ /dev/null @@ -1,219 +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.publishing; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.repo.node.encryption.MetadataEncryptor; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * @author Nick Smith - * @since 4.0 - */ -public abstract class AbstractChannelType implements ChannelType, ChannelTypePublishingOperations -{ - private NodeService nodeService; - private ChannelService channelService; - private MetadataEncryptor encryptor; - private boolean hidden = false; - - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - channelService.register(this); - } - - protected ChannelService getChannelService() - { - return channelService; - } - - public void setEncryptor(MetadataEncryptor encryptor) - { - this.encryptor = encryptor; - } - - protected MetadataEncryptor getEncryptor() - { - return encryptor; - } - - protected NodeService getNodeService() - { - return nodeService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - @Override - public String getTitle() - { - String title = I18NUtil.getMessage("publishing.channel-type." + getId() + ".title"); - return title == null ? getId() : title; - } - - /** - * {@inheritDoc} - */ - @Override - public int getMaximumStatusLength() - { - return 0; - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - // Returning a null as the authorisation request URL here to indicate that we should use our own - // credential-gathering mechanism. - return new AuthUrlPair(null, callbackUrl); - } - - @Override - public final AuthStatus acceptAuthorisationCallback(Channel channel, Map callbackHeaders, - Map callbackParams) - { - ParameterCheck.mandatory("channel", channel); - ParameterCheck.mandatory("callbackHeaders", callbackHeaders); - ParameterCheck.mandatory("callbackParams", callbackParams); - if (!getId().equals(channel.getChannelType().getId())) - { - throw new IllegalArgumentException("Supplied channel is of the incorrect type. Expected " + getId() - + "; Received " + channel.getChannelType().getId()); - } - - AuthStatus result = internalAcceptAuthorisation(channel, callbackHeaders, callbackParams); - - Map props = new HashMap(); - props.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.valueOf(AuthStatus.AUTHORISED.equals(result))); - channelService.updateChannel(channel, props); - return result; - } - - protected AuthStatus internalAcceptAuthorisation(Channel channel, Map callbackHeaders, - Map callbackParams) - { - AuthStatus result = AuthStatus.UNAUTHORISED; - String[] username = callbackParams.get("username"); - String[] password = callbackParams.get("password"); - if (username != null && password != null) - { - Map props = new HashMap(); - props.put(PublishingModel.PROP_CHANNEL_USERNAME, username[0]); - props.put(PublishingModel.PROP_CHANNEL_PASSWORD, password[0]); - channelService.updateChannel(channel, props); - // TODO: BJR: 20110707: Should test the connection here - result = AuthStatus.AUTHORISED; - } - return result; - } - - public Resource getIcon(String sizeSuffix) - { - String className = this.getClass().getCanonicalName(); - className = className.replaceAll("\\.", "\\/"); - StringBuilder iconPath = new StringBuilder(className); - iconPath.append(sizeSuffix).append('.').append(getIconFileExtension()); - Resource resource = new ClassPathResource(iconPath.toString()); - return resource.exists() ? resource : null; - } - - public String getIconFileExtension() - { - return "png"; - } - - @Override - public Set getSupportedContentTypes() - { - return Collections.emptySet(); - } - - @Override - public Set getSupportedMimeTypes() - { - return Collections.emptySet(); - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - throw new UnsupportedOperationException(); - } - - @Override - public void publish(NodeRef nodeToPublish, Map channelProperties) - { - throw new UnsupportedOperationException(); - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map channelProperties) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getNodeUrl(NodeRef node) - { - String url = null; - if (node != null && nodeService.exists(node) && nodeService.hasAspect(node, PublishingModel.ASPECT_ASSET)) - { - url = (String)nodeService.getProperty(node, PublishingModel.PROP_ASSET_URL); - } - return url; - } - - @Override - public boolean isHidden() - { - return hidden; - } - - @Override - public void setHidden(boolean hidden) - { - this.hidden = hidden; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/AbstractOAuth1ChannelType.java b/src/main/java/org/alfresco/repo/publishing/AbstractOAuth1ChannelType.java deleted file mode 100644 index 351ecdf55d..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/AbstractOAuth1ChannelType.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.publishing; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.springframework.social.connect.Connection; -import org.springframework.social.connect.support.OAuth1ConnectionFactory; -import org.springframework.social.oauth1.AuthorizedRequestToken; -import org.springframework.social.oauth1.OAuth1Operations; -import org.springframework.social.oauth1.OAuth1Parameters; -import org.springframework.social.oauth1.OAuthToken; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - * - * @param The API type, e.g. Twitter, Flickr, LinkedIn, etc. - */ -public abstract class AbstractOAuth1ChannelType extends AbstractChannelType -{ - private OAuth1ConnectionFactory connectionFactory; - - protected Connection getConnectionForChannel(NodeRef channelNode) - { - NodeService nodeService = getNodeService(); - Connection connection = null; - if (nodeService.exists(channelNode) - && nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL)) - { - String tokenValue = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, nodeService - .getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_VALUE)); - String tokenSecret = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, nodeService - .getProperty(channelNode, PublishingModel.PROP_OAUTH1_TOKEN_SECRET)); - Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE); - - if (danceComplete) - { - OAuthToken token = new OAuthToken(tokenValue, tokenSecret); - connection = connectionFactory.createConnection(token); - } - } - return connection; - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - ParameterCheck.mandatory("channel", channel); - ParameterCheck.mandatory("callbackUrl", callbackUrl); - if (!getId().equals(channel.getChannelType().getId())) - { - throw new IllegalArgumentException("Invalid channel type: " + channel.getChannelType().getId()); - } - - NodeService nodeService = getNodeService(); - OAuth1Operations oauthOperations = getOAuth1Operations(); - OAuthToken requestToken = oauthOperations.fetchRequestToken(callbackUrl, null); - - NodeRef channelNodeRef = channel.getNodeRef(); - nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_SECRET, - getEncryptor().encrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, requestToken.getSecret())); - nodeService.setProperty(channelNodeRef, PublishingModel.PROP_OAUTH1_TOKEN_VALUE, - getEncryptor().encrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, requestToken.getValue())); - - String authUrl = oauthOperations.buildAuthorizeUrl(requestToken.getValue(), getOAuth1Parameters(callbackUrl)); - return new AuthUrlPair(authUrl, callbackUrl); - } - - @Override - protected AuthStatus internalAcceptAuthorisation(Channel channel, Map callbackHeaders, - Map callbackParams) - { - NodeService nodeService = getNodeService(); - AuthStatus authorised = AuthStatus.UNAUTHORISED; - String[] verifier = callbackParams.get(getOAuthVerifierParamName()); - if (verifier != null) - { - OAuth1Operations oauthOperations = getOAuth1Operations(); - NodeRef channelNodeRef = channel.getNodeRef(); - - Map currentProps = nodeService.getProperties(channelNodeRef); - String tokenValue = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, currentProps - .get(PublishingModel.PROP_OAUTH1_TOKEN_VALUE)); - String tokenSecret = (String) getEncryptor().decrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, currentProps - .get(PublishingModel.PROP_OAUTH1_TOKEN_SECRET)); - OAuthToken token = new OAuthToken(tokenValue, tokenSecret); - OAuthToken accessToken = oauthOperations.exchangeForAccessToken(new AuthorizedRequestToken(token, verifier[0]), null); - - Map newProps = new HashMap(); - newProps.put(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, accessToken.getValue()); - newProps.put(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, accessToken.getSecret()); - newProps = getEncryptor().encrypt(newProps); - getChannelService().updateChannel(channel, newProps); - authorised = AuthStatus.AUTHORISED; - } - return authorised; - } - - /** - * Override this method to add additonal parameters onto the URL that the user is redirected to - * to authorise access to their account. By default, no parameters are added, but this may be useful to - * specify things such as the permissions being sought, and so on. - * @param callbackUrl String - * @return Do not return null. If no parameters are to be added, return {@link OAuth1Parameters#NONE} - */ - protected OAuth1Parameters getOAuth1Parameters(String callbackUrl) - { - return OAuth1Parameters.NONE; - } - - protected String getOAuthVerifierParamName() - { - return "oauth_verifier"; - } - - private OAuth1Operations getOAuth1Operations() - { - return connectionFactory.getOAuthOperations(); - } - - /** - * @param connectionFactory the connectionFactory to set - */ - public void setConnectionFactory(OAuth1ConnectionFactory connectionFactory) - { - this.connectionFactory = connectionFactory; - } -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/ChannelHelper.java b/src/main/java/org/alfresco/repo/publishing/ChannelHelper.java deleted file mode 100644 index b5f6872911..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/ChannelHelper.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.publishing; - -import static org.alfresco.model.ContentModel.ASSOC_CONTAINS; -import static org.alfresco.repo.publishing.PublishingModel.ASPECT_PUBLISHED; -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_SOURCE; -import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL; -import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE; -import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE_ID; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.node.NodeUtils; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.dictionary.TypeDefinition; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.alfresco.util.collections.CollectionUtils; -import org.alfresco.util.collections.Filter; -import org.alfresco.util.collections.Function; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class ChannelHelper -{ - public static final String NAME = "channelHelper"; - - private NodeService nodeService; - private DictionaryService dictionaryService; - private FileFolderService fileFolderService; - private PermissionService permissionService; - - private ServiceRegistry serviceRegistry; - private PublishingEventHelper eventHelper; - - public ChannelHelper() - { - super(); - } - - public ChannelHelper(ServiceRegistry serviceRegistry, PublishingEventHelper eventHelper) - { - this.serviceRegistry = serviceRegistry; - this.eventHelper = eventHelper; - } - - public NodeRef createChannelNode(NodeRef parent, ChannelType channelType, String channelName, - Map props) - { - QName channelQName = getChannelQName(channelName); - QName channelNodeType = channelType.getChannelNodeType(); - ChildAssociationRef channelAssoc = - nodeService.createNode(parent, ASSOC_CONTAINS, channelQName, channelNodeType, props); - NodeRef channelNode = channelAssoc.getChildRef(); - // Allow any user to read Channel permissions. - permissionService.setPermission(channelNode, PermissionService.ALL_AUTHORITIES, PermissionService.READ_ASSOCIATIONS, true); - return channelNode; - } - - public Channel buildChannelObject(NodeRef nodeRef, ChannelService channelService) - { - if (nodeRef == null || nodeService.exists(nodeRef) == false) - { - return null; - } - Map props = nodeService.getProperties(nodeRef); - String channelTypeId = (String) props.get(PROP_CHANNEL_TYPE_ID); - ChannelType channelType = channelService.getChannelType(channelTypeId); - String name = (String) props.get(ContentModel.PROP_NAME); - return new ChannelImpl(serviceRegistry, (AbstractChannelType) channelType, nodeRef, name, this, eventHelper); - } - - /** - * Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef published to the specified channel. - * @param source NodeRef - * @param channelNode NodeRef - * @return NodeRef - */ - public NodeRef mapSourceToEnvironment(NodeRef source, final NodeRef channelNode) - { - return mapSourceToEnvironment(source, channelNode, nodeService); - } - - /** - * Given a noderef from the editorial space (e.g. the doclib), this returns the corresponding noderef published to the specified channel. - * @param source NodeRef - * @param channelNode NodeRef - * @param nodeService NodeService - * @return NodeRef - */ - public static NodeRef mapSourceToEnvironment(NodeRef source, final NodeRef channelNode, final NodeService nodeService) - { - if (source == null || channelNode == null) - { - return null; - } - List sourceAssocs = nodeService.getSourceAssocs(source, ASSOC_SOURCE); - Function acceptor = new Filter() - { - public Boolean apply(AssociationRef assoc) - { - NodeRef publishedNode = assoc.getSourceRef(); - NodeRef parent = nodeService.getPrimaryParent(publishedNode).getParentRef(); - return channelNode.equals(parent); - } - }; - AssociationRef assoc = CollectionUtils.findFirst(sourceAssocs, acceptor); - return assoc == null ? null : assoc.getSourceRef(); - } - - /** - * Given a published noderef, this returns the corresponding source noderef in the editorial space (doclib). - * @param publishedNode NodeRef - * @return NodeRef - */ - public NodeRef mapEnvironmentToSource(NodeRef publishedNode) - { - return mapEnvironmentToSource(publishedNode, nodeService); - } - - /** - * Given a published noderef, this returns the corresponding source noderef in the editorial space (doclib). - * @param publishedNode NodeRef - * @param nodeService NodeService - * @return NodeRef - */ - public static NodeRef mapEnvironmentToSource(NodeRef publishedNode, NodeService nodeService) - { - List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_SOURCE); - return NodeUtils.getSingleAssocNode(assocs, true); - } - - /** - * Finds the {@link Channel} NodeRef and {@link ChannelType} id for a given node, if such a Channel exists. - * @param node NodeRef - * @return a {@link Pair} containing the Channel {@link NodeRef} and ChannelType Id. - */ - public Pair findChannelAndType(NodeRef node) - { - Pair result = getChannelAndTypeIfChannel(node); - if (result == null) - { - result = getChannelAndType(node); - if (result == null) - { - ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node); - if (parentAssoc != null) - { - NodeRef parent = parentAssoc.getParentRef(); - if (parent != null) - { - result = findChannelAndType(parent); - } - } - } - } - return result; - } - - public Map getChannelProperties(NodeRef channel) - { - return nodeService.getProperties(channel); - } - - public AssociationRef createMapping(NodeRef source, NodeRef publishedNode) - { - AssociationRef assoc = nodeService.createAssociation(publishedNode, source, ASSOC_SOURCE); - return assoc; - } - - public boolean canPublish(NodeRef nodeToPublish, ChannelType type) - { - if (type.canPublish() == false) - { - return false; - } - FileInfo file = fileFolderService.getFileInfo(nodeToPublish); - ContentData contentData = file.getContentData(); - String mimetype = contentData == null ? null : contentData.getMimetype(); - boolean isContentTypeSupported = isContentTypeSupported(file.getType(), type); - boolean isMimetypeSupported = isMimetypeSupported(mimetype, type); - return isContentTypeSupported && isMimetypeSupported; - } - - private boolean isMimetypeSupported(String mimetype, ChannelType type) - { - Set supportedMimetypes = type.getSupportedMimeTypes(); - if (supportedMimetypes == null || supportedMimetypes.isEmpty()) - { - return true; - } - return supportedMimetypes.contains(mimetype); - } - - private boolean isContentTypeSupported(QName contentType, ChannelType type) - { - Set supportedContentTypes = type.getSupportedContentTypes(); - if (supportedContentTypes == null || supportedContentTypes.isEmpty()) - { - return true; - } - for (QName supportedType : supportedContentTypes) - { - if (contentType.equals(supportedType) - || dictionaryService.isSubClass(contentType, supportedType)) - { - return true; - } - } - return false; - } - - private QName getChannelQName(String channelName) - { - return QName.createQName(NamespaceService.APP_MODEL_1_0_URI, channelName); - } - - private Pair getChannelAndTypeIfChannel(NodeRef node) - { - QName type = nodeService.getType(node); - if (dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) - { - String channelTypeId = (String) nodeService.getProperty(node, PROP_CHANNEL_TYPE_ID); - if (channelTypeId == null) - { - TypeDefinition typeDef = dictionaryService.getType(type); - PropertyDefinition channelTypeProp = typeDef.getProperties().get(PROP_CHANNEL_TYPE_ID); - if (channelTypeProp !=null) - { - channelTypeId = channelTypeProp.getDefaultValue(); - } - } - return new Pair(node, channelTypeId); - } - return null; - } - - public List getAllChannels(NodeRef channelContainer, final ChannelService channelService) - { - List channelAssocs = getChannelAssocs(channelContainer); - return CollectionUtils.transform(channelAssocs, getChannelTransformer(channelService, false)); - } - - - public List getChannelsForTypes(final NodeRef containerNode, List types, final ChannelService channelService, final boolean checkPermissions) - { - return CollectionUtils.transformFlat(types, new Function>() - { - public List apply(ChannelType channelType) - { - return getChannelsByType(containerNode, channelType.getId(), channelService, checkPermissions); - } - }); - } - - public List getChannelsByType(NodeRef containerNode, String channelTypeId, ChannelService channelService, boolean checkPermissions) - { - List channelAssocs = getChannelAssocsByType(containerNode, channelTypeId); - return CollectionUtils.transform(channelAssocs, getChannelTransformer(channelService, checkPermissions)); - } - - public List filterAuthorisedChannels(Collection channels) - { - return CollectionUtils.filter(channels, new Filter() - { - @Override - public Boolean apply(Channel value) - { - return value.isAuthorised(); - } - }); - } - - public List getReleventChannelTypes(final NodeRef nodeToPublish, Collection channelTypes) - { - return CollectionUtils.filter(channelTypes, new Filter() - { - public Boolean apply(ChannelType type) - { - return canPublish(nodeToPublish, type); - } - }); - } - - public List getStatusUpdateChannelTypes(Collection channelTypes) - { - return CollectionUtils.filter(channelTypes, new Filter() - { - public Boolean apply(ChannelType type) - { - return type.canPublishStatusUpdates(); - } - }); - } - - public void addPublishedAspect(NodeRef publishedNode, NodeRef channelNode) - { - nodeService.addAspect(publishedNode, ASPECT_PUBLISHED, null); - } - - private List getChannelAssocs(NodeRef channelContainer) - { - if (channelContainer == null) - { - return null; - } - Collection channelNodeTypes = dictionaryService.getSubTypes(TYPE_DELIVERY_CHANNEL, true); - HashSet childNodeTypeQNames = new HashSet(channelNodeTypes); - return nodeService.getChildAssocs(channelContainer, childNodeTypeQNames); - } - - private List getChannelAssocsByType(NodeRef channelContainer, String channelTypeId) - { - if (channelContainer == null) - { - return null; - } - return nodeService.getChildAssocsByPropertyValue(channelContainer, PROP_CHANNEL_TYPE_ID, channelTypeId); - } - - private Pair getChannelAndType(NodeRef node) - { - NodeRef channel = (NodeRef) nodeService.getProperty(node, PROP_CHANNEL); - if (channel != null) - { - String channelType = (String) nodeService.getProperty(node, PROP_CHANNEL_TYPE); - return new Pair(channel, channelType); - } - return null; - } - - private Function getChannelTransformer(final ChannelService channelService, final boolean checkPermissions) - { - return new Function() - { - public Channel apply(ChildAssociationRef value) - { - NodeRef channelNode = value.getChildRef(); - if (checkPermissions && hasPublishPermissions(channelNode)==false) - { - return null; - } - return buildChannelObject(channelNode, channelService); - } - }; - } - - public boolean hasPublishPermissions(NodeRef channelNode) - { - AccessStatus access = permissionService.hasPermission(channelNode, PermissionService.ADD_CHILDREN); - return AccessStatus.ALLOWED == access; - } - - public boolean isChannelAuthorised(NodeRef channelNode) - { - Boolean isAuthorised = Boolean.FALSE; - if (nodeService.exists(channelNode)) - { - isAuthorised = (Boolean)nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE); - } - return isAuthorised; - } - - /** - * @param nodeService the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param dictionaryService the dictionaryService to set - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param fileFolderService the fileFolderService to set - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * @param permissionService the permissionService to set - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setServiceRegistry(ServiceRegistry serviceRegistry) - { - this.serviceRegistry = serviceRegistry; - } - - public void setEventHelper(PublishingEventHelper eventHelper) - { - this.eventHelper = eventHelper; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/ChannelImpl.java b/src/main/java/org/alfresco/repo/publishing/ChannelImpl.java deleted file mode 100644 index d3a9fe302c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/ChannelImpl.java +++ /dev/null @@ -1,413 +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.publishing; - -import static org.alfresco.repo.publishing.PublishingModel.ASPECT_PUBLISHED; -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_LAST_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.NAMESPACE; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.node.NodeUtils; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.publishing.NodeSnapshot; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.GUID; -import org.alfresco.util.ParameterCheck; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class ChannelImpl implements Channel -{ - private static final String PERMISSIONS_ERR_ACCESS_DENIED = "permissions.err_access_denied"; - private final NodeRef nodeRef; - private final AbstractChannelType channelType; - private final String name; - private final ChannelHelper channelHelper; - private final NodeService nodeService; - private final DictionaryService dictionaryService; - private final PublishingEventHelper eventHelper; - - - public ChannelImpl(ServiceRegistry serviceRegistry, AbstractChannelType channelType, NodeRef nodeRef, String name, - ChannelHelper channelHelper, PublishingEventHelper eventHelper) - { - this.nodeRef = nodeRef; - this.channelType = channelType; - this.name = name; - this.channelHelper = channelHelper; - this.nodeService = serviceRegistry.getNodeService(); - this.dictionaryService = serviceRegistry.getDictionaryService(); - this.eventHelper = eventHelper; - } - - /** - * {@inheritDoc} - */ - public String getId() - { - return nodeRef.toString(); - } - - /** - * {@inheritDoc} - */ - public ChannelType getChannelType() - { - return channelType; - } - - /** - * {@inheritDoc} - */ - public String getName() - { - return name; - } - - /** - * {@inheritDoc} - */ - public NodeRef getNodeRef() - { - return nodeRef; - } - - /** - * {@inheritDoc} - */ - public Map getProperties() - { - return channelHelper.getChannelProperties(nodeRef); - } - - public void publishEvent(PublishingEvent event) - { - NodeRef eventNode = eventHelper.getPublishingEventNode(event.getId()); - for (PublishingPackageEntry entry : event.getPackage().getEntries()) - { - if (entry.isPublish()) - { - publishEntry(entry, eventNode); - } - else - { - unpublishEntry(entry); - } - } - } - - public void unpublishEntry(final PublishingPackageEntry entry) - { - final NodeRef channelNode = getNodeRef(); - if (channelHelper.hasPublishPermissions(channelNode)) - { - AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public NodeRef doWork() throws Exception - { - NodeRef unpublishedNode = channelHelper.mapSourceToEnvironment(entry.getNodeRef(), channelNode); - if (NodeUtils.exists(unpublishedNode, nodeService)) - { - unpublish(unpublishedNode); - // Need to set as temporary to delete node instead of archiving. - nodeService.addAspect(unpublishedNode, ContentModel.ASPECT_TEMPORARY, null); - nodeService.deleteNode(unpublishedNode); - } - return unpublishedNode; - } - }); - } - } - - public NodeRef publishEntry(final PublishingPackageEntry entry, final NodeRef eventNode) - { - NodeRef publishedNode; - //We decouple the permissions needed to publish from the permissions needed to do what's - //necessary to actually do the publish. If that makes sense... - //For example, a user may be able to publish to a channel even if they do not have permission - //to add an aspect to a published node (which is a necessary part of the publishing process). - if (channelHelper.hasPublishPermissions(getNodeRef())) - { - publishedNode = AuthenticationUtil.runAsSystem(new RunAsWork() - { - @Override - public NodeRef doWork() throws Exception - { - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(entry.getNodeRef(), getNodeRef()); - if (publishedNode == null) - { - publishedNode = publishNewNode(getNodeRef(), entry.getSnapshot()); - } - else - { - updatePublishedNode(publishedNode, entry); - } - eventHelper.linkToLastEvent(publishedNode, eventNode); - publish(publishedNode); - return publishedNode; - } - }); - } - else - { - throw new AccessDeniedException(PERMISSIONS_ERR_ACCESS_DENIED); - } - return publishedNode; - } - - /** - * Creates a new node under the root of the specified channel. The type, - * aspects and properties of the node are determined by the supplied - * snapshot. - * - * @param channel NodeRef - * @param snapshot NodeSnapshot - * @return the newly published node. - */ - private NodeRef publishNewNode(NodeRef channel, NodeSnapshot snapshot) - { - ParameterCheck.mandatory("channel", channel); - ParameterCheck.mandatory("snapshot", snapshot); - - NodeRef publishedNode = createPublishedNode(channel, snapshot); - addAspects(publishedNode, snapshot.getAspects()); - NodeRef source = snapshot.getNodeRef(); - channelHelper.createMapping(source, publishedNode); - return publishedNode; - } - - private void updatePublishedNode(NodeRef publishedNode, PublishingPackageEntry entry) - { - NodeSnapshot snapshot = entry.getSnapshot(); - Set newAspects = snapshot.getAspects(); - removeUnwantedAspects(publishedNode, newAspects); - - Map snapshotProps = snapshot.getProperties(); - removeUnwantedProperties(publishedNode, snapshotProps); - - // Add new properties - Map newProps= new HashMap(snapshotProps); - newProps.remove(ContentModel.PROP_NODE_UUID); - nodeService.setProperties(publishedNode, snapshotProps); - - // Add new aspects - addAspects(publishedNode, newAspects); - - List assocs = nodeService.getChildAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - nodeService.removeChildAssociation(assoc); - } - } - - /** - * @param publishedNode NodeRef - * @param snapshotProps Map - */ - private void removeUnwantedProperties(NodeRef publishedNode, Map snapshotProps) - { - Map publishProps = nodeService.getProperties(publishedNode); - Set propsToRemove = new HashSet(publishProps.keySet()); - propsToRemove.removeAll(snapshotProps.keySet()); - - //We want to retain the published asset id and URL in the updated node... - snapshotProps.put(PublishingModel.PROP_ASSET_ID, nodeService.getProperty(publishedNode, - PublishingModel.PROP_ASSET_ID)); - snapshotProps.put(PublishingModel.PROP_ASSET_URL, nodeService.getProperty(publishedNode, - PublishingModel.PROP_ASSET_URL)); - - for (QName propertyToRemove : propsToRemove) - { - nodeService.removeProperty(publishedNode, propertyToRemove); - } - } - - /** - * @param publishedNode NodeRef - * @param newAspects Set - */ - private void removeUnwantedAspects(NodeRef publishedNode, Set newAspects) - { - Set aspectsToRemove = nodeService.getAspects(publishedNode); - aspectsToRemove.removeAll(newAspects); - aspectsToRemove.remove(ASPECT_PUBLISHED); - aspectsToRemove.remove(PublishingModel.ASPECT_ASSET); - for (QName publishedAssetAspect : dictionaryService.getSubAspects(PublishingModel.ASPECT_ASSET, true)) - { - aspectsToRemove.remove(publishedAssetAspect); - } - - for (QName aspectToRemove : aspectsToRemove) - { - nodeService.removeAspect(publishedNode, aspectToRemove); - } - } - - private void addAspects(NodeRef publishedNode, Collection aspects) - { - Set currentAspects = nodeService.getAspects(publishedNode); - for (QName aspect : aspects) - { - if (currentAspects.contains(aspect) == false) - { - nodeService.addAspect(publishedNode, aspect, null); - } - } - } - - private NodeRef createPublishedNode(NodeRef root, NodeSnapshot snapshot) - { - QName type = snapshot.getType(); - Map actualProps = getPropertiesToPublish(snapshot); - String name = (String) actualProps.get(ContentModel.PROP_NAME); - if (name == null) - { - name = GUID.generate(); - } - QName assocName = QName.createQName(NAMESPACE, name); - ChildAssociationRef publishedAssoc = nodeService.createNode(root, PublishingModel.ASSOC_PUBLISHED_NODES, assocName, type, actualProps); - NodeRef publishedNode = publishedAssoc.getChildRef(); - return publishedNode; - } - - private Map getPropertiesToPublish(NodeSnapshot snapshot) - { - Map properties = snapshot.getProperties(); - // Remove the Node Ref Id - Map actualProps = new HashMap(properties); - actualProps.remove(ContentModel.PROP_NODE_UUID); - return actualProps; - } - - - private void publish(NodeRef nodeToPublish) - { - if (channelHelper.canPublish(nodeToPublish, channelType)) - { - channelHelper.addPublishedAspect(nodeToPublish, nodeRef); - channelType.publish(nodeToPublish, getProperties()); - } - } - - private void unpublish(NodeRef nodeToUnpublish) - { - if (channelType.canUnpublish()) - { - channelType.unpublish(nodeToUnpublish, getProperties()); - } - } - - /** - * {@inheritDoc} - */ - public void sendStatusUpdate(String status, String nodeUrl) - { - if (channelType.canPublishStatusUpdates()) - { - int urlLength = nodeUrl == null ? 0 : nodeUrl.length(); - int maxLength = channelType.getMaximumStatusLength() - urlLength; - if (maxLength > 0) - { - int endpoint = Math.min(maxLength, status.length()); - status = status.substring(0, endpoint ); - } - String msg = nodeUrl == null ? status : status + nodeUrl; - channelType.sendStatusUpdate(this, msg); - } - } - - /** - * {@inheritDoc} - */ - public String getUrl(NodeRef publishedNode) - { - NodeRef mappedNode = channelHelper.mapSourceToEnvironment(publishedNode, nodeRef); - return channelType.getNodeUrl(mappedNode); - } - - /** - * {@inheritDoc} - */ - public boolean isAuthorised() - { - return channelHelper.isChannelAuthorised(nodeRef); - } - - /** - * {@inheritDoc} - */ - public boolean canPublish() - { - return channelType.canPublish() && - isAuthorised() && - channelHelper.hasPublishPermissions(nodeRef); - } - - /** - * {@inheritDoc} - */ - public boolean canUnpublish() - { - return channelType.canPublish() && - isAuthorised() && - channelHelper.hasPublishPermissions(nodeRef); - } - - /** - * {@inheritDoc} - */ - public boolean canPublishStatusUpdates() - { - return channelType.canPublish() && - isAuthorised() && - channelHelper.hasPublishPermissions(nodeRef); - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/ChannelServiceImpl.java b/src/main/java/org/alfresco/repo/publishing/ChannelServiceImpl.java deleted file mode 100644 index 0c3bd8df0c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/ChannelServiceImpl.java +++ /dev/null @@ -1,319 +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.publishing; - -import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE_ID; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.node.encryption.MetadataEncryptor; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.alfresco.util.collections.CollectionUtils; -import org.alfresco.util.collections.Filter; - -/** - * @author Nick Smith - * @author Brian - * @since 4.0 - */ -public class ChannelServiceImpl implements ChannelService -{ - public static final String NAME = "ChannelService"; - - private final Map channelTypes = new TreeMap(); - private NodeService nodeService; - private DictionaryService dictionaryService; - private ChannelHelper channelHelper; - private PublishingRootObject rootObject; - private MetadataEncryptor encryptor; - - /** - * @param nodeService - * the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param dictionaryService - * the dictionaryService to set - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param rootObject the rootObject to set - */ - public void setPublishingRootObject(PublishingRootObject rootObject) - { - this.rootObject = rootObject; - } - - /** - * @param channelHelper the channelHelper to set - */ - public void setChannelHelper(ChannelHelper channelHelper) - { - this.channelHelper = channelHelper; - } - - public void setEncryptor(MetadataEncryptor encryptor) - { - this.encryptor = encryptor; - } - - /** - * {@inheritDoc} - */ - public void register(AbstractChannelType channelType) - { - ParameterCheck.mandatory("channelType", channelType); - String id = channelType.getId(); - if (channelTypes.containsKey(id)) - { - throw new IllegalArgumentException("Channel type " + id + " is already registered!"); - } - channelTypes.put(id, channelType); - } - - /** - * {@inheritDoc} - */ - public List getChannelTypes() - { - List result = new ArrayList(); - for (ChannelType channelType : channelTypes.values()) - { - if (!channelType.isHidden()) - { - result.add(channelType); - } - } - return result; - } - - /** - * {@inheritDoc} - */ - public Channel createChannel(String channelTypeId, String name, Map properties) - { - NodeRef channelContainer = getChannelContainer(); - ChannelType channelType = channelTypes.get(channelTypeId); - if (channelType == null) - { - String message = "Channel Type: " + channelTypeId + " does not exist!"; - throw new IllegalArgumentException(message); - } - Map actualProps = new HashMap(); - if (properties != null) - { - actualProps.putAll(properties); - } - actualProps.put(ContentModel.PROP_NAME, name); - actualProps.put(PROP_CHANNEL_TYPE_ID, channelType.getId()); - actualProps.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.FALSE); - actualProps = encryptor.encrypt(actualProps); - NodeRef channelNode = channelHelper.createChannelNode(channelContainer, channelType, name, actualProps); - return channelHelper.buildChannelObject(channelNode, this); - } - - /** - * {@inheritDoc} - */ - public void deleteChannel(Channel channel) - { - nodeService.deleteNode(channel.getNodeRef()); - } - - /** - * {@inheritDoc} - */ - public List getChannels() - { - NodeRef channelContainer = getChannelContainer(); - return channelHelper.getAllChannels(channelContainer, this); - } - - /** - * {@inheritDoc} - */ - @Override - public Channel getChannelByName(String channelName) - { - NodeRef node = getChannelNodeByName(channelName); - return channelHelper.buildChannelObject(node, this); - } - - private NodeRef getChannelNodeByName(String channelName) - { - ParameterCheck.mandatory("channelName", channelName); - - NodeRef channelContainer = getChannelContainer(); - if (channelContainer == null) - { - return null; - } - - NodeRef child = nodeService.getChildByName(channelContainer, ContentModel.ASSOC_CONTAINS, channelName); - if (child != null) - { - QName type = nodeService.getType(child); - if (dictionaryService.isSubClass(type, TYPE_DELIVERY_CHANNEL)) - { - return child; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - public List getRelevantPublishingChannels(NodeRef nodeToPublish) - { - NodeRef containerNode = getChannelContainer(); - List types = channelHelper.getReleventChannelTypes(nodeToPublish, channelTypes.values()); - List channels = channelHelper.getChannelsForTypes(containerNode, types, this, true); - return channelHelper.filterAuthorisedChannels(channels); - } - - /** - * {@inheritDoc} - */ - public List getPublishingChannels(boolean filterByPublishPermission) - { - final NodeRef containerNode = getChannelContainer(); - if (containerNode != null) - { - List types = CollectionUtils.filter(channelTypes.values(), new Filter() - { - public Boolean apply(ChannelType type) - { - return type.canPublish(); - } - }); - return channelHelper.getChannelsForTypes(containerNode, types, this, filterByPublishPermission); - } - return Collections.emptyList(); - } - - /** - * {@inheritDoc} - */ - public List getStatusUpdateChannels(boolean filterByPublishPermission) - { - final NodeRef containerNode = getChannelContainer(); - if (containerNode != null) - { - List types = channelHelper.getStatusUpdateChannelTypes(channelTypes.values()); - return channelHelper.getChannelsForTypes(containerNode, types, this, filterByPublishPermission); - } - return Collections.emptyList(); - } - - public List getAuthorisedStatusUpdateChannels() - { - return channelHelper.filterAuthorisedChannels(getStatusUpdateChannels(false)); - } - - private NodeRef getChannelContainer() - { - return rootObject.getChannelContainer(); - } - - /** - * {@inheritDoc} - */ - public ChannelType getChannelType(String id) - { - return channelTypes.get(id); - } - - /** - * {@inheritDoc} - */ - public void renameChannel(Channel channel, String newName) - { - NodeRef channelNode = channel.getNodeRef(); - if (channelNode != null && nodeService.exists(channelNode)) - { - NodeRef channelContainer = getChannelContainer(); - nodeService.setProperty(channelNode, ContentModel.PROP_NAME, newName); - nodeService.moveNode(channelNode, channelContainer, ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.APP_MODEL_1_0_URI, newName)); - } - } - - /** - * {@inheritDoc} - */ - public void updateChannel(Channel channel, Map properties) - { - Map actualProps = new HashMap(properties); - actualProps.remove(ContentModel.PROP_NODE_UUID); - NodeRef editorialNode = new NodeRef(channel.getId()); - actualProps = encryptor.encrypt(actualProps); - for (Map.Entry entry : actualProps.entrySet()) - { - nodeService.setProperty(editorialNode, entry.getKey(), entry.getValue()); - } - } - - /** - * {@inheritDoc} - */ - public Channel getChannelById(String id) - { - if (id != null && NodeRef.isNodeRef(id)) - { - NodeRef node = new NodeRef(id); - return channelHelper.buildChannelObject(node, this); - } - return null; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/ChannelTypePublishingOperations.java b/src/main/java/org/alfresco/repo/publishing/ChannelTypePublishingOperations.java deleted file mode 100644 index b48915e0cb..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/ChannelTypePublishingOperations.java +++ /dev/null @@ -1,38 +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.publishing; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -public interface ChannelTypePublishingOperations -{ - void publish(NodeRef nodeToPublish, Map channelProperties); - void unpublish(NodeRef nodeToUnpublish, Map channelProperties); -} diff --git a/src/main/java/org/alfresco/repo/publishing/Environment.java b/src/main/java/org/alfresco/repo/publishing/Environment.java deleted file mode 100644 index 8f037c5d84..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/Environment.java +++ /dev/null @@ -1,66 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class Environment -{ - private final NodeRef nodeRef; - private final PublishingQueueImpl queue; - private final NodeRef channelsContainer; - - public Environment(NodeRef nodeRef, PublishingQueueImpl queue, NodeRef channelsContainer) - { - this.nodeRef = nodeRef; - this.queue = queue; - this.channelsContainer = channelsContainer; - } - - public PublishingQueueImpl getPublishingQueue() - { - return queue; - } - - /** - * @return the channelsContainer - */ - public NodeRef getChannelsContainer() - { - return channelsContainer; - } - - public NodeRef getNodeRef() - { - return nodeRef; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java b/src/main/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java deleted file mode 100644 index e5cc5fdd4e..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/JaxbHttpMessageConverter.java +++ /dev/null @@ -1,253 +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.publishing; - -import java.io.IOException; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.MarshalException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.PropertyException; -import javax.xml.bind.UnmarshalException; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.transform.Result; -import javax.xml.transform.Source; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.converter.HttpMessageConversionException; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.http.converter.HttpMessageNotWritableException; -import org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * @author Brian - * @since 4.0 - */ -public class JaxbHttpMessageConverter extends AbstractXmlHttpMessageConverter -{ - private static Log log = LogFactory.getLog(JaxbHttpMessageConverter.class); - private JAXBContext defaultJaxbContext = null; - private final ConcurrentMap, JAXBContext> jaxbContexts = new ConcurrentHashMap, JAXBContext>(); - - public JaxbHttpMessageConverter() - { - super(); - } - - /** - * Create a JAXB message converter, specifying the Java packages it should use to find JAXB classes - * @param packagesToInclude A colon-separated list of package names. - * @see JAXBContext#newInstance(String) - */ - public JaxbHttpMessageConverter(String packagesToInclude) - { - super(); - try - { - defaultJaxbContext = JAXBContext.newInstance(packagesToInclude); - } - catch (JAXBException e) - { - log.error("Failed to instantiate JAXB context with supplied context path " + packagesToInclude, e); - } - } - - @Override - public boolean canRead(Class clazz, MediaType mediaType) - { - return (clazz.isAnnotationPresent(XmlRootElement.class) || clazz.isAnnotationPresent(XmlType.class)) - && canRead(mediaType); - } - - @Override - public boolean canWrite(Class clazz, MediaType mediaType) - { - return AnnotationUtils.findAnnotation(clazz, XmlRootElement.class) != null && canWrite(mediaType); - } - - @Override - protected boolean supports(Class clazz) - { - // should not be called, since we override canRead/Write - throw new UnsupportedOperationException(); - } - - @Override - protected boolean canWrite(MediaType mediaType) - { - return super.canWrite(mediaType) || MediaType.TEXT_XML.equals(mediaType); - } - - @Override - protected Object readFromSource(Class clazz, HttpHeaders headers, Source source) throws IOException - { - try - { - Unmarshaller unmarshaller = createUnmarshaller(clazz); - if (clazz.isAnnotationPresent(XmlRootElement.class)) - { - return unmarshaller.unmarshal(source); - } - else - { - JAXBElement jaxbElement = unmarshaller.unmarshal(source, clazz); - return jaxbElement.getValue(); - } - } - catch (UnmarshalException ex) - { - throw new HttpMessageNotReadableException("Could not unmarshal to [" + clazz + "]: " + ex.getMessage(), ex); - - } - catch (JAXBException ex) - { - throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex); - } - } - - @Override - protected void writeToResult(Object o, HttpHeaders headers, Result result) throws IOException - { - try - { - Class clazz = ClassUtils.getUserClass(o); - Marshaller marshaller = createMarshaller(clazz); - setCharset(headers.getContentType(), marshaller); - marshaller.marshal(o, result); - } - catch (MarshalException ex) - { - throw new HttpMessageNotWritableException("Could not marshal [" + o + "]: " + ex.getMessage(), ex); - } - catch (JAXBException ex) - { - throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex); - } - } - - private void setCharset(MediaType contentType, Marshaller marshaller) throws PropertyException - { - if (contentType != null && contentType.getCharSet() != null) - { - marshaller.setProperty(Marshaller.JAXB_ENCODING, contentType.getCharSet().name()); - } - } - - /** - * Creates a new {@link Marshaller} for the given class. - * - * @param clazz - * the class to create the marshaller for - * @return the {@code Marshaller} - * @throws HttpMessageConversionException - * in case of JAXB errors - */ - protected final Marshaller createMarshaller(Class clazz) - { - try - { - JAXBContext jaxbContext = getJaxbContext(clazz); - return jaxbContext.createMarshaller(); - } - catch (JAXBException ex) - { - throw new HttpMessageConversionException("Could not create Marshaller for class [" + clazz + "]: " - + ex.getMessage(), ex); - } - } - - /** - * Creates a new {@link Unmarshaller} for the given class. - * - * @param clazz - * the class to create the unmarshaller for - * @return the {@code Unmarshaller} - * @throws HttpMessageConversionException - * in case of JAXB errors - */ - protected final Unmarshaller createUnmarshaller(Class clazz) throws JAXBException - { - try - { - JAXBContext jaxbContext = getJaxbContext(clazz); - return jaxbContext.createUnmarshaller(); - } - catch (JAXBException ex) - { - throw new HttpMessageConversionException("Could not create Unmarshaller for class [" + clazz + "]: " - + ex.getMessage(), ex); - } - } - - /** - * Returns a {@link JAXBContext} for the given class. - * - * @param clazz - * the class to return the context for - * @return the {@code JAXBContext} - * @throws HttpMessageConversionException - * in case of JAXB errors - */ - protected final JAXBContext getJaxbContext(Class clazz) - { - Assert.notNull(clazz, "'clazz' must not be null"); - JAXBContext result = null; - if (defaultJaxbContext != null) - { - result = defaultJaxbContext; - } - else - { - result = jaxbContexts.get(clazz); - if (result == null) - { - try - { - result = JAXBContext.newInstance(clazz); - jaxbContexts.putIfAbsent(clazz, result); - } - catch (JAXBException ex) - { - throw new HttpMessageConversionException("Could not instantiate JAXBContext for class [" + clazz - + "]: " + ex.getMessage(), ex); - } - } - } - return result; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/MockChannelType.java b/src/main/java/org/alfresco/repo/publishing/MockChannelType.java deleted file mode 100644 index 40aa0c0d33..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/MockChannelType.java +++ /dev/null @@ -1,156 +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.publishing; - -import java.io.Serializable; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * For test purposes only. - * - * @author Nick Smith - * @since 4.0 - */ -public class MockChannelType extends AbstractChannelType -{ - public final static String ID = "MockChannelType"; - - /** - * {@inheritDoc} - */ - public String getId() - { - return ID; - } - - public Map getCapabilities() - { - return null; - } - - public QName getChannelNodeType() - { - return PublishingModel.TYPE_DELIVERY_CHANNEL; - } - - public QName getContentRootNodeType() - { - return ContentModel.TYPE_FOLDER; - } - - /** - * {@inheritDoc} - */ - @Override - public void publish(NodeRef nodeToPublish, Map properties) - { - // NOOP - } - - /** - * {@inheritDoc} - */ - @Override - public void unpublish(NodeRef nodeToUnpublish, Map properties) - { - //NOOP - } - - /** - * {@inheritDoc} - */ - @Override - public void sendStatusUpdate(Channel channel, String status) - { - //NOOP - } - - /** - * {@inheritDoc} - */ - @Override - public boolean canPublish() - { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean canUnpublish() - { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getSupportedMimeTypes() - { - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getSupportedContentTypes() - { - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean canPublishStatusUpdates() - { - return false; - } - - /** - * {@inheritDoc} - */ - public String getNodeUrl(NodeRef node) - { - return null; - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - return new AuthUrlPair("", ""); - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/MutablePublishingEventImpl.java b/src/main/java/org/alfresco/repo/publishing/MutablePublishingEventImpl.java deleted file mode 100644 index 46546e93cb..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/MutablePublishingEventImpl.java +++ /dev/null @@ -1,64 +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.publishing; - -import java.util.Calendar; - -import org.alfresco.service.cmr.publishing.MutablePublishingEvent; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class MutablePublishingEventImpl extends PublishingEventImpl implements MutablePublishingEvent -{ - /** - * @param event PublishingEventImpl - */ - public MutablePublishingEventImpl(PublishingEventImpl event) - { - super(event); - } - - /** - * {@inheritDoc} - */ - @Override - public void setScheduledTime(Calendar time) - { - this.scheduledTime.setTimeInMillis(time.getTimeInMillis()); - } - - /** - * {@inheritDoc} - */ - @Override - public void setComment(String comment) - { - this.comment = comment; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/NodeRefMapper.java b/src/main/java/org/alfresco/repo/publishing/NodeRefMapper.java deleted file mode 100644 index 13c3ba4c4b..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/NodeRefMapper.java +++ /dev/null @@ -1,132 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public class NodeRefMapper -{ - public NodeRef mapSourceNodeRef(NodeRef node) - { - StringBuilder nodeId = new StringBuilder(node.getId()); - if (nodeId.length() == 36) - { - for (int index = 35; index >= 0; --index) - { - int srcChar = nodeId.charAt(index); - if (srcChar == '-') - { - continue; - } - int destChar = srcCharToDestChar(srcChar); - if (destChar != srcChar) - { - nodeId.setCharAt(index, (char)destChar); - break; - } - } - } - else - { - nodeId.append('f'); - } - return new NodeRef(node.getStoreRef(), nodeId.toString()); - } - - public NodeRef mapDestinationNodeRef(NodeRef node) - { - StringBuilder nodeId = new StringBuilder(node.getId()); - if (node.getId().endsWith("f")) - { - nodeId.deleteCharAt(nodeId.length() - 1); - } - else - { - int lastDestCharIndex = nodeId.length(); - int lastDestChar = 0; - for (int index = nodeId.length() - 1; index >= 0; --index) - { - int destChar = nodeId.charAt(index); - if (destChar == '-') - { - continue; - } - if (isDestChar(destChar)) - { - lastDestCharIndex = index; - lastDestChar = destChar; - } - else - { - break; - } - } - if (lastDestCharIndex < nodeId.length()) - { - int srcChar = destCharToSrcChar(lastDestChar); - nodeId.setCharAt(lastDestCharIndex, (char)srcChar); - } - } - return new NodeRef(node.getStoreRef(), nodeId.toString()); - } - - private int srcCharToDestChar(int ch) - { - int result = ch; - if (ch >= '0' && ch <= '9') - { - result = (ch - '0') + 'A'; - } - else if (ch >= 'a' && ch <= 'f') - { - result = (ch - 'a') + 10 + 'A'; - } - return result; - } - - private int destCharToSrcChar(int ch) - { - int result = ch; - if (ch >= 'A' && ch <= 'J') //'J' is the 10th uppercase character - { - result = ch - 'A' + '0'; - } - else if (ch >= 'K' && ch <= 'P') //'P' is the 16th uppercase character - { - result = ch - 'K' + 'a'; - } - return result; - } - - private boolean isDestChar(int ch) - { - return (ch >= 'A' && ch <= 'P'); - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/NodeSnapshotFactory.java b/src/main/java/org/alfresco/repo/publishing/NodeSnapshotFactory.java deleted file mode 100644 index 5d68a9c65e..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/NodeSnapshotFactory.java +++ /dev/null @@ -1,36 +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.publishing; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class NodeSnapshotFactory -{ - -} diff --git a/src/main/java/org/alfresco/repo/publishing/NodeSnapshotSerializer.java b/src/main/java/org/alfresco/repo/publishing/NodeSnapshotSerializer.java deleted file mode 100644 index 0309f6d100..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/NodeSnapshotSerializer.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.publishing; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Collection; -import java.util.List; - -import org.alfresco.service.cmr.publishing.NodeSnapshot; - -/** - * @author Brian - * @author Nick Smith - * - * @since 4.0 - */ -public interface NodeSnapshotSerializer -{ - void serialize(Collection snapshots, OutputStream output) throws Exception; - - List deserialize(InputStream input) throws Exception; -} diff --git a/src/main/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.java b/src/main/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.java deleted file mode 100644 index 8201aa024c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/NodeSnapshotTransferImpl.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.publishing; - -import java.io.Serializable; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode; -import org.alfresco.service.cmr.publishing.NodeSnapshot; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.namespace.QName; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class NodeSnapshotTransferImpl implements NodeSnapshot -{ - private final TransferManifestNormalNode transferNode; - - /** - * @param transferNode TransferManifestNormalNode - */ - public NodeSnapshotTransferImpl(TransferManifestNormalNode transferNode) - { - this.transferNode = transferNode; - } - - public List getAllParentAssocs() - { - if (transferNode == null) - { - return Collections.emptyList(); - } - return transferNode.getParentAssocs(); - } - - /** - * {@inheritDoc} - */ - public Set getAspects() - { - if (transferNode == null) - { - return Collections.emptySet(); - } - return transferNode.getAspects(); - } - - /** - * {@inheritDoc} - */ - public NodeRef getNodeRef() - { - if (transferNode == null) - { - return null; - } - return transferNode.getNodeRef(); - } - - /** - */ - public List getOutboundPeerAssociations() - { - if (transferNode == null) - { - return Collections.emptyList(); - } - return transferNode.getTargetAssocs(); - } - - /** - * @return ChildAssociationRef - */ - public ChildAssociationRef getPrimaryParentAssoc() - { - if (transferNode == null) - { - return null; - } - return transferNode.getPrimaryParentAssoc(); - } - - /** - * @return Path - */ - public Path getPrimaryPath() - { - if (transferNode == null) - { - return null; - } - return transferNode.getParentPath(); - } - - /** - * {@inheritDoc} - */ - public Map getProperties() - { - if (transferNode == null) - { - return Collections.emptyMap(); - } - return transferNode.getProperties(); - } - - /** - * {@inheritDoc} - */ - public QName getType() - { - if (transferNode == null) - { - return null; - } - return transferNode.getType(); - } - - /** - * {@inheritDoc} - */ - public String getVersion() - { - return (String) getProperties().get(ContentModel.PROP_VERSION_LABEL); - } - - /** - * @return the transferNode - */ - public TransferManifestNormalNode getTransferNode() - { - return transferNode; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishContentActionExecuter.java b/src/main/java/org/alfresco/repo/publishing/PublishContentActionExecuter.java deleted file mode 100644 index 0510772195..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishContentActionExecuter.java +++ /dev/null @@ -1,378 +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.publishing; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -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.action.ParameterizedItem; -import org.alfresco.service.cmr.action.ParameterizedItemDefinition; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.rule.RuleServiceException; -import org.alfresco.service.namespace.QName; - -/** - * This class defines an action that publishes or unpublishes the acted-upon - * node to a specified publishing channel. - * - * @author Brian - * @since 4.0 - */ -public class PublishContentActionExecuter extends ActionExecuterAbstractBase -{ - public final static String NAME = "publish-content"; - - /** - * A single-valued, optional text parameter that names the publishing - * channel to which the specified content is to be published. Although this - * is optional, one of either "publishChannelName" or "publishChannelId" - * MUST be specified. If both are specified then "publishChannelId" takes - * precedence. - * - * @see PublishContentActionExecuter#PARAM_PUBLISH_CHANNEL_ID - */ - public final static String PARAM_PUBLISH_CHANNEL_NAME = "publishChannelName"; - - /** - * A single-valued, optional text parameter that identifies the publishing - * channel to which the specified content is to be published. Although this - * is optional, one of either "publishChannelName" or "publishChannelId" - * MUST be specified. If both are specified then "publishChannelId" takes - * precedence. - * - * @see PublishContentActionExecuter#PARAM_PUBLISH_CHANNEL_NAME - */ - public final static String PARAM_PUBLISH_CHANNEL_ID = "publishChannelId"; - - /** - * A single-valued, optional boolean parameter that indicates whether the - * node being acted on should be unpublished (true) or published (false, the - * default). - */ - public final static String PARAM_UNPUBLISH = "unpublish"; - - /** - * A single-valued, optional text parameter that specifies the text of a - * status update that is to be sent to the specified channels upon - * successful publication - * - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_NAMES - */ - public final static String PARAM_STATUS_UPDATE = "statusUpdate"; - - /** - * A single-valued, optional boolean parameter that specifies whether a link - * to the published content should be appended (in shortened form) to the - * status update. Defaults to true if not set. - * - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_NAMES - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE - */ - public final static String PARAM_INCLUDE_LINK_IN_STATUS_UPDATE = "includeLinkInStatusUpdate"; - - /** - * A single-valued, optional NodeRef parameter that specifies which published node should be - * referenced by the status update. This is only relevant if the "includeLinkInStatusUpdate" is - * true AND the node being acted upon is a folder AND the "unpublish" parameter value is false. - * If the node being acted on is not a folder then - * the link appended to the status update will always be a link to the published node. If the "unpublish" - * parameter is set to true then no link is appended to the status update. - * @see PublishContentActionExecuter#PARAM_INCLUDE_LINK_IN_STATUS_UPDATE - * @see PublishContentActionExecuter#PARAM_UNPUBLISH - */ - public final static String PARAM_NODE_TO_LINK_STATUS_UPDATE_TO = "nodeToLinkStatusUpdateTo"; - - /** - * A multi-valued, optional text parameter that identifies by name the - * publishing channels to which the status update (if any) should be sent. - * If both this parameter and the "statusUpdateChannelIds" parameter are - * given values then they are combined. - * - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_IDS - */ - public final static String PARAM_STATUS_UPDATE_CHANNEL_NAMES = "statusUpdateChannelNames"; - - /** - * A multi-valued, optional text parameter that identifies the publishing - * channels to which the status update (if any) should be sent. If both this - * parameter and the "statusUpdateChannelNames" parameter are given - * values then they are combined. - * - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE - * @see PublishContentActionExecuter#PARAM_STATUS_UPDATE_CHANNEL_NAMES - */ - public final static String PARAM_STATUS_UPDATE_CHANNEL_IDS = "statusUpdateChannelIds"; - - /** - * A single-valued, optional datetime parameter that specifies when the - * publish should happen. - */ - public final static String PARAM_SCHEDULED_TIME = "scheduledTime"; - - /** - * A single-valued, optional text parameter that is stored on the publishing - * event that is created by this action. - */ - public final static String PARAM_COMMENT = "comment"; - - private static final String MSG_CHANNEL_NOT_FOUND = "publishing.channelNotFound"; - private static final String MSG_NEITHER_CHANNEL_NAME_NOR_ID_SPECIFIED = "publishing.neitherNameNorIdSpecified"; - - private PublishingService publishingService; - private ChannelService channelService; - private NodeService nodeService; - private DictionaryService dictionaryService; - - public void setPublishingService(PublishingService publishingService) - { - this.publishingService = publishingService; - } - - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - @SuppressWarnings("unchecked") - @Override - protected void executeImpl(Action action, NodeRef actionedUponNodeRef) - { - Boolean isUnpublish = (Boolean) action.getParameterValue(PARAM_UNPUBLISH); - boolean unpublish = ((isUnpublish != null) && isUnpublish); - String publishChannelId = (String) action.getParameterValue(PARAM_PUBLISH_CHANNEL_ID); - String publishChannelName = (String) action.getParameterValue(PARAM_PUBLISH_CHANNEL_NAME); - String statusUpdate = (String) action.getParameterValue(PARAM_STATUS_UPDATE); - List statusUpdateChannelNames = buildStringList(action - .getParameterValue(PARAM_STATUS_UPDATE_CHANNEL_NAMES)); - List statusUpdateChannelIds = buildStringList(action.getParameterValue(PARAM_STATUS_UPDATE_CHANNEL_IDS)); - Boolean includeLinkInStatusUpdate = (Boolean) action.getParameterValue(PARAM_INCLUDE_LINK_IN_STATUS_UPDATE); - boolean appendLink = ((includeLinkInStatusUpdate == null) || includeLinkInStatusUpdate); - Date scheduledTime = (Date) action.getParameterValue(PARAM_SCHEDULED_TIME); - String comment = (String) action.getParameterValue(PARAM_COMMENT); - - Channel publishChannel = publishChannelId == null ? channelService.getChannelByName(publishChannelName) - : channelService.getChannelById(publishChannelId); - if (publishChannel != null) - { - PublishingDetails details = publishingService.createPublishingDetails(); - details.setPublishChannelId(publishChannel.getId()); - List nodes = setNodes(actionedUponNodeRef, unpublish, details); - if (statusUpdateChannelNames != null) - { - for (String statusUpdateChannelName : statusUpdateChannelNames) - { - Channel statusUpdateChannel = channelService.getChannelByName(statusUpdateChannelName); - if (statusUpdateChannel != null) - { - details.addStatusUpdateChannels(statusUpdateChannel.getId()); - } - } - } - if (statusUpdateChannelIds != null) - { - for (String statusUpdateChannelId : statusUpdateChannelIds) - { - Channel statusUpdateChannel = channelService.getChannelById(statusUpdateChannelId); - if (statusUpdateChannel != null) - { - details.addStatusUpdateChannels(statusUpdateChannel.getId()); - } - } - } - if (!unpublish && !details.getStatusUpdateChannels().isEmpty()) - { - details.setStatusMessage(statusUpdate); - if (appendLink) - { - NodeRef nodeToLinkTo = (NodeRef) action.getParameterValue(PARAM_NODE_TO_LINK_STATUS_UPDATE_TO); - if (nodeToLinkTo == null) - { - //No node has been specified explicitly as being the one to link to - //We'll make an assumption if only one node is being published... - if (nodes.size() == 1) - { - nodeToLinkTo = nodes.get(0); - } - } - if ((nodeToLinkTo != null) && nodes.contains(nodeToLinkTo)) - { - details.setStatusNodeToLinkTo(nodeToLinkTo); - } - } - } - if (scheduledTime != null) - { - Calendar cal = Calendar.getInstance(); - cal.setTime(scheduledTime); - details.setSchedule(cal); - } - details.setComment(comment); - publishingService.scheduleNewEvent(details); - } - else - { - throw new AlfrescoRuntimeException(MSG_CHANNEL_NOT_FOUND, - new Object[] { publishChannelId == null ? publishChannelName : publishChannelId }); - } - } - - /** - * This method sets the node(s) to publish or unpublish on the supplied publishing details. - * If the actionedUponNode is a folder then it will include all content nodes within that folder. - * @param actionedUponNodeRef NodeRef - * @param unpublish boolean - * @param details PublishingDetails - */ - private List setNodes(NodeRef actionedUponNodeRef, boolean unpublish, PublishingDetails details) - { - List nodes = new ArrayList(); - QName nodeType = nodeService.getType(actionedUponNodeRef); - if (dictionaryService.isSubClass(nodeType, ContentModel.TYPE_FOLDER)) - { - List children = nodeService.getChildAssocs(actionedUponNodeRef); - for (ChildAssociationRef childRef : children) - { - NodeRef child = childRef.getChildRef(); - if (dictionaryService.isSubClass(nodeService.getType(child), ContentModel.TYPE_CONTENT)) - { - nodes.add(child); - } - } - } - else - { - nodes.add(actionedUponNodeRef); - } - - if (unpublish) - { - details.addNodesToUnpublish(nodes); - } - else - { - details.addNodesToPublish(nodes); - } - return nodes; - } - - private List buildStringList(Serializable parameterValue) - { - List result = null; - if (parameterValue != null && String.class.isAssignableFrom(parameterValue.getClass())) - { - String[] split = ((String)parameterValue).split(","); - result = Arrays.asList(split); - } - else if (parameterValue != null && Iterable.class.isAssignableFrom(parameterValue.getClass())) - { - result = new ArrayList(); - Iterable iter = (Iterable)parameterValue; - for (Object obj : iter) - { - if (obj != null && String.class.isAssignableFrom(obj.getClass())) - { - result.add((String)obj); - } - } - } - return result; - } - - @Override - protected void addParameterDefinitions(List paramList) - { - paramList.add(new ParameterDefinitionImpl(PARAM_PUBLISH_CHANNEL_NAME, DataTypeDefinition.TEXT, false, - getParamDisplayLabel(PARAM_PUBLISH_CHANNEL_NAME), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_PUBLISH_CHANNEL_ID, DataTypeDefinition.TEXT, false, - getParamDisplayLabel(PARAM_PUBLISH_CHANNEL_ID), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_UNPUBLISH, DataTypeDefinition.BOOLEAN, false, - getParamDisplayLabel(PARAM_UNPUBLISH), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_STATUS_UPDATE, DataTypeDefinition.TEXT, false, - getParamDisplayLabel(PARAM_STATUS_UPDATE), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_INCLUDE_LINK_IN_STATUS_UPDATE, DataTypeDefinition.BOOLEAN, - false, getParamDisplayLabel(PARAM_INCLUDE_LINK_IN_STATUS_UPDATE), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_STATUS_UPDATE_CHANNEL_NAMES, DataTypeDefinition.TEXT, false, - getParamDisplayLabel(PARAM_STATUS_UPDATE_CHANNEL_NAMES), true)); - - paramList.add(new ParameterDefinitionImpl(PARAM_STATUS_UPDATE_CHANNEL_IDS, DataTypeDefinition.TEXT, false, - getParamDisplayLabel(PARAM_STATUS_UPDATE_CHANNEL_IDS), true)); - - paramList.add(new ParameterDefinitionImpl(PARAM_SCHEDULED_TIME, DataTypeDefinition.DATETIME, false, - getParamDisplayLabel(PARAM_SCHEDULED_TIME), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_NODE_TO_LINK_STATUS_UPDATE_TO, DataTypeDefinition.NODE_REF, false, - getParamDisplayLabel(PARAM_NODE_TO_LINK_STATUS_UPDATE_TO), false)); - - paramList.add(new ParameterDefinitionImpl(PARAM_COMMENT, DataTypeDefinition.TEXT, false, - getParamDisplayLabel(PARAM_COMMENT), false)); - } - - @Override - protected void checkMandatoryProperties(ParameterizedItem ruleItem, ParameterizedItemDefinition ruleItemDefinition) - { - super.checkMandatoryProperties(ruleItem, ruleItemDefinition); - String publishChannelName = (String) ruleItem.getParameterValue(PARAM_PUBLISH_CHANNEL_NAME); - String publishChannelId = (String) ruleItem.getParameterValue(PARAM_PUBLISH_CHANNEL_ID); - if (publishChannelId == null && publishChannelName == null) - { - throw new RuleServiceException(MSG_NEITHER_CHANNEL_NAME_NOR_ID_SPECIFIED); - } - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishEventAction.java b/src/main/java/org/alfresco/repo/publishing/PublishEventAction.java deleted file mode 100644 index c6f80c0de7..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishEventAction.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.repo.publishing; - -import java.util.List; - -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.repository.NodeRef; - -/** - * This ActionExecuter adds a publish event to the publish event queue. - * - * @author Nick Smith - * @since 4.0 - */ -public class PublishEventAction extends ActionExecuterAbstractBase -{ - private PublishingEventProcessor processor; - - /** - * {@inheritDoc} - */ - @Override - protected void executeImpl(Action action, NodeRef eventNode) - { - processor.processEventNode(eventNode); - } - - /** - * {@inheritDoc} - */ - @Override - protected void addParameterDefinitions(List paramList) - { - //NOOP - } - - /** - * @param processor the processor to set - */ - public void setPublishingEventProcessor(PublishingEventProcessor processor) - { - this.processor = processor; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishServiceImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishServiceImpl.java deleted file mode 100644 index 9647b8de4f..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishServiceImpl.java +++ /dev/null @@ -1,146 +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.publishing; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.publishing.NodePublishStatus; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingQueue; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.util.ParameterCheck; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class PublishServiceImpl implements PublishingService -{ - public static final String NAME = "PublishingService"; - - private PublishingEventHelper publishingEventHelper; - private PublishingRootObject rootObject; - - /** - * @param rootObject the rootObject to set - */ - public void setPublishingRootObject(PublishingRootObject rootObject) - { - this.rootObject = rootObject; - } - - /** - * @param publishingEventHelper the publishingEventHelper to set - */ - public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper) - { - this.publishingEventHelper = publishingEventHelper; - } - - /** - * {@inheritDoc} - */ - public PublishingEvent getPublishingEvent(String id) - { - return publishingEventHelper.getPublishingEvent(id); - } - - /** - * {@inheritDoc} - */ - public List getPublishEventsForNode(NodeRef publishedNode) - { - NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef(); - List eventNodes = publishingEventHelper.getEventNodesForPublishedNode(queueNode, publishedNode); - return publishingEventHelper.getPublishingEvents(eventNodes); - } - - /** - * {@inheritDoc} - */ - public List getUnpublishEventsForNode(NodeRef unpublishedNode) - { - NodeRef queueNode = rootObject.getPublishingQueue().getNodeRef(); - List eventNodes = publishingEventHelper.getEventNodesForUnpublishedNode(queueNode, unpublishedNode); - return publishingEventHelper.getPublishingEvents(eventNodes); - } - - /** - * {@inheritDoc} - */ - public void cancelPublishingEvent(String id) - { - ParameterCheck.mandatory("id", id); - publishingEventHelper.cancelEvent(id); - } - - private PublishingQueue getPublishingQueue() - { - return rootObject.getPublishingQueue(); - } - - public Map checkPublishStatus(String channelId, Collection nodes) - { -// Map results = new HashMap(); -// for (NodeRef node : nodes) -// { -// if(node!=null && results.containsKey(node)==false) -// { -// results.put(node, environmentHelper.checkNodeStatus(node, channelId)); -// } -// } -// return results; - //TODO - return null; - } - - public Map checkPublishStatus(String channelId, NodeRef... nodes) - { -// return checkPublishStatus(channelId, Arrays.asList(nodes)); - //TODO - return null; - } - - public PublishingDetails createPublishingDetails() - { - return getPublishingQueue().createPublishingDetails(); - } - - /** - * {@inheritDoc} - */ - public String scheduleNewEvent(PublishingDetails publishingDetails) - { - return getPublishingQueue().scheduleNewEvent(publishingDetails); - } - -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingChannelParameterConstraint.java b/src/main/java/org/alfresco/repo/publishing/PublishingChannelParameterConstraint.java deleted file mode 100644 index e9b6d31268..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingChannelParameterConstraint.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.publishing; - -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.alfresco.repo.action.constraint.BaseParameterConstraint; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; - -/** - * Action parameter constraint that constrains to list of publishing channels - * - * @see PublishContentActionExecuter - * @author Brian - * @since 4.0 - */ -public class PublishingChannelParameterConstraint extends BaseParameterConstraint -{ - public static final String NAME = "ac-publishing-channels"; - - private ChannelService channelService; - - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - } - - /** - * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() - */ - protected Map getAllowableValuesImpl() - { - List channels = channelService.getPublishingChannels(false); - Map result = new TreeMap(); - for (Channel channel : channels) - { - result.put(channel.getId(), channel.getName()); - } - return result; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java deleted file mode 100644 index 128e0b0a96..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingDetailsImpl.java +++ /dev/null @@ -1,222 +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.publishing; - -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * - * @since 4.0 - */ -public class PublishingDetailsImpl implements PublishingDetails -{ - private final Set nodesToPublish = new HashSet(); - private final Set nodesToUnpublish= new HashSet(); - private final Set statusChannels = new HashSet(); - - private NodeRef nodeToLinkTo = null; - private String message = null; - private Calendar schedule = null; - private String comment = null; - private String publishChannelId = null; - - /** - * {@inheritDoc} - */ - public PublishingDetails addNodesToPublish(NodeRef... nodesToAdd) - { - return addNodesToPublish(Arrays.asList(nodesToAdd)); - } - - /** - * {@inheritDoc} - */ - public PublishingDetails addNodesToUnpublish(NodeRef... nodesToRemove) - { - return addNodesToUnpublish(Arrays.asList(nodesToRemove)); - } - - /** - * {@inheritDoc} - */ - @Override - public PublishingDetails addNodesToUnpublish(Collection nodesToRemove) - { - this.nodesToUnpublish.addAll(nodesToRemove); - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails addNodesToPublish(Collection nodesToAdd) - { - this.nodesToPublish.addAll(nodesToAdd); - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails setPublishChannelId(String publishChannelId) - { - this.publishChannelId = publishChannelId; - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails setComment(String comment) - { - this.comment = comment; - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails setSchedule(Calendar schedule) - { - this.schedule = schedule; - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails setStatusMessage(String message) - { - this.message = message; - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails setStatusNodeToLinkTo(NodeRef nodeToLinkTo) - { - this.nodeToLinkTo = nodeToLinkTo; - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails addStatusUpdateChannels(Collection channelIds) - { - statusChannels.addAll(channelIds); - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails addStatusUpdateChannels(String... channelIds) - { - return addStatusUpdateChannels(Arrays.asList(channelIds)); - } - - - /** - * {@inheritDoc} - */ - public Set getNodesToPublish() - { - return nodesToPublish; - } - - /** - * {@inheritDoc} - */ - public Set getNodesToUnpublish() - { - return nodesToUnpublish; - } - - /** - * @return the statusChannels - */ - public Set getStatusChannels() - { - return statusChannels; - } - - /** - * @return the comment - */ - public String getComment() - { - return comment; - } - - /** - * @return the message - */ - public String getStatusMessage() - { - return message; - } - - /** - * @return the nodeToLinkTo - */ - public NodeRef getNodeToLinkTo() - { - return nodeToLinkTo; - } - - /** - * @return the publishChannelId - */ - public String getPublishChannelId() - { - return publishChannelId; - } - - /** - * @return the schedule - */ - public Calendar getSchedule() - { - return schedule; - } - - public Set getStatusUpdateChannels() - { - return statusChannels; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java deleted file mode 100644 index f2352c81aa..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingEventFilterImpl.java +++ /dev/null @@ -1,143 +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.publishing; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.service.cmr.publishing.PublishingEventFilter; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class PublishingEventFilterImpl implements PublishingEventFilter -{ - private Set ids = Collections.emptySet(); - private Set publishedNodes = Collections.emptySet(); - private Set unpublishedNodes = Collections.emptySet(); - - /** - * {@inheritDoc} - */ - public PublishingEventFilter setIds(String... ids) - { - if (ids != null && ids.length > 0) - { - this.ids = new HashSet(Arrays.asList(ids)); - } - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public PublishingEventFilter setIds(Collection ids) - { - if (ids != null && ids.isEmpty() == false) - { - this.ids = new HashSet(ids); - } - return this; - } - /** - * {@inheritDoc} - */ - public Set getIds() - { - return Collections.unmodifiableSet(ids); - } - - /** - * {@inheritDoc} - */ - public PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes) - { - if (publishedNodes != null && publishedNodes.length > 0) - { - this.publishedNodes = new HashSet(Arrays.asList(publishedNodes)); - } - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingEventFilter setPublishedNodes(Collection publishedNodes) - { - if (publishedNodes != null && publishedNodes.isEmpty() == false) - { - this.publishedNodes = new HashSet(publishedNodes); - } - return this; - } - - /** - * {@inheritDoc} - */ - public Set getPublishedNodes() - { - return Collections.unmodifiableSet(publishedNodes); - } - - /** - * {@inheritDoc} - */ - public PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes) - { - if (unpublishedNodes != null && unpublishedNodes.length > 0) - { - this.unpublishedNodes = new HashSet(Arrays.asList(unpublishedNodes)); - } - return this; - } - - /** - * {@inheritDoc} - */ - public PublishingEventFilter setUnpublishedNodes(Collection unpublishedNodes) - { - if (unpublishedNodes != null && unpublishedNodes.isEmpty() == false) - { - this.unpublishedNodes = new HashSet(unpublishedNodes); - } - return this; - } - - /** - * {@inheritDoc} - */ - public Set getUnpublishedNodes() - { - return Collections.unmodifiableSet(unpublishedNodes); - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingEventHelper.java b/src/main/java/org/alfresco/repo/publishing/PublishingEventHelper.java deleted file mode 100644 index f743fd0800..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingEventHelper.java +++ /dev/null @@ -1,694 +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.publishing; - -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_LAST_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.NAMESPACE; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_COMMENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_PAYLOAD; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_STATUS; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_TIME; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_TIME_ZONE; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_WORKFLOW_ID; -import static org.alfresco.repo.publishing.PublishingModel.PROP_STATUS_UPDATE_CHANNEL_NAMES; -import static org.alfresco.repo.publishing.PublishingModel.PROP_STATUS_UPDATE_MESSAGE; -import static org.alfresco.repo.publishing.PublishingModel.PROP_STATUS_UPDATE_NODE_REF; -import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_SCHEDULED_PUBLISH_DATE; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_EVENT; -import static org.alfresco.util.collections.CollectionUtils.filter; -import static org.alfresco.util.collections.CollectionUtils.isEmpty; -import static org.alfresco.util.collections.CollectionUtils.toListOfStrings; -import static org.alfresco.util.collections.CollectionUtils.transform; -import static org.alfresco.util.collections.CollectionUtils.transformFlat; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TimeZone; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.node.NodeUtils; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.repo.transfer.TransferContext; -import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory; -import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.repo.workflow.WorkflowModel; -import org.alfresco.service.cmr.publishing.NodeSnapshot; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingEventFilter; -import org.alfresco.service.cmr.publishing.PublishingPackage; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.publishing.StatusUpdate; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -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.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.transfer.TransferDefinition; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.service.cmr.workflow.WorkflowDefinition; -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.GUID; -import org.alfresco.util.collections.Filter; -import org.alfresco.util.collections.Function; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class PublishingEventHelper -{ - private static final Log log = LogFactory.getLog(PublishingEventHelper.class); - public static final String WORKFLOW_DEFINITION_NAME = "publishWebContent"; - - private NodeService nodeService; - private ContentService contentService; - private VersionService versionService; - private WorkflowService workflowService; - private NodeSnapshotSerializer serializer; - private PermissionService permissionService; - private TransferManifestNodeFactory transferManifestNodeFactory; - private List excludedAspects = new ArrayList(); - - private String workflowEngineId; - private TransferDefinition excludedAspectsTransferDefinition; - - /** - * @param nodeService - * the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param contentService - * the contentService to set - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * @param transferManifestNodeFactory the transferManifestNodeFactory to set - */ - public void setTransferManifestNodeFactory(TransferManifestNodeFactory transferManifestNodeFactory) - { - this.transferManifestNodeFactory = transferManifestNodeFactory; - } - - /** - * @param versionService the versionService to set - */ - public void setVersionService(VersionService versionService) - { - this.versionService = versionService; - } - - /** - * @param workflowService the workflowService to set - */ - public void setWorkflowService(WorkflowService workflowService) - { - this.workflowService = workflowService; - } - - /** - * @param workflowEngineId the workflowEngineId to set - */ - public void setWorkflowEngineId(String workflowEngineId) - { - this.workflowEngineId = workflowEngineId; - } - - /** - * @param serializer the serializer to set - */ - public void setSerializer(NodeSnapshotSerializer serializer) - { - this.serializer = serializer; - } - - /** - * @param permissionService the permissionService to set - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public PublishingEvent getPublishingEvent(NodeRef eventNode) throws AlfrescoRuntimeException - { - if (eventNode == null) - { - return null; - } - - Map props = nodeService.getProperties(eventNode); - String statusStr = (String) props.get(PROP_PUBLISHING_EVENT_STATUS); - Status status = Status.valueOf(statusStr); - String channel = (String) props.get(PROP_PUBLISHING_EVENT_CHANNEL); - Date createdTime = (Date) props.get(ContentModel.PROP_CREATED); - String creator = (String) props.get(ContentModel.PROP_CREATOR); - Date modifiedTime = (Date) props.get(ContentModel.PROP_MODIFIED); - String modifier = (String) props.get(ContentModel.PROP_MODIFIER); - String comment = (String) props.get(PROP_PUBLISHING_EVENT_COMMENT); - Calendar scheduledTime = getScheduledTime(props); - PublishingPackage publishingPackage = getPublishingPackage(eventNode, channel); - - StatusUpdate statusUpdate = buildStatusUpdate(props); - return new PublishingEventImpl(eventNode.toString(), - status, channel, - publishingPackage, createdTime, - creator,modifiedTime, modifier, - scheduledTime, comment, statusUpdate); - } - - @SuppressWarnings("unchecked") - private StatusUpdate buildStatusUpdate(Map props) - { - String message = (String) props.get(PROP_STATUS_UPDATE_MESSAGE); - Collection channelNames = (Collection) props.get(PROP_STATUS_UPDATE_CHANNEL_NAMES); - if (channelNames == null || channelNames.isEmpty()) - { - return null; - } - String nodeId = (String) props.get(PROP_STATUS_UPDATE_NODE_REF); - NodeRef nodeToLinkTo = nodeId==null ? null : new NodeRef(nodeId); - return new StatusUpdateImpl(message, nodeToLinkTo, channelNames); - } - - public List getPublishingEvents(List eventNodes) - { - return transform(eventNodes, new Function() - { - public PublishingEvent apply(NodeRef eventNode) - { - return getPublishingEvent(eventNode); - } - }); - } - - public NodeRef createNode(NodeRef queueNode, PublishingDetails details) throws Exception - { - checkChannelAccess(details.getPublishChannelId()); - Set statusChannelIds = details.getStatusUpdateChannels(); - if (isEmpty(statusChannelIds) == false) - for (String statusChannelId : statusChannelIds) - { - checkChannelAccess(statusChannelId); - } - String name = GUID.generate(); - Map props = buildPublishingEventProperties(details, name); - ChildAssociationRef newAssoc = nodeService.createNode(queueNode, - ASSOC_PUBLISHING_EVENT, - QName.createQName(NAMESPACE, name), - TYPE_PUBLISHING_EVENT, props); - NodeRef eventNode = newAssoc.getChildRef(); - serializePublishNodes(eventNode, details); - return eventNode; - } - - private void checkChannelAccess(String channelId) - { - NodeRef channelNode = new NodeRef(channelId); - AccessStatus accessStatus = permissionService.hasPermission(channelNode, PermissionService.ADD_CHILDREN); - if (AccessStatus.ALLOWED != accessStatus) - { - throw new AccessDeniedException("You do not have access to channel: " + channelId); - } - } - - private Map buildPublishingEventProperties(PublishingDetails details, String name) - { - Calendar schedule = details.getSchedule(); - if (schedule == null) - { - schedule = Calendar.getInstance(); - } - Map props = new HashMap(); - props.put(ContentModel.PROP_NAME, name); - props.put(PROP_PUBLISHING_EVENT_STATUS, Status.IN_PROGRESS.name()); - props.put(PROP_PUBLISHING_EVENT_TIME, schedule.getTime()); - props.put(PublishingModel.PROP_PUBLISHING_EVENT_TIME_ZONE, schedule.getTimeZone().getID()); - props.put(PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL, details.getPublishChannelId()); - props.put(PublishingModel.PROP_PUBLISHING_EVENT_STATUS, PublishingModel.PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED); - String comment = details.getComment(); - if (comment != null) - { - props.put(PROP_PUBLISHING_EVENT_COMMENT, comment); - } - Collection publshStrings = mapNodesToStrings(details.getNodesToPublish()); - props.put(PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, (Serializable) publshStrings); - Collection unpublshStrings = mapNodesToStrings(details.getNodesToUnpublish()); - props.put(PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH, (Serializable) unpublshStrings); - String message = details.getStatusMessage(); - Set statusChannels = details.getStatusUpdateChannels(); - if (message != null && isEmpty(statusChannels) == false) - { - props.put(PROP_STATUS_UPDATE_MESSAGE, message); - NodeRef statusNode = details.getNodeToLinkTo(); - if (statusNode != null) - { - props.put(PROP_STATUS_UPDATE_NODE_REF, statusNode.toString()); - } - props.put(PROP_STATUS_UPDATE_CHANNEL_NAMES, (Serializable) statusChannels); - } - return props; - } - - private List mapNodesToStrings(Collection nodes) - { - return toListOfStrings(nodes); - } - - public List findPublishingEventNodes(final NodeRef queue, PublishingEventFilter filter) - { - List eventNodes; - Set publishedNodes = filter.getPublishedNodes(); - if (isEmpty(publishedNodes) == false) - { - eventNodes= getEventNodesForPublishedNodes(queue, publishedNodes); - } - else - { - eventNodes = getAllPublishingEventNodes(queue); - } - Set ids = filter.getIds(); - if (isEmpty(ids) == false) - { - eventNodes = filterEventNodesById(eventNodes, ids); - } - return eventNodes; - } - - private List filterEventNodesById(Collection eventNodes, final Collection ids) - { - return filter(eventNodes, new Filter() - { - public Boolean apply(NodeRef node) - { - return ids.contains(node.toString()); - } - }); - } - - private List getAllPublishingEventNodes(final NodeRef queue) - { - List assocs = - nodeService.getChildAssocs(queue, ASSOC_PUBLISHING_EVENT, RegexQNamePattern.MATCH_ALL); - return transform(assocs, NodeUtils.toChildRef()); - } - - /** - * Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to publish at least one of the specified publishedNodes. - * @param queue NodeRef - * @param publishedNodes NodeRef.. - */ - public List getEventNodesForPublishedNodes(final NodeRef queue, NodeRef... publishedNodes) - { - return getEventNodesForPublishedNodes(queue, Arrays.asList(publishedNodes)); - } - - /** - * Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to publish at least one of the specified publishedNodes. - * @param queue NodeRef - */ - public List getEventNodesForPublishedNodes(final NodeRef queue, Collection publishedNodes) - { - return getEventNodesForNodeProperty(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, publishedNodes); - } - - /** - * Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to unpublish at least one of the specified unpublishedNodes. - * @param queue NodeRef - */ - public List getEventNodesForUnpublishedNodes(final NodeRef queue, Collection unpublishedNodes) - { - return getEventNodesForNodeProperty(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, unpublishedNodes); - } - - /** - * Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to publish the specified publishedNode. - * @param queue NodeRef - * @param publishedNode NodeRef - */ - public List getEventNodesForPublishedNode(final NodeRef queue, NodeRef publishedNode) - { - Function> transformer = eventNodeForNodePropertyFinder(queue, PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH); - return transformer.apply(publishedNode); - } - - /** - * Returns a {@link List} of the {@link NodeRef}s representing PublishingEvents that were scheduled to unpublish the specified unpublishedNode. - * @param queue NodeRef - * @param unpublishedNode NodeRef - */ - public List getEventNodesForUnpublishedNode(final NodeRef queue, NodeRef unpublishedNode) - { - Function> transformer = eventNodeForNodePropertyFinder(queue, PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH); - return transformer.apply(unpublishedNode); - } - - private List getEventNodesForNodeProperty(final NodeRef queue, final QName propertyKey, Collection publishedNodes) - { - Function> transformer = eventNodeForNodePropertyFinder(queue, propertyKey); - return transformFlat(publishedNodes, transformer); - } - - private Function> eventNodeForNodePropertyFinder(final NodeRef queue, - final QName propertyKey) - { - return new Function>() - { - public List apply(NodeRef publishedNode) - { - String nodeString = publishedNode.toString(); - List assocs = - nodeService.getChildAssocsByPropertyValue(queue, propertyKey, nodeString); - return transform(assocs, NodeUtils.toChildRef()); - } - }; - } - - public List findPublishingEvents(NodeRef queue, PublishingEventFilter filter) - { - List eventNodes = findPublishingEventNodes(queue, filter); - return getPublishingEvents(eventNodes); - } - - public PublishingEvent getPublishingEvent(String id) - { - NodeRef eventNode = getPublishingEventNode(id); - return getPublishingEvent(eventNode); - } - - public NodeRef getPublishingEventNode(String id) - { - if (id != null && NodeRef.isNodeRef(id)) - { - NodeRef eventNode = new NodeRef(id); - if (nodeService.exists(eventNode) && TYPE_PUBLISHING_EVENT.equals(nodeService.getType(eventNode))) - { - return eventNode; - } - } - return null; - } - - public String startPublishingWorkflow(NodeRef eventNode, Calendar scheduledTime) - { - //Set parameters - Map parameters = new HashMap(); - parameters.put(PROP_WF_PUBLISHING_EVENT, eventNode); - parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null)); - parameters.put(PROP_WF_SCHEDULED_PUBLISH_DATE, scheduledTime); - - //Start workflow - WorkflowPath path = workflowService.startWorkflow(getPublshingWorkflowDefinitionId(), parameters); - String instanceId = path.getInstance().getId(); - - //Set the Workflow Id on the event node. - nodeService.setProperty(eventNode, PROP_PUBLISHING_EVENT_WORKFLOW_ID, instanceId); - - //End the start task. - //TODO Replace with endStartTask() call after merge to HEAD. - WorkflowTask startTask = workflowService.getStartTask(instanceId); - workflowService.endTask(startTask.getId(), null); - return instanceId; - } - - private String getPublshingWorkflowDefinitionId() - { - String definitionName = workflowEngineId + "$" + WORKFLOW_DEFINITION_NAME; - WorkflowDefinition definition = workflowService.getDefinitionByName(definitionName); - if (definition == null) - { - String msg = "The Web publishing workflow definition does not exist! Definition name: " + definitionName; - throw new AlfrescoRuntimeException(msg); - } - return definition.getId(); - } - - public Calendar getScheduledTime(NodeRef eventNode) - { - if (eventNode == null) - { - return null; - } - return getScheduledTime(nodeService.getProperties(eventNode)); - } - - public Calendar getScheduledTime(Map eventProperties) - { - Date time = (Date) eventProperties.get(PROP_PUBLISHING_EVENT_TIME); - String timezone= (String) eventProperties.get(PROP_PUBLISHING_EVENT_TIME_ZONE); - Calendar scheduledTime = Calendar.getInstance(); - scheduledTime.setTime(time); - scheduledTime.setTimeZone(TimeZone.getTimeZone(timezone)); - return scheduledTime; - } - - private void serializePublishNodes(NodeRef eventNode, PublishingDetails details) throws Exception - { - try - { - NodeRef channelNode = new NodeRef(details.getPublishChannelId()); - List snapshots = createPublishSnapshots(details.getNodesToPublish()); - snapshots.addAll(createUnpublishSnapshots(details.getNodesToUnpublish(), channelNode)); - ContentWriter contentWriter = contentService.getWriter(eventNode, - PROP_PUBLISHING_EVENT_PAYLOAD, true); - contentWriter.setEncoding("UTF-8"); - OutputStream os = contentWriter.getContentOutputStream(); - serializer.serialize(snapshots, os); - os.flush(); - os.close(); - } - catch (Exception ex) - { - log.warn("Failed to serialize publishing package", ex); - throw ex; - } - } - - private List createUnpublishSnapshots(Set nodes, final NodeRef channelNode) - { - return transform(nodes, new Function() - { - public NodeSnapshot apply(NodeRef node) - { - return createUnpublishSnapshot(node, channelNode); - } - }); - } - - private PublishingPackage getPublishingPackage(NodeRef eventNode, String channelId) throws AlfrescoRuntimeException - { - Map entries = getPublishingPackageEntries(eventNode); - return new PublishingPackageImpl(entries); - } - - - private List createPublishSnapshots(final Collection nodes) - { - return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork>() - { - public List doWork() throws Exception - { - return transform(nodes, new Function() - { - public NodeSnapshot apply(NodeRef node) - { - return createPublishSnapshot(node); - } - }); - } - }, AuthenticationUtil.getSystemUserName()); - } - - private NodeSnapshotTransferImpl createPublishSnapshot(NodeRef node) - { - if (!nodeService.hasAspect(node, ContentModel.ASPECT_VERSIONABLE)) - { - Map props = new HashMap(1, 1.0f); - props.put(ContentModel.PROP_AUTO_VERSION, true); - props.put(ContentModel.PROP_AUTO_VERSION_PROPS, false); - versionService.ensureVersioningEnabled(node, props); - } - versionService.createVersion(node, null); - TransferManifestNormalNode payload = (TransferManifestNormalNode) transferManifestNodeFactory.createTransferManifestNode(node, excludedAspectsTransferDefinition, new TransferContext()); - NodeSnapshotTransferImpl snapshot = new NodeSnapshotTransferImpl(payload); - return snapshot; - } - - @SuppressWarnings("unchecked") - private Map getPublishingPackageEntries(NodeRef eventNode) - { - List idsToUnpublish = (List) nodeService.getProperty(eventNode, PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH); - List nodesToUnpublish = NodeUtils.toNodeRefs(idsToUnpublish); - ContentReader contentReader = contentService.getReader(eventNode, PROP_PUBLISHING_EVENT_PAYLOAD); - InputStream input = contentReader.getContentInputStream(); - try - { - List snapshots = serializer.deserialize(input); - Map entries = new HashMap(snapshots.size()); - for (NodeSnapshot snapshot : snapshots) - { - NodeRef node = snapshot.getNodeRef(); - boolean isPublish = false == nodesToUnpublish.contains(node); - PublishingPackageEntryImpl entry = new PublishingPackageEntryImpl(isPublish, node, snapshot); - entries.put(node, entry); - } - return entries; - } - catch (Exception ex) - { - String msg ="Failed to deserialize publishing package for PublishingEvent: " +eventNode; - throw new AlfrescoRuntimeException(msg, ex); - } - } - - - private NodeSnapshot createUnpublishSnapshot(NodeRef source, NodeRef channelNode) - { - NodeRef lastEvent = getLastPublishEvent(source, channelNode); - if (lastEvent == null) - { - String msg = "Cannot create unpublish snapshot as last publishing event does not exist! Source node: "+ source + " channelId: "+channelNode; - throw new AlfrescoRuntimeException(msg); - } - Map entries = getPublishingPackageEntries(lastEvent); - PublishingPackageEntry entry = entries.get(source); - return entry.getSnapshot(); - } - - public NodeRef getLastPublishEvent(NodeRef source, NodeRef channelNode) - { - NodeRef publishedNode = ChannelHelper.mapSourceToEnvironment(source, channelNode, nodeService); - if (publishedNode == null) - { - return null; - } - List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); - return NodeUtils.getSingleAssocNode(assocs, true); - } - - public void cancelEvent(String id) - { - NodeRef eventNode = getPublishingEventNode(id); - if (eventNode != null) - { - Map eventProps = nodeService.getProperties(eventNode); - String status = (String)eventProps.get(PublishingModel.PROP_PUBLISHING_EVENT_STATUS); - //If this event has not started to be processed yet then we can stop the associated workflow and - //delete the event... - if (PublishingModel.PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED.equals(status)) - { - //Get hold of the process id - String processId = (String)eventProps.get(PublishingModel.PROP_PUBLISHING_EVENT_WORKFLOW_ID); - if (processId != null) - { - workflowService.cancelWorkflow(processId); - } - nodeService.deleteNode(eventNode); - } - - //Otherwise, if the current event is being processed now we just set its status to "CANCELLED REQUESTED" - else if (PublishingModel.PROPVAL_PUBLISHING_EVENT_STATUS_IN_PROGRESS.equals(status)) - { - nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, PublishingModel.PROPVAL_PUBLISHING_EVENT_STATUS_CANCEL_REQUESTED); - } - - //Otherwise this event has already been processed or has already been cancelled. Do nothing. - } - } - - public AssociationRef linkToLastEvent(NodeRef publishedNode, NodeRef eventNode) - { - List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); - if (isEmpty(assocs) == false) - { - // Remove old association. - AssociationRef assoc = assocs.get(0); - nodeService.removeAssociation(assoc.getSourceRef(), assoc.getTargetRef(), assoc.getTypeQName()); - } - return nodeService.createAssociation(publishedNode, eventNode, ASSOC_LAST_PUBLISHING_EVENT); - } - - public PublishingDetails createPublishingDetails() - { - return new PublishingDetailsImpl(); - } - - /** - * Sets a list of excluded aspects, assumes the fully qualified name. Replaces any exising excluded aspects. - */ - public void setExcludedAspects(Collection excludedAspects) - { - this.excludedAspects.clear(); - - for (String aspect : excludedAspects) - { - this.excludedAspects.add(QName.createQName(aspect)); - } - this.excludedAspectsTransferDefinition = new TransferDefinition(); - excludedAspectsTransferDefinition.setExcludedAspects(this.excludedAspects); - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingEventImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishingEventImpl.java deleted file mode 100644 index e53a806cc0..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingEventImpl.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.publishing; - -import java.util.Calendar; -import java.util.Date; - -import org.alfresco.service.cmr.publishing.MutablePublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingPackage; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.publishing.StatusUpdate; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class PublishingEventImpl implements PublishingEvent -{ - private final String id; - private final Status status; - private final String channelId; - private final PublishingPackage publishingPackage; - private final Date createdTime; - private final String creator; - private final Date modifiedTime; - private final String modifier; - private final StatusUpdate statusUpdate; - protected final Calendar scheduledTime; - protected String comment; - - public PublishingEventImpl(String id, - Status status, String channelName, - PublishingPackage publishingPackage,Date createdTime, - String creator, Date modifiedTime, - String modifier, Calendar scheduledTime, String comment, - StatusUpdate statusUpdate) - { - this.id = id; - this.status = status; - this.channelId = channelName; - this.publishingPackage = publishingPackage; - this.createdTime = createdTime; - this.creator = creator; - this.modifiedTime = modifiedTime; - this.modifier = modifier; - this.scheduledTime = scheduledTime; - this.comment = comment; - this.statusUpdate = statusUpdate; - } - - public PublishingEventImpl(PublishingEvent event) - { - this(event.getId(), - event.getStatus(), event.getChannelId(), - event.getPackage(), event.getCreatedTime(), - event.getCreator(), event.getModifiedTime(), - event.getModifier(), event.getScheduledTime(), event.getComment(), - event.getStatusUpdate()); - } - - /** - * {@inheritDoc} - */ - public String getId() - { - return id; - } - - /** - * {@inheritDoc} - */ - public Status getStatus() - { - return status; - } - - /** - * {@inheritDoc} - */ - public String getChannelId() - { - return channelId; - } - - /** - * {@inheritDoc} - */ - public Calendar getScheduledTime() - { - return (Calendar) scheduledTime.clone(); - } - - /** - * {@inheritDoc} - */ - public PublishingPackage getPackage() - { - return publishingPackage; - } - - /** - * {@inheritDoc} - */ - public Date getCreatedTime() - { - return new Date(createdTime.getTime()); - } - - /** - * {@inheritDoc} - */ - public String getCreator() - { - return creator; - } - - /** - * {@inheritDoc} - */ - public Date getModifiedTime() - { - return new Date(modifiedTime.getTime()); - } - - /** - * {@inheritDoc} - */ - public String getModifier() - { - return modifier; - } - - /** - * {@inheritDoc} - */ - public String getComment() - { - return comment; - } - - /** - * {@inheritDoc} - */ - public StatusUpdate getStatusUpdate() - { - return statusUpdate; - } - - public MutablePublishingEvent edit() - { - return new MutablePublishingEventImpl(this); - } - - /** - * {@inheritDoc} - */ - public int compareTo(PublishingEvent event) - { - if (event == null) - { - return 1; - } - Date eventTime = event.getCreatedTime(); - if (eventTime == null) - { - return 1; - } - return (int)(createdTime.getTime() - eventTime.getTime()); - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingEventProcessor.java b/src/main/java/org/alfresco/repo/publishing/PublishingEventProcessor.java deleted file mode 100644 index c10ae82598..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingEventProcessor.java +++ /dev/null @@ -1,207 +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.publishing; - -import java.util.Set; - -import org.alfresco.repo.policy.BehaviourFilter; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.publishing.StatusUpdate; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.urlshortening.UrlShortener; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ParameterCheck; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class PublishingEventProcessor -{ - private static final Log log = LogFactory.getLog(PublishingEventProcessor.class); - - private PublishingEventHelper eventHelper; - private ChannelService channelService; - private NodeService nodeService; - private BehaviourFilter behaviourFilter; - private UrlShortener urlShortener; - private TransactionService transactionService; - - public void processEventNode(NodeRef eventNode) - { - ParameterCheck.mandatory("eventNode", eventNode); - try - { - updateEventStatus(eventNode, Status.IN_PROGRESS); - final PublishingEvent event = eventHelper.getPublishingEvent(eventNode); - String channelName = event.getChannelId(); - final ChannelImpl channel = (ChannelImpl) channelService.getChannelById(channelName); - if (channel == null) - { - fail(eventNode, "No channel found"); - } - else - { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - @Override - public Void execute() throws Throwable - { - try - { - behaviourFilter.disableBehaviour(); - channel.publishEvent(event); - sendStatusUpdate(channel, event.getStatusUpdate()); - } - finally - { - behaviourFilter.enableBehaviour(); - } - return null; - } - }, false, true); - updateEventStatus(eventNode, Status.COMPLETED); - } - } - catch (Exception e) - { - log.error("Caught exception while processing publishing event " + eventNode, e); - fail(eventNode, e.getMessage()); - } - } - - public void sendStatusUpdate(Channel publishChannel, StatusUpdate update) - { - if (update == null) - { - return; - } - String message = update.getMessage(); - String nodeUrl = getNodeUrl(publishChannel, update); - Set channels = update.getChannelIds(); - for (String channelId : channels) - { - Channel channel = channelService.getChannelById(channelId); - if (channel != null) - { - channel.sendStatusUpdate(message, nodeUrl); - } - } - } - - /** - * @param publishChannel Channel - * @param update StatusUpdate - * @return String - */ - private String getNodeUrl(Channel publishChannel, StatusUpdate update) - { - NodeRef node = update.getNodeToLinkTo(); - String nodeUrl = null; - if (node!= null) - { - nodeUrl = publishChannel.getUrl(node); - if (nodeUrl != null) - { - nodeUrl = " " + urlShortener.shortenUrl(nodeUrl); - } - } - return nodeUrl; - } - - public void fail(NodeRef eventNode, String msg) - { - log.error("Failed to process publishing event " + eventNode + ": " + msg); - updateEventStatus(eventNode, Status.FAILED); - } - - private void updateEventStatus(final NodeRef eventNode, final Status status) - { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - @Override - public Void execute() throws Throwable - { - nodeService.setProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS, status.name()); - return null; - } - }, false, true); - } - - - /** - * @param channelService the channelService to set - */ - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - } - - /** - * @param eventHelper the Publishing Event Helper to set - */ - public void setPublishingEventHelper(PublishingEventHelper eventHelper) - { - this.eventHelper = eventHelper; - } - - /** - * @param nodeService the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param behaviourFilter the behaviourFilter to set - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - - /** - * @param urlShortener the urlShortener to set - */ - public void setUrlShortener(UrlShortener urlShortener) - { - this.urlShortener = urlShortener; - } - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingModel.java b/src/main/java/org/alfresco/repo/publishing/PublishingModel.java deleted file mode 100644 index ae81728ac4..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingModel.java +++ /dev/null @@ -1,105 +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.publishing; - -import org.alfresco.service.namespace.QName; - -/** - * @author Nick Smith - * @since 4.0 - */ -public interface PublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/1.0"; - public static final String PREFIX = "pub"; - - public static final String WF_NAMESPACE = "http://www.alfresco.org/model/publishingworkflow/1.0"; - public static final String WF_PREFIX = "pubwf"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - public static final QName TYPE_DELIVERY_SERVER = QName.createQName(NAMESPACE, "DeliveryServer"); - public static final QName TYPE_ENVIRONMENT= QName.createQName(NAMESPACE, "Environment"); - public static final QName TYPE_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "PublishingQueue"); - public static final QName TYPE_CHANNEL_CONTAINER = QName.createQName(NAMESPACE, "SiteChannelContainer"); - public static final QName TYPE_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "PublishingEvent"); - public static final QName TYPE_PUBLISHING_CONNECTION = QName.createQName(NAMESPACE, "Connection"); - - public static final QName ASPECT_CHANNEL_INFO= QName.createQName(NAMESPACE, "channelInfo"); - public static final QName ASPECT_PUBLISHED = QName.createQName(NAMESPACE, "published"); - public static final QName ASPECT_OAUTH1_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "OAuth1DeliveryChannelAspect"); - public static final QName ASPECT_OAUTH2_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "OAuth2DeliveryChannelAspect"); - public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect"); - - public static final QName PROP_CHANNEL = QName.createQName(NAMESPACE, "channel"); - public static final QName PROP_CHANNEL_TYPE = QName.createQName(NAMESPACE, "channelType"); - public static final QName PROP_CHANNEL_TYPE_ID = QName.createQName(NAMESPACE, "channelTypeId"); - public static final QName PROP_PUBLISHING_EVENT_STATUS= QName.createQName(NAMESPACE, "publishingEventStatus"); - public static final QName PROP_PUBLISHING_EVENT_TIME = QName.createQName(NAMESPACE, "publishingEventTime"); - public static final QName PROP_PUBLISHING_EVENT_TIME_ZONE = QName.createQName(NAMESPACE, "publishingEventTimeZone"); - public static final QName PROP_PUBLISHING_EVENT_COMMENT = QName.createQName(NAMESPACE, "publishingEventComment"); - public static final QName PROP_PUBLISHING_EVENT_CHANNEL= QName.createQName(NAMESPACE, "publishingEventChannel"); - public static final QName PROP_PUBLISHING_EVENT_WORKFLOW_ID= QName.createQName(NAMESPACE, "publishingEventWorkflowId"); - public static final QName PROP_PUBLISHING_EVENT_PAYLOAD = QName.createQName(NAMESPACE, "publishingEventPayload"); - public static final QName PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH = QName.createQName(NAMESPACE, "publishingEventNodesToPublish"); - public static final QName PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH = QName.createQName(NAMESPACE, "publishingEventNodesToUnpublish"); - public static final QName PROP_STATUS_UPDATE_CHANNEL_NAMES = QName.createQName(NAMESPACE, "statusUpdateChannelNames"); - public static final QName PROP_STATUS_UPDATE_NODE_REF = QName.createQName(NAMESPACE, "statusUpdateNodeRef"); - public static final QName PROP_STATUS_UPDATE_MESSAGE = QName.createQName(NAMESPACE, "statusUpdateMessage"); - public static final QName PROP_AUTHORISATION_COMPLETE = QName.createQName(NAMESPACE, "authorisationComplete"); - public static final QName PROP_OAUTH1_TOKEN_VALUE = QName.createQName(NAMESPACE, "oauth1TokenValue"); - public static final QName PROP_OAUTH1_TOKEN_SECRET = QName.createQName(NAMESPACE, "oauth1TokenSecret"); - public static final QName PROP_CHANNEL_USERNAME = QName.createQName(NAMESPACE, "channelUsername"); - public static final QName PROP_CHANNEL_PASSWORD = QName.createQName(NAMESPACE, "channelPassword"); - public static final QName PROP_OAUTH2_TOKEN = QName.createQName(NAMESPACE, "oauth2Token"); - public static final QName PROP_ASSET_ID = QName.createQName(NAMESPACE, "assetId"); - public static final QName PROP_ASSET_URL = QName.createQName(NAMESPACE, "assetUrl"); - - // Publishing Connection Properties - public static final QName PROP_ACCOUNT_ID= QName.createQName(NAMESPACE, "accountId"); - public static final QName PROP_PROVIDER_ID= QName.createQName(NAMESPACE, "providerId"); - public static final QName PROP_PROVIDER_ACCOUNT_ID= QName.createQName(NAMESPACE, "providerAccountId"); - public static final QName PROP_ACCESS_TOKEN= QName.createQName(NAMESPACE, "accessToken"); - public static final QName PROP_ACCESS_SECRET= QName.createQName(NAMESPACE, "secret"); - public static final QName PROP_REFRESH_TOKEN= QName.createQName(NAMESPACE, "refreshToken"); - - public static final String PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED = "SCHEDULED"; - public static final String PROPVAL_PUBLISHING_EVENT_STATUS_IN_PROGRESS = "IN_PROGRESS"; - public static final String PROPVAL_PUBLISHING_EVENT_STATUS_CANCEL_REQUESTED = "CANCEL_REQUESTED"; - public static final String PROPVAL_PUBLISHING_EVENT_STATUS_COMPLETED = "COMPLETED"; - public static final String PROPVAL_PUBLISHING_EVENT_STATUS_FAILED = "FAILED"; - - - public static final QName ASSOC_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "publishingQueueAssoc"); - public static final QName ASSOC_PUBLISHING_EVENT = QName.createQName(NAMESPACE, "publishingEventAssoc"); - public static final QName ASSOC_SOURCE = QName.createQName(NAMESPACE, "source"); - public static final QName ASSOC_LAST_PUBLISHING_EVENT= QName.createQName(NAMESPACE, "lastPublishingEvent"); - public static final QName ASSOC_PUBLISHED_NODES = QName.createQName(NAMESPACE, "publishedNodes"); - - // Workflow Properties - public static final QName PROP_WF_PUBLISHING_EVENT= QName.createQName(WF_NAMESPACE, "publishingEvent"); - public static final QName PROP_WF_SCHEDULED_PUBLISH_DATE= QName.createQName(WF_NAMESPACE, "scheduledPublishDate"); -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java deleted file mode 100644 index bb24f1a927..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingPackageEntryImpl.java +++ /dev/null @@ -1,75 +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.publishing; - -import org.alfresco.service.cmr.publishing.NodeSnapshot; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -// Package protected -class PublishingPackageEntryImpl implements PublishingPackageEntry -{ - private final boolean publish; - private final NodeRef nodeRef; - private final NodeSnapshot snapshot; - - public PublishingPackageEntryImpl(boolean publish, NodeRef nodeRef, NodeSnapshot snapshot) - { - this.publish = publish; - this.nodeRef = nodeRef; - this.snapshot= snapshot; - } - - /** - * {@inheritDoc} - */ - public NodeRef getNodeRef() - { - return nodeRef; - } - - /** - * {@inheritDoc} - */ - public boolean isPublish() - { - return publish; - } - - /** - * {@inheritDoc} - */ - public NodeSnapshot getSnapshot() - { - return snapshot; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingPackageImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishingPackageImpl.java deleted file mode 100644 index ad7f732121..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingPackageImpl.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.publishing; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.publishing.PublishingPackage; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class PublishingPackageImpl implements PublishingPackage -{ - private final Map entries; - private final Set nodesToPublish; - private final Set nodesToUnpublish; - - public PublishingPackageImpl(Map entries) - { - Set toPublish = new HashSet(); - Set toUnpublish = new HashSet(); - for (PublishingPackageEntry entry : entries.values()) - { - NodeRef node = entry.getNodeRef(); - if (entry.isPublish()) - { - toPublish.add(node); - } - else - { - toUnpublish.add(node); - } - } - HashMap entryMap = new HashMap(entries); - this.entries = Collections.unmodifiableMap(entryMap); - this.nodesToPublish = Collections.unmodifiableSet(toPublish); - this.nodesToUnpublish = Collections.unmodifiableSet(toUnpublish); - } - - /** - * {@inheritDoc} - */ - public Collection getEntries() - { - return entries.values(); - } - - public Map getEntryMap() - { - return entries; - } - - /** - * {@inheritDoc} - */ - public Set getNodesToPublish() - { - return nodesToPublish; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getNodesToUnpublish() - { - return nodesToUnpublish; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingQueueFactory.java b/src/main/java/org/alfresco/repo/publishing/PublishingQueueFactory.java deleted file mode 100644 index d78ff62831..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingQueueFactory.java +++ /dev/null @@ -1,41 +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.publishing; - -import org.alfresco.service.cmr.publishing.PublishingQueue; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public interface PublishingQueueFactory -{ - PublishingQueue createPublishingQueueObject(String siteId); - - PublishingQueue createPublishingQueueObject(NodeRef environmentNodeRef); -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingQueueImpl.java b/src/main/java/org/alfresco/repo/publishing/PublishingQueueImpl.java deleted file mode 100644 index 06ecb7edb3..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingQueueImpl.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.publishing; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingEventFilter; -import org.alfresco.service.cmr.publishing.PublishingQueue; -import org.alfresco.service.cmr.publishing.StatusUpdate; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class PublishingQueueImpl implements PublishingQueue -{ - private final static String MSG_FAILED_TO_CREATE_PUBLISHING_EVENT = "publishing-create-event-failed"; - private final NodeRef nodeRef; - private final PublishingEventHelper publishingEventHelper; - - public PublishingQueueImpl(NodeRef nodeRef, PublishingEventHelper publishingEventHelper) - { - this.nodeRef = nodeRef; - this.publishingEventHelper = publishingEventHelper; - } - - /** - * {@inheritDoc} - */ - public PublishingDetails createPublishingDetails() - { - return publishingEventHelper.createPublishingDetails(); - } - - public StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, String... channelNames) - { - return createStatusUpdate(message, nodeToLinkTo, Arrays.asList(channelNames)); - } - - public StatusUpdate createStatusUpdate(String message, NodeRef nodeToLinkTo, Collection channelNames) - { - return new StatusUpdateImpl(message, nodeToLinkTo, channelNames); - } - - public List getPublishingEvents(PublishingEventFilter filter) - { - return publishingEventHelper.findPublishingEvents(nodeRef, filter); - } - - public PublishingEventFilter createPublishingEventFilter() - { - return new PublishingEventFilterImpl(); - } - - public String scheduleNewEvent(PublishingDetails publishingDetails) - { - try - { - NodeRef eventNode = publishingEventHelper.createNode(nodeRef, publishingDetails); - publishingEventHelper.startPublishingWorkflow(eventNode, publishingDetails.getSchedule()); - return eventNode.toString(); - } - catch (Exception ex) - { - throw new AlfrescoRuntimeException(MSG_FAILED_TO_CREATE_PUBLISHING_EVENT, ex); - } - } - - /** - * @return the nodeRef - */ - public NodeRef getNodeRef() - { - return nodeRef; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/PublishingRootObject.java b/src/main/java/org/alfresco/repo/publishing/PublishingRootObject.java deleted file mode 100644 index 21a2d9aad4..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/PublishingRootObject.java +++ /dev/null @@ -1,248 +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.publishing; - -import static org.alfresco.model.ContentModel.ASSOC_CONTAINS; -import static org.alfresco.model.ContentModel.TYPE_FOLDER; -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_PUBLISHING_QUEUE; -import static org.alfresco.repo.publishing.PublishingModel.NAMESPACE; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_QUEUE; - -import java.util.List; - -import org.alfresco.repo.node.NodeUtils; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.service.transaction.TransactionService; -import org.springframework.beans.BeansException; - -/** - * Returns a properly configured Environment. The factory is multi-tenancy enabled, returning the correct Environment object for the current domain. - * - * @author Nick Smith - * @since 4.0 - */ -public class PublishingRootObject -{ - public static final String NAME = "publishingRootObject"; - protected static final QName CHANNELS_QNAME = QName.createQName(NAMESPACE, "channels"); - - private NodeService nodeService; - private PublishingEventHelper publishingEventHelper; - private NamespaceService namespaceService; - private SearchService searchService; - private TransactionService transactionService; - private PermissionService permissionService; - - private StoreRef publishingStore; - private String publishingRootPath; - - - public void setTransactionService(TransactionService transactionService) - { - this.transactionService = transactionService; - } - - /** - * @return the approprieate {@link Environment} for the current domain. - * @throws BeansException - */ - public Environment getEnvironment() throws BeansException - { - return createEnvironment(); - } - - public NodeRef getChannelContainer() - { - return getEnvironment().getChannelsContainer(); - } - - public PublishingQueueImpl getPublishingQueue() - { - return getEnvironment().getPublishingQueue(); - } - - private Environment createEnvironment() - { - return AuthenticationUtil.runAs(new RunAsWork() - { - public Environment doWork() throws Exception - { - RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); - txnHelper.setForceWritable(true); - boolean requiresNew = false; - if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE) - { - //We can be in a read-only transaction, so force a new transaction - requiresNew = true; - } - - return txnHelper.doInTransaction(new RetryingTransactionCallback() - { - public Environment execute() throws Exception - { - NodeRef environmentNode = getEnvironmentNode(); - PublishingQueueImpl queue = createPublishingQueue(environmentNode); - NodeRef channelsContainer = getChannelsContainer(environmentNode); - return new Environment(environmentNode, queue, channelsContainer); - } - }, false,requiresNew); - } - - }, AuthenticationUtil.getSystemUserName()); - } - - private NodeRef getChannelsContainer(NodeRef environmentNode) - { - List childAssocs = - nodeService.getChildAssocs(environmentNode,ASSOC_CONTAINS, CHANNELS_QNAME); - NodeRef channels = NodeUtils.getSingleChildAssocNode(childAssocs, true); - if (channels == null) - { - // No channels container. - channels = nodeService.createNode(environmentNode, - ASSOC_CONTAINS, - CHANNELS_QNAME, - TYPE_FOLDER).getChildRef(); - } - return channels; - } - - private PublishingQueueImpl createPublishingQueue(NodeRef environmentNode) - { - NodeRef queueNode = getPublishingQueueNode(environmentNode); - return new PublishingQueueImpl(queueNode, publishingEventHelper); - } - - private NodeRef getPublishingQueueNode(NodeRef environmentNode) - { - List childAssocs = nodeService.getChildAssocs(environmentNode, ASSOC_PUBLISHING_QUEUE, RegexQNamePattern.MATCH_ALL); - NodeRef queueNode = NodeUtils.getSingleChildAssocNode(childAssocs, true); - if (queueNode == null) - { - // No publishing queue - queueNode = nodeService.createNode(environmentNode, - ASSOC_PUBLISHING_QUEUE, - QName.createQName(NAMESPACE, "publishingQueue"), - TYPE_PUBLISHING_QUEUE).getChildRef(); - permissionService.setPermission(queueNode, PermissionService.ALL_AUTHORITIES, PermissionService.ADD_CHILDREN, true); - } - return queueNode; - } - - private NodeRef getEnvironmentNode() - { - return transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Exception - { - return findEnvrionmentNode(); - } - }, true); - } - - private NodeRef findEnvrionmentNode() - { - NodeRef rootNode = nodeService.getRootNode(publishingStore); - List refs = searchService.selectNodes(rootNode, publishingRootPath, null, namespaceService, false); - if (refs.size() != 1) - { - String msg = "Invalid publishing root path: " + publishingRootPath + " - found: " + refs.size(); - throw new IllegalStateException(msg); - } - return refs.get(0); - } - - /** - * @param publishingStore the publishingStore to set - */ - public void setPublishingStore(String publishingStore) - { - this.publishingStore = new StoreRef(publishingStore); - } - - /** - * @param publishingRootPath the publishingRootPath to set - */ - public void setPublishingRootPath(String publishingRootPath) - { - this.publishingRootPath = publishingRootPath; - } - - /** - * @param namespaceService the namespaceService to set - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param nodeService the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param publishingEventHelper the publishingEventHelper to set - */ - public void setPublishingEventHelper(PublishingEventHelper publishingEventHelper) - { - this.publishingEventHelper = publishingEventHelper; - } - - /** - * @param searchService the searchService to set - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * @param permissionService the permissionService to set - */ - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.java b/src/main/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.java deleted file mode 100644 index 68ee86a0cf..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/StandardNodeSnapshotSerializer.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.publishing; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.transfer.manifest.TransferManifestDeletedNode; -import org.alfresco.repo.transfer.manifest.TransferManifestHeader; -import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode; -import org.alfresco.repo.transfer.manifest.TransferManifestProcessor; -import org.alfresco.repo.transfer.manifest.XMLTransferManifestReader; -import org.alfresco.repo.transfer.manifest.XMLTransferManifestWriter; -import org.alfresco.service.cmr.publishing.NodeSnapshot; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class StandardNodeSnapshotSerializer implements NodeSnapshotSerializer -{ - /** - * {@inheritDoc} - */ - @Override - public List deserialize(InputStream input) throws Exception - { - SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); - SAXParser parser = saxParserFactory.newSAXParser(); - NodeSnapshotDeserializer processor = new NodeSnapshotDeserializer(); - - XMLTransferManifestReader xmlReader = new XMLTransferManifestReader(processor); - parser.parse(input, xmlReader); - return processor.getSnapshots(); - } - - /** - * {@inheritDoc} - */ - public void serialize(Collection snapshots, OutputStream output) throws Exception - { - try - { - TransferManifestHeader header = new TransferManifestHeader(); - header.setCreatedDate(new Date()); - header.setNodeCount(snapshots.size()); - header.setReadOnly(false); - header.setSync(false); - - Writer writer = new OutputStreamWriter(output, "UTF-8"); - - XMLTransferManifestWriter transferManifestWriter = new XMLTransferManifestWriter(); - transferManifestWriter.startTransferManifest(writer); - transferManifestWriter.writeTransferManifestHeader(header); - - // Iterate over NodesToPublish and Serialize. - for (NodeSnapshot snapshot: snapshots) - { - if (snapshot instanceof NodeSnapshotTransferImpl) - { - NodeSnapshotTransferImpl snapshotImpl = (NodeSnapshotTransferImpl)snapshot; - transferManifestWriter.writeTransferManifestNode(snapshotImpl.getTransferNode()); - } - } - transferManifestWriter.endTransferManifest(); - writer.flush(); - } - catch (Exception e) - { - throw new AlfrescoRuntimeException("Failed to serialize node snapshots.", e); - } - } - - /** - * @author Brian - * @author Nick Smith - * - */ - public static class NodeSnapshotDeserializer implements TransferManifestProcessor - { - private List snapshots = new ArrayList(); - - - /** - * @return the snapshots - */ - public List getSnapshots() - { - return snapshots; - } - - /** - * {@inheritDoc} - */ - public void endTransferManifest() - { - //NOOP - } - - /** - * {@inheritDoc} - */ - public void processTransferManifestNode(TransferManifestNormalNode node) - { - NodeSnapshotTransferImpl snapshot = new NodeSnapshotTransferImpl(node); - snapshots.add(snapshot); - } - - /** - * {@inheritDoc} - */ - public void processTransferManifestNode(TransferManifestDeletedNode node) - { - //NOOP - } - - /** - * {@inheritDoc} - */ - public void processTransferManifiestHeader(TransferManifestHeader header) - { - //NOOP - } - - /** - * {@inheritDoc} - */ - public void startTransferManifest() - { - //NOOP - } - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/StatusUpdateChannelParameterConstraint.java b/src/main/java/org/alfresco/repo/publishing/StatusUpdateChannelParameterConstraint.java deleted file mode 100644 index f0fb4684dc..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/StatusUpdateChannelParameterConstraint.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.publishing; - -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.alfresco.repo.action.constraint.BaseParameterConstraint; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; - -/** - * Action parameter constraint that constrains value to a list of publishing channels that support status updates - * - * @see PublishContentActionExecuter - * @author Brian - * @since 4.0 - */ -public class StatusUpdateChannelParameterConstraint extends BaseParameterConstraint -{ - public static final String NAME = "ac-status-update-channels"; - - private ChannelService channelService; - - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - } - - /** - * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() - */ - protected Map getAllowableValuesImpl() - { - List channels = channelService.getStatusUpdateChannels(false); - Map result = new TreeMap(); - for (Channel channel : channels) - { - result.put(channel.getId(), channel.getName()); - } - return result; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/StatusUpdateImpl.java b/src/main/java/org/alfresco/repo/publishing/StatusUpdateImpl.java deleted file mode 100644 index 4801acf491..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/StatusUpdateImpl.java +++ /dev/null @@ -1,77 +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.publishing; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.alfresco.service.cmr.publishing.StatusUpdate; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class StatusUpdateImpl implements StatusUpdate -{ - private final String message; - private final NodeRef nodeToLinkTo; - private final Set channelNames; - - public StatusUpdateImpl(String message, NodeRef nodeToLinkTo, Collection channelNames) - { - this.message = message; - this.nodeToLinkTo = nodeToLinkTo; - this.channelNames = Collections.unmodifiableSet(new HashSet(channelNames)); - } - - /** - * {@inheritDoc} - */ - public String getMessage() - { - return message; - } - - /** - * {@inheritDoc} - */ - public Set getChannelIds() - { - return channelNames; - } - - /** - * {@inheritDoc} - */ - public NodeRef getNodeToLinkTo() - { - return nodeToLinkTo; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.java b/src/main/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.java deleted file mode 100644 index e02b32a745..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/facebook/FacebookChannelType.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.publishing.facebook; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; -import org.springframework.social.connect.Connection; -import org.springframework.social.facebook.api.Facebook; -import org.springframework.social.oauth2.AccessGrant; -import org.springframework.social.oauth2.GrantType; -import org.springframework.social.oauth2.OAuth2Operations; -import org.springframework.social.oauth2.OAuth2Parameters; - -/** - * @author Brian - * @since 4.0 - */ -public class FacebookChannelType extends AbstractChannelType -{ - public final static String ID = "facebook"; - public final static String DEFAULT_REDIRECT_URI = "https://www.alfresco.com/stand-alone-auth-return.html"; - - private FacebookPublishingHelper publishingHelper; - private String redirectUri = DEFAULT_REDIRECT_URI; - - public void setPublishingHelper(FacebookPublishingHelper facebookPublishingHelper) - { - this.publishingHelper = facebookPublishingHelper; - } - - public void setRedirectUri(String redirectUri) - { - this.redirectUri = redirectUri; - } - - @Override - public boolean canPublish() - { - return false; - } - - @Override - public boolean canPublishStatusUpdates() - { - return true; - } - - @Override - public boolean canUnpublish() - { - return false; - } - - @Override - public QName getChannelNodeType() - { - return FacebookPublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return ID; - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - Connection connection = publishingHelper.getFacebookConnectionForChannel(channel.getNodeRef()); - connection.updateStatus(status); - } - - @Override - public String getNodeUrl(NodeRef node) - { - return null; - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - ParameterCheck.mandatory("channel", channel); - if (!ID.equals(channel.getChannelType().getId())) - { - throw new IllegalArgumentException("Invalid channel type: " + channel.getChannelType().getId()); - } - - NodeRef channelRef = channel.getNodeRef(); - StringBuilder authStateBuilder = new StringBuilder(channelRef.getStoreRef().getProtocol()).append('.').append( - channelRef.getStoreRef().getIdentifier()).append('.').append(channelRef.getId()); - OAuth2Operations oauthOperations = publishingHelper.getConnectionFactory().getOAuthOperations(); - OAuth2Parameters params = new OAuth2Parameters(); - params.setRedirectUri(redirectUri); - params.setScope("publish_stream,offline_access,user_photos,user_videos"); - params.setState(authStateBuilder.toString()); - String authRequestUrl = oauthOperations.buildAuthorizeUrl(GrantType.IMPLICIT_GRANT, params); - return new AuthUrlPair(authRequestUrl, redirectUri); - } - - @Override - protected AuthStatus internalAcceptAuthorisation(Channel channel, Map callbackHeaders, - Map callbackParams) - { - AuthStatus authorised = AuthStatus.UNAUTHORISED; - - String accessToken = null; - if (callbackParams.containsKey("access_token")) - { - //We have been given the access token directly. - accessToken = callbackParams.get("access_token")[0]; - } - else if (callbackParams.containsKey("code")) - { - //We have been passed an authorisation code that needs to be exchanged for a token - OAuth2Operations oauthOps = publishingHelper.getConnectionFactory().getOAuthOperations(); - AccessGrant grant = oauthOps.exchangeForAccess(callbackParams.get("code")[0], redirectUri, null); - accessToken = grant.getAccessToken(); - } - if (accessToken != null) - { - Map channelProps = new HashMap(); - channelProps.put(PublishingModel.PROP_OAUTH2_TOKEN, accessToken); - channelProps = getEncryptor().encrypt(channelProps); - getChannelService().updateChannel(channel, channelProps); - authorised = AuthStatus.AUTHORISED; - } - return authorised; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java b/src/main/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java deleted file mode 100644 index 0e3dbe92ad..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/facebook/FacebookPublishingHelper.java +++ /dev/null @@ -1,86 +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.publishing.facebook; - -import org.alfresco.repo.node.encryption.MetadataEncryptor; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.springframework.social.connect.Connection; -import org.springframework.social.facebook.api.Facebook; -import org.springframework.social.facebook.connect.FacebookConnectionFactory; -import org.springframework.social.oauth2.AccessGrant; - -/** - * @author Brian - * @since 4.0 - */ -public class FacebookPublishingHelper -{ - private NodeService nodeService; - private FacebookConnectionFactory connectionFactory; - private MetadataEncryptor encryptor; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setConnectionFactory(FacebookConnectionFactory connectionFactory) - { - this.connectionFactory = connectionFactory; - } - - public FacebookConnectionFactory getConnectionFactory() - { - return connectionFactory; - } - - public void setEncryptor(MetadataEncryptor encryptor) - { - this.encryptor = encryptor; - } - - public Connection getFacebookConnectionForChannel(NodeRef channelNode) - { - Connection connection = null; - if (nodeService.exists(channelNode) - && nodeService.hasAspect(channelNode, FacebookPublishingModel.ASPECT_DELIVERY_CHANNEL)) - { - String tokenValue = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH2_TOKEN, nodeService.getProperty( - channelNode, PublishingModel.PROP_OAUTH2_TOKEN)); - Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE); - - if (danceComplete) - { - AccessGrant token = new AccessGrant(tokenValue); - connection = connectionFactory.createConnection(token); - } - } - return connection; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java b/src/main/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java deleted file mode 100644 index c4b0d0fa5f..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/facebook/FacebookPublishingModel.java +++ /dev/null @@ -1,43 +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.publishing.facebook; - -import org.alfresco.service.namespace.QName; - -/** - * @author Brian - * @since 4.0 - */ -public interface FacebookPublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/facebook/1.0"; - public static final String PREFIX = "facebook"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - - public static final QName ASPECT_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannelAspect"); -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java b/src/main/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java deleted file mode 100644 index a23a72771b..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/FlickrChannelType.java +++ /dev/null @@ -1,226 +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.publishing.flickr; - -import java.io.File; -import java.io.Serializable; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.publishing.AbstractOAuth1ChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr; -import org.alfresco.repo.publishing.flickr.springsocial.api.MediaOperations; -import org.alfresco.repo.publishing.flickr.springsocial.api.PhotoInfo; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.TempFileProvider; -import org.alfresco.util.collections.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; -import org.springframework.social.connect.Connection; -import org.springframework.social.oauth1.OAuth1Parameters; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -/** - * @author Brian - * @since 4.0 - */ -public class FlickrChannelType extends AbstractOAuth1ChannelType -{ - public final static String ID = "flickr"; - private final static Set DEFAULT_SUPPORTED_MIME_TYPES = CollectionUtils.unmodifiableSet( - MimetypeMap.MIMETYPE_IMAGE_GIF, - MimetypeMap.MIMETYPE_IMAGE_JPEG, - MimetypeMap.MIMETYPE_IMAGE_PNG); - private static Log log = LogFactory.getLog(FlickrChannelType.class); - - private ContentService contentService; - private TaggingService taggingService; - private FlickrPublishingHelper flickrHelper; - private Set supportedMimeTypes = DEFAULT_SUPPORTED_MIME_TYPES; - - public void setSupportedMimeTypes(Set mimeTypes) - { - supportedMimeTypes = Collections.unmodifiableSet(new TreeSet(mimeTypes)); - } - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - public void setTaggingService(TaggingService taggingService) - { - this.taggingService = taggingService; - } - - public void setFlickrHelper(FlickrPublishingHelper flickrHelper) - { - this.flickrHelper = flickrHelper; - } - - @Override - public boolean canPublish() - { - return true; - } - - @Override - public boolean canPublishStatusUpdates() - { - return false; - } - - @Override - public boolean canUnpublish() - { - return true; - } - - @Override - public QName getChannelNodeType() - { - return FlickrPublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return ID; - } - - @Override - public Set getSupportedMimeTypes() - { - return supportedMimeTypes; - } - - @Override - public void publish(NodeRef nodeToPublish, Map channelProperties) - { - NodeService nodeService = getNodeService(); - ContentReader reader = contentService.getReader(nodeToPublish, ContentModel.PROP_CONTENT); - if (reader.exists()) - { - File contentFile; - boolean deleteContentFileOnCompletion = false; - if (FileContentReader.class.isAssignableFrom(reader.getClass())) - { - // Grab the content straight from the content store if we can... - contentFile = ((FileContentReader) reader).getFile(); - } - else - { - // ...otherwise copy it to a temp file and use the copy... - File tempDir = TempFileProvider.getLongLifeTempDir("flickr"); - contentFile = TempFileProvider.createTempFile("flickr", "", tempDir); - reader.getContent(contentFile); - deleteContentFileOnCompletion = true; - } - try - { - Resource res = new FileSystemResource(contentFile); - Connection connection = flickrHelper.getConnectionFromChannelProps(channelProperties); - - String name = (String) nodeService.getProperty(nodeToPublish, ContentModel.PROP_NAME); - String title = (String) nodeService.getProperty(nodeToPublish, ContentModel.PROP_TITLE); - if (title == null || title.length() == 0) - { - title = name; - } - String description = (String) nodeService.getProperty(nodeToPublish, ContentModel.PROP_DESCRIPTION); - if (description == null || description.length() == 0) - { - description = title; - } - List tags = taggingService.getTags(nodeToPublish); - String[] tagArray = tags.toArray(new String[tags.size()]); - - MediaOperations mediaOps = connection.getApi().mediaOperations(); - String id = mediaOps.postPhoto(res, title, description, tagArray); - - //Store info onto the published node... - nodeService.addAspect(nodeToPublish, FlickrPublishingModel.ASPECT_ASSET, null); - log.info("Posted image " + name + " to Flickr with id " + id); - nodeService.setProperty(nodeToPublish, PublishingModel.PROP_ASSET_ID, id); - - PhotoInfo photoInfo = mediaOps.getPhoto(id); - String url = photoInfo.getPrimaryUrl(); - log.info("Photo url = " + url); - nodeService.setProperty(nodeToPublish, PublishingModel.PROP_ASSET_URL, url); - } - finally - { - if (deleteContentFileOnCompletion) - { - contentFile.delete(); - } - } - } - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map channelProperties) - { - NodeService nodeService = getNodeService(); - if (nodeService.hasAspect(nodeToUnpublish, FlickrPublishingModel.ASPECT_ASSET)) - { - String assetId = (String) nodeService.getProperty(nodeToUnpublish, PublishingModel.PROP_ASSET_ID); - if (assetId != null) - { - Connection connection = flickrHelper.getConnectionFromChannelProps(channelProperties); - MediaOperations mediaOps = connection.getApi().mediaOperations(); - mediaOps.deletePhoto(assetId); - nodeService.removeAspect(nodeToUnpublish, FlickrPublishingModel.ASPECT_ASSET); - nodeService.removeAspect(nodeToUnpublish, PublishingModel.ASPECT_ASSET); - } - } - } - - @Override - protected OAuth1Parameters getOAuth1Parameters(String callbackUrl) - { - OAuth1Parameters oAuth1Parameters = new OAuth1Parameters(); - oAuth1Parameters.setCallbackUrl(callbackUrl); - oAuth1Parameters.set("perms", "delete"); - return oAuth1Parameters; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/FlickrPublishingHelper.java b/src/main/java/org/alfresco/repo/publishing/flickr/FlickrPublishingHelper.java deleted file mode 100644 index 015cd7dc2a..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/FlickrPublishingHelper.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.publishing.flickr; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.node.encryption.MetadataEncryptor; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr; -import org.alfresco.repo.publishing.flickr.springsocial.connect.FlickrConnectionFactory; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.springframework.social.connect.Connection; -import org.springframework.social.oauth1.OAuthToken; - -/** - * A utility class to support the {@link FlickrChannelType}. - * @author Brian - * @since 4.0 - */ -public class FlickrPublishingHelper -{ - private NodeService nodeService; - private FlickrConnectionFactory connectionFactory; - private MetadataEncryptor encryptor; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setConnectionFactory(FlickrConnectionFactory connectionFactory) - { - this.connectionFactory = connectionFactory; - } - - public void setEncryptor(MetadataEncryptor encryptor) - { - this.encryptor = encryptor; - } - - public FlickrConnectionFactory getConnectionFactory() - { - return connectionFactory; - } - - public Connection getConnectionFromChannelProps(Map channelProperties) - { - Connection connection = null; - String tokenValue = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, channelProperties - .get(PublishingModel.PROP_OAUTH1_TOKEN_VALUE)); - String tokenSecret = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, channelProperties - .get(PublishingModel.PROP_OAUTH1_TOKEN_SECRET)); - Boolean danceComplete = (Boolean) channelProperties.get(PublishingModel.PROP_AUTHORISATION_COMPLETE); - - if (danceComplete) - { - OAuthToken token = new OAuthToken(tokenValue, tokenSecret); - connection = connectionFactory.createConnection(token); - } - return connection; - } - - public Connection getConnectionForPublishNode(NodeRef publishNode) - { - Connection connection = null; - NodeRef channelNode = nodeService.getPrimaryParent(publishNode).getParentRef(); - if (nodeService.exists(channelNode) - && nodeService.hasAspect(channelNode, PublishingModel.ASPECT_OAUTH1_DELIVERY_CHANNEL)) - { - connection = getConnectionFromChannelProps(nodeService.getProperties(channelNode)); - } - return connection; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/FlickrPublishingModel.java b/src/main/java/org/alfresco/repo/publishing/flickr/FlickrPublishingModel.java deleted file mode 100644 index 6b9a7e67bc..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/FlickrPublishingModel.java +++ /dev/null @@ -1,43 +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.publishing.flickr; - -import org.alfresco.service.namespace.QName; - -/** - * @author Brian - * - */ -public interface FlickrPublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/flickr/1.0"; - public static final String PREFIX = "flickr"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - - public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect"); -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/Flickr.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/Flickr.java deleted file mode 100644 index 5fdefd44e0..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/Flickr.java +++ /dev/null @@ -1,43 +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.publishing.flickr.springsocial.api; - -import org.springframework.social.ApiBinding; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface Flickr extends ApiBinding -{ - boolean test(); - - /** - * API for performing operations on albums, photos, and videos. - */ - MediaOperations mediaOperations(); -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/FlickrException.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/FlickrException.java deleted file mode 100644 index 383c990546..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/FlickrException.java +++ /dev/null @@ -1,49 +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.publishing.flickr.springsocial.api; - -/** - * - * @author Brian - * @since 4.0 - */ -public class FlickrException extends RuntimeException -{ - private static final long serialVersionUID = 7938720115597007302L; - private String code; - - public FlickrException(String errorCode, String message) - { - super(message); - this.code = errorCode; - } - - public String getCode() - { - return code; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/FlickrHelper.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/FlickrHelper.java deleted file mode 100644 index 598d6fbab7..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/FlickrHelper.java +++ /dev/null @@ -1,45 +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.publishing.flickr.springsocial.api; - -import org.springframework.social.support.URIBuilder; -import org.springframework.util.MultiValueMap; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface FlickrHelper -{ - String getRestEndpoint(); - - String getUploadEndpoint(); - - void addStandardParams(URIBuilder uriBuilder); - - void addStandardParams(MultiValueMap params); -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/MediaOperations.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/MediaOperations.java deleted file mode 100644 index 27955291ba..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/MediaOperations.java +++ /dev/null @@ -1,43 +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.publishing.flickr.springsocial.api; - -import org.springframework.core.io.Resource; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface MediaOperations -{ - - String postPhoto(Resource photo, String title, String description, String... tags) throws FlickrException; - - PhotoInfo getPhoto(String id) throws FlickrException; - - void deletePhoto(String id) throws FlickrException; -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/PhotoInfo.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/PhotoInfo.java deleted file mode 100644 index a99dfd39c5..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/PhotoInfo.java +++ /dev/null @@ -1,37 +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.publishing.flickr.springsocial.api; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface PhotoInfo -{ - String getId(); - String getPrimaryUrl(); -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/UserOperations.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/UserOperations.java deleted file mode 100644 index c42f98015b..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/UserOperations.java +++ /dev/null @@ -1,36 +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.publishing.flickr.springsocial.api; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface UserOperations -{ - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/AbstractFlickrOperations.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/AbstractFlickrOperations.java deleted file mode 100644 index fd2d91e455..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/AbstractFlickrOperations.java +++ /dev/null @@ -1,53 +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.publishing.flickr.springsocial.api.impl; - -import org.springframework.social.MissingAuthorizationException; - -/** - * - * @author Brian - * @since 4.0 - */ -class AbstractFlickrOperations -{ - - private final boolean isAuthorized; - - public AbstractFlickrOperations(boolean isAuthorized) - { - this.isAuthorized = isAuthorized; - } - - protected void requireAuthorization() - { - if (!isAuthorized) - { - throw new MissingAuthorizationException(); - } - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/FlickrErrorHandler.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/FlickrErrorHandler.java deleted file mode 100644 index 03f7fdc739..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/FlickrErrorHandler.java +++ /dev/null @@ -1,217 +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.publishing.flickr.springsocial.api.impl; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Map; - -import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.social.ExpiredAuthorizationException; -import org.springframework.social.InsufficientPermissionException; -import org.springframework.social.InternalServerErrorException; -import org.springframework.social.InvalidAuthorizationException; -import org.springframework.social.MissingAuthorizationException; -import org.springframework.social.NotAuthorizedException; -import org.springframework.social.OperationNotPermittedException; -import org.springframework.social.ResourceNotFoundException; -import org.springframework.social.RevokedAuthorizationException; -import org.springframework.social.UncategorizedApiException; -import org.springframework.social.facebook.api.NotAFriendException; -import org.springframework.social.facebook.api.ResourceOwnershipException; -import org.springframework.web.client.DefaultResponseErrorHandler; - -/** - * - * @author Brian - * @since 4.0 - */ -class FlickrErrorHandler extends DefaultResponseErrorHandler -{ - - @Override - public void handleError(ClientHttpResponse response) throws IOException - { - Map errorDetails = extractErrorDetailsFromResponse(response); - if (errorDetails == null) - { - handleUncategorizedError(response, errorDetails); - } - - handleFlickrError(response.getStatusCode(), errorDetails); - - // if not otherwise handled, do default handling and wrap with - // UncategorizedApiException - handleUncategorizedError(response, errorDetails); - } - - @Override - public boolean hasError(ClientHttpResponse response) throws IOException - { - BufferedReader reader = new BufferedReader(new InputStreamReader(response.getBody())); - return super.hasError(response) || (reader.ready() && reader.readLine().startsWith("{\"error\":")); - } - - /** - * Examines the error data returned from Facebook and throws the most - * applicable exception. - * - * @param errorDetails - * a Map containing a "type" and a "message" corresponding to the - * Graph API's error response structure. - */ - void handleFlickrError(HttpStatus statusCode, Map errorDetails) - { - // Can't trust the type to be useful. It's often OAuthException, even - // for things not OAuth-related. - // Can rely only on the message (which itself isn't very consistent). - String message = errorDetails.get("message"); - - if (statusCode == HttpStatus.OK) - { - if (message.contains("Some of the aliases you requested do not exist")) - { - throw new ResourceNotFoundException(message); - } - } - else if (statusCode == HttpStatus.BAD_REQUEST) - { - if (message.contains("Unknown path components")) - { - throw new ResourceNotFoundException(message); - } - else if (message.equals("An access token is required to request this resource.")) - { - throw new MissingAuthorizationException(); - } - else if (message.equals("An active access token must be used to query information about the current user.")) - { - throw new MissingAuthorizationException(); - } - else if (message.startsWith("Error validating access token")) - { - if (message.contains("Session has expired at unix time")) - { - throw new ExpiredAuthorizationException(); - } - else if (message - .contains("The session has been invalidated because the user has changed the password.")) - { - throw new RevokedAuthorizationException(); - } - else if (message.contains("The session is invalid because the user logged out.")) - { - throw new RevokedAuthorizationException(); - } - else if (message.contains("has not authorized application")) - { - // Per https://developers.facebook.com/blog/post/500/, this - // could be in the message when the user removes the - // application. - // In reality, - // "The session has been invalidated because the user has changed the password." - // is what you get in that case. - // Leaving this check in place in case there FB does return - // this message (could be a bug in FB?) - throw new RevokedAuthorizationException(); - } - else - { - throw new InvalidAuthorizationException(message); - } - } - else if (message.equals("Error validating application.")) - { // Access token with incorrect app ID - throw new InvalidAuthorizationException(message); - } - else if (message.equals("Invalid access token signature.")) - { // Access token that fails signature validation - throw new InvalidAuthorizationException(message); - } - } - else if (statusCode == HttpStatus.UNAUTHORIZED) - { - throw new NotAuthorizedException(message); - } - else if (statusCode == HttpStatus.FORBIDDEN) - { - if (message.contains("Requires extended permission")) - { - String requiredPermission = message.split(": ")[1]; - throw new InsufficientPermissionException(requiredPermission); - } - else - { - throw new OperationNotPermittedException(message); - } - } - else if (statusCode == HttpStatus.INTERNAL_SERVER_ERROR) - { - if (message.equals("User must be an owner of the friendlist")) - { // watch for pattern in similar message in other resources - throw new ResourceOwnershipException(message); - } - else if (message.equals("The member must be a friend of the current user.")) - { - throw new NotAFriendException(message); - } - else - { - throw new InternalServerErrorException(message); - } - } - } - - private void handleUncategorizedError(ClientHttpResponse response, Map errorDetails) - { - try - { - super.handleError(response); - } - catch (Exception e) - { - if (errorDetails != null) - { - throw new UncategorizedApiException(errorDetails.get("message"), e); - } - else - { - throw new UncategorizedApiException("No error details from Facebook", e); - } - } - } - - /* - * Attempts to extract Facebook error details from the response. Returns - * null if the response doesn't match the expected JSON error response. - */ - private Map extractErrorDetailsFromResponse(ClientHttpResponse response) throws IOException - { - return null; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/FlickrTemplate.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/FlickrTemplate.java deleted file mode 100644 index d8cdb66979..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/FlickrTemplate.java +++ /dev/null @@ -1,152 +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.publishing.flickr.springsocial.api.impl; - -import java.net.URI; -import java.util.List; - -import javax.xml.transform.Source; - -import org.alfresco.repo.publishing.JaxbHttpMessageConverter; -import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr; -import org.alfresco.repo.publishing.flickr.springsocial.api.FlickrHelper; -import org.alfresco.repo.publishing.flickr.springsocial.api.MediaOperations; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.xml.SourceHttpMessageConverter; -import org.springframework.social.oauth1.AbstractOAuth1ApiBinding; -import org.springframework.social.support.ClientHttpRequestFactorySelector; -import org.springframework.social.support.URIBuilder; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -/** - * - * @author Brian - * @since 4.0 - */ -public class FlickrTemplate extends AbstractOAuth1ApiBinding implements Flickr, FlickrHelper -{ - private static final String DEFAULT_ENDPOINT = "https://api.flickr.com/services/"; - - private static String endpoint = DEFAULT_ENDPOINT; - - private String consumerKey; - private MediaOperations mediaOperations; - - public FlickrTemplate() - { - initialize(); - } - - public FlickrTemplate(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) - { - super(consumerKey, consumerSecret, accessToken, accessTokenSecret); - this.consumerKey = consumerKey; - initialize(); - } - - private void initSubApis() - { - mediaOperations = new MediaTemplate(this, getRestTemplate(), isAuthorized()); - } - - @Override - public void setRequestFactory(ClientHttpRequestFactory requestFactory) - { - // Wrap the request factory with a BufferingClientHttpRequestFactory so - // that the error handler can do repeat reads on the response.getBody() - super.setRequestFactory(ClientHttpRequestFactorySelector.bufferRequests(requestFactory)); - } - - public static void setEndpoint(String endpoint) - { - FlickrTemplate.endpoint = endpoint; - } - - public MediaOperations mediaOperations() - { - return mediaOperations; - } - - @Override - protected List> getMessageConverters() - { - List> messageConverters = super.getMessageConverters(); - messageConverters.add(new ByteArrayHttpMessageConverter()); - messageConverters.add(new SourceHttpMessageConverter()); - messageConverters.add(new JaxbHttpMessageConverter("org.alfresco.repo.publishing.flickr.springsocial.api.impl.xml")); - return messageConverters; - } - - // private helpers - private void initialize() - { - getRestTemplate().setErrorHandler(new FlickrErrorHandler()); - // Wrap the request factory with a BufferingClientHttpRequestFactory so - // that the error handler can do repeat reads on the response.getBody() - super.setRequestFactory(ClientHttpRequestFactorySelector.bufferRequests(getRestTemplate().getRequestFactory())); - initSubApis(); - } - - @Override - public boolean test() - { - MultiValueMap params = new LinkedMultiValueMap(); - params.add("method", "flickr.test.login"); - addStandardParams(params); - URI uri = URIBuilder.fromUri(getRestEndpoint()).queryParams(params).build(); - getRestTemplate().getForObject(uri, String.class); - return true; - } - - @Override - public void addStandardParams(URIBuilder uriBuilder) - { - MultiValueMap params = new LinkedMultiValueMap(); - addStandardParams(params); - uriBuilder.queryParams(params); - } - - @Override - public void addStandardParams(MultiValueMap params) - { - params.set("api_key", consumerKey); - } - - @Override - public String getRestEndpoint() - { - return endpoint + "rest/"; - } - - @Override - public String getUploadEndpoint() - { - return endpoint + "upload/"; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/MediaTemplate.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/MediaTemplate.java deleted file mode 100644 index db76fda2dd..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/MediaTemplate.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.publishing.flickr.springsocial.api.impl; - -import org.alfresco.repo.publishing.flickr.springsocial.api.FlickrException; -import org.alfresco.repo.publishing.flickr.springsocial.api.FlickrHelper; -import org.alfresco.repo.publishing.flickr.springsocial.api.MediaOperations; -import org.alfresco.repo.publishing.flickr.springsocial.api.PhotoInfo; -import org.alfresco.repo.publishing.flickr.springsocial.api.impl.xml.FlickrError; -import org.alfresco.repo.publishing.flickr.springsocial.api.impl.xml.FlickrPayload; -import org.alfresco.repo.publishing.flickr.springsocial.api.impl.xml.FlickrResponse; -import org.alfresco.repo.publishing.flickr.springsocial.api.impl.xml.Photo; -import org.alfresco.repo.publishing.flickr.springsocial.api.impl.xml.PhotoId; -import org.springframework.core.io.Resource; -import org.springframework.social.support.URIBuilder; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -/** - * - * @author Brian - * @since 4.0 - */ -class MediaTemplate extends AbstractFlickrOperations implements MediaOperations -{ - private final RestTemplate restTemplate; - private FlickrHelper helper; - - public MediaTemplate(FlickrHelper helper, RestTemplate restTemplate, boolean isAuthorizedForUser) - { - super(isAuthorizedForUser); - this.restTemplate = restTemplate; - this.helper = helper; - } - - public String postPhoto(Resource photo, String title, String description, String... tags) - { - String id = null; - requireAuthorization(); - MultiValueMap parts = new LinkedMultiValueMap(); - URIBuilder uriBuilder = URIBuilder.fromUri(helper.getUploadEndpoint()); - - parts.set("photo", photo); - if (description != null) - { - uriBuilder.queryParam("description", description); - parts.set("description", description); - } - if (title != null) - { - uriBuilder.queryParam("title", title); - parts.set("title", title); - } - if (tags.length > 0) - { - StringBuilder tagBuilder = new StringBuilder(); - for (String tag : tags) - { - tagBuilder.append(tag).append(' '); - } - String tagsString = tagBuilder.toString(); - uriBuilder.queryParam("tags", tagsString); - parts.set("tags", tagsString); - } - helper.addStandardParams(uriBuilder); - FlickrResponse response = restTemplate.postForObject(uriBuilder.build(), parts, FlickrResponse.class); - FlickrPayload payload = response.payload; - checkError(payload); - if (PhotoId.class.isAssignableFrom(payload.getClass())) - { - id = ((PhotoId)payload).id; - } - return id; - } - - public PhotoInfo getPhoto(String id) - { - Photo result = null; - requireAuthorization(); - URIBuilder uriBuilder = URIBuilder.fromUri(helper.getRestEndpoint()); - helper.addStandardParams(uriBuilder); - uriBuilder.queryParam("method", "flickr.photos.getInfo"); - uriBuilder.queryParam("photo_id", id); - FlickrResponse response = restTemplate.getForObject(uriBuilder.build(), FlickrResponse.class); - FlickrPayload payload = response.payload; - checkError(payload); - if (Photo.class.isAssignableFrom(payload.getClass())) - { - result = (Photo)payload; - } - return result; - } - - public void deletePhoto(String id) - { - requireAuthorization(); - MultiValueMap parts = new LinkedMultiValueMap(); - helper.addStandardParams(parts); - parts.add("method", "flickr.photos.delete"); - parts.add("photo_id", id); - FlickrResponse response = restTemplate.postForObject(helper.getRestEndpoint(), parts, FlickrResponse.class); - FlickrPayload payload = response.payload; - checkError(payload); - } - - private void checkError(FlickrPayload payload) throws FlickrException - { - if (payload != null && FlickrError.class.isAssignableFrom(payload.getClass())) - { - FlickrError error = (FlickrError) payload; - throw new FlickrException(error.code, error.msg); - } - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/UserTemplate.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/UserTemplate.java deleted file mode 100644 index 2f7355db2e..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/UserTemplate.java +++ /dev/null @@ -1,43 +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.publishing.flickr.springsocial.api.impl; - -import org.alfresco.repo.publishing.flickr.springsocial.api.UserOperations; - -/** - * - * @author Brian - * @since 4.0 - */ -class UserTemplate extends AbstractFlickrOperations implements UserOperations -{ - - public UserTemplate(boolean isAuthorized) - { - super(isAuthorized); - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrError.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrError.java deleted file mode 100644 index 21f18ce6f3..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrError.java +++ /dev/null @@ -1,45 +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.publishing.flickr.springsocial.api.impl.xml; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - * @author Brian - * @since 4.0 - */ - -@XmlRootElement(name = "err") -public class FlickrError implements FlickrPayload -{ - @XmlAttribute - public String code; - - @XmlAttribute - public String msg; -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrPayload.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrPayload.java deleted file mode 100644 index 0aa37ed69c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrPayload.java +++ /dev/null @@ -1,36 +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.publishing.flickr.springsocial.api.impl.xml; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface FlickrPayload -{ - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrResponse.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrResponse.java deleted file mode 100644 index 3f4612037a..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/FlickrResponse.java +++ /dev/null @@ -1,49 +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.publishing.flickr.springsocial.api.impl.xml; - -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlRootElement(name = "rsp") -public class FlickrResponse -{ - @XmlAttribute - public String stat = "ok"; - @XmlAnyElement(lax = true) - public FlickrPayload payload; - - public String toString() - { - return "FlickrResponse[stat=" + stat + ", payload=" + payload + "]"; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/Photo.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/Photo.java deleted file mode 100644 index 4ab711e152..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/Photo.java +++ /dev/null @@ -1,77 +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.publishing.flickr.springsocial.api.impl.xml; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; - -import org.alfresco.repo.publishing.flickr.springsocial.api.PhotoInfo; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlRootElement(name = "photo") -public class Photo implements FlickrPayload, PhotoInfo -{ - @XmlAttribute - public String id; - - @XmlElement(name = "urls") - public UrlList urlList = new UrlList(); - - public static class UrlList - { - @XmlElement(name = "url") - public List urls = new ArrayList(); - } - - public static class PhotoUrl - { - @XmlAttribute - public String type; - @XmlValue - public String url; - } - - @Override - public String getId() - { - return id; - } - - @Override - public String getPrimaryUrl() - { - return urlList.urls.isEmpty() ? null : urlList.urls.get(0).url; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/PhotoId.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/PhotoId.java deleted file mode 100644 index ee6c553cbb..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/PhotoId.java +++ /dev/null @@ -1,41 +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.publishing.flickr.springsocial.api.impl.xml; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlRootElement(name = "photoid") -public class PhotoId implements FlickrPayload -{ - @XmlValue - public String id; -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrAdapter.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrAdapter.java deleted file mode 100644 index 2057b610f7..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrAdapter.java +++ /dev/null @@ -1,70 +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.publishing.flickr.springsocial.connect; - -import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr; -import org.springframework.social.ApiException; -import org.springframework.social.connect.ApiAdapter; -import org.springframework.social.connect.ConnectionValues; -import org.springframework.social.connect.UserProfile; -import org.springframework.social.connect.UserProfileBuilder; - -/** - * - * @author Brian - * @since 4.0 - */ -public class FlickrAdapter implements ApiAdapter -{ - - public boolean test(Flickr flickr) - { - try - { - flickr.test(); - return true; - } - catch (ApiException e) - { - return false; - } - } - - public void setConnectionValues(Flickr flickr, ConnectionValues values) - { - } - - public UserProfile fetchUserProfile(Flickr flickr) - { - return new UserProfileBuilder().setName("Brian").setFirstName("Brian").setLastName( - "Brian").setEmail("Brian").setUsername("Brian").build(); - } - - public void updateStatus(Flickr flickr, String message) - { - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrConnectionFactory.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrConnectionFactory.java deleted file mode 100644 index 9fb3d93e3d..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrConnectionFactory.java +++ /dev/null @@ -1,45 +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.publishing.flickr.springsocial.connect; - -import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr; -import org.alfresco.repo.publishing.flickr.springsocial.connect.FlickrAdapter; -import org.springframework.social.connect.support.OAuth1ConnectionFactory; - -/** - * - * @author Brian - * @since 4.0 - */ -public class FlickrConnectionFactory extends OAuth1ConnectionFactory -{ - - public FlickrConnectionFactory(String consumerKey, String consumerSecret) - { - super("flickr", new FlickrServiceProvider(consumerKey, consumerSecret), new FlickrAdapter()); - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrServiceProvider.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrServiceProvider.java deleted file mode 100644 index 567393a4ab..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/FlickrServiceProvider.java +++ /dev/null @@ -1,53 +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.publishing.flickr.springsocial.connect; - -import org.alfresco.repo.publishing.flickr.springsocial.api.Flickr; -import org.alfresco.repo.publishing.flickr.springsocial.api.impl.FlickrTemplate; -import org.springframework.social.oauth1.AbstractOAuth1ServiceProvider; -import org.springframework.social.oauth1.OAuth1Template; - -/** - * - * @author Brian - * @since 4.0 - */ -public class FlickrServiceProvider extends AbstractOAuth1ServiceProvider -{ - - public FlickrServiceProvider(String consumerKey, String consumerSecret) - { - super(consumerKey, consumerSecret, new OAuth1Template(consumerKey, consumerSecret, - "http://www.flickr.com/services/oauth/request_token", "http://www.flickr.com/services/oauth/authorize", - "http://www.flickr.com/services/oauth/access_token")); - } - - public Flickr getApi(String accessToken, String secret) - { - return new FlickrTemplate(getConsumerKey(), getConsumerSecret(), accessToken, secret); - } - -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/package-info.java b/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/package-info.java deleted file mode 100644 index 4c09b905bc..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/flickr/springsocial/connect/package-info.java +++ /dev/null @@ -1,31 +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% - */ -/** - * Flickr service provider connection repository and API adapter implementations. - */ -@PackageMarker -package org.alfresco.repo.publishing.flickr.springsocial.connect; -import org.alfresco.util.PackageMarker; diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/LinkedInChannelType.java b/src/main/java/org/alfresco/repo/publishing/linkedin/LinkedInChannelType.java deleted file mode 100644 index 587aa228c6..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/LinkedInChannelType.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.publishing.linkedin; - -import static org.alfresco.repo.publishing.linkedin.LinkedInPublishingModel.TYPE_DELIVERY_CHANNEL; - -import org.alfresco.repo.publishing.AbstractOAuth1ChannelType; -import org.alfresco.repo.publishing.linkedin.springsocial.api.AlfrescoLinkedIn; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.social.connect.Connection; - -/** - * @author Nick Smith - * @author Brian - * @since 4.0 - */ -public class LinkedInChannelType extends AbstractOAuth1ChannelType -{ - private final static Log log = LogFactory.getLog(LinkedInChannelType.class); - public final static String ID = "linkedin"; - - @Override - public boolean canPublish() - { - return false; - } - - @Override - public boolean canPublishStatusUpdates() - { - return true; - } - - @Override - public boolean canUnpublish() - { - return false; - } - - @Override - public QName getChannelNodeType() - { - return TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return ID; - } - - @Override - public int getMaximumStatusLength() - { - return 700; - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - NodeRef channelNode = new NodeRef(channel.getId()); - Connection connection = getConnectionForChannel(channelNode); - if (log.isInfoEnabled()) - { - log.info("Posting update to LinkedIn channel " + channel.getName() + ": " + status); - } - connection.getApi().shareComment(status); - } - - @Override - public String getNodeUrl(NodeRef node) - { - return null; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/LinkedInPublishingModel.java b/src/main/java/org/alfresco/repo/publishing/linkedin/LinkedInPublishingModel.java deleted file mode 100644 index 894ac52150..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/LinkedInPublishingModel.java +++ /dev/null @@ -1,43 +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.publishing.linkedin; - -import org.alfresco.service.namespace.QName; - -/** - * @author Nick Smith - * @since 4.0 - */ -public interface LinkedInPublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/linkedin/1.0"; - public static final String PREFIX = "linkedin"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - - public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect"); -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/Activity.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/Activity.java deleted file mode 100644 index 1b857a26aa..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/Activity.java +++ /dev/null @@ -1,46 +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.publishing.linkedin.springsocial.api; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface Activity -{ - public String getContentType(); - - public void setContentType(String value); - - public String getBody(); - - public void setBody(String value); - - public String getLocale(); - - public void setLocale(String value); -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/AlfrescoLinkedIn.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/AlfrescoLinkedIn.java deleted file mode 100644 index 02a724e888..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/AlfrescoLinkedIn.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.publishing.linkedin.springsocial.api; - -import org.springframework.social.linkedin.api.LinkedIn; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface AlfrescoLinkedIn extends LinkedIn -{ - void postNetworkUpdate(String update); - - void shareComment(String comment); -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/Share.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/Share.java deleted file mode 100644 index 6698ed6f17..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/Share.java +++ /dev/null @@ -1,43 +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.publishing.linkedin.springsocial.api; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface Share -{ - public String getComment(); - - public void setComment(String comment); - - public ShareVisibility getVisibility(); - - public void setVisibility(ShareVisibility visibility); - -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/ShareVisibility.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/ShareVisibility.java deleted file mode 100644 index 99edb3eb08..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/ShareVisibility.java +++ /dev/null @@ -1,37 +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.publishing.linkedin.springsocial.api; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface ShareVisibility -{ - ShareVisibilityCode getCode(); - void setCode(ShareVisibilityCode code); -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/ShareVisibilityCode.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/ShareVisibilityCode.java deleted file mode 100644 index 34def3de9d..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/ShareVisibilityCode.java +++ /dev/null @@ -1,70 +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.publishing.linkedin.springsocial.api; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlEnum -public enum ShareVisibilityCode -{ - - @XmlEnumValue("anyone") - ANYONE("anyone"), - - @XmlEnumValue("connections-only") - CONNECTIONS_ONLY("connections-only"); - - private final String value; - - ShareVisibilityCode(String value) - { - this.value = value; - } - - public String value() - { - return value; - } - - public static ShareVisibilityCode fromValue(String value) - { - for (ShareVisibilityCode validCode : ShareVisibilityCode.values()) - { - if (validCode.value.equals(value)) - { - return validCode; - } - } - throw new IllegalArgumentException(value); - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/AlfrescoLinkedInTemplate.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/AlfrescoLinkedInTemplate.java deleted file mode 100644 index 996b5c349c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/AlfrescoLinkedInTemplate.java +++ /dev/null @@ -1,103 +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.publishing.linkedin.springsocial.api.impl; - -import java.util.List; - -import org.alfresco.repo.publishing.JaxbHttpMessageConverter; -import org.alfresco.repo.publishing.linkedin.springsocial.api.Activity; -import org.alfresco.repo.publishing.linkedin.springsocial.api.AlfrescoLinkedIn; -import org.alfresco.repo.publishing.linkedin.springsocial.api.Share; -import org.alfresco.repo.publishing.linkedin.springsocial.api.impl.xml.JaxbActivityImpl; -import org.alfresco.repo.publishing.linkedin.springsocial.api.impl.xml.JaxbShareImpl; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.social.linkedin.api.impl.LinkedInTemplate; -import org.springframework.social.support.URIBuilder; - -/** - * - * @author Brian - * @since 4.0 - */ -public class AlfrescoLinkedInTemplate extends LinkedInTemplate implements AlfrescoLinkedIn -{ - private static String JAXB_CONTEXT_PATH = "org.alfresco.repo.publishing.linkedin.springsocial.api.impl.xml:" - + "org.alfresco.repo.publishing.linkedin.springsocial.api"; - - public AlfrescoLinkedInTemplate(String consumerKey, String consumerSecret, String accessToken, - String accessTokenSecret) - { - super(consumerKey, consumerSecret, accessToken, accessTokenSecret); - } - - protected List> getMessageConverters() - { - List> messageConverters = super.getMessageConverters(); - messageConverters.add(new JaxbHttpMessageConverter(JAXB_CONTEXT_PATH)); - return messageConverters; - } - - @Override - public void postNetworkUpdate(String update) - { - if (update == null || update.trim().length() == 0) - return; - - URIBuilder uriBuilder = URIBuilder.fromUri("http://api.linkedin.com/v1/people/~/person-activities"); - - Activity activity = new JaxbActivityImpl(); - activity.setBody(update); - - HttpEntity entity = buildEntity(activity); - getRestTemplate().postForObject(uriBuilder.build(), entity, String.class); - } - - @Override - public void shareComment(String comment) - { - if (comment == null || comment.trim().length() == 0) - return; - - URIBuilder uriBuilder = URIBuilder.fromUri("http://api.linkedin.com/v1/people/~/shares"); - - Share share = new JaxbShareImpl(); - share.setComment(comment); - - HttpEntity entity = buildEntity(share); - getRestTemplate().postForLocation(uriBuilder.build(), entity); - } - - private HttpEntity buildEntity(Object body) - { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.TEXT_XML); - - return new HttpEntity(body, headers); - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbActivityImpl.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbActivityImpl.java deleted file mode 100644 index e3515db6f1..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbActivityImpl.java +++ /dev/null @@ -1,85 +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.publishing.linkedin.springsocial.api.impl.xml; - -import java.util.Locale; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.alfresco.repo.publishing.linkedin.springsocial.api.Activity; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = {"contentType", "body"}) -@XmlRootElement(name = "activity") -public class JaxbActivityImpl implements Activity -{ - @XmlElement(name = "content-type") - protected String contentType = "linkedin-html"; - @XmlElement(required = true) - protected String body; - @XmlAttribute(required = true) - protected String locale = Locale.getDefault().toString(); - - public String getContentType() - { - return contentType; - } - - public void setContentType(String value) - { - this.contentType = value; - } - - public String getBody() - { - return body; - } - - public void setBody(String value) - { - this.body = value; - } - - public String getLocale() - { - return locale; - } - - public void setLocale(String value) - { - this.locale = value; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbShareImpl.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbShareImpl.java deleted file mode 100644 index 1a34374191..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbShareImpl.java +++ /dev/null @@ -1,74 +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.publishing.linkedin.springsocial.api.impl.xml; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.alfresco.repo.publishing.linkedin.springsocial.api.Share; -import org.alfresco.repo.publishing.linkedin.springsocial.api.ShareVisibility; -import org.alfresco.repo.publishing.linkedin.springsocial.api.ShareVisibilityCode; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { "comment", "visibility" }) -@XmlRootElement(name = "share") -public class JaxbShareImpl implements Share -{ - @XmlElement(required = true, name = "comment") - protected String comment; - - @XmlElement(required = true, name = "visibility") - protected JaxbShareVisibilityImpl visibility = new JaxbShareVisibilityImpl(ShareVisibilityCode.ANYONE); - - public String getComment() - { - return comment; - } - - public void setComment(String comment) - { - this.comment = comment; - } - - public ShareVisibility getVisibility() - { - return visibility; - } - - public void setVisibility(ShareVisibility visibility) - { - this.visibility = new JaxbShareVisibilityImpl(visibility.getCode()); - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbShareVisibilityImpl.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbShareVisibilityImpl.java deleted file mode 100644 index 65f4aeda81..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/JaxbShareVisibilityImpl.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.repo.publishing.linkedin.springsocial.api.impl.xml; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.alfresco.repo.publishing.linkedin.springsocial.api.ShareVisibility; -import org.alfresco.repo.publishing.linkedin.springsocial.api.ShareVisibilityCode; - -/** - * - * @author Brian - * @since 4.0 - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { "code" }) -@XmlRootElement(name = "visibility") -public class JaxbShareVisibilityImpl implements ShareVisibility -{ - @XmlElement(required = true) - protected ShareVisibilityCode code; - - public JaxbShareVisibilityImpl() - { - super(); - } - - public JaxbShareVisibilityImpl(ShareVisibilityCode code) - { - super(); - this.code = code; - } - - public ShareVisibilityCode getCode() - { - return code; - } - - public void setCode(ShareVisibilityCode value) - { - this.code = value; - } - -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInAdapter.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInAdapter.java deleted file mode 100644 index 9bbb79fedb..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInAdapter.java +++ /dev/null @@ -1,70 +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.publishing.linkedin.springsocial.connect; - -import org.alfresco.repo.publishing.linkedin.springsocial.api.AlfrescoLinkedIn; -import org.springframework.social.connect.ApiAdapter; -import org.springframework.social.connect.ConnectionValues; -import org.springframework.social.connect.UserProfile; -import org.springframework.social.connect.UserProfileBuilder; -import org.springframework.social.linkedin.api.LinkedInProfile; -import org.springframework.web.client.HttpClientErrorException; - -/** - * - * @author Brian - * @since 4.0 - */ -public class LinkedInAdapter implements ApiAdapter -{ - public boolean test(AlfrescoLinkedIn linkedin) { - try { - linkedin.getUserProfile(); - return true; - } catch (HttpClientErrorException e) { - // TODO: Have api throw more specific exception and trigger off of that. - return false; - } - } - - public void setConnectionValues(AlfrescoLinkedIn linkedin, ConnectionValues values) { - LinkedInProfile profile = linkedin.getUserProfile(); - values.setProviderUserId(profile.getId()); - values.setDisplayName(profile.getFirstName() + " " + profile.getLastName()); - values.setProfileUrl(profile.getPublicProfileUrl()); - values.setImageUrl(profile.getProfilePictureUrl()); - } - - public UserProfile fetchUserProfile(AlfrescoLinkedIn linkedin) { - LinkedInProfile profile = linkedin.getUserProfile(); - return new UserProfileBuilder().setName(profile.getFirstName() + " " + profile.getLastName()).build(); - } - - public void updateStatus(AlfrescoLinkedIn linkedin, String message) { - // not supported yet - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInConnectionFactory.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInConnectionFactory.java deleted file mode 100644 index 48023f829d..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInConnectionFactory.java +++ /dev/null @@ -1,42 +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.publishing.linkedin.springsocial.connect; - -import org.alfresco.repo.publishing.linkedin.springsocial.api.AlfrescoLinkedIn; -import org.springframework.social.connect.support.OAuth1ConnectionFactory; - -/** - * - * @author Brian - * @since 4.0 - */ -public class LinkedInConnectionFactory extends OAuth1ConnectionFactory{ - - public LinkedInConnectionFactory(String consumerKey, String consumerSecret) { - super("linkedin", new LinkedInServiceProvider(consumerKey, consumerSecret), new LinkedInAdapter()); - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInServiceProvider.java b/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInServiceProvider.java deleted file mode 100644 index a808ff0153..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/linkedin/springsocial/connect/LinkedInServiceProvider.java +++ /dev/null @@ -1,53 +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.publishing.linkedin.springsocial.connect; - -import org.alfresco.repo.publishing.linkedin.springsocial.api.AlfrescoLinkedIn; -import org.alfresco.repo.publishing.linkedin.springsocial.api.impl.AlfrescoLinkedInTemplate; -import org.springframework.social.oauth1.AbstractOAuth1ServiceProvider; -import org.springframework.social.oauth1.OAuth1Template; - -/** - * - * @author Brian - * @since 4.0 - */ -public class LinkedInServiceProvider extends AbstractOAuth1ServiceProvider { - - public LinkedInServiceProvider(String consumerKey, String consumerSecret) { - super(consumerKey, consumerSecret, new OAuth1Template(consumerKey, consumerSecret, - "https://api.linkedin.com/uas/oauth/requestToken", - "https://www.linkedin.com/uas/oauth/authorize", - "https://www.linkedin.com/uas/oauth/authenticate", - "https://api.linkedin.com/uas/oauth/accessToken")); - } - - public AlfrescoLinkedIn getApi(String accessToken, String secret) { - return new AlfrescoLinkedInTemplate(getConsumerKey(), getConsumerSecret(), accessToken, secret); - } - - -} diff --git a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareApi.java b/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareApi.java deleted file mode 100644 index 6764b4e536..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareApi.java +++ /dev/null @@ -1,41 +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.publishing.slideshare; - -import com.benfante.jslideshare.SlideShareAPI; -import com.benfante.jslideshare.SlideShareErrorException; -import com.benfante.jslideshare.SlideShareException; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface SlideShareApi extends SlideShareAPI -{ - String deleteSlideshow(String username, String password, String id) throws SlideShareException, - SlideShareErrorException; -} diff --git a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareApiImpl.java b/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareApiImpl.java deleted file mode 100644 index 43d4e4c230..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareApiImpl.java +++ /dev/null @@ -1,314 +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.publishing.slideshare; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.benfante.jslideshare.DocumentParser; -import com.benfante.jslideshare.DocumentParserResult; -import com.benfante.jslideshare.SlideShareConnector; -import com.benfante.jslideshare.SlideShareErrorException; -import com.benfante.jslideshare.SlideShareException; -import com.benfante.jslideshare.messages.Group; -import com.benfante.jslideshare.messages.Slideshow; -import com.benfante.jslideshare.messages.SlideshowInfo; -import com.benfante.jslideshare.messages.Tag; -import com.benfante.jslideshare.messages.User; - -/** - * - * @author Brian - * @since 4.0 - */ -public class SlideShareApiImpl implements SlideShareApi -{ - private static final Log logger = LogFactory.getLog(SlideShareApiImpl.class); - - public static final String URL_GET_SLIDESHOW = "URL_GET_SLIDESHOW"; - public static final String URL_GET_SLIDESHOW_INFO = "URL_GET_SLIDESHOW_INFO"; - public static final String URL_GET_SLIDESHOW_BY_USER = "URL_GET_SLIDESHOW_BY_USER"; - public static final String URL_GET_SLIDESHOW_BY_TAG = "URL_GET_SLIDESHOW_BY_TAG"; - public static final String URL_GET_SLIDESHOW_BY_GROUP = "URL_GET_SLIDESHOW_BY_GROUP"; - public static final String URL_UPLOAD_SLIDESHOW = "URL_UPLOAD_SLIDESHOW"; - public static final String URL_DELETE_SLIDESHOW = "URL_DELETE_SLIDESHOW"; - - private static Map DEFAULT_API_URLS = new TreeMap(); - - static - { - DEFAULT_API_URLS.put(URL_GET_SLIDESHOW, "https://www.slideshare.net/api/2/get_slideshow"); - DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_INFO, "https://www.slideshare.net/api/2/get_slideshow"); - DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_USER, "https://www.slideshare.net/api/2/get_slideshow_by_user"); - DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_TAG, "https://www.slideshare.net/api/2/get_slideshow_by_tag"); - DEFAULT_API_URLS.put(URL_GET_SLIDESHOW_BY_GROUP, "https://www.slideshare.net/api/2/get_slideshow_from_group"); - DEFAULT_API_URLS.put(URL_UPLOAD_SLIDESHOW, "https://www.slideshare.net/api/2/upload_slideshow"); - DEFAULT_API_URLS.put(URL_DELETE_SLIDESHOW, "https://www.slideshare.net/api/2/delete_slideshow"); - } - - private Map apiUrls = new TreeMap(DEFAULT_API_URLS); - - protected SlideShareConnector connector; - - private String username; - - private String password; - - public SlideShareApiImpl() - { - } - - public SlideShareApiImpl(SlideShareConnector connector) - { - this.connector = connector; - } - - public SlideShareConnector getConnector() - { - return connector; - } - - public void setConnector(SlideShareConnector connector) - { - this.connector = connector; - } - - public void setApiUrls(Map urls) - { - if (urls == null || !urls.keySet().containsAll(DEFAULT_API_URLS.keySet())) - { - throw new IllegalArgumentException("Specified URL set is missing one or more values. Expected " - + DEFAULT_API_URLS.keySet() + "; Received " + (urls == null ? urls : urls.keySet())); - } - } - - public Slideshow getSlideshow(String id) throws SlideShareException, SlideShareErrorException - { - logger.info("Called getSlideshow with id=" + id); - Map parameters = new HashMap(); - addParameter(parameters, "slideshow_id", id); - return sendMessage(URL_GET_SLIDESHOW, parameters).getSlideShow(); - } - - public SlideshowInfo getSlideshowInfo(String id, String url) throws SlideShareException, SlideShareErrorException - { - logger.info("Called getSlideshowInfo with id=" + id + ", url=" + url); - Map parameters = new HashMap(); - addParameter(parameters, "slideshow_id", id); - addParameter(parameters, "slideshow_url", url); - return sendGetMessage(URL_GET_SLIDESHOW_INFO, parameters).getSlideShowInfo(); - } - - public User getSlideshowByUser(String username) throws SlideShareException, SlideShareErrorException - { - logger.info("Called getSlideshowByUser with username=" + username); - return getSlideshowByUser(username, -1, -1); - } - - public User getSlideshowByUser(String username, int offset, int limit) throws SlideShareException, - SlideShareErrorException - { - logger.info("Called getSlideshowByUser with username=" + username + ", offset=" + offset + ", limit=" + limit); - Map parameters = new HashMap(); - addParameter(parameters, "username_for", username); - addLimits(parameters, offset, limit); - return sendMessage(URL_GET_SLIDESHOW_BY_USER, parameters).getUser(); - } - - public Tag getSlideshowByTag(String tag) throws SlideShareException, SlideShareErrorException - { - logger.info("Called getSlideshowByTag with tag=" + tag); - return getSlideshowByTag(tag, -1, -1); - } - - public Tag getSlideshowByTag(String tag, int offset, int limit) throws SlideShareException, - SlideShareErrorException - { - logger.info("Called getSlideshowByTag with tag=" + tag + ", offset=" + offset + ", limit=" + limit); - Map parameters = new HashMap(); - addParameter(parameters, "tag", tag); - addLimits(parameters, offset, limit); - return sendMessage(URL_GET_SLIDESHOW_BY_TAG, parameters).getTag(); - } - - public Group getSlideshowByGroup(String groupName) throws SlideShareException, SlideShareErrorException - { - logger.info("Called getSlideshowByGroup with groupName=" + groupName); - return getSlideshowByGroup(groupName, -1, -1); - } - - public Group getSlideshowByGroup(String groupName, int offset, int limit) throws SlideShareException, - SlideShareErrorException - { - logger - .info("Called getSlideshowByGrop with groupName=" + groupName + ", offset=" + offset + ", limit=" - + limit); - Map parameters = new HashMap(); - addParameter(parameters, "group_name", groupName); - addLimits(parameters, offset, limit); - return sendMessage(URL_GET_SLIDESHOW_BY_GROUP, parameters).getGroup(); - } - - public String uploadSlideshow(String username, String password, String title, File src, String description, - String tags, boolean makeSrcPublic, boolean makeSlideshowPrivate, boolean generateSecretUrl, - boolean allowEmbeds, boolean shareWithContacts) throws SlideShareException, SlideShareErrorException - { - logger.info("Called uploadSlideshow with username=" + username + ", password=XXX, title=" + title - + ", description=" + description + ", tags=" + tags + ", makeSrcPublic=" + makeSrcPublic - + ", makeSlideshowPrivate=" + makeSlideshowPrivate + ", generateSecretUrl=" + generateSecretUrl - + ", allowEmbeds=" + allowEmbeds + ", shareWithContacts=" + shareWithContacts); - Map parameters = new HashMap(); - addParameter(parameters, "username", username); - addParameter(parameters, "password", password); - addParameter(parameters, "slideshow_title", title); - addParameter(parameters, "slideshow_description", description); - addParameter(parameters, "slideshow_tags", tags); - addParameter(parameters, "make_src_public", makeSrcPublic); - addParameter(parameters, "make_slideshow_private", makeSlideshowPrivate); - addParameter(parameters, "generate_secret_url", generateSecretUrl); - addParameter(parameters, "allow_embeds", allowEmbeds); - addParameter(parameters, "share_with_contacts", shareWithContacts); - Map files = new HashMap(); - files.put("slideshow_srcfile", src); - return sendMessage(URL_UPLOAD_SLIDESHOW, parameters, files).getSlideShowId(); - } - - public String deleteSlideshow(String username, String password, String id) throws SlideShareException, - SlideShareErrorException - { - logger.info("Called deleteSlideshow with username=" + username + ", password=XXX, id=" + id); - Map parameters = new HashMap(); - addParameter(parameters, "username", username); - addParameter(parameters, "password", password); - addParameter(parameters, "slideshow_id", id); - return sendGetMessage(URL_DELETE_SLIDESHOW, parameters).getSlideShowId(); - } - - private Map addParameter(Map parameters, String name, String value) - { - if (value != null) - { - parameters.put(name, value); - } - return parameters; - } - - private Map addParameter(Map parameters, String name, boolean value) - { - parameters.put(name, value ? "Y" : "N"); - return parameters; - } - - private Map addLimits(Map parameters, int offset, int limit) - { - if (offset >= 0) - { - parameters.put("offset", Integer.toString(offset)); - } - if (limit >= 0) - { - parameters.put("limit", Integer.toString(limit)); - } - return parameters; - } - - private DocumentParserResult sendMessage(String url, Map parameters) - throws SlideShareErrorException - { - addCredentials(parameters); - DocumentParserResult result; - try - { - InputStream response = connector.sendMessage(apiUrls.get(url), parameters); - result = DocumentParser.parse(response); - } - catch (IOException iOException) - { - throw new SlideShareErrorException(-1, "Error sending a message to the url " + apiUrls.get(url), iOException); - } - return result; - } - - private DocumentParserResult sendGetMessage(String url, Map parameters) - throws SlideShareErrorException - { - addCredentials(parameters); - DocumentParserResult result; - try - { - InputStream response = connector.sendGetMessage(apiUrls.get(url), parameters); - result = DocumentParser.parse(response); - } - catch (IOException iOException) - { - throw new SlideShareErrorException(-1, "Error sending a message to the url " + apiUrls.get(url), iOException); - } - return result; - } - - private DocumentParserResult sendMessage(String url, Map parameters, Map files) - throws SlideShareErrorException - { - addCredentials(parameters); - DocumentParserResult result; - try - { - InputStream response = connector.sendMultiPartMessage(apiUrls.get(url), parameters, files); - result = DocumentParser.parse(response); - } - catch (IOException iOException) - { - throw new SlideShareErrorException(-1, "Error sending a multipart message to the url " + apiUrls.get(url), iOException); - } - return result; - } - - private void addCredentials(Map parameters) - { - if (username != null && password != null) - { - addParameter(parameters, "username", username); - addParameter(parameters, "password", password); - } - } - - public void setUsername(String username) - { - this.username = username; - } - - public void setPassword(String password) - { - this.password = password; - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareChannelType.java b/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareChannelType.java deleted file mode 100644 index de7d56a5bd..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareChannelType.java +++ /dev/null @@ -1,284 +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.publishing.slideshare; - -import java.io.File; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.benfante.jslideshare.SlideShareAPI; -import com.benfante.jslideshare.messages.SlideshowInfo; - -/** - * - * @author Brian - * @since 4.0 - */ -public class SlideShareChannelType extends AbstractChannelType -{ - public final static String ID = "slideshare"; - - private final static Log log = LogFactory.getLog(SlideShareChannelType.class); - - private final static int STATUS_QUEUED = 0; - // private final static int STATUS_CONVERTING = 1; - private final static int STATUS_SUCCEEDED = 2; - private final static int STATUS_FAILED = 3; - private final static int STATUS_TIMED_OUT = 10; - private static final String ERROR_SLIDESHARE_CONVERSION_FAILED = "publish.slideshare.conversionFailed"; - private static final String ERROR_SLIDESHARE_CONVERSION_TIMED_OUT = "publish.slideshare.conversionTimedOut"; - - private SlideSharePublishingHelper publishingHelper; - private ContentService contentService; - private TaggingService taggingService; - - private long timeoutMilliseconds = 60L * 60L * 1000L; // 1 hour default - - public void setPublishingHelper(SlideSharePublishingHelper publishingHelper) - { - this.publishingHelper = publishingHelper; - } - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - public void setTaggingService(TaggingService taggingService) - { - this.taggingService = taggingService; - } - - public void setTimeoutMilliseconds(long timeoutMilliseconds) - { - this.timeoutMilliseconds = timeoutMilliseconds; - } - - @Override - public boolean canPublish() - { - return true; - } - - @Override - public boolean canPublishStatusUpdates() - { - return false; - } - - @Override - public boolean canUnpublish() - { - return true; - } - - @Override - public QName getChannelNodeType() - { - return SlideSharePublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return ID; - } - - @Override - public Set getSupportedMimeTypes() - { - return publishingHelper.getAllowedMimeTypes().keySet(); - } - - @Override - public void publish(NodeRef nodeToPublish, Map properties) - { - NodeService nodeService = getNodeService(); - Pair usernamePassword = publishingHelper - .getSlideShareCredentialsFromChannelProperties(properties); - if (usernamePassword == null) - { - throw new AlfrescoRuntimeException("publish.failed.no_credentials_found"); - } - SlideShareAPI api = publishingHelper - .getSlideShareApi(usernamePassword.getFirst(), usernamePassword.getSecond()); - - ContentReader reader = contentService.getReader(nodeToPublish, ContentModel.PROP_CONTENT); - if (reader.exists()) - { - File contentFile; - String mime = reader.getMimetype(); - - String extension = publishingHelper.getAllowedMimeTypes().get(mime); - if (extension == null) - extension = ""; - - boolean deleteContentFileOnCompletion = false; - - // SlideShare seems to work entirely off file extension, so we - // always copy onto the - // file system and upload from there. - File tempDir = TempFileProvider.getLongLifeTempDir("slideshare"); - contentFile = TempFileProvider.createTempFile("slideshare", extension, tempDir); - reader.getContent(contentFile); - deleteContentFileOnCompletion = true; - - try - { - - String name = (String) nodeService.getProperty(nodeToPublish, ContentModel.PROP_NAME); - String title = (String) nodeService.getProperty(nodeToPublish, ContentModel.PROP_TITLE); - if (title == null || title.length() == 0) - { - title = name; - } - String description = (String) nodeService.getProperty(nodeToPublish, ContentModel.PROP_DESCRIPTION); - if (description == null || description.length() == 0) - { - description = title; - } - - List tagList = taggingService.getTags(nodeToPublish); - StringBuilder tags = new StringBuilder(); - for (String tag : tagList) - { - tags.append(tag); - tags.append(' '); - } - - String assetId = api.uploadSlideshow(usernamePassword.getFirst(), usernamePassword.getSecond(), title, - contentFile, description, tags.toString(), false, false, false, false, false); - - String url = null; - int status = STATUS_QUEUED; - boolean finished = false; - long timeoutTime = System.currentTimeMillis() + timeoutMilliseconds; - // Fetch the slideshow info every 30 seconds until we timeout - while (!finished) - { - SlideshowInfo slideInfo = api.getSlideshowInfo(assetId, ""); - if (slideInfo != null) - { - if (url == null) - { - url = slideInfo.getUrl(); - if (log.isInfoEnabled()) - { - log.info("SlideShare has provided a URL for asset " + assetId + ": " + url); - } - } - status = slideInfo.getStatus(); - } - finished = (status == STATUS_FAILED || status == STATUS_SUCCEEDED); - - if (!finished) - { - if (System.currentTimeMillis() < timeoutTime) - { - try - { - Thread.sleep(30000L); - } - catch (InterruptedException e) - { - } - } - else - { - status = STATUS_TIMED_OUT; - finished = true; - } - } - } - if (status == STATUS_SUCCEEDED) - { - if (log.isInfoEnabled()) - { - log.info("File " + name + " has been published to SlideShare with id " + assetId + " at URL " - + url); - } - nodeService.addAspect(nodeToPublish, SlideSharePublishingModel.ASPECT_ASSET, null); - nodeService.setProperty(nodeToPublish, PublishingModel.PROP_ASSET_ID, assetId); - nodeService.setProperty(nodeToPublish, PublishingModel.PROP_ASSET_URL, url); - } - else - { - throw new AlfrescoRuntimeException(status == STATUS_FAILED ? ERROR_SLIDESHARE_CONVERSION_FAILED - : ERROR_SLIDESHARE_CONVERSION_TIMED_OUT); - } - } - finally - { - if (deleteContentFileOnCompletion) - { - contentFile.delete(); - } - } - } - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map properties) - { - NodeService nodeService = getNodeService(); - if (nodeService.hasAspect(nodeToUnpublish, SlideSharePublishingModel.ASPECT_ASSET)) - { - String assetId = (String) nodeService.getProperty(nodeToUnpublish, PublishingModel.PROP_ASSET_ID); - if (assetId != null) - { - Pair usernamePassword = publishingHelper - .getSlideShareCredentialsFromChannelProperties(properties); - if (usernamePassword == null) - { - throw new AlfrescoRuntimeException("publish.failed.no_credentials_found"); - } - SlideShareApi api = publishingHelper.getSlideShareApi(usernamePassword.getFirst(), usernamePassword - .getSecond()); - - api.deleteSlideshow(usernamePassword.getFirst(), usernamePassword.getSecond(), assetId); - nodeService.removeAspect(nodeToUnpublish, SlideSharePublishingModel.ASPECT_ASSET); - nodeService.removeAspect(nodeToUnpublish, PublishingModel.ASPECT_ASSET); - } - } - } -} diff --git a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareConnectorImpl.java b/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareConnectorImpl.java deleted file mode 100644 index a54265b8b8..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideShareConnectorImpl.java +++ /dev/null @@ -1,236 +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.publishing.slideshare; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.multipart.FilePart; -import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; -import org.apache.commons.httpclient.methods.multipart.Part; -import org.apache.commons.httpclient.methods.multipart.StringPart; -import org.apache.log4j.Logger; - -import com.benfante.jslideshare.SlideShareConnector; -import com.benfante.jslideshare.SlideShareErrorException; - -/** - * - * @author Brian - * @since 4.0 - */ -public class SlideShareConnectorImpl implements SlideShareConnector -{ - - private static final Logger logger = Logger.getLogger(SlideShareConnectorImpl.class); - - private String apiKey; - private String sharedSecret; - private HttpClient httpClient; - - public SlideShareConnectorImpl() - { - httpClient = new HttpClient(); - httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager()); - } - - public SlideShareConnectorImpl(String apiKey, String sharedSecret) - { - this(); - this.apiKey = apiKey; - this.sharedSecret = sharedSecret; - } - - public String getApiKey() - { - return apiKey; - } - - public void setApiKey(String apiKey) - { - this.apiKey = apiKey; - } - - public String getSharedSecret() - { - return sharedSecret; - } - - public void setSharedSecret(String sharedSecret) - { - this.sharedSecret = sharedSecret; - } - - - public InputStream sendMessage(String url, Map parameters) throws IOException, - SlideShareErrorException - { - PostMethod method = new PostMethod(url); - method.addParameter("api_key", this.apiKey); - Iterator> entryIt = parameters.entrySet().iterator(); - while (entryIt.hasNext()) - { - Map.Entry entry = entryIt.next(); - method.addParameter(entry.getKey(), entry.getValue()); - } - Date now = new Date(); - String ts = Long.toString(now.getTime() / 1000); - String hash = DigestUtils.shaHex(this.sharedSecret + ts).toLowerCase(); - method.addParameter("ts", ts); - method.addParameter("hash", hash); - logger.debug("Sending POST message to " + method.getURI().getURI() + " with parameters " - + Arrays.toString(method.getParameters())); - int statusCode = httpClient.executeMethod(method); - if (statusCode != HttpStatus.SC_OK) - { - logger.debug("Server replied with a " + statusCode + " HTTP status code (" - + HttpStatus.getStatusText(statusCode) + ")"); - throw new SlideShareErrorException(statusCode, HttpStatus.getStatusText(statusCode)); - } - if (logger.isDebugEnabled()) - { - logger.debug(method.getResponseBodyAsString()); - } - InputStream result = new ByteArrayInputStream(method.getResponseBody()); - method.releaseConnection(); - return result; - } - - public InputStream sendMultiPartMessage(String url, Map parameters, Map files) - throws IOException, SlideShareErrorException - { - PostMethod method = new PostMethod(url); - List partList = new ArrayList(); - partList.add(createStringPart("api_key", this.apiKey)); - Date now = new Date(); - String ts = Long.toString(now.getTime() / 1000); - String hash = DigestUtils.shaHex(this.sharedSecret + ts).toLowerCase(); - partList.add(createStringPart("ts", ts)); - partList.add(createStringPart("hash", hash)); - Iterator> entryIt = parameters.entrySet().iterator(); - while (entryIt.hasNext()) - { - Map.Entry entry = entryIt.next(); - partList.add(createStringPart(entry.getKey(), entry.getValue())); - } - Iterator> entryFileIt = files.entrySet().iterator(); - while (entryFileIt.hasNext()) - { - Map.Entry entry = entryFileIt.next(); - partList.add(createFilePart(entry.getKey(), entry.getValue())); - } - MultipartRequestEntity requestEntity = new MultipartRequestEntity(partList.toArray(new Part[partList.size()]), - method.getParams()); - method.setRequestEntity(requestEntity); - logger.debug("Sending multipart POST message to " + method.getURI().getURI() + " with parts " + partList); - int statusCode = httpClient.executeMethod(method); - if (statusCode != HttpStatus.SC_OK) - { - logger.debug("Server replied with a " + statusCode + " HTTP status code (" - + HttpStatus.getStatusText(statusCode) + ")"); - throw new SlideShareErrorException(statusCode, HttpStatus.getStatusText(statusCode)); - } - if (logger.isDebugEnabled()) - { - logger.debug(method.getResponseBodyAsString()); - } - InputStream result = new ByteArrayInputStream(method.getResponseBody()); - method.releaseConnection(); - return result; - } - - public InputStream sendGetMessage(String url, Map parameters) throws IOException, - SlideShareErrorException - { - GetMethod method = new GetMethod(url); - NameValuePair[] params = new NameValuePair[parameters.size() + 3]; - int i = 0; - params[i++] = new NameValuePair("api_key", this.apiKey); - Iterator> entryIt = parameters.entrySet().iterator(); - while (entryIt.hasNext()) - { - Map.Entry entry = entryIt.next(); - params[i++] = new NameValuePair(entry.getKey(), entry.getValue()); - } - Date now = new Date(); - String ts = Long.toString(now.getTime() / 1000); - String hash = DigestUtils.shaHex(this.sharedSecret + ts).toLowerCase(); - params[i++] = new NameValuePair("ts", ts); - params[i++] = new NameValuePair("hash", hash); - method.setQueryString(params); - logger.debug("Sending GET message to " + method.getURI().getURI() + " with parameters " - + Arrays.toString(params)); - int statusCode = httpClient.executeMethod(method); - if (statusCode != HttpStatus.SC_OK) - { - logger.debug("Server replied with a " + statusCode + " HTTP status code (" - + HttpStatus.getStatusText(statusCode) + ")"); - throw new SlideShareErrorException(statusCode, HttpStatus.getStatusText(statusCode)); - } - if (logger.isDebugEnabled()) - { - logger.debug(method.getResponseBodyAsString()); - } - InputStream result = new ByteArrayInputStream(method.getResponseBody()); - method.releaseConnection(); - return result; - } - - private StringPart createStringPart(String name, String value) - { - StringPart stringPart = new StringPart(name, value); - stringPart.setContentType(null); - stringPart.setTransferEncoding(null); - stringPart.setCharSet("UTF-8"); - return stringPart; - } - - private FilePart createFilePart(String name, File value) throws FileNotFoundException - { - FilePart filePart = new FilePart(name, value); - filePart.setTransferEncoding(null); - filePart.setCharSet(null); - return filePart; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideSharePublishingHelper.java b/src/main/java/org/alfresco/repo/publishing/slideshare/SlideSharePublishingHelper.java deleted file mode 100644 index 99e879e667..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideSharePublishingHelper.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.publishing.slideshare; - -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; - -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.node.encryption.MetadataEncryptor; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.Pair; - -import com.benfante.jslideshare.SlideShareAPI; -import com.benfante.jslideshare.SlideShareConnector; - -/** - * - * @author Brian - * @since 4.0 - */ -public class SlideSharePublishingHelper -{ - private final static Map DEFAULT_MIME_TYPES = new TreeMap(); - static - { - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_PPT, ".ppt"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_PDF, ".pdf"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION, ".odp"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION, ".pptx"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, ""); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_IWORK_PAGES, ""); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_TEXT_PLAIN, ".txt"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENDOCUMENT_TEXT, ".odt"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_TEXT_CSV, ".csv"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_EXCEL, ".xls"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING, ".docx"); - DEFAULT_MIME_TYPES.put(MimetypeMap.MIMETYPE_OPENDOCUMENT_SPREADSHEET, ".ods"); - } - - private Map allowedMimeTypes = Collections.unmodifiableMap(DEFAULT_MIME_TYPES); - private SlideShareConnector slideshareConnector; - private MetadataEncryptor encryptor; - - public void setSlideshareConnector(SlideShareConnector slideshareConnector) - { - this.slideshareConnector = slideshareConnector; - } - - public Map getAllowedMimeTypes() - { - return allowedMimeTypes; - } - - public void setAllowedMimeTypes(Map allowedMimeTypes) - { - this.allowedMimeTypes = Collections.unmodifiableMap(allowedMimeTypes); - } - - public void setEncryptor(MetadataEncryptor encryptor) - { - this.encryptor = encryptor; - } - - public SlideShareAPI getSlideShareApi() - { - return createApiObject(); - } - - private SlideShareApiImpl createApiObject() - { - return new SlideShareApiImpl(slideshareConnector); - } - - public Pair getSlideShareCredentialsFromChannelProperties(Map channelProperties) - { - Pair result = null; - String username = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_USERNAME, - channelProperties.get(PublishingModel.PROP_CHANNEL_USERNAME)); - String password = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_PASSWORD, - channelProperties.get(PublishingModel.PROP_CHANNEL_PASSWORD)); - if (username != null && password != null) - { - result = new Pair(username, password); - } - return result; - } - - public SlideShareApi getSlideShareApi(String username, String password) - { - SlideShareApiImpl api = createApiObject(); - api.setUsername(username); - api.setPassword(password); - return api; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideSharePublishingModel.java b/src/main/java/org/alfresco/repo/publishing/slideshare/SlideSharePublishingModel.java deleted file mode 100644 index 564441c61f..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/slideshare/SlideSharePublishingModel.java +++ /dev/null @@ -1,46 +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.publishing.slideshare; - -import org.alfresco.service.namespace.QName; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface SlideSharePublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/slideshare/1.0"; - public static final String PREFIX = "slideshare"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - - public static final QName ASPECT_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannelAspect"); - - public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect"); -} diff --git a/src/main/java/org/alfresco/repo/publishing/twitter/TwitterChannelType.java b/src/main/java/org/alfresco/repo/publishing/twitter/TwitterChannelType.java deleted file mode 100644 index 269e27d0ec..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/twitter/TwitterChannelType.java +++ /dev/null @@ -1,100 +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.publishing.twitter; - -import org.alfresco.repo.publishing.AbstractOAuth1ChannelType; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.social.connect.Connection; -import org.springframework.social.twitter.api.Twitter; - -/** - * - * @author Brian - * @since 4.0 - */ -public class TwitterChannelType extends AbstractOAuth1ChannelType -{ - private final static Log log = LogFactory.getLog(TwitterChannelType.class); - public final static String ID = "twitter"; - - @Override - public boolean canPublish() - { - return false; - } - - @Override - public boolean canPublishStatusUpdates() - { - return true; - } - - @Override - public boolean canUnpublish() - { - return false; - } - - @Override - public QName getChannelNodeType() - { - return TwitterPublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return ID; - } - - @Override - public int getMaximumStatusLength() - { - return 140; - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - Connection connection = getConnectionForChannel(channel.getNodeRef()); - if (log.isInfoEnabled()) - { - log.info("Posting update to Twitter channel " + channel.getName() + ": " + status); - } - connection.getApi().timelineOperations().updateStatus(status); - } - - @Override - public String getNodeUrl(NodeRef node) - { - return null; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/twitter/TwitterPublishingModel.java b/src/main/java/org/alfresco/repo/publishing/twitter/TwitterPublishingModel.java deleted file mode 100644 index 2e9e2664c7..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/twitter/TwitterPublishingModel.java +++ /dev/null @@ -1,44 +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.publishing.twitter; - -import org.alfresco.service.namespace.QName; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface TwitterPublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/twitter/1.0"; - public static final String PREFIX = "twitter"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - - public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect"); -} diff --git a/src/main/java/org/alfresco/repo/publishing/youtube/YouTubeChannelType.java b/src/main/java/org/alfresco/repo/publishing/youtube/YouTubeChannelType.java deleted file mode 100644 index d116916c1c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/youtube/YouTubeChannelType.java +++ /dev/null @@ -1,335 +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.publishing.youtube; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.filestore.FileContentReader; -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.TempFileProvider; -import org.alfresco.util.collections.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.google.gdata.client.media.ResumableGDataFileUploader; -import com.google.gdata.client.uploader.ProgressListener; -import com.google.gdata.client.uploader.ResumableHttpFileUploader; -import com.google.gdata.client.youtube.YouTubeService; -import com.google.gdata.data.media.MediaFileSource; -import com.google.gdata.data.media.mediarss.MediaCategory; -import com.google.gdata.data.media.mediarss.MediaDescription; -import com.google.gdata.data.media.mediarss.MediaKeywords; -import com.google.gdata.data.media.mediarss.MediaTitle; -import com.google.gdata.data.youtube.VideoEntry; -import com.google.gdata.data.youtube.YouTubeMediaGroup; -import com.google.gdata.data.youtube.YouTubeNamespace; -import com.google.gdata.util.ServiceException; - -/** - * - * @author Brian - * @since 4.0 - */ -public class YouTubeChannelType extends AbstractChannelType -{ - private final static Log log = LogFactory.getLog(YouTubeChannelType.class); - private final static Set DEFAULT_SUPPORTED_MIME_TYPES = CollectionUtils.unmodifiableSet( - MimetypeMap.MIMETYPE_VIDEO_MPG, MimetypeMap.MIMETYPE_VIDEO_MP4, MimetypeMap.MIMETYPE_VIDEO_FLV, - MimetypeMap.MIMETYPE_VIDEO_3GP, MimetypeMap.MIMETYPE_VIDEO_AVI, MimetypeMap.MIMETYPE_VIDEO_QUICKTIME, - MimetypeMap.MIMETYPE_VIDEO_WMV); - - public static final String RESUMABLE_UPLOAD_URL = "http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads"; - - /** Time interval at which upload task will notify about the progress */ - private static final int PROGRESS_UPDATE_INTERVAL = 1000; - - /** Max size for each upload chunk */ - private static final int DEFAULT_CHUNK_SIZE = 10000000; - - private Set supportedMimeTypes = DEFAULT_SUPPORTED_MIME_TYPES; - - public final static String ID = "youtube"; - private YouTubePublishingHelper youTubeHelper; - private ContentService contentService; - private TaggingService taggingService; - - public void setYouTubeHelper(YouTubePublishingHelper youTubeHelper) - { - this.youTubeHelper = youTubeHelper; - } - - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - public void setTaggingService(TaggingService taggingService) - { - this.taggingService = taggingService; - } - - public void setSupportedMimeTypes(Set supportedMimeTypes) - { - this.supportedMimeTypes = Collections.unmodifiableSet(new TreeSet(supportedMimeTypes)); - } - - @Override - public boolean canPublish() - { - return true; - } - - @Override - public boolean canPublishStatusUpdates() - { - return false; - } - - @Override - public boolean canUnpublish() - { - return true; - } - - @Override - public QName getChannelNodeType() - { - return YouTubePublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return ID; - } - - @Override - public Set getSupportedMimeTypes() - { - return supportedMimeTypes; - } - - @Override - public void publish(NodeRef nodeToPublish, Map properties) - { - YouTubeService service = youTubeHelper.getYouTubeServiceFromChannelProperties(properties); - if (service != null) - { - try - { - uploadVideo(service, nodeToPublish); - } - catch (Exception ex) - { - log.error("Failed to send asset to YouTube", ex); - throw new AlfrescoRuntimeException("exception.publishing.youtube.publishFailed", ex); - } - } - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map properties) - { - YouTubeService service = youTubeHelper.getYouTubeServiceFromChannelProperties(properties); - if (service != null) - { - try - { - removeVideo(service, nodeToUnpublish); - } - catch (Exception ex) - { - log.error("Failed to remove asset from YouTube", ex); - throw new AlfrescoRuntimeException("exception.publishing.youtube.unpublishFailed", ex); - } - } - } - - private void removeVideo(YouTubeService service, NodeRef nodeRef) throws MalformedURLException, IOException, - ServiceException - { - NodeService nodeService = getNodeService(); - if (nodeService.hasAspect(nodeRef, YouTubePublishingModel.ASPECT_ASSET)) - { - String youtubeId = (String) nodeService.getProperty(nodeRef, PublishingModel.PROP_ASSET_ID); - if (youtubeId != null) - { - String videoEntryUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads/" + youtubeId; - VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class); - videoEntry.delete(); - nodeService.removeAspect(nodeRef, YouTubePublishingModel.ASPECT_ASSET); - nodeService.removeAspect(nodeRef, PublishingModel.ASPECT_ASSET); - } - } - } - - private void uploadVideo(YouTubeService service, NodeRef nodeRef) throws IOException, ServiceException, - InterruptedException - { - NodeService nodeService = getNodeService(); - ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); - if (reader.exists()) - { - File contentFile; - boolean deleteContentFileOnCompletion = false; - if (FileContentReader.class.isAssignableFrom(reader.getClass())) - { - // Grab the content straight from the content store if we can... - contentFile = ((FileContentReader) reader).getFile(); - } - else - { - // ...otherwise copy it to a temp file and use the copy... - File tempDir = TempFileProvider.getLongLifeTempDir("youtube"); - contentFile = TempFileProvider.createTempFile("youtube", "", tempDir); - reader.getContent(contentFile); - deleteContentFileOnCompletion = true; - } - MediaFileSource ms = new MediaFileSource(contentFile, reader.getMimetype()); - - String videoName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - String videoTitle = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE); - if (videoTitle == null || videoTitle.length() == 0) - { - videoTitle = videoName; - } - String videoDescription = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION); - if (videoDescription == null || videoDescription.length() == 0) - { - videoDescription = videoTitle; - } - - VideoEntry newEntry = new VideoEntry(); - YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup(); - mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Tech")); - mg.setTitle(new MediaTitle()); - mg.getTitle().setPlainTextContent(videoTitle); - mg.setKeywords(new MediaKeywords()); - List tags = taggingService.getTags(nodeRef); - for (String tag : tags) - { - mg.getKeywords().addKeyword(tag); - } - mg.setDescription(new MediaDescription()); - mg.getDescription().setPlainTextContent(videoDescription); - - FileUploadProgressListener listener = new FileUploadProgressListener(videoName); - ResumableGDataFileUploader uploader = new ResumableGDataFileUploader.Builder(service, new URL( - RESUMABLE_UPLOAD_URL), ms, newEntry).title(videoTitle).trackProgress(listener, - PROGRESS_UPDATE_INTERVAL).chunkSize(DEFAULT_CHUNK_SIZE).build(); - - uploader.start(); - while (!uploader.isDone()) - { - Thread.sleep(PROGRESS_UPDATE_INTERVAL); - } - - switch (uploader.getUploadState()) - { - case COMPLETE: - VideoEntry entry = uploader.getResponse(VideoEntry.class); - String videoId = entry.getMediaGroup().getVideoId(); - String contentUrl = entry.getMediaGroup().getContents().get(0).getUrl(); - String playerUrl = entry.getMediaGroup().getPlayer().getUrl(); - if (log.isDebugEnabled()) - { - log.debug("Video content uploaded successfully: " + videoName); - log.debug("YouTube video id is " + videoId); - log.debug("YouTube content URL is " + contentUrl); - log.debug("YouTube video player URL is " + playerUrl); - } - nodeService.addAspect(nodeRef, YouTubePublishingModel.ASPECT_ASSET, null); - nodeService.setProperty(nodeRef, PublishingModel.PROP_ASSET_ID, videoId); - nodeService.setProperty(nodeRef, PublishingModel.PROP_ASSET_URL, playerUrl); - break; - case CLIENT_ERROR: - log.error("Video content failed to upload: " + videoName); - break; - default: - log.warn("Unknown upload state. Video content may not have uploaded: " + videoName + "(" - + uploader.getUploadState() + ") :" + nodeRef); - break; - } - - if (deleteContentFileOnCompletion) - { - contentFile.delete(); - } - } - } - - /** - * A {@link ProgressListener} implementation to track upload progress. The - * listener can track multiple uploads at the same time. - */ - private class FileUploadProgressListener implements ProgressListener - { - String videoName; - - public FileUploadProgressListener(String videoName) - { - this.videoName = videoName; - } - - public synchronized void progressChanged(ResumableHttpFileUploader uploader) - { - switch (uploader.getUploadState()) - { - case COMPLETE: - log.info("Upload Completed: " + videoName); - break; - case CLIENT_ERROR: - log.error("Upload Failed: " + videoName); - break; - case IN_PROGRESS: - log.info(videoName + String.format(" %3.0f", uploader.getProgress() * 100) + "%"); - break; - case NOT_STARTED: - log.info("Upload Not Started: " + videoName); - break; - } - } - } -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/publishing/youtube/YouTubePublishingHelper.java b/src/main/java/org/alfresco/repo/publishing/youtube/YouTubePublishingHelper.java deleted file mode 100644 index dbd053df8c..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/youtube/YouTubePublishingHelper.java +++ /dev/null @@ -1,78 +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.publishing.youtube; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.repo.node.encryption.MetadataEncryptor; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.google.gdata.client.youtube.YouTubeService; - -/** - * - * @author Brian - * @since 4.0 - */ -public class YouTubePublishingHelper -{ - private static final Log log = LogFactory.getLog(YouTubePublishingHelper.class); - private MetadataEncryptor encryptor; - - public void setEncryptor(MetadataEncryptor encryptor) - { - this.encryptor = encryptor; - } - - public YouTubeService getYouTubeServiceFromChannelProperties(Map channelProperties) - { - YouTubeService service = null; - if (channelProperties != null) - { - String youtubeUsername = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_USERNAME, - channelProperties.get(PublishingModel.PROP_CHANNEL_USERNAME)); - String youtubePassword = (String) encryptor.decrypt(PublishingModel.PROP_CHANNEL_PASSWORD, - channelProperties.get(PublishingModel.PROP_CHANNEL_PASSWORD)); - service = new YouTubeService("Alfresco", - "AI39si78RHlniONCtnu9o8eBfwZToBAp2ZbbURm5eoJjj4gZi0LcxjDqJTzD35oYokmtFXbCo5ojofbimGnMlRbmNrh7-M7ZCw"); - try - { - service.setUserCredentials(youtubeUsername, youtubePassword); - } - catch (Exception e) - { - service = null; - log.error("Failed to connect to YouTube", e); - } - } - return service; - } - -} diff --git a/src/main/java/org/alfresco/repo/publishing/youtube/YouTubePublishingModel.java b/src/main/java/org/alfresco/repo/publishing/youtube/YouTubePublishingModel.java deleted file mode 100644 index 1ff2deac4e..0000000000 --- a/src/main/java/org/alfresco/repo/publishing/youtube/YouTubePublishingModel.java +++ /dev/null @@ -1,46 +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.publishing.youtube; - -import org.alfresco.service.namespace.QName; - -/** - * - * @author Brian - * @since 4.0 - */ -public interface YouTubePublishingModel -{ - public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/youtube/1.0"; - public static final String PREFIX = "youtube"; - - public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel"); - - public static final QName ASPECT_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannelAspect"); - - public static final QName ASPECT_ASSET = QName.createQName(NAMESPACE, "AssetAspect"); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java b/src/main/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java deleted file mode 100644 index a5050c258e..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/BaseNodePublishStatus.java +++ /dev/null @@ -1,62 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public abstract class BaseNodePublishStatus implements NodePublishStatus -{ - private final NodeRef nodeRef; - private final String channelId; - - public BaseNodePublishStatus(NodeRef nodeRef, String channelName) - { - this.nodeRef = nodeRef; - this.channelId = channelName; - } - - /** - * {@inheritDoc} - */ - public NodeRef getNodeRef() - { - return nodeRef; - } - - /** - * {@inheritDoc} - */ - public String getChannelId() - { - return channelId; - } -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java b/src/main/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java deleted file mode 100644 index 15de9bce7e..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/MutablePublishingEvent.java +++ /dev/null @@ -1,41 +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.publishing; - -import java.util.Calendar; - -/** - * An extension of the {@link PublishingEvent} interface that allows some changes to be made. - * - * @author Brian - * @since 4.0 - */ -public interface MutablePublishingEvent extends PublishingEvent -{ - void setScheduledTime(Calendar time); - void setComment(String comment); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java b/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatus.java deleted file mode 100644 index 9c3031ad0f..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatus.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.service.cmr.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public interface NodePublishStatus -{ - enum Status {NOT_PUBLISHED, ON_QUEUE, PUBLISHED, PUBLISHED_AND_ON_QUEUE} - - T visit(NodePublishStatusVisitor visitor); - - NodeRef getNodeRef(); - - Status getStatus(); - - String getChannelId(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java b/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java deleted file mode 100644 index 363f32bc20..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusNotPublished.java +++ /dev/null @@ -1,61 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public class NodePublishStatusNotPublished extends BaseNodePublishStatus -{ - /** - * @param node NodeRef - * @param channelName TODO - */ - public NodePublishStatusNotPublished(NodeRef node, String channelName) - { - super(node, channelName); - } - - /** - * {@inheritDoc} - */ - public T visit(NodePublishStatusVisitor visitor) - { - return visitor.accept(this); - } - - /** - * {@inheritDoc} - */ - public Status getStatus() - { - return Status.NOT_PUBLISHED; - } -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java b/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java deleted file mode 100644 index 0201b97395..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusOnQueue.java +++ /dev/null @@ -1,66 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public class NodePublishStatusOnQueue extends BaseNodePublishStatus -{ - private final PublishingEvent queuedEvent; - - public NodePublishStatusOnQueue(NodeRef nodeRef, String channelName, PublishingEvent queuedEvent) - { - super(nodeRef, channelName); - this.queuedEvent =queuedEvent; - } - - /** - * {@inheritDoc} - */ - public T visit(NodePublishStatusVisitor visitor) - { - return visitor.accept(this); - } - - public PublishingEvent getQueuedPublishingEvent() - { - return queuedEvent; - } - - /** - * {@inheritDoc} - */ - public Status getStatus() - { - return Status.ON_QUEUE; - } -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java b/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java deleted file mode 100644 index af5c251f6c..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublished.java +++ /dev/null @@ -1,72 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public class NodePublishStatusPublished extends BaseNodePublishStatus -{ - - private final PublishingEvent lastEvent; - - public NodePublishStatusPublished(NodeRef node, String channelId, PublishingEvent lastEvent) - { - super(node, channelId); - this.lastEvent = lastEvent; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.publishing.NodePublishStatus#visit(org.alfresco.service.cmr.publishing.NodePublishStatusVisitor) - */ - @Override - public T visit(NodePublishStatusVisitor visitor) - { - return visitor.accept(this); - } - - /** - * Retrieve the most recent publishing event that affected (created or updated) the node relevant to this status. - * @return PublishingEvent - */ - public PublishingEvent getLatestPublishingEvent() - { - return lastEvent; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.publishing.NodePublishStatus#getStatus() - */ - @Override - public Status getStatus() - { - return Status.PUBLISHED; - } -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java b/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java deleted file mode 100644 index 0d055ce5ea..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusPublishedAndOnQueue.java +++ /dev/null @@ -1,86 +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.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public class NodePublishStatusPublishedAndOnQueue extends BaseNodePublishStatus -{ - - private final PublishingEvent queuedPublishingEvent; - private final PublishingEvent latestPublishingEvent; - - /** - * @param nodeRef NodeRef - * @param channelName TODO - * @param queuedPublishingEvent The next scheduled {@link PublishingEvent} on the {@link PublishingQueue} - * @param latestPublishingEvent The last {@link PublishingEvent} to successfully publish the node. - */ - public NodePublishStatusPublishedAndOnQueue(NodeRef nodeRef, String channelName, - PublishingEvent queuedPublishingEvent, PublishingEvent latestPublishingEvent) - { - super(nodeRef, channelName); - this.queuedPublishingEvent = queuedPublishingEvent; - this.latestPublishingEvent = latestPublishingEvent; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.publishing.NodePublishStatus#visit(org.alfresco.service.cmr.publishing.NodePublishStatusVisitor) - */ - @Override - public T visit(NodePublishStatusVisitor visitor) - { - return visitor.accept(this); - } - - public PublishingEvent getQueuedPublishingEvent() - { - return queuedPublishingEvent; - } - - /** - * Retrieve the most recent publishing event that affected (created or updated) the node relevant to this status. - * @return PublishingEvent - */ - public PublishingEvent getLatestPublishingEvent() - { - return latestPublishingEvent; - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.publishing.NodePublishStatus#getStatus() - */ - @Override - public Status getStatus() - { - return Status.PUBLISHED_AND_ON_QUEUE; - } -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java b/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java deleted file mode 100644 index a58f364a0a..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodePublishStatusVisitor.java +++ /dev/null @@ -1,41 +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.publishing; - -/** - * An interface that enables the use of the Visitor pattern on {@link NodePublishStatus} objects. - * - * @author Brian - * @since 4.0 - */ -public interface NodePublishStatusVisitor -{ - T accept(NodePublishStatusNotPublished status); - T accept(NodePublishStatusOnQueue status); - T accept(NodePublishStatusPublished status); - T accept(NodePublishStatusPublishedAndOnQueue status); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java b/src/main/java/org/alfresco/service/cmr/publishing/NodeSnapshot.java deleted file mode 100644 index 0dd47b6a27..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/NodeSnapshot.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.service.cmr.publishing; - -import java.io.Serializable; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public interface NodeSnapshot -{ - /** - * Retrieve the identifier of the node of which this is a snapshot - * @return The NodeRef object that identifies the node - */ - NodeRef getNodeRef(); - - /** - * The property values assigned to the node at the moment the snapshot was taken. - * @return A map that associates property names to property values for the node. - */ - Map getProperties(); - - /** - * Retrieve the type of the node at the moment the snapshot was taken. - * @return The QName that identifies the type of the node - */ - QName getType(); - - /** - * Retrieve all the aspects that were applied to the node at the moment the snapshot was taken - * @return A set of QName objects, each identifying an aspect that is applied to the node - */ - Set getAspects(); - - /** - * @return the version of the node when the snapshot was taken. - */ - String getVersion(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingDetails.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingDetails.java deleted file mode 100644 index 6f4deb963a..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingDetails.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.service.cmr.publishing; - -import java.util.Calendar; -import java.util.Collection; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * A simple DTO used to gather parameters for scheduling a Publishing Event. - * - * @author Brian - * @author Nick Smith - * - * @since 4.0 - */ -public interface PublishingDetails -{ - PublishingDetails addNodesToUnpublish(NodeRef... nodesToRemove); - - PublishingDetails addNodesToUnpublish(Collection nodesToRemove); - - PublishingDetails addNodesToPublish(NodeRef... nodesToPublish); - - PublishingDetails addNodesToPublish(Collection nodesToPublish); - - PublishingDetails setPublishChannelId(String channelId); - - PublishingDetails setComment(String comment); - - PublishingDetails setSchedule(Calendar schedule); - - PublishingDetails setStatusMessage(String message); - - PublishingDetails setStatusNodeToLinkTo(NodeRef nodeToLinkTo); - - PublishingDetails addStatusUpdateChannels(Collection channelIds); - PublishingDetails addStatusUpdateChannels(String... channelIds); - - /** - * @return the comment - */ - String getComment(); - - /** - * @return the message - */ - String getStatusMessage(); - - /** - * @return the nodeToLinkTo - */ - NodeRef getNodeToLinkTo(); - - /** - * @return the publishChannelId - */ - String getPublishChannelId(); - - /** - * @return the schedule - */ - Calendar getSchedule(); - - Set getStatusUpdateChannels(); - - /** - * @return a {@link Set} of all the {@link NodeRef}s to be published. - */ - Set getNodesToPublish(); - - /** - * @return a {@link Set} of all the {@link NodeRef}s to be unpublished. - */ - Set getNodesToUnpublish(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingEvent.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingEvent.java deleted file mode 100644 index ed348c3a96..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingEvent.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.service.cmr.publishing; - -import java.util.Calendar; -import java.util.Date; - -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; - - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public interface PublishingEvent extends Comparable -{ - /** - * @return a unique {@link String} identifier for this {@link PublishingEvent} - */ - String getId(); - - /** - * @return the current {@link Status} of this {@link PublishingEvent}. - */ - Status getStatus(); - - /** - * @return the date and time when this {@link PublishingEvent} is scheduled to publish its content. - */ - Calendar getScheduledTime(); - - /** - * @return the {@link PublishingPackage} containing all the {@link NodeRef}s to be published and unpublished. - */ - PublishingPackage getPackage(); - - /** - * @return the date and time when this {@link PublishingEvent} was created. - */ - Date getCreatedTime(); - - /** - * @return the name of the user who created this {@link PublishingEvent}. - */ - String getCreator(); - - /** - * @return the date and time when this {@link PublishingEvent} was last modified. - */ - Date getModifiedTime(); - - /** - * @return the name of the user who last modified this {@link PublishingEvent}. - */ - String getModifier(); - - /** - * @return the comment associatied with this {@link PublishingEvent}. - */ - String getComment(); - - /** - * @return a unique identifier indicating which {@link Channel} this {@link PublishingEvent} publishes to. - */ - String getChannelId(); - - /** - * @return the {@link StatusUpdate} information, if any. - */ - StatusUpdate getStatusUpdate(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.java deleted file mode 100644 index fa419acf92..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingEventFilter.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.service.cmr.publishing; - -import java.util.Collection; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public interface PublishingEventFilter -{ - PublishingEventFilter setIds(String... ids); - - PublishingEventFilter setIds(Collection ids); - - Set getIds(); - - PublishingEventFilter setPublishedNodes(NodeRef... publishedNodes); - - PublishingEventFilter setPublishedNodes(Collection publishedNodes); - - Set getPublishedNodes(); - - PublishingEventFilter setUnpublishedNodes(NodeRef... unpublishedNodes); - - PublishingEventFilter setUnpublishedNodes(Collection unpublishedNodes); - - Set getUnpublishedNodes(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingPackage.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingPackage.java deleted file mode 100644 index e8406eb1fc..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingPackage.java +++ /dev/null @@ -1,61 +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.publishing; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public interface PublishingPackage -{ - /** - * Retrieve the collection of publishing package entries contained by this publishing package. - * @return The collection of publishing package entries. Never null. - */ - Collection getEntries(); - - /** - * Returns a {@link Map} from the {@link NodeRef} to be published/unpublished to the corresponding {@link PublishingPackageEntry}. - * @return the {@link Map} of Publishing Package Entries. - */ - Map getEntryMap(); - - /** - * @return a {@link Set} of all the {@link NodeRef}s to be published. - */ - Set getNodesToPublish(); - - /** - * @return a {@link Set} of all the {@link NodeRef}s to be unpublished. - */ - Set getNodesToUnpublish(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.java deleted file mode 100644 index 0719916a30..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingPackageEntry.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.service.cmr.publishing; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public interface PublishingPackageEntry -{ - /** - * Retrieve the identifier of the node that this publishing package entry - * relates to - * - * @return A NodeRef object that identifies the node that this publishing - * package entry relates to - */ - NodeRef getNodeRef(); - - /** - * Retrieve the snapshot of the node that is held as the payload of this - * publishing package entry. The snapshot is taken when the containing - * publishing package is placed on the publishing queue IF this is a - * "publish" entry as opposed to an "unpublish" entry. No snapshot is taken - * for an unpublish entry. - * - * @return The snapshot of the node that this publishing package entry - * relates to if this is a "publish" entry ( - * null if this is an "unpublish" entry). The snapshot is taken when - * the containing publishing package is placed on the publishing queue, so if this operation is called before that point - * then it will return null. - */ - NodeSnapshot getSnapshot(); - - /** - * Determine if this entry relates to a publish request or an unpublish - * request - * - * @return true if this entry relates to a publish request and - * false if it relates to an unpublish request - */ - boolean isPublish(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingQueue.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingQueue.java deleted file mode 100644 index 03f523775f..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingQueue.java +++ /dev/null @@ -1,48 +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.publishing; - -/** - * @author Brian - * @since 4.0 - */ -public interface PublishingQueue -{ - /** - * A factory method to create an empty publishing package that can be populated before being passed into - * a call to the {@link PublishingQueue#scheduleNewEvent(PublishingDetails)} operation. - * @return A publishing package that can be populated before being placed on the publishing queue. - */ - PublishingDetails createPublishingDetails(); - - /** - * Adds the supplied publishing package onto the queue. - * @param publishingDetails The publishing package that is to be enqueued - * @return The identifier of the newly scheduled event - */ - String scheduleNewEvent(PublishingDetails publishingDetails); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/PublishingService.java b/src/main/java/org/alfresco/service/cmr/publishing/PublishingService.java deleted file mode 100644 index c6eba86263..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/PublishingService.java +++ /dev/null @@ -1,93 +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.publishing; - -import java.util.List; - -import org.alfresco.service.Auditable; -import org.alfresco.service.NotAuditable; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Brian - * @since 4.0 - */ -public interface PublishingService -{ - /** - * Retrieve the publishing event that has the specified identifier - * - * @param id The identifier of the required publishing event - * @return The PublishingEvent object that corresponds to the requested - * identifier or null if no such publishing event can - * be located - */ - @NotAuditable - PublishingEvent getPublishingEvent(String id); - - /** - * Retrieve a list of publishing events for which the specified node was published. - * @param publishedNode The node that was published. - * @return A list of {@link PublishingEvent}s. - */ - @NotAuditable - List getPublishEventsForNode(NodeRef publishedNode); - - /** - * Retrieve a list of publishing events for which the specified node was unpublished. - * @param unpublishedNode The node that was unpublished. - * @return A list of {@link PublishingEvent}s. - */ - @NotAuditable - List getUnpublishEventsForNode(NodeRef unpublishedNode); - - /** - * Request that the specified publishing event be cancelled. This call will - * cancel the identified publishing event immediately if it hasn't been - * started. If it has been started but not yet completed then the request - * for cancellation will be recorded, and acted upon when (and if) possible. - * - * @param id The identifier of the publishing event that is to be cancelled. - */ - @Auditable(parameters={"id"}) - void cancelPublishingEvent(String id); - - /** - * A factory method to create an empty publishing package that can be populated before being passed into - * a call to the {@link PublishingQueue#scheduleNewEvent(PublishingDetails)} operation. - * @return A publishing package that can be populated before being placed on the publishing queue. - */ - @NotAuditable - PublishingDetails createPublishingDetails(); - - /** - * Adds the supplied publishing package onto the queue. - * @param publishingDetails The publishing package that is to be enqueued - * @return The identifier of the newly scheduled event - */ - @Auditable - String scheduleNewEvent(PublishingDetails publishingDetails); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/Status.java b/src/main/java/org/alfresco/service/cmr/publishing/Status.java deleted file mode 100644 index bb6437916e..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/Status.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.service.cmr.publishing; - -/** - * @author Brian - * @since 4.0 - */ -public enum Status -{ - SCHEDULED, - IN_PROGRESS, - CANCEL_REQUESTED, - COMPLETED, - FAILED -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/service/cmr/publishing/StatusUpdate.java b/src/main/java/org/alfresco/service/cmr/publishing/StatusUpdate.java deleted file mode 100644 index f807dd3fb9..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/StatusUpdate.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.service.cmr.publishing; - -import java.util.Set; - -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Nick Smith - * @since 4.0 - */ -public interface StatusUpdate -{ - /** - * @return the status message to be published. - */ - String getMessage(); - - /** - * @return a {@link Set} of String identifiers indicating which {@link Channel} the status update will be published to. - */ - Set getChannelIds(); - - /** - * Returns a {@link NodeRef}. The returned {@link NodeRef} is one of the {@link NodeRef}s to be published by the associated {@link PublishingEvent}. The status update message will have a URL appended to it which links to the published resource represented by this {@link NodeRef}. - * @return the {@link NodeRef} to link to. - */ - NodeRef getNodeToLinkTo(); -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/channels/Channel.java b/src/main/java/org/alfresco/service/cmr/publishing/channels/Channel.java deleted file mode 100644 index 9a2335c118..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/channels/Channel.java +++ /dev/null @@ -1,128 +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.publishing.channels; - -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * Represents a publishing channel - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public interface Channel -{ - /** - * @return a unique identifier for this {@link Channel}. - */ - String getId(); - - /** - * @return the {@link ChannelType} for this Channel. - */ - ChannelType getChannelType(); - - /** - * Retrieve the node ref of the node that represents this channel object in the repository - * @return NodeRef - */ - NodeRef getNodeRef(); - - /** - * Retrieve the name of this channel - * @return String - */ - String getName(); - - /** - * Retrieve the properties defined on this channel. - * @return Map - */ - Map getProperties(); - - /** - * Post the specified text onto this channel as a status update. - * @param status The text of the status update. Note that if the length of this text plus the - * length of the urlToAppend text is greater than the maximum length permitted as a status - * update on this channel then this text will be truncated to fit. - * @param urlToAppend Text that is to be appended to the status update - often a URL to a relevant - * piece of content. If this channel can't accept both the status text and the URL then the status text - * will be truncated in preference to the URL. This argument may be null. - */ - void sendStatusUpdate(String status, String urlToAppend); - - /** - * Returns the URL for the specified node on this channel. - * @param publishedNode The content node whose published URL is being requested. - * @return a URL for the published content. May return null if the specified node has not - * been published to this channel. - */ - String getUrl(NodeRef publishedNode); - - /** - * Has this channel been authorised yet? - * Typically, when a channel is created in Alfresco the user is sent to the service provider to authorise - * Alfresco to access their account on their behalf. Once Alfresco has been told that the user has done that then - * this operation will return true. Until then, this operation will return false. - * - * A channel that is not authorised cannot be used to publish content or status updates to. - * @return true if this channel has been authorised and is ready for use. - */ - boolean isAuthorised(); - - /** - * Returns true only if the currently authenticated user can publish content to this {@link Channel}. - * If the {@link ChannelType} does not support publishing, if the {@link Channel} is not authorised or if the - * currently authenticated user does not have permission to publish to this {@link Channel} then this - * method will return false. - * @return boolean - */ - boolean canPublish(); - - /** - * Returns true only if the currently authenticated user can unpublish content from this {@link Channel}. - * If the {@link ChannelType} does not support unpublishing, if the {@link Channel} is not authorised or if the - * currently authenticated user does not have permission to publish to this {@link Channel} then this method - * will return false. - * @return boolean - */ - boolean canUnpublish(); - - /** - * Returns true only if the currently authenticated user can unpublish status updates to this {@link Channel}. - * If the {@link ChannelType} does not support publishing of status updates, if the {@link Channel} is not authorised - * or if the currently authenticated user does not have permission to publish to this {@link Channel} then this method - * will return false. - * @return boolean - */ - boolean canPublishStatusUpdates(); - -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java b/src/main/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java deleted file mode 100644 index 4cc9f53706..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/channels/ChannelService.java +++ /dev/null @@ -1,150 +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.publishing.channels; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.service.Auditable; -import org.alfresco.service.NotAuditable; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -public interface ChannelService -{ - /** - * Register a new channel type with the channel service - * @param channelType The channel type to be registered. - * @throws IllegalArgumentException if a channel type is already registered that has the same identifier as the supplied one - */ - @NotAuditable - void register(AbstractChannelType channelType); - - /** - * Retrieve the channel type that has the specified identifier - * @param id The identifier of the channel type to be retrieved - * @return A ChannelType object that represents the channel type with the specified identifier - */ - @NotAuditable - ChannelType getChannelType(String id); - - /** - * Retrieve all the registered channel types, excluding any that are hidden - * @return A list of ChannelType objects, each representing a channel type registered with this channel service - */ - @NotAuditable - List getChannelTypes(); - - /** - * Create a new channel of the specified channel type on the specified Share site with the specified name and properties. - * @param channelTypeId The identifier of the channel type that is to be used for the new channel. This must identify a channel type that - * has been registered with the channel service. - * @param name The name of the new channel. This must be unique within the specified Share site. - * @param properties Any additional properties that are to be saved as part of the new channel. - * @return A Channel object corresponding to the newly created channel. - */ - @Auditable(parameters={"channelTypeId", "name"}) - Channel createChannel(String channelTypeId, String name, Map properties); - - /** - * Remove the specified channel. - * @param channel The channel to delete. - */ - @Auditable - void deleteChannel(Channel channel); - - /** - * Rename the specified channel - * @param channel The channel that is to be renamed. - * @param newName The new name of the channel - */ - @Auditable(parameters={"newName"}) - void renameChannel(Channel channel, String newName); - - /** - * Update the properties of the specified channel. - * @param channel The channel that is to be updated. - * @param properties The properties to set on the channel. These are blended with the current properties - * on the channel. Any that aren't currently set will be added, others will be updated. - */ - @Auditable - void updateChannel(Channel channel, Map properties); - - /** - * Retrieve all the channels. - * @return A list of Channel objects, each one representing a channel that exists within the specified Share site. - */ - @NotAuditable - List getChannels(); - - /** - * Retrieve the channel with the given channel name. - * @param channelName The name of the channel - * @return The specified Channel objects or null if the specified channel does not exist. - */ - @NotAuditable - Channel getChannelByName(String channelName); - - /** - * Retrieve the channel with the given id. - * @param id The string value of the channel {@link NodeRef}. - * @return The specified Channel objects or null if the specified channel does not exist. - */ - @NotAuditable - Channel getChannelById(String id); - - /** - * Returns a list of all the channels that are capable of publishing the specified NodeRef. - * @param nodeToPublish NodeRef - */ - @NotAuditable - List getRelevantPublishingChannels(NodeRef nodeToPublish); - - /** - * Returns a list of all the channels that are capable of publishing in the specified Share site. - * @param filterByPublishPermission If true then the returned channels are filtered to include only those - * to which the authenticated user can publish - */ - @NotAuditable - List getPublishingChannels(boolean filterByPublishPermission); - - /** - * Returns all {@link Channel}s cpaable of performing a status update for the given Share Site. - * @param filterByPublishPermission If true then the returned channels are filtered to include only those - * to which the authenticated user can post status updates - */ - @NotAuditable - List getStatusUpdateChannels(boolean filterByPublishPermission); - -} diff --git a/src/main/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java b/src/main/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java deleted file mode 100644 index 0c3b0217e8..0000000000 --- a/src/main/java/org/alfresco/service/cmr/publishing/channels/ChannelType.java +++ /dev/null @@ -1,182 +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.publishing.channels; - -import java.util.Map; -import java.util.Set; - -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.springframework.core.io.Resource; - -/** - * @author Brian - * @since 4.0 - */ -public interface ChannelType -{ - public final class AuthUrlPair - { - /** - * The URL to which the user should be sent in order to grant Alfresco access to a channel. - */ - public final String authorisationRequestUrl; - - /** - * The URL to which the service provider is expected to send the user once the user's authorisation - * has been sought. - */ - public final String authorisationRedirectUrl; - - public AuthUrlPair(String authorisationRequestUrl, String authorisationRedirectUrl) - { - this.authorisationRequestUrl = authorisationRequestUrl; - this.authorisationRedirectUrl = authorisationRedirectUrl; - } - - } - - enum AuthStatus {AUTHORISED, RETRY, UNAUTHORISED} - - /** - * Returns the unique identifier of this channel type - * @return String - */ - String getId(); - - /** - * Returns the title (display name) of this channel type. - * The title may be localised, but this is implementation specific - * @return String - */ - String getTitle(); - - /** - * Each channel is stored in the repository as a node. This operation returns - * the qualified name of the type of that node. - * @return QName - */ - QName getChannelNodeType(); - - /** - * Does this channel type support publishing content? - * @return boolean - */ - boolean canPublish(); - - /** - * Does this channel type support unpublishing content? That is to say, once content has been published - * to a channel of this type, can it later be removed from that channel? - * @return boolean - */ - boolean canUnpublish(); - - /** - * Does this channel type support status updates? - * @return boolean - */ - boolean canPublishStatusUpdates(); - - /** - * Send the specified status update to the specified channel - * @param channel Channel - * @param status String - */ - void sendStatusUpdate(Channel channel, String status); - - /** - * Returns the set of MIME types supported by channels of this type. - * @return The set of MIME types supported by channels of this type or an empty set - * if content of any MIME type can be published. - */ - Set getSupportedMimeTypes(); - - /** - * Returns the set of content types supported by channels of this type. - * @return The set of content types supported by channels of this type or an empty set - * if content of any content type can be published. - */ - Set getSupportedContentTypes(); - - /** - * Returns the URL for a piece of content represented by the supplied node. - * @param node The published content node in the live environment. - * @return a URL for the published content. - */ - String getNodeUrl(NodeRef node); - - /** - * If this channel type supports status updates then this operation returns the maximum permitted - * length of those status updates. - * @return The maximum length of status updates on channels of this type. A value of zero indicates that there - * is no maximum. - */ - int getMaximumStatusLength(); - - /** - * When creating a new channel of this type, this operation is called to find out where the user should be taken - * in order to authorise Alfresco to publish content / status updates to that channel. - * @param channel The channel that needs to be authorised. - * @param alfrescoCallbackUrl Where the user's browser needs to send the authorisation tokens once - * the authorisation procedure is complete. If possible, the authorisation URL should include this information - * so the service provider can send the tokens straight back to us via the browser without any intermediate steps - * being needed. - * @return The URL that the user should be taken to in order to authorise access to Alfresco for the specified channel. - */ - AuthUrlPair getAuthorisationUrls(Channel channel, String alfrescoCallbackUrl); - - /** - * This operation is called after the service provider represented by this channel type has redirected the user - * back to Alfresco. The HTTP headers and parameters received from the service provider are included, as they are likely - * to contain essential information such as tokens, error codes, and so on. - * @param channel The channel related to this authorisation callback. - * @param callbackHeaders All the HTTP headers received in the callback. - * @param callbackParams All the HTTP parameters received in the callback. - * @return A value indicating whether the authorisation was successful or not. If not, there is an indication as to - * whether the user may try again or not. - */ - AuthStatus acceptAuthorisationCallback(Channel channel, Map callbackHeaders, Map callbackParams); - - /** - * Obtain the resource that represents an icon for this channel type. - * @param size A text representation of the icon size required. "16", "32", etc. - * @return The resource that represents the requested icon if available. null otherwise. - */ - Resource getIcon(String size); - - /** - * If a channel type is hidden then it doesn't appear in the list returned by {@link ChannelService#getChannelTypes()} - * @param hidden - */ - void setHidden(boolean hidden); - - /** - * If a channel type is hidden then it doesn't appear in the list returned by {@link ChannelService#getChannelTypes()} - * @param hidden - */ - boolean isHidden(); -} diff --git a/src/main/resources/alfresco/application-context-highlevel.xml b/src/main/resources/alfresco/application-context-highlevel.xml index eeec9fc5f9..7eba2d1e2b 100644 --- a/src/main/resources/alfresco/application-context-highlevel.xml +++ b/src/main/resources/alfresco/application-context-highlevel.xml @@ -28,13 +28,6 @@ - - - - - - - @@ -45,4 +38,5 @@ + diff --git a/src/main/resources/alfresco/bootstrap-context.xml b/src/main/resources/alfresco/bootstrap-context.xml index bed203582a..4589c521a1 100644 --- a/src/main/resources/alfresco/bootstrap-context.xml +++ b/src/main/resources/alfresco/bootstrap-context.xml @@ -230,7 +230,6 @@ alfresco/workflow/workflowModel.xml alfresco/workflow/invitation-nominated-workflow-model.xml alfresco/workflow/invitation-moderated-workflow-model.xml - alfresco/workflow/publishingWorkflowModel.xml alfresco/workflow/reset-password-workflow-model.xml diff --git a/src/main/resources/alfresco/bootstrap/publishingRootFolder.xml b/src/main/resources/alfresco/bootstrap/publishingRootFolder.xml deleted file mode 100644 index 3bed60601a..0000000000 --- a/src/main/resources/alfresco/bootstrap/publishingRootFolder.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - workspace - SpacesStore - publishing_root_space - ${spaces.publishing.root.name} - ${spaces.publishing.root.name} - ${spaces.publishing.root.description} - - - diff --git a/src/main/resources/alfresco/bootstrap/site/surf-config.xml b/src/main/resources/alfresco/bootstrap/site/surf-config.xml index 8d04b2ee44..3ffea167c9 100644 --- a/src/main/resources/alfresco/bootstrap/site/surf-config.xml +++ b/src/main/resources/alfresco/bootstrap/site/surf-config.xml @@ -1,6 +1,6 @@ - + diff --git a/src/main/resources/alfresco/content-publishing-context.xml b/src/main/resources/alfresco/content-publishing-context.xml deleted file mode 100644 index 905409c2d5..0000000000 --- a/src/main/resources/alfresco/content-publishing-context.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - activiti - alfresco/workflow/publish-web-content.bpmn20.xml - text/xml - false - - - - - - alfresco/workflow/publishingWorkflowModel.xml - - - - - - - - alfresco.messages.publishing-service - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {http://www.alfresco.org/model/rule/1.0}rules - {http://www.alfresco.org/model/content/1.0}mlDocument - {http://www.alfresco.org/model/forum/1.0}discussable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/core-services-context.xml b/src/main/resources/alfresco/core-services-context.xml index 054362d0f3..add0fea2da 100644 --- a/src/main/resources/alfresco/core-services-context.xml +++ b/src/main/resources/alfresco/core-services-context.xml @@ -708,9 +708,6 @@ alfresco/model/siteModel.xml - - alfresco/model/publishingModel.xml - alfresco/model/smartfolder-model.xml @@ -726,7 +723,6 @@ alfresco/messages/forum-model alfresco/messages/email-server-model alfresco/messages/transfer-model - alfresco/messages/publishing-model alfresco/messages/site-model alfresco/messages/smartfolder-model diff --git a/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml b/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml new file mode 100644 index 0000000000..e89fff0476 --- /dev/null +++ b/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml @@ -0,0 +1,20 @@ + + + + + + + + + + alfresco/model/deprecated/publishingModel.xml + alfresco/model/deprecated/facebookPublishingModel.xml + alfresco/model/deprecated/flickrPublishingModel.xml + alfresco/model/deprecated/linkedInPublishingModel.xml + alfresco/model/deprecated/slidesharePublishingModel.xml + alfresco/model/deprecated/twitterPublishingModel.xml + alfresco/model/deprecated/youtubePublishingModel.xml + + + + \ No newline at end of file diff --git a/src/main/resources/alfresco/facebook-publishing-context.xml b/src/main/resources/alfresco/facebook-publishing-context.xml deleted file mode 100644 index abb5d6aaf2..0000000000 --- a/src/main/resources/alfresco/facebook-publishing-context.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - alfresco/model/facebookPublishingModel.xml - - - - - - - - org.alfresco.repo.publishing.facebook.facebook-publishing - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/flickr-publishing-context.xml b/src/main/resources/alfresco/flickr-publishing-context.xml deleted file mode 100644 index 10dd078202..0000000000 --- a/src/main/resources/alfresco/flickr-publishing-context.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - alfresco/model/flickrPublishingModel.xml - - - - - - - - org.alfresco.repo.publishing.flickr.flickr-publishing - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/import-export-context.xml b/src/main/resources/alfresco/import-export-context.xml index a030948dcc..74a300a141 100644 --- a/src/main/resources/alfresco/import-export-context.xml +++ b/src/main/resources/alfresco/import-export-context.xml @@ -366,7 +366,6 @@ ${spaces.scheduled_actions.childname} ${spaces.rendition.rendering_actions.childname} ${spaces.replication.replication_actions.childname} - ${spaces.publishing.root.childname} ${spaces.nodetemplates.childname} ${spaces.shared.childname} ${system.remote_credentials_container.childname} @@ -674,12 +673,6 @@ alfresco/messages/bootstrap-spaces - - ${publishing.root.path} - alfresco/bootstrap/publishingRootFolder.xml - alfresco/messages/bootstrap-spaces - - /${system.system_container.childname} alfresco/bootstrap/downloadsSpace.xml diff --git a/src/main/resources/alfresco/linkedin-publishing-context.xml b/src/main/resources/alfresco/linkedin-publishing-context.xml deleted file mode 100644 index db1c40bce8..0000000000 --- a/src/main/resources/alfresco/linkedin-publishing-context.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - alfresco/model/linkedInPublishingModel.xml - - - - - - - - org.alfresco.repo.publishing.linkedin.linkedin-publishing - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces.properties b/src/main/resources/alfresco/messages/bootstrap-spaces.properties index 5d4f0efe5b..38e55f5806 100644 --- a/src/main/resources/alfresco/messages/bootstrap-spaces.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=RSS templates spaces.actions.scheduled_actions.name=Scheduled Actions spaces.actions.scheduled_actions.description=Schedule of when persistent actions are executed -spaces.publishing.root.name=Publishing Root -spaces.publishing.root.description=Root folder for the PublishingService. - spaces.remote_credentials.root.name=Remote Credentials spaces.remote_credentials.root.description=Root folder for Shared Remote Credentials diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_de.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_de.properties index a6bec0cbec..53accea69b 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_de.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_de.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=RSS Mustervorlagen spaces.actions.scheduled_actions.name=Geplante Aktionen spaces.actions.scheduled_actions.description=Ablaufplan f\u00fcr st\u00e4ndig auszuf\u00fchrende Aktionen -spaces.publishing.root.name=Ver\u00f6ffentlichung Root -spaces.publishing.root.description=Root-Ordner f\u00fcr Ver\u00f6ffentlichungsdienst. - spaces.remote_credentials.root.name=Remote-Anmeldedaten spaces.remote_credentials.root.description=Root-Ordner f\u00fcr freigegebene Remote-Anmeldedaten diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_es.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_es.properties index 3c74dd5027..d1f24e3c5d 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_es.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_es.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=Plantillas RSS spaces.actions.scheduled_actions.name=Acciones programadas spaces.actions.scheduled_actions.description=Programaci\u00f3n de cu\u00e1ndo se realizan las acciones persistentes -spaces.publishing.root.name=Ra\u00edz de publicaci\u00f3n -spaces.publishing.root.description=Carpeta ra\u00edz para el servicio de publicaci\u00f3n. - spaces.remote_credentials.root.name=Credenciales remotas spaces.remote_credentials.root.description=Carpeta ra\u00edz para las credenciales remotas compartidas diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_fr.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_fr.properties index 577c0109f5..dd9a28033e 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_fr.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_fr.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=Mod\u00e8les RSS spaces.actions.scheduled_actions.name=Actions planifi\u00e9es spaces.actions.scheduled_actions.description=Planning d'ex\u00e9cution des actions persistantes -spaces.publishing.root.name=Racine de publication -spaces.publishing.root.description=Dossier racine associ\u00e9 au service de publication. - spaces.remote_credentials.root.name=Identifiants distants spaces.remote_credentials.root.description=Espace racine pour les identifiants distants partag\u00e9s diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_it.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_it.properties index 27d02ac07e..29cc298a48 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_it.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_it.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=Modelli RSS spaces.actions.scheduled_actions.name=Azioni programmate spaces.actions.scheduled_actions.description=Programma per l'esecuzione di azioni persistenti -spaces.publishing.root.name=Radice di pubblicazione -spaces.publishing.root.description=Cartella radice per PublishingService - spaces.remote_credentials.root.name=Credenziali remote spaces.remote_credentials.root.description=Cartella radice per le credenziali remote condivise diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_ja.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_ja.properties index 90a6e96049..8fa5544104 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_ja.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_ja.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=RSS \u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8 spaces.actions.scheduled_actions.name=\u51e6\u7406\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb spaces.actions.scheduled_actions.description=\u9023\u7d9a\u7684\u306b\u884c\u3046\u51e6\u7406\u306e\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb -spaces.publishing.root.name=\u516c\u958b\u30eb\u30fc\u30c8 -spaces.publishing.root.description=\u516c\u958b\u30b5\u30fc\u30d3\u30b9\u306e\u30eb\u30fc\u30c8\u30d5\u30a9\u30eb\u30c0\u3002 - spaces.remote_credentials.root.name=\u30ea\u30e2\u30fc\u30c8\u8cc7\u683c\u60c5\u5831 spaces.remote_credentials.root.description=\u5171\u6709\u3057\u3066\u3044\u308b\u30ea\u30e2\u30fc\u30c8\u8cc7\u683c\u60c5\u5831\u306e\u30eb\u30fc\u30c8\u30d5\u30a9\u30eb\u30c0 diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_nb.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_nb.properties index 4cf2a47c7a..9ba92f4810 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_nb.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_nb.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=RSS-maler spaces.actions.scheduled_actions.name=Planlagte handlinger spaces.actions.scheduled_actions.description=Tidsplan for n\u00e5r faste handlinger utf\u00f8res -spaces.publishing.root.name=Publiseringsrot -spaces.publishing.root.description=Rotmappe for publiseringstjeneste - spaces.remote_credentials.root.name=Ekstern legitimasjon spaces.remote_credentials.root.description=Rotmappe for delt ekstern legitimasjon diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_nl.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_nl.properties index 82c93e42c5..92ad88f105 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_nl.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_nl.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=RSS-sjablonen spaces.actions.scheduled_actions.name=Geplande acties spaces.actions.scheduled_actions.description=Schema van wanneer persistente acties worden uitgevoerd -spaces.publishing.root.name=Publicatiehoofdmap -spaces.publishing.root.description=Hoofdmap voor de publicatieservice - spaces.remote_credentials.root.name=Externe-verificatiegegevens spaces.remote_credentials.root.description=Hoofdmap voor gedeelde externe-verificatiegegevens diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_pt_BR.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_pt_BR.properties index 747e578bd8..31b6581c58 100644 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_pt_BR.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_pt_BR.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=Modelos de RSS spaces.actions.scheduled_actions.name=A\u00e7\u00f5es programadas spaces.actions.scheduled_actions.description=Programa de quando a\u00e7\u00f5es persistentes s\u00e3o executadas -spaces.publishing.root.name=Raiz de publica\u00e7\u00e3o -spaces.publishing.root.description=Pasta raiz para o PublishingService. - spaces.remote_credentials.root.name=Credenciais remotas spaces.remote_credentials.root.description=Pasta raiz para credenciais remotas compartilhadas diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_ru.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_ru.properties index 22cd98a2a7..e933031cc3 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_ru.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_ru.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=\u0428\u0430\u0431\u043b\u043e\u043d\u044b RSS- spaces.actions.scheduled_actions.name=\u0417\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f spaces.actions.scheduled_actions.description=\u0420\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 -spaces.publishing.root.name=\u041a\u043e\u0440\u0435\u043d\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 -spaces.publishing.root.description=\u041a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u043f\u0430\u043f\u043a\u0430 \u0434\u043b\u044f PublishingService. - spaces.remote_credentials.root.name=\u0423\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 spaces.remote_credentials.root.description=\u041a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u043f\u0430\u043f\u043a\u0430 \u0434\u043b\u044f \u043e\u0431\u0449\u0438\u0445 \u0443\u0447\u0435\u0442\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 diff --git a/src/main/resources/alfresco/messages/bootstrap-spaces_zh_CN.properties b/src/main/resources/alfresco/messages/bootstrap-spaces_zh_CN.properties index 05f0478400..5096d498fd 100755 --- a/src/main/resources/alfresco/messages/bootstrap-spaces_zh_CN.properties +++ b/src/main/resources/alfresco/messages/bootstrap-spaces_zh_CN.properties @@ -52,9 +52,6 @@ spaces.templates.rss.description=RSS \u6a21\u677f spaces.actions.scheduled_actions.name=\u8ba1\u5212\u7684\u64cd\u4f5c spaces.actions.scheduled_actions.description=\u8ba1\u5212\u4f55\u65f6\u6267\u884c\u6301\u4e45\u5316\u64cd\u4f5c -spaces.publishing.root.name=\u53d1\u5e03\u6839 -spaces.publishing.root.description=PublishingService \u7684\u6839\u6587\u4ef6\u5939\u3002 - spaces.remote_credentials.root.name=\u8fdc\u7a0b\u51ed\u636e spaces.remote_credentials.root.description=\u5171\u4eab\u8fdc\u7a0b\u51ed\u636e\u7684\u6839\u6587\u4ef6\u5939 diff --git a/src/main/resources/alfresco/messages/publishing-model.properties b/src/main/resources/alfresco/messages/publishing-model.properties deleted file mode 100644 index 6c04662790..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Publishing Content Model - -pub_publishingmodel.type.pub_DeliveryChannel.title=Delivery Channel -pub_publishingmodel.type.pub_DeliveryChannel.description=The base type for all delivery channels -pub_publishingmodel.type.pub_DeliveryServer.title=Delivery Server -pub_publishingmodel.type.pub_DeliveryServer.description=The base type for all delivery servers -pub_publishingmodel.type.pub_Environment.title=Publishing Environment -pub_publishingmodel.type.pub_Environment.description=A container type that holds a set of delivery channels -pub_publishingmodel.type.pub_PublishingQueue.title=Publishing Queue -pub_publishingmodel.type.pub_PublishingQueue.description=A container type that holds publishing events that are yet to be processed - -pub_publishingmodel.aspect.pub_ContentRoot.title=Content Root Aspect -pub_publishingmodel.aspect.pub_ContentRoot.description=Applied to a node that represents the root of a delivery channel's content hierarchy - -pub_publishingmodel.association.pub_deliveryServers.title=Delivery Servers -pub_publishingmodel.association.pub_deliveryServers.description=The delivery servers associated with a delivery channel -pub_publishingmodel.association.pub_publishingQueue.title=Publishing Queue -pub_publishingmodel.association.pub_publishingQueue.description=The publishing queue for a publishing environment diff --git a/src/main/resources/alfresco/messages/publishing-model_de.properties b/src/main/resources/alfresco/messages/publishing-model_de.properties deleted file mode 100755 index fdd4824ab5..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_de.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Publishing Content Model - -pub_publishingmodel.type.pub_DeliveryChannel.title=Zustellkanal -pub_publishingmodel.type.pub_DeliveryChannel.description=Der Basistyp f\u00fcr alle Zustellkan\u00e4le -pub_publishingmodel.type.pub_DeliveryServer.title=Zustellserver -pub_publishingmodel.type.pub_DeliveryServer.description=Der Basistyp f\u00fcr alle Zustellserver -pub_publishingmodel.type.pub_Environment.title=Ver\u00f6ffentlichungsumgebung -pub_publishingmodel.type.pub_Environment.description=Ein Containertyp, der einen Satz an Zustellkan\u00e4len enth\u00e4lt -pub_publishingmodel.type.pub_PublishingQueue.title=Ver\u00f6ffentlichungswarteschlange -pub_publishingmodel.type.pub_PublishingQueue.description=Ein Containertyp mit Ver\u00f6ffentlichungsereignissen, die noch verarbeitet werden m\u00fcssen - -pub_publishingmodel.aspect.pub_ContentRoot.title=Inhalts-Root-Aspekt -pub_publishingmodel.aspect.pub_ContentRoot.description=Wird auf einen Node angewendet, der das Root der Inhaltshierarchie eines Zustellkanals darstellt - -pub_publishingmodel.association.pub_deliveryServers.title=Zustellserver -pub_publishingmodel.association.pub_deliveryServers.description=Die mit einem Zustellkanal verbundenen Zustellserver -pub_publishingmodel.association.pub_publishingQueue.title=Ver\u00f6ffentlichungswarteschlange -pub_publishingmodel.association.pub_publishingQueue.description=Die Ver\u00f6ffentlichungswarteschlange f\u00fcr eine Ver\u00f6ffentlichungsumgebung diff --git a/src/main/resources/alfresco/messages/publishing-model_es.properties b/src/main/resources/alfresco/messages/publishing-model_es.properties deleted file mode 100755 index a06937ae69..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_es.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Modelo de publicaci\u00f3n de contenidos - -pub_publishingmodel.type.pub_DeliveryChannel.title=Canal de entrega -pub_publishingmodel.type.pub_DeliveryChannel.description=El tipo b\u00e1sico para todos los canales de entrega -pub_publishingmodel.type.pub_DeliveryServer.title=Servicio de entrega -pub_publishingmodel.type.pub_DeliveryServer.description=El tipo b\u00e1sico para todos los servidores de entrega -pub_publishingmodel.type.pub_Environment.title=Entorno de publicaci\u00f3n -pub_publishingmodel.type.pub_Environment.description=Un tipo de contenedor que mantiene un conjunto de canales de entrega -pub_publishingmodel.type.pub_PublishingQueue.title=Cola de publicaci\u00f3n -pub_publishingmodel.type.pub_PublishingQueue.description=Un tipo de contenedor que guarda eventos de publicaci\u00f3n que a\u00fan no se han procesado - -pub_publishingmodel.aspect.pub_ContentRoot.title=Aspecto ra\u00edz de contenido -pub_publishingmodel.aspect.pub_ContentRoot.description=Aplicado a un nodo que representa la ra\u00edz de la jerarqu\u00eda de contenido de un canal de entrega - -pub_publishingmodel.association.pub_deliveryServers.title=Servidores de entrega -pub_publishingmodel.association.pub_deliveryServers.description=Servidores de entrega asociados con un canal de entrega -pub_publishingmodel.association.pub_publishingQueue.title=Cola de publicaci\u00f3n -pub_publishingmodel.association.pub_publishingQueue.description=La cola de publicaci\u00f3n para un entorno de publicaci\u00f3n diff --git a/src/main/resources/alfresco/messages/publishing-model_fr.properties b/src/main/resources/alfresco/messages/publishing-model_fr.properties deleted file mode 100755 index a498c018c0..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_fr.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Mod\u00e8le de contenu de publication - -pub_publishingmodel.type.pub_DeliveryChannel.title=Canal de distribution -pub_publishingmodel.type.pub_DeliveryChannel.description=Type de base pour tous les canaux de distribution -pub_publishingmodel.type.pub_DeliveryServer.title=Serveur de distribution -pub_publishingmodel.type.pub_DeliveryServer.description=Type de base pour tous les serveurs de distribution -pub_publishingmodel.type.pub_Environment.title=Environnement de publication -pub_publishingmodel.type.pub_Environment.description=Type de contenant comprenant un ensemble de canaux de distribution -pub_publishingmodel.type.pub_PublishingQueue.title=File d'attente de publication -pub_publishingmodel.type.pub_PublishingQueue.description=Type de contenant comprenant des \u00e9v\u00e9nements de publication qui n'ont pas encore \u00e9t\u00e9 trait\u00e9s - -pub_publishingmodel.aspect.pub_ContentRoot.title=Aspect racine du contenu -pub_publishingmodel.aspect.pub_ContentRoot.description=S'applique \u00e0 un n\u0153ud qui repr\u00e9sente la racine de la hi\u00e9rarchie de contenu d'un canal de distribution - -pub_publishingmodel.association.pub_deliveryServers.title=Serveurs de distribution -pub_publishingmodel.association.pub_deliveryServers.description=Serveurs de distribution associ\u00e9s \u00e0 un canal de distribution -pub_publishingmodel.association.pub_publishingQueue.title=File d'attente de publication -pub_publishingmodel.association.pub_publishingQueue.description=File d'attente de publication pour un environnement de publication diff --git a/src/main/resources/alfresco/messages/publishing-model_it.properties b/src/main/resources/alfresco/messages/publishing-model_it.properties deleted file mode 100755 index cb28dc2a97..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_it.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Modello di contenuti di pubblicazione - -pub_publishingmodel.type.pub_DeliveryChannel.title=Canale di recapito -pub_publishingmodel.type.pub_DeliveryChannel.description=Il tipo base per tutti i canali di recapito -pub_publishingmodel.type.pub_DeliveryServer.title=Server di recapito -pub_publishingmodel.type.pub_DeliveryServer.description=Il tipo base per tutti i server di recapito -pub_publishingmodel.type.pub_Environment.title=Ambiente di pubblicazione -pub_publishingmodel.type.pub_Environment.description=Un tipo di contenitore che contiene una serie di canali di recapito -pub_publishingmodel.type.pub_PublishingQueue.title=Coda di pubblicazione -pub_publishingmodel.type.pub_PublishingQueue.description=Un tipo di contenitore che contiene eventi di pubblicazione che non sono ancora stati elaborati - -pub_publishingmodel.aspect.pub_ContentRoot.title=Aspetto root di contenuti -pub_publishingmodel.aspect.pub_ContentRoot.description=Applicato a un nodo che rappresenta la root di una gerarchia di contenuti del canale di recapito - -pub_publishingmodel.association.pub_deliveryServers.title=Server di recapito -pub_publishingmodel.association.pub_deliveryServers.description=I server di recapito associati a un canale di recapito -pub_publishingmodel.association.pub_publishingQueue.title=Coda di pubblicazione -pub_publishingmodel.association.pub_publishingQueue.description=La coda di pubblicazione di un ambiente di pubblicazione diff --git a/src/main/resources/alfresco/messages/publishing-model_ja.properties b/src/main/resources/alfresco/messages/publishing-model_ja.properties deleted file mode 100755 index e0dd88def1..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_ja.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Publishing Content Model (\u30b3\u30f3\u30c6\u30f3\u30c4\u516c\u958b\u30e2\u30c7\u30eb) - -pub_publishingmodel.type.pub_DeliveryChannel.title=\u914d\u4fe1\u30c1\u30e3\u30cd\u30eb -pub_publishingmodel.type.pub_DeliveryChannel.description=\u3059\u3079\u3066\u306e\u914d\u4fe1\u30c1\u30e3\u30cd\u30eb\u306e\u57fa\u672c\u30bf\u30a4\u30d7 -pub_publishingmodel.type.pub_DeliveryServer.title=\u914d\u4fe1\u30b5\u30fc\u30d0\u30fc -pub_publishingmodel.type.pub_DeliveryServer.description=\u3059\u3079\u3066\u306e\u914d\u4fe1\u30b5\u30fc\u30d0\u30fc\u306e\u57fa\u672c\u30bf\u30a4\u30d7 -pub_publishingmodel.type.pub_Environment.title=\u516c\u958b\u74b0\u5883 -pub_publishingmodel.type.pub_Environment.description=\u914d\u4fe1\u30c1\u30e3\u30cd\u30eb\u306e\u30bb\u30c3\u30c8\u3092\u4fdd\u6301\u3059\u308b\u30b3\u30f3\u30c6\u30ca\u30bf\u30a4\u30d7 -pub_publishingmodel.type.pub_PublishingQueue.title=\u516c\u958b\u30ad\u30e5\u30fc -pub_publishingmodel.type.pub_PublishingQueue.description=\u672a\u51e6\u7406\u306e\u516c\u958b\u30a4\u30d9\u30f3\u30c8\u3092\u4fdd\u6301\u3059\u308b\u30b3\u30f3\u30c6\u30ca\u30bf\u30a4\u30d7 - -pub_publishingmodel.aspect.pub_ContentRoot.title=\u30b3\u30f3\u30c6\u30f3\u30c4\u30eb\u30fc\u30c8\u306e\u30a2\u30b9\u30da\u30af\u30c8 -pub_publishingmodel.aspect.pub_ContentRoot.description=\u914d\u4fe1\u30c1\u30e3\u30cd\u30eb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u968e\u5c64\u306e\u30eb\u30fc\u30c8\u3092\u8868\u3059\u30ce\u30fc\u30c9\u306b\u9069\u7528\u3055\u308c\u307e\u3057\u305f\u3002 - -pub_publishingmodel.association.pub_deliveryServers.title=\u914d\u4fe1\u30b5\u30fc\u30d0\u30fc -pub_publishingmodel.association.pub_deliveryServers.description=\u914d\u4fe1\u30c1\u30e3\u30cd\u30eb\u306b\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u914d\u4fe1\u30b5\u30fc\u30d0\u30fc -pub_publishingmodel.association.pub_publishingQueue.title=\u516c\u958b\u30ad\u30e5\u30fc -pub_publishingmodel.association.pub_publishingQueue.description=\u516c\u958b\u74b0\u5883\u306e\u516c\u958b\u30ad\u30e5\u30fc diff --git a/src/main/resources/alfresco/messages/publishing-model_nb.properties b/src/main/resources/alfresco/messages/publishing-model_nb.properties deleted file mode 100755 index 1f2ea9daea..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_nb.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Modell for publiseringsinnhold - -pub_publishingmodel.type.pub_DeliveryChannel.title=Leveringskanal -pub_publishingmodel.type.pub_DeliveryChannel.description=Basistypen for alle leveringskanaler -pub_publishingmodel.type.pub_DeliveryServer.title=Leveringsserver -pub_publishingmodel.type.pub_DeliveryServer.description=Basistypen for alle leveringsservere -pub_publishingmodel.type.pub_Environment.title=Publiseringsmilj\u00f8 -pub_publishingmodel.type.pub_Environment.description=En beholdertype som inneholder et sett med leveringskanaler -pub_publishingmodel.type.pub_PublishingQueue.title=Publiseringsk\u00f8 -pub_publishingmodel.type.pub_PublishingQueue.description=En beholdertype som inneholder publiseringshendelser som ikke er behandlet enn\u00e5 - -pub_publishingmodel.aspect.pub_ContentRoot.title=Rotaspekt for innhold -pub_publishingmodel.aspect.pub_ContentRoot.description=Brukes p\u00e5 en node som representerer roten av en leveringskanals innholdshierarki - -pub_publishingmodel.association.pub_deliveryServers.title=Leveringsservere -pub_publishingmodel.association.pub_deliveryServers.description=Leveringsserverne som er tilknyttet en leveringskanal -pub_publishingmodel.association.pub_publishingQueue.title=Publiseringsk\u00f8 -pub_publishingmodel.association.pub_publishingQueue.description=Publiseringsk\u00f8en for et publiseringsmilj\u00f8 diff --git a/src/main/resources/alfresco/messages/publishing-model_nl.properties b/src/main/resources/alfresco/messages/publishing-model_nl.properties deleted file mode 100755 index cf204155e0..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_nl.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Publicatiecontentmodel - -pub_publishingmodel.type.pub_DeliveryChannel.title=Leveringskanaal -pub_publishingmodel.type.pub_DeliveryChannel.description=Het basistype voor alle leveringskanalen -pub_publishingmodel.type.pub_DeliveryServer.title=Leveringsserver -pub_publishingmodel.type.pub_DeliveryServer.description=Het basistype voor alle leveringsservers -pub_publishingmodel.type.pub_Environment.title=Publicatieomgeving -pub_publishingmodel.type.pub_Environment.description=Een containertype dat een reeks leveringskanalen bevat -pub_publishingmodel.type.pub_PublishingQueue.title=Publicatiewachtrij -pub_publishingmodel.type.pub_PublishingQueue.description=Een containertype dat publicatiegebeurtenissen bevat die nog moeten worden verwerkt - -pub_publishingmodel.aspect.pub_ContentRoot.title=Aspect voor contenthoofdaspect -pub_publishingmodel.aspect.pub_ContentRoot.description=Wordt toegepast op een node die de hoofdmap vormt van de contenthi\u00ebrarchie van een leveringskanaal - -pub_publishingmodel.association.pub_deliveryServers.title=Leveringsservers -pub_publishingmodel.association.pub_deliveryServers.description=De leveringsservers die zijn gekoppeld aan een leveringskanaal -pub_publishingmodel.association.pub_publishingQueue.title=Publicatiewachtrij -pub_publishingmodel.association.pub_publishingQueue.description=De publicatiewachtrij voor een publicatieomgeving diff --git a/src/main/resources/alfresco/messages/publishing-model_pt_BR.properties b/src/main/resources/alfresco/messages/publishing-model_pt_BR.properties deleted file mode 100644 index 0d3569f102..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_pt_BR.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=Modelo de conte\u00fado de publica\u00e7\u00e3o - -pub_publishingmodel.type.pub_DeliveryChannel.title=Canal de distribui\u00e7\u00e3o -pub_publishingmodel.type.pub_DeliveryChannel.description=O tipo de base para todos os canais de distribui\u00e7\u00e3o -pub_publishingmodel.type.pub_DeliveryServer.title=Servidor de distribui\u00e7\u00e3o -pub_publishingmodel.type.pub_DeliveryServer.description=O tipo de base para todos os servidores de distribui\u00e7\u00e3o -pub_publishingmodel.type.pub_Environment.title=Ambiente de publica\u00e7\u00e3o -pub_publishingmodel.type.pub_Environment.description=Um tipo de cont\u00eainer que cont\u00e9m um conjunto de canais de distribui\u00e7\u00e3o -pub_publishingmodel.type.pub_PublishingQueue.title=Fila de publica\u00e7\u00e3o -pub_publishingmodel.type.pub_PublishingQueue.description=Um tipo de cont\u00eainer que cont\u00e9m eventos de publica\u00e7\u00e3o que ainda ser\u00e3o processados. - -pub_publishingmodel.aspect.pub_ContentRoot.title=Aspecto raiz do conte\u00fado -pub_publishingmodel.aspect.pub_ContentRoot.description=Aplicado a um n\u00f3 que representa a raiz da hierarquia de conte\u00fado de um canal de distribui\u00e7\u00e3o - -pub_publishingmodel.association.pub_deliveryServers.title=Servidores de distribui\u00e7\u00e3o -pub_publishingmodel.association.pub_deliveryServers.description=Os servidores de distribui\u00e7\u00e3o associados a um canal de distribui\u00e7\u00e3o -pub_publishingmodel.association.pub_publishingQueue.title=Fila de publica\u00e7\u00e3o -pub_publishingmodel.association.pub_publishingQueue.description=A fila de publica\u00e7\u00e3o de um ambiente de publica\u00e7\u00e3o diff --git a/src/main/resources/alfresco/messages/publishing-model_ru.properties b/src/main/resources/alfresco/messages/publishing-model_ru.properties deleted file mode 100755 index 569e748f5f..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_ru.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=\u041c\u043e\u0434\u0435\u043b\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 - -pub_publishingmodel.type.pub_DeliveryChannel.title=\u041a\u0430\u043d\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.type.pub_DeliveryChannel.description=\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.type.pub_DeliveryServer.title=\u0421\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.type.pub_DeliveryServer.description=\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.type.pub_Environment.title=\u0421\u0440\u0435\u0434\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 -pub_publishingmodel.type.pub_Environment.description=\u0422\u0438\u043f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.type.pub_PublishingQueue.title=\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 -pub_publishingmodel.type.pub_PublishingQueue.description=\u0422\u0438\u043f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043b\u0435\u0436\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 - -pub_publishingmodel.aspect.pub_ContentRoot.title=\u0410\u0441\u043f\u0435\u043a\u0442 \u043a\u043e\u0440\u043d\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 -pub_publishingmodel.aspect.pub_ContentRoot.description=\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0440\u0435\u043d\u044c \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043a\u0430\u043d\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 - -pub_publishingmodel.association.pub_deliveryServers.title=\u0421\u0435\u0440\u0432\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.association.pub_deliveryServers.description=\u0421\u0435\u0440\u0432\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u0430\u043d\u0430\u043b\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 -pub_publishingmodel.association.pub_publishingQueue.title=\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 -pub_publishingmodel.association.pub_publishingQueue.description=\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0440\u0435\u0434\u044b \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 diff --git a/src/main/resources/alfresco/messages/publishing-model_zh_CN.properties b/src/main/resources/alfresco/messages/publishing-model_zh_CN.properties deleted file mode 100755 index d2ad1e38df..0000000000 --- a/src/main/resources/alfresco/messages/publishing-model_zh_CN.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Display labels for Publishing Model (publishingModel.xml) - -pub_publishingmodel.description=\u53d1\u5e03\u5185\u5bb9\u6a21\u578b - -pub_publishingmodel.type.pub_DeliveryChannel.title=\u4ea4\u4ed8\u6e20\u9053 -pub_publishingmodel.type.pub_DeliveryChannel.description=\u6240\u6709\u4ea4\u4ed8\u6e20\u9053\u7684\u57fa\u7c7b -pub_publishingmodel.type.pub_DeliveryServer.title=\u4ea4\u4ed8\u670d\u52a1\u5668 -pub_publishingmodel.type.pub_DeliveryServer.description=\u6240\u6709\u4ea4\u4ed8\u670d\u52a1\u5668\u7684\u57fa\u7c7b -pub_publishingmodel.type.pub_Environment.title=\u53d1\u5e03\u73af\u5883 -pub_publishingmodel.type.pub_Environment.description=\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u4ea4\u4ed8\u6e20\u9053\u96c6\u7684\u5bb9\u5668\u7c7b\u578b -pub_publishingmodel.type.pub_PublishingQueue.title=\u53d1\u5e03\u961f\u5217 -pub_publishingmodel.type.pub_PublishingQueue.description=\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u5c1a\u672a\u5904\u7406\u7684\u53d1\u5e03\u4e8b\u4ef6\u7684\u5bb9\u5668\u7c7b\u578b - -pub_publishingmodel.aspect.pub_ContentRoot.title=\u5185\u5bb9\u6839\u5207\u9762 -pub_publishingmodel.aspect.pub_ContentRoot.description=\u6240\u5e94\u7528\u7684\u8282\u70b9\u8868\u793a\u4ea4\u4ed8\u6e20\u9053\u5185\u5bb9\u5c42\u6b21\u7ed3\u6784\u7684\u6839 - -pub_publishingmodel.association.pub_deliveryServers.title=\u4ea4\u4ed8\u670d\u52a1\u5668 -pub_publishingmodel.association.pub_deliveryServers.description=\u4e0e\u4ea4\u4ed8\u6e20\u9053\u5173\u8054\u7684\u4ea4\u4ed8\u670d\u52a1\u5668 -pub_publishingmodel.association.pub_publishingQueue.title=\u53d1\u5e03\u961f\u5217 -pub_publishingmodel.association.pub_publishingQueue.description=\u53d1\u5e03\u73af\u5883\u7684\u53d1\u5e03\u961f\u5217 diff --git a/src/main/resources/alfresco/messages/publishing-service.properties b/src/main/resources/alfresco/messages/publishing-service.properties deleted file mode 100644 index 3811c42299..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=Unable to find specified publishing channel: {0} -publishing.neitherNameNorIdSpecified=Neither channel name nor identifier has been specified - -publish-content.title=Publish -publish-content.description=Publish content to a publishing channel -publish-content.publishChannelName.display-label=Channel to publish content to -publish-content.publishChannelId.display-label=Channel to publish content to -publish-content.unpublish.display-label=Unpublish -publish-content.statusUpdate.display-label=Status update -publish-content.includeLinkInStatusUpdate.display-label=Append link to status update -publish-content.statusUpdateChannelNames.display-label=Channels to post status update to -publish-content.statusUpdateChannelIds.display-label=Channels to post status update to -publish-content.scheduledTime.display-label=Scheduled time -publish-content.comment.display-label=Comment -publish-content.nodeToLinkStatusUpdateTo.display-label=Node to link status update to diff --git a/src/main/resources/alfresco/messages/publishing-service_de.properties b/src/main/resources/alfresco/messages/publishing-service_de.properties deleted file mode 100755 index 401b14c007..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_de.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=Der angegebene Ver\u00f6ffentlichungskanal wurde nicht gefunden: {0} -publishing.neitherNameNorIdSpecified=Weder eine Kanalname noch ein Kanalbezeichner wurden angegeben - -publish-content.title=Ver\u00f6ffentlichen -publish-content.description=Ver\u00f6ffentlichen von Content duch einen Ver\u00f6ffentlichungskanal -publish-content.publishChannelName.display-label=Kanal, der zur Ver\u00f6ffentlichung genutzt werden soll -publish-content.publishChannelId.display-label=Kanal, der zur Ver\u00f6ffentlichung genutzt werden soll -publish-content.unpublish.display-label=Ver\u00f6ffentlichung zur\u00fccknehmen -publish-content.statusUpdate.display-label=Statusaktualisierung -publish-content.includeLinkInStatusUpdate.display-label=Link an Statusaktualisierung anh\u00e4ngen -publish-content.statusUpdateChannelNames.display-label=Kanal, an den Statusaktualisierungen gesendet werden sollen -publish-content.statusUpdateChannelIds.display-label=Kanal, an den Statusaktualisierungen gesendet werden sollen -publish-content.scheduledTime.display-label=Geplante Zeit -publish-content.comment.display-label=Kommentar -publish-content.nodeToLinkStatusUpdateTo.display-label=Node, mit dem Statusaktualisierungen verkn\u00fcpft werden sollen diff --git a/src/main/resources/alfresco/messages/publishing-service_es.properties b/src/main/resources/alfresco/messages/publishing-service_es.properties deleted file mode 100755 index 73d0526e58..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_es.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=No se puede encontrar el canal de publicaci\u00f3n especificado: {0} -publishing.neitherNameNorIdSpecified=No se ha especificado el nombre del canal ni su identificador - -publish-content.title=Publicar -publish-content.description=Publicar contenido en un canal de publicaci\u00f3n -publish-content.publishChannelName.display-label=Canal para publicar contenido -publish-content.publishChannelId.display-label=Canal para publicar contenido -publish-content.unpublish.display-label=No publicar -publish-content.statusUpdate.display-label=Actualizaci\u00f3n de estado -publish-content.includeLinkInStatusUpdate.display-label=A\u00f1adir enlace a la actualizaci\u00f3n de estado -publish-content.statusUpdateChannelNames.display-label=Canales a enviar la actualizaci\u00f3n de estado -publish-content.statusUpdateChannelIds.display-label=Canales a enviar la actualizaci\u00f3n de estado -publish-content.scheduledTime.display-label=Hora programada -publish-content.comment.display-label=Comentario -publish-content.nodeToLinkStatusUpdateTo.display-label=Nodo a enlazar la actualizaci\u00f3n de estado diff --git a/src/main/resources/alfresco/messages/publishing-service_fr.properties b/src/main/resources/alfresco/messages/publishing-service_fr.properties deleted file mode 100755 index 3f9ce0105f..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_fr.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=Le canal de publication sp\u00e9cifi\u00e9 est introuvable : {0} -publishing.neitherNameNorIdSpecified=Ni le nom du canal ni l'identifiant n'ont \u00e9t\u00e9 sp\u00e9cifi\u00e9 - -publish-content.title=Publier -publish-content.description=Publier le contenu sur un canal de publication -publish-content.publishChannelName.display-label=Canal pour publier le contenu sur -publish-content.publishChannelId.display-label=Canal pour publier le contenu sur -publish-content.unpublish.display-label=Supprimer de la publication -publish-content.statusUpdate.display-label=Mise \u00e0 jour du statut -publish-content.includeLinkInStatusUpdate.display-label=Ajouter un lien vers la mise \u00e0 jour du statut -publish-content.statusUpdateChannelNames.display-label=Canaux pour envoyer la mise \u00e0 jour du statut vers -publish-content.statusUpdateChannelIds.display-label=Canaux pour envoyer la mise \u00e0 jour du statut vers -publish-content.scheduledTime.display-label=Heure pr\u00e9vue -publish-content.comment.display-label=Commenter -publish-content.nodeToLinkStatusUpdateTo.display-label=Noeud pour lier la mise \u00e0 jour du statut vers diff --git a/src/main/resources/alfresco/messages/publishing-service_it.properties b/src/main/resources/alfresco/messages/publishing-service_it.properties deleted file mode 100755 index 97ac36199a..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_it.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=Impossibile trovare il canale di pubblicazione specificato: {0} -publishing.neitherNameNorIdSpecified=Non \u00e8 stato specificato n\u00e8 il nome del canale n\u00e8 il suo identificatore - -publish-content.title=Pubblica -publish-content.description=Pubblica il contenuto in un canale di pubblicazione -publish-content.publishChannelName.display-label=Canale per pubblicare un contenuto -publish-content.publishChannelId.display-label=Canale per pubblicare un contenuto -publish-content.unpublish.display-label=Non pubblicare -publish-content.statusUpdate.display-label=Aggiornamento di stato -publish-content.includeLinkInStatusUpdate.display-label=Aggiungi il link all'aggiornamento dello stato -publish-content.statusUpdateChannelNames.display-label=Canali per inviare l'aggiornamento dello stato -publish-content.statusUpdateChannelIds.display-label=Canali per inviare l'aggiornamento dello stato -publish-content.scheduledTime.display-label=Ora programmata -publish-content.comment.display-label=Commento -publish-content.nodeToLinkStatusUpdateTo.display-label=Nodo per collegare l'attualizzazione di stato diff --git a/src/main/resources/alfresco/messages/publishing-service_ja.properties b/src/main/resources/alfresco/messages/publishing-service_ja.properties deleted file mode 100755 index 38d0806e53..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_ja.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=\u6307\u5b9a\u3057\u305f\u516c\u958b\u30c1\u30e3\u30cd\u30eb\u306f\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f: {0} -publishing.neitherNameNorIdSpecified=\u30c1\u30e3\u30cd\u30eb\u540d\u3001\u307e\u305f\u306f\u8b58\u5225\u5b50\u304c\u6307\u5b9a\u3055\u308c\u307e\u3057\u305f\u3002 - -publish-content.title=\u516c\u958b -publish-content.description=\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u516c\u958b\u30c1\u30e3\u30cd\u30eb\u3078\u516c\u958b\u3057\u307e\u3059\u3002 -publish-content.publishChannelName.display-label=\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u516c\u958b\u5148\u3092\u30c1\u30e3\u30cd\u30eb\u3057\u307e\u3059\u3002 -publish-content.publishChannelId.display-label=\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u516c\u958b\u5148\u3092\u30c1\u30e3\u30cd\u30eb\u3057\u307e\u3059\u3002 -publish-content.unpublish.display-label=\u975e\u516c\u958b -publish-content.statusUpdate.display-label=\u30b9\u30c6\u30fc\u30bf\u30b9\u66f4\u65b0 -publish-content.includeLinkInStatusUpdate.display-label=\u30b9\u30c6\u30fc\u30bf\u30b9\u66f4\u65b0\u3078\u30ea\u30f3\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 -publish-content.statusUpdateChannelNames.display-label=\u30b9\u30c6\u30fc\u30bf\u30b9\u66f4\u65b0\u306e\u6295\u7a3f\u5148\u3092\u30c1\u30e3\u30cd\u30eb\u3057\u307e\u3059\u3002 -publish-content.statusUpdateChannelIds.display-label=\u30b9\u30c6\u30fc\u30bf\u30b9\u66f4\u65b0\u306e\u6295\u7a3f\u5148\u3092\u30c1\u30e3\u30cd\u30eb\u3057\u307e\u3059\u3002 -publish-content.scheduledTime.display-label=\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u3057\u305f\u6642\u9593 -publish-content.comment.display-label=\u30b3\u30e1\u30f3\u30c8 -publish-content.nodeToLinkStatusUpdateTo.display-label=\u30b9\u30c6\u30fc\u30bf\u30b9\u306e\u66f4\u65b0\u3092\u30ea\u30f3\u30af\u3059\u308b\u30ce\u30fc\u30c9 diff --git a/src/main/resources/alfresco/messages/publishing-service_nb.properties b/src/main/resources/alfresco/messages/publishing-service_nb.properties deleted file mode 100755 index 2c1122fa07..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_nb.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=Finner ikke angitt publiseringskanal: {0} -publishing.neitherNameNorIdSpecified=Verken kanalnavn eller identifikator er angitt - -publish-content.title=Publiser -publish-content.description=Publiser innhold til en publiseringskanal -publish-content.publishChannelName.display-label=Kanal som innhold skal publiseres til -publish-content.publishChannelId.display-label=Kanal som innhold skal publiseres til -publish-content.unpublish.display-label=Stopp publisering -publish-content.statusUpdate.display-label=Statusoppdatering -publish-content.includeLinkInStatusUpdate.display-label=Legg ved kobling til statusoppdatering -publish-content.statusUpdateChannelNames.display-label=Kanaler som statusoppdatering skal legges inn i -publish-content.statusUpdateChannelIds.display-label=Kanaler som statusoppdatering skal legges inn i -publish-content.scheduledTime.display-label=Planlagt tid -publish-content.comment.display-label=Kommentar -publish-content.nodeToLinkStatusUpdateTo.display-label=Node statusoppdatering skal kobles til diff --git a/src/main/resources/alfresco/messages/publishing-service_nl.properties b/src/main/resources/alfresco/messages/publishing-service_nl.properties deleted file mode 100755 index b163ed83bc..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_nl.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=Kan opgegeven publicatiekanaal niet vinden: {0} -publishing.neitherNameNorIdSpecified=De kanaalnaam en de id zijn niet opgegeven - -publish-content.title=Publiceren -publish-content.description=Content publiceren naar een publicatiekanaal -publish-content.publishChannelName.display-label=Kanaal om content naartoe te publiceren -publish-content.publishChannelId.display-label=Kanaal om content naartoe te publiceren -publish-content.unpublish.display-label=Publicatie ongedaan maken -publish-content.statusUpdate.display-label=Statusupdate -publish-content.includeLinkInStatusUpdate.display-label=Koppeling aan statusupdate toevoegen -publish-content.statusUpdateChannelNames.display-label=Kanalen om statusupdate naartoe te posten -publish-content.statusUpdateChannelIds.display-label=Kanalen om statusupdate naartoe te posten -publish-content.scheduledTime.display-label=Geplande tijd -publish-content.comment.display-label=Opmerking -publish-content.nodeToLinkStatusUpdateTo.display-label=Node om statusdate aan te koppelen diff --git a/src/main/resources/alfresco/messages/publishing-service_pt_BR.properties b/src/main/resources/alfresco/messages/publishing-service_pt_BR.properties deleted file mode 100644 index 084bca407d..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_pt_BR.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=N\u00e3o \u00e9 poss\u00edvel localizar o canal de publica\u00e7\u00e3o especificado: {0} -publishing.neitherNameNorIdSpecified=N\u00e3o foi especificado nem o nome do canal, nem o identificador - -publish-content.title=Publicar -publish-content.description=Publicar conte\u00fado em um canal de publica\u00e7\u00e3o -publish-content.publishChannelName.display-label=Canal no qual publicar conte\u00fado -publish-content.publishChannelId.display-label=Canal no qual publicar conte\u00fado -publish-content.unpublish.display-label=Cancelar a publica\u00e7\u00e3o -publish-content.statusUpdate.display-label=Atualiza\u00e7\u00e3o de status -publish-content.includeLinkInStatusUpdate.display-label=Anexar link \u00e0 atualiza\u00e7\u00e3o de status -publish-content.statusUpdateChannelNames.display-label=Canais nos quais postar a atualiza\u00e7\u00e3o de status -publish-content.statusUpdateChannelIds.display-label=Canais nos quais postar a atualiza\u00e7\u00e3o de status -publish-content.scheduledTime.display-label=Hora programada -publish-content.comment.display-label=Coment\u00e1rio -publish-content.nodeToLinkStatusUpdateTo.display-label=N\u00f3 para o qual vincular a atualiza\u00e7\u00e3o de status diff --git a/src/main/resources/alfresco/messages/publishing-service_ru.properties b/src/main/resources/alfresco/messages/publishing-service_ru.properties deleted file mode 100755 index dc7c46a061..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_ru.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=\u041d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438: {0} -publishing.neitherNameNorIdSpecified=\u041d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0438 \u0438\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430, \u043d\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 - -publish-content.title=\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c -publish-content.description=\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u043a\u0430\u043d\u0430\u043b\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 -publish-content.publishChannelName.display-label=\u041a\u0430\u043d\u0430\u043b \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 -publish-content.publishChannelId.display-label=\u041a\u0430\u043d\u0430\u043b \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 -publish-content.unpublish.display-label=\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e -publish-content.statusUpdate.display-label=\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 -publish-content.includeLinkInStatusUpdate.display-label=\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 -publish-content.statusUpdateChannelNames.display-label=\u041a\u0430\u043d\u0430\u043b\u044b \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 -publish-content.statusUpdateChannelIds.display-label=\u041a\u0430\u043d\u0430\u043b\u044b \u0434\u043b\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 -publish-content.scheduledTime.display-label=\u0417\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f -publish-content.comment.display-label=\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c -publish-content.nodeToLinkStatusUpdateTo.display-label=\u041e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 diff --git a/src/main/resources/alfresco/messages/publishing-service_zh_CN.properties b/src/main/resources/alfresco/messages/publishing-service_zh_CN.properties deleted file mode 100755 index 6207397ce0..0000000000 --- a/src/main/resources/alfresco/messages/publishing-service_zh_CN.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Publish service externalised display strings -publishing.channelNotFound=\u65e0\u6cd5\u627e\u5230\u6307\u5b9a\u7684\u53d1\u5e03\u6e20\u9053\uff1a{0} -publishing.neitherNameNorIdSpecified=\u6e20\u9053\u540d\u79f0\u548c\u6807\u8bc6\u7b26\u5747\u672a\u6307\u5b9a - -publish-content.title=\u53d1\u5e03 -publish-content.description=\u5c06\u5185\u5bb9\u53d1\u5e03\u5230\u53d1\u5e03\u6e20\u9053 -publish-content.publishChannelName.display-label=\u8981\u5c06\u5185\u5bb9\u53d1\u5e03\u5230\u7684\u6e20\u9053 -publish-content.publishChannelId.display-label=\u8981\u5c06\u5185\u5bb9\u53d1\u5e03\u5230\u7684\u6e20\u9053 -publish-content.unpublish.display-label=\u53d6\u6d88\u53d1\u5e03 -publish-content.statusUpdate.display-label=\u72b6\u6001\u66f4\u65b0 -publish-content.includeLinkInStatusUpdate.display-label=\u9644\u52a0\u72b6\u6001\u66f4\u65b0\u7684\u94fe\u63a5 -publish-content.statusUpdateChannelNames.display-label=\u8981\u5c06\u72b6\u6001\u66f4\u65b0\u53d1\u5e03\u5230\u7684\u6e20\u9053 -publish-content.statusUpdateChannelIds.display-label=\u8981\u5c06\u72b6\u6001\u66f4\u65b0\u53d1\u5e03\u5230\u7684\u6e20\u9053 -publish-content.scheduledTime.display-label=\u8ba1\u5212\u65f6\u95f4 -publish-content.comment.display-label=\u8bc4\u8bba -publish-content.nodeToLinkStatusUpdateTo.display-label=\u8981\u5c06\u72b6\u6001\u66f4\u65b0\u94fe\u63a5\u5230\u7684\u8282\u70b9 diff --git a/src/main/resources/alfresco/model/facebookPublishingModel.xml b/src/main/resources/alfresco/model/deprecated/facebookPublishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/facebookPublishingModel.xml rename to src/main/resources/alfresco/model/deprecated/facebookPublishingModel.xml diff --git a/src/main/resources/alfresco/model/flickrPublishingModel.xml b/src/main/resources/alfresco/model/deprecated/flickrPublishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/flickrPublishingModel.xml rename to src/main/resources/alfresco/model/deprecated/flickrPublishingModel.xml diff --git a/src/main/resources/alfresco/model/linkedInPublishingModel.xml b/src/main/resources/alfresco/model/deprecated/linkedInPublishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/linkedInPublishingModel.xml rename to src/main/resources/alfresco/model/deprecated/linkedInPublishingModel.xml diff --git a/src/main/resources/alfresco/model/publishingModel.xml b/src/main/resources/alfresco/model/deprecated/publishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/publishingModel.xml rename to src/main/resources/alfresco/model/deprecated/publishingModel.xml diff --git a/src/main/resources/alfresco/model/slidesharePublishingModel.xml b/src/main/resources/alfresco/model/deprecated/slidesharePublishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/slidesharePublishingModel.xml rename to src/main/resources/alfresco/model/deprecated/slidesharePublishingModel.xml diff --git a/src/main/resources/alfresco/model/twitterPublishingModel.xml b/src/main/resources/alfresco/model/deprecated/twitterPublishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/twitterPublishingModel.xml rename to src/main/resources/alfresco/model/deprecated/twitterPublishingModel.xml diff --git a/src/main/resources/alfresco/model/youtubePublishingModel.xml b/src/main/resources/alfresco/model/deprecated/youtubePublishingModel.xml similarity index 100% rename from src/main/resources/alfresco/model/youtubePublishingModel.xml rename to src/main/resources/alfresco/model/deprecated/youtubePublishingModel.xml diff --git a/src/main/resources/alfresco/publishing-context-highlevel.xml b/src/main/resources/alfresco/publishing-context-highlevel.xml deleted file mode 100644 index 035e5135bc..0000000000 --- a/src/main/resources/alfresco/publishing-context-highlevel.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - - - - - - - org.alfresco.service.cmr.publishing.PublishingService - - - - - - - - - - - - - - - - - - - - - - - - ${server.transaction.mode.readOnly} - ${server.transaction.mode.default} - - - - - - - org.alfresco.service.cmr.publishing.channels.ChannelService - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/repository.properties b/src/main/resources/alfresco/repository.properties index 4f69ab54cf..0a1d3c2ccc 100644 --- a/src/main/resources/alfresco/repository.properties +++ b/src/main/resources/alfresco/repository.properties @@ -477,7 +477,6 @@ spaces.webscripts.childname=cm:webscripts spaces.extension_webscripts.childname=cm:extensionwebscripts spaces.models.childname=app:models spaces.workflow.definitions.childname=app:workflow_defs -spaces.publishing.root.childname=app:publishing_root spaces.templates.email.workflowemailnotification.childname=cm:workflownotification spaces.nodetemplates.childname=app:node_templates spaces.shared.childname=app:shared @@ -923,12 +922,6 @@ solr6.store.mappings.value.solrMappingHistory.baseUrl=/solr/history solr6.store.mappings.value.solrMappingHistory.protocol=workspace solr6.store.mappings.value.solrMappingHistory.identifier=history -# -# Web Publishing Properties -# -publishing.root.path=/app:company_home/app:dictionary -publishing.root=${publishing.root.path}/${spaces.publishing.root.childname} - # # URL Shortening Properties # diff --git a/src/main/resources/alfresco/slideshare-publishing-context.xml b/src/main/resources/alfresco/slideshare-publishing-context.xml deleted file mode 100644 index f7c90fb762..0000000000 --- a/src/main/resources/alfresco/slideshare-publishing-context.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - alfresco/model/slidesharePublishingModel.xml - - - - - - - - org.alfresco.repo.publishing.slideshare.slideshare-publishing - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/twitter-publishing-context.xml b/src/main/resources/alfresco/twitter-publishing-context.xml deleted file mode 100644 index 5d40a0a602..0000000000 --- a/src/main/resources/alfresco/twitter-publishing-context.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - alfresco/model/twitterPublishingModel.xml - - - - - - - - org.alfresco.repo.publishing.twitter.twitter-publishing - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/workflow/publish-web-content.bpmn20.xml b/src/main/resources/alfresco/workflow/publish-web-content.bpmn20.xml deleted file mode 100644 index c293b96c17..0000000000 --- a/src/main/resources/alfresco/workflow/publish-web-content.bpmn20.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - // Check if the publish should be scheduled or performed immediatly - if (typeof pubwf_scheduledPublishDate != 'undefined' && pubwf_scheduledPublishDate != null) { - execution.setVariable("schedule", true); - } else { - execution.setVariable("schedule", false); - } - - - - - - - - - - - - - - - - ${schedule} - - - - - - - - - var publishEventAction = actions.create("pub_publishEvent"); - publishEventAction.executeAsynchronously(pubwf_publishingEvent); - - - - - - - - - - ${iso8601PublishDate} - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/alfresco/workflow/publishingWorkflowModel.xml b/src/main/resources/alfresco/workflow/publishingWorkflowModel.xml deleted file mode 100644 index 1347b54f88..0000000000 --- a/src/main/resources/alfresco/workflow/publishingWorkflowModel.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - bpm:startTask - - - d:noderef - true - - - d:any - - - - - - \ No newline at end of file diff --git a/src/main/resources/alfresco/workflow/workflow-messages.properties b/src/main/resources/alfresco/workflow/workflow-messages.properties index bb4aae4726..514c1de136 100644 --- a/src/main/resources/alfresco/workflow/workflow-messages.properties +++ b/src/main/resources/alfresco/workflow/workflow-messages.properties @@ -46,13 +46,6 @@ activitiParallelGroupReview.workflow.description=Assign a review task to a group activitiParallelGroupReview.task.approved.description=The document was reviewed and approved. activitiParallelGroupReview.task.rejected.description=The document was reviewed and rejected. -# -# Activiti Publish Web Content Workflow -# - -publishWebContent.workflow.title=Publish Web Content Activiti Process -publishWebContent.workflow.description=Publishing of web content using Activiti workflow engine - ############################ # WORKFLOW MODEL LABELS # ############################ diff --git a/src/main/resources/alfresco/youtube-publishing-context.xml b/src/main/resources/alfresco/youtube-publishing-context.xml deleted file mode 100644 index 68122bccc6..0000000000 --- a/src/main/resources/alfresco/youtube-publishing-context.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - alfresco/model/youtubePublishingModel.xml - - - - - - - - org.alfresco.repo.publishing.youtube.youtube-publishing - - - - - - - - - - - - - - - diff --git a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType16.png b/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType16.png deleted file mode 100644 index 8f016ed9eb..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType16.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType20.png b/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType20.png deleted file mode 100644 index d909413f9e..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType20.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType32.png b/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType32.png deleted file mode 100644 index a06222c1d6..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType32.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType64.png b/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType64.png deleted file mode 100644 index 322fa4c678..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/facebook/FacebookChannelType64.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/facebook/facebook-publishing.properties b/src/main/resources/org/alfresco/repo/publishing/facebook/facebook-publishing.properties deleted file mode 100644 index 2170416867..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/facebook/facebook-publishing.properties +++ /dev/null @@ -1 +0,0 @@ -publishing.channel-type.facebook.title=Facebook \ No newline at end of file diff --git a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType16.png b/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType16.png deleted file mode 100644 index 840c6afb8f..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType16.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType20.png b/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType20.png deleted file mode 100644 index dfba7509d1..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType20.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType32.png b/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType32.png deleted file mode 100644 index 73ec84bca5..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType32.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType64.png b/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType64.png deleted file mode 100644 index df1c54a7c4..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/flickr/FlickrChannelType64.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/flickr/flickr-publishing.properties b/src/main/resources/org/alfresco/repo/publishing/flickr/flickr-publishing.properties deleted file mode 100644 index efc55ed550..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/flickr/flickr-publishing.properties +++ /dev/null @@ -1 +0,0 @@ -publishing.channel-type.flickr.title=Flickr \ No newline at end of file diff --git a/src/main/resources/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/jaxb.index b/src/main/resources/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/jaxb.index deleted file mode 100644 index ee6e5c5f28..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/flickr/springsocial/api/impl/xml/jaxb.index +++ /dev/null @@ -1,4 +0,0 @@ -FlickrResponse -Photo -PhotoId -FlickrError diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType16.png b/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType16.png deleted file mode 100644 index 97c15ed5de..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType16.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType20.png b/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType20.png deleted file mode 100644 index 55ddc58c7e..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType20.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType32.png b/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType32.png deleted file mode 100644 index 37157a0216..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType32.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType64.png b/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType64.png deleted file mode 100644 index 3cc8d004c0..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/linkedin/LinkedInChannelType64.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/linkedin-publishing.properties b/src/main/resources/org/alfresco/repo/publishing/linkedin/linkedin-publishing.properties deleted file mode 100644 index 74e1cf3d48..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/linkedin/linkedin-publishing.properties +++ /dev/null @@ -1 +0,0 @@ -publishing.channel-type.linkedin.title=LinkedIn \ No newline at end of file diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/jaxb.index b/src/main/resources/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/jaxb.index deleted file mode 100644 index 4da699670d..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/linkedin/springsocial/api/impl/xml/jaxb.index +++ /dev/null @@ -1,3 +0,0 @@ -JaxbShareImpl -JaxbShareVisibilityImpl -JaxbActivityImpl diff --git a/src/main/resources/org/alfresco/repo/publishing/linkedin/springsocial/api/jaxb.index b/src/main/resources/org/alfresco/repo/publishing/linkedin/springsocial/api/jaxb.index deleted file mode 100644 index c090449d8f..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/linkedin/springsocial/api/jaxb.index +++ /dev/null @@ -1 +0,0 @@ -ShareVisibilityCode \ No newline at end of file diff --git a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType16.png b/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType16.png deleted file mode 100644 index a9b211c4cc..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType16.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType20.png b/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType20.png deleted file mode 100644 index 42cc98ee49..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType20.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType32.png b/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType32.png deleted file mode 100644 index 69077b4c10..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType32.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType64.png b/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType64.png deleted file mode 100644 index 6e52cdaaa7..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/slideshare/SlideShareChannelType64.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/slideshare/slideshare-publishing.properties b/src/main/resources/org/alfresco/repo/publishing/slideshare/slideshare-publishing.properties deleted file mode 100644 index 6f9930d962..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/slideshare/slideshare-publishing.properties +++ /dev/null @@ -1 +0,0 @@ -publishing.channel-type.slideshare.title=SlideShare \ No newline at end of file diff --git a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType16.png b/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType16.png deleted file mode 100644 index 7faef269a0..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType16.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType20.png b/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType20.png deleted file mode 100644 index 58c4dc6346..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType20.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType32.png b/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType32.png deleted file mode 100644 index 82632052d5..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType32.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType64.png b/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType64.png deleted file mode 100644 index 21c6b94097..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/twitter/TwitterChannelType64.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/twitter/twitter-publishing.properties b/src/main/resources/org/alfresco/repo/publishing/twitter/twitter-publishing.properties deleted file mode 100644 index 2b6c4b41c0..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/twitter/twitter-publishing.properties +++ /dev/null @@ -1 +0,0 @@ -publishing.channel-type.twitter.title=Twitter \ No newline at end of file diff --git a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType16.png b/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType16.png deleted file mode 100644 index 50ae1a90f3..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType16.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType20.png b/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType20.png deleted file mode 100644 index ddc8ad4da0..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType20.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType32.png b/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType32.png deleted file mode 100644 index ef0f0f859d..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType32.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType64.png b/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType64.png deleted file mode 100644 index 0bdb02ebc8..0000000000 Binary files a/src/main/resources/org/alfresco/repo/publishing/youtube/YouTubeChannelType64.png and /dev/null differ diff --git a/src/main/resources/org/alfresco/repo/publishing/youtube/youtube-publishing.properties b/src/main/resources/org/alfresco/repo/publishing/youtube/youtube-publishing.properties deleted file mode 100644 index 8aee7d850a..0000000000 --- a/src/main/resources/org/alfresco/repo/publishing/youtube/youtube-publishing.properties +++ /dev/null @@ -1 +0,0 @@ -publishing.channel-type.youtube.title=YouTube \ No newline at end of file diff --git a/src/test/java/org/alfresco/AppContext03TestSuite.java b/src/test/java/org/alfresco/AppContext03TestSuite.java index 336a7f3adb..c45d3d4adf 100644 --- a/src/test/java/org/alfresco/AppContext03TestSuite.java +++ b/src/test/java/org/alfresco/AppContext03TestSuite.java @@ -52,8 +52,6 @@ import org.junit.runners.Suite; org.alfresco.repo.rendition.MultiUserRenditionTest.class, org.alfresco.repo.rendition.RenditionServiceIntegrationTest.class, - org.alfresco.repo.publishing.PublishingQueueImplTest.class, - org.alfresco.repo.publishing.PublishingIntegratedTest.class, org.alfresco.repo.lock.LockBehaviourImplTest.class, org.alfresco.repo.node.archive.LargeArchiveAndRestoreTest.class, org.alfresco.repo.copy.CopyServiceImplTest.class, @@ -82,9 +80,6 @@ import org.junit.runners.Suite; org.alfresco.repo.node.NodeRefPropertyMethodInterceptorTest.class, org.alfresco.repo.node.PerformanceNodeServiceTest.class, org.alfresco.repo.node.archive.ArchiveAndRestoreTest.class, - org.alfresco.repo.publishing.ChannelServiceImplIntegratedTest.class, - org.alfresco.repo.publishing.PublishingPackageSerializerTest.class, - org.alfresco.repo.publishing.PublishingRootObjectTest.class, org.alfresco.repo.node.db.DbNodeServiceImplTest.class, org.alfresco.repo.node.cleanup.TransactionCleanupTest.class, org.alfresco.repo.node.db.DbNodeServiceImplPropagationTest.class, diff --git a/src/test/java/org/alfresco/MiscContextTestSuite.java b/src/test/java/org/alfresco/MiscContextTestSuite.java index 76457d895b..1ef965210a 100644 --- a/src/test/java/org/alfresco/MiscContextTestSuite.java +++ b/src/test/java/org/alfresco/MiscContextTestSuite.java @@ -122,11 +122,6 @@ import org.springframework.context.ApplicationContext; // [module/module-component-test-beans.xml] org.alfresco.repo.module.ComponentsTest.class, - // TODO can we remove this? Was it EOLed? - // [classpath:test/alfresco/test-web-publishing-context.xml] - org.alfresco.repo.publishing.ChannelServiceImplTest.class, - org.alfresco.repo.publishing.PublishingEventHelperTest.class, - // [alfresco/scheduler-core-context.xml, org/alfresco/util/test-scheduled-jobs-context.xml] org.alfresco.util.CronTriggerBeanTest.class, diff --git a/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java b/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java index f2caec8c08..5319330f49 100644 --- a/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.java +++ b/src/test/java/org/alfresco/repo/dictionary/DictionaryLoadDAOTest.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 - 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.dictionary; import java.util.ArrayList; @@ -108,7 +108,6 @@ public class DictionaryLoadDAOTest bootstrapModels.add("alfresco/model/quickShareModel.xml"); bootstrapModels.add("alfresco/model/surfModel.xml"); bootstrapModels.add("alfresco/model/siteModel.xml"); - bootstrapModels.add("alfresco/model/publishingModel.xml"); List labels = new ArrayList(); bootstrap.setModels(bootstrapModels); diff --git a/src/test/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java b/src/test/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java deleted file mode 100644 index c39bbdd584..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/AbstractPublishingIntegrationTest.java +++ /dev/null @@ -1,95 +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.publishing; - -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.person.TestPersonManager; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; -import org.junit.After; -import org.junit.Before; - -/** - * @author Nick Smith - * @since 4.0 - */ -public abstract class AbstractPublishingIntegrationTest extends BaseSpringTest -{ - protected static final String channelTypeId = "MockChannelType"; - - protected ServiceRegistry serviceRegistry; - protected NodeService nodeService; - protected PublishingTestHelper testHelper; - protected TestPersonManager personManager; - - protected String username; - - @Override - @Before - public void onSetUp() throws Exception - { - super.onSetUp(); - serviceRegistry = (ServiceRegistry) getApplicationContext().getBean(ServiceRegistry.SERVICE_REGISTRY); - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - SiteService siteService = serviceRegistry.getSiteService(); - FileFolderService fileFolderService = serviceRegistry.getFileFolderService(); - PermissionService permissionService = serviceRegistry.getPermissionService(); - this.nodeService = serviceRegistry.getNodeService(); - ChannelService channelService = (ChannelService) getApplicationContext().getBean(ChannelServiceImpl.NAME); - PublishingService publishingService = (PublishingService) getApplicationContext().getBean(PublishServiceImpl.NAME); - MutableAuthenticationService authenticationService= (MutableAuthenticationService) getApplicationContext().getBean(ServiceRegistry.AUTHENTICATION_SERVICE.getLocalName()); - PersonService personService= (PersonService) getApplicationContext().getBean(ServiceRegistry.PERSON_SERVICE.getLocalName()); - - this.personManager = new TestPersonManager(authenticationService, personService, nodeService); - this.testHelper = new PublishingTestHelper(channelService, publishingService, siteService, fileFolderService, permissionService); - - this.username = GUID.generate(); - personManager.createPerson(username); - } - - @After - public void onTearDown() throws Exception - { - try - { - testHelper.tearDown(); - } - finally - { - super.onTearDown(); - } - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/ChannelHelperTest.java b/src/test/java/org/alfresco/repo/publishing/ChannelHelperTest.java deleted file mode 100644 index 2362399554..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/ChannelHelperTest.java +++ /dev/null @@ -1,58 +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.publishing; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Nick Smith - * @since 4.0 - * - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:test/alfresco/test-web-publishing-context.xml"}) -public class ChannelHelperTest -{ - @Autowired - private ChannelHelper helper; - - @Test - public void testMapNodeRef() throws Exception - { -// String guid = GUID.generate(); -// NodeRef testNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, guid); -// NodeRef liveEnvironmentNode = environmentHelper.getEnvironment(siteId, PublishingService.LIVE_ENVIRONMENT_NAME); -// NodeRef mappedNodeRef = environmentHelper.mapEditorialToEnvironment(liveEnvironmentNode, testNodeRef); -// assertNotSame(mappedNodeRef, testNodeRef); -// NodeRef unmappedNodeRef = environmentHelper.mapEnvironmentToEditorial(liveEnvironmentNode, mappedNodeRef); -// assertEquals(testNodeRef, unmappedNodeRef); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/ChannelImplTest.java b/src/test/java/org/alfresco/repo/publishing/ChannelImplTest.java deleted file mode 100644 index 6b775e886c..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/ChannelImplTest.java +++ /dev/null @@ -1,128 +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.publishing; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import junit.framework.TestCase; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class ChannelImplTest extends TestCase -{ - ServiceRegistry serviceRegMock; - - @Override - protected void setUp() throws Exception { - super.setUp(); - serviceRegMock = mock(ServiceRegistry.class); - } - - public void testUpdateStatus() throws Exception - { - int maxLength = 30; - AbstractChannelType channelType = mockChannelType(maxLength); - - ChannelHelper helper = mock(ChannelHelper.class); - when(helper.getChannelProperties(any(NodeRef.class))).thenReturn(null); - NodeRef node = new NodeRef("test://channel/node"); - - ChannelImpl channel = new ChannelImpl(serviceRegMock, channelType, node, "Name", helper, null); - - String msg = "Here is a message"; - channel.sendStatusUpdate(msg, null); - verify(channelType).sendStatusUpdate(channel, msg); - } - - public void testUpdateStatusTruncates() throws Exception - { - int maxLength = 30; - AbstractChannelType channelType = mockChannelType(maxLength); - - ChannelHelper helper = mock(ChannelHelper.class); - when(helper.getChannelProperties(any(NodeRef.class))).thenReturn(null); - NodeRef node = new NodeRef("test://channel/node"); - - ChannelImpl channel = new ChannelImpl(serviceRegMock, channelType, node, "Name", helper, null); - - String msg = "Here is a much longer message to truncate."; - String expMsg = msg.substring(0, maxLength); - channel.sendStatusUpdate(msg, null); - verify(channelType).sendStatusUpdate(channel, expMsg); - } - - public void testUpdateStatusTruncatesWithUrl() throws Exception - { - int maxLength = 30; - AbstractChannelType channelType = mockChannelType(maxLength); - - ChannelHelper helper = mock(ChannelHelper.class); - when(helper.getChannelProperties(any(NodeRef.class))).thenReturn(null); - NodeRef node = new NodeRef("test://channel/node"); - - ChannelImpl channel = new ChannelImpl(serviceRegMock, channelType, node, "Name", helper, null); - String nodeUrl ="http://foo/bar"; - int endpoint = maxLength - nodeUrl.length(); - - String msg = "Here is a much longer message to truncate."; - String expMsg = msg.substring(0, endpoint) + nodeUrl; - channel.sendStatusUpdate(msg, nodeUrl); - verify(channelType).sendStatusUpdate(channel, expMsg); - } - - public void testUpdateStatusNoMaxLength() throws Exception - { - AbstractChannelType channelType = mockChannelType(0); - - ChannelHelper helper = mock(ChannelHelper.class); - when(helper.getChannelProperties(any(NodeRef.class))).thenReturn(null); - NodeRef node = new NodeRef("test://channel/node"); - - ChannelImpl channel = new ChannelImpl(serviceRegMock, channelType, node, "Name", helper, null); - String nodeUrl ="http://foo/bar"; - - String msg = "Here is a much longer message to truncate."; - String expMsg = msg + nodeUrl; - channel.sendStatusUpdate(msg, nodeUrl); - verify(channelType).sendStatusUpdate(channel, expMsg); - } - - private AbstractChannelType mockChannelType(int maxLength) - { - AbstractChannelType channelType = mock(AbstractChannelType.class); - when(channelType.canPublishStatusUpdates()).thenReturn(true); - when(channelType.getMaximumStatusLength()).thenReturn(maxLength); - return channelType; - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java b/src/test/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java deleted file mode 100644 index efc75205ac..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/ChannelServiceImplIntegratedTest.java +++ /dev/null @@ -1,310 +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.publishing; - -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.GUID; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -@Category(OwnJVMTestsCategory.class) -public class ChannelServiceImplIntegratedTest extends AbstractPublishingIntegrationTest -{ - private static final String channelName = GUID.generate(); - - private ChannelService channelService; - - @Test - public void testCreateChannel() throws Exception - { -// personManager.setUser(username); -// try -// { -// createChannel(); -// fail("Only Admin user can create channels!"); -// } -// catch(AccessDeniedException e) -// { -// // NOOP -// } - - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - Channel channel = createChannel(); - assertEquals(channelTypeId, channel.getChannelType().getId()); - assertNotNull(channelName, channel.getName()); - NodeRef channelNode = new NodeRef(channel.getId()); - assertTrue(nodeService.exists(channelNode)); - } - - @Test - public void testDeleteChannel() throws Exception - { - Channel channel = createChannel(); - assertNotNull("The channel should exist! Id: "+channel.getId(), channelService.getChannelById(channel.getId())); - assertNotNull("The channel should exist! Name: "+channelName, channelService.getChannelByName(channelName)); - - personManager.setUser(username); - try - { - channelService.deleteChannel(channel); - fail("Only Admin users should be able to delete channels."); - } - catch(AccessDeniedException e) - { - //NOOP - } - - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - channelService.deleteChannel(channel); - - assertNull("The channel should have been deleed! Id: "+channel.getId(), channelService.getChannelById(channel.getId())); - assertNull("The channel should have been deleed! Name: "+channelName, channelService.getChannelByName(channelName)); - } - - @Test - public void testRenameChannel() throws Exception - { - String newChannelName = "New Channel Name"; - Channel channel = createChannel(); - - personManager.setUser(username); - try - { - channelService.renameChannel(channel, newChannelName); - fail("Only Admin user can rename Channel."); - } - catch(AccessDeniedException e) - { - //NOOP - } - - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - channelService.renameChannel(channel, newChannelName); - Channel renamedChannel = channelService.getChannelById(channel.getId()); - assertNotNull(renamedChannel); - assertEquals(newChannelName, renamedChannel.getName()); - assertNotNull(channelService.getChannelByName(newChannelName)); - assertNotNull(channelService.getChannelById(channel.getId())); - assertNull(channelService.getChannelByName(channelName)); - } - - @Test - public void testUpdateChannel() throws Exception - { - String newTitle = "This is my title"; - Channel channel = createChannel(); - - Map props = channel.getProperties(); - assertNull(props.get(ContentModel.PROP_TITLE)); - - props.put(ContentModel.PROP_TITLE, newTitle); - - - personManager.setUser(username); - try - { - channelService.updateChannel(channel, props); - fail("Only Admin user can rename Channel."); - } - catch(AccessDeniedException e) - { - //NOOP - } - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - channelService.updateChannel(channel, props); - Channel updatedChannel = channelService.getChannelById(channel.getId()); - Serializable title = updatedChannel.getProperties().get(ContentModel.PROP_TITLE); - assertNotNull(title); - assertEquals(newTitle, title); - } - - @Test - public void testGetChannels() throws Exception - { - int startingSize = channelService.getChannels().size(); - - int channelCount = 7; - Set ids = new HashSet(); - for (int i = 0; i < channelCount; ++i) - { - Channel newChannel = testHelper.createChannel(channelTypeId); - ids.add(newChannel.getId()); - - List channels = channelService.getChannels(); - assertEquals(i + 1 + startingSize, channels.size()); - Set idsToCheck = new HashSet(ids); - for (Channel channel : channels) - { - idsToCheck.remove(channel.getId()); - } - assertTrue(idsToCheck.isEmpty()); - } - } - - @Test - public void testGetChannelsPermissions() throws Exception - { - ChannelType publishType = testHelper.mockChannelType(GUID.generate()); - when(publishType.canPublish()).thenReturn(true); - ChannelType statusType = testHelper.mockChannelType(GUID.generate()); - when(statusType.canPublishStatusUpdates()).thenReturn(true); - - Channel publishChannel = testHelper.createChannel(publishType.getId()); - Channel statusChannel = testHelper.createChannel(statusType.getId()); - - // Create User1 and set as FullyAuthenticatedUser. - String user1 = GUID.generate(); - personManager.createPerson(user1); - personManager.setUser(user1); - - // User1 should have access to Channel with no permissions filtering. - Channel channelById = channelService.getChannelById(publishChannel.getId()); - assertNotNull("User1 should have access to the channel!", channelById); - List channels = channelService.getChannels(); - assertTrue("Result of getChannels() should contain the channel!", checkContainsChannel(channels, publishChannel.getId(), statusChannel.getId())); - channels = channelService.getPublishingChannels(false); - assertTrue("User1 should have access to unfiltered publishing channels", checkContainsChannel(channels, publishChannel.getId())); - channels = channelService.getStatusUpdateChannels(false); - assertTrue("User1 should have access to unfiltered status update channels", checkContainsChannel(channels, statusChannel.getId())); - - // User1 should not have access if permissions are filtered. - channels = channelService.getPublishingChannels(true); - assertFalse("User1 should not have access to filtered publishing channels", checkContainsChannel(channels, publishChannel.getId())); - channels = channelService.getStatusUpdateChannels(true); - assertFalse("User1 should not have access to filtered status update channels", checkContainsChannel(channels, statusChannel.getId())); - - //Add Read permissions to User1. - testHelper.setChannelPermission(user1, publishChannel.getId(), PermissionService.READ); - testHelper.setChannelPermission(user1, statusChannel.getId(), PermissionService.READ); - - // Read permissions should not allow access to filtered channels. - channels = channelService.getPublishingChannels(true); - assertFalse("User1 should not have access to filtered publishing channels", checkContainsChannel(channels, publishChannel.getId())); - channels = channelService.getStatusUpdateChannels(true); - assertFalse("User1 should not have access to filtered status update channels", checkContainsChannel(channels, statusChannel.getId())); - - //Add ADD_CHILD permissions to User1. - testHelper.setChannelPermission(user1, publishChannel.getId(), PermissionService.ADD_CHILDREN); - testHelper.setChannelPermission(user1, statusChannel.getId(), PermissionService.ADD_CHILDREN); - - // Add Child permissions should allow access to filtered channels. - channels = channelService.getPublishingChannels(true); - assertTrue("User1 should have access to filtered publishing channels", checkContainsChannel(channels, publishChannel.getId())); - channels = channelService.getStatusUpdateChannels(true); - assertTrue("User1 should have access to filtered status update channels", checkContainsChannel(channels, statusChannel.getId())); - } - - @Test - public void testGetChannelByName() throws Exception - { - Channel channel = channelService.getChannelById(null); - assertNull("Should return null if unknown channelName", channel); - - channel = channelService.getChannelByName(channelName); - assertNull("Should return null if null channelName", channel); - - Channel createdChannel = createChannel(); - - channel = channelService.getChannelByName(channelName); - assertNotNull("Should return created channel!", channel); - assertEquals(channelName, channel.getName()); - assertEquals(createdChannel.getChannelType().getId(), channel.getChannelType().getId()); - assertEquals(createdChannel.getId(), channel.getId()); - } - - @Test - public void testGetChannelById() throws Exception - { - Channel channel = channelService.getChannelById(null); - assertNull("Should return null if null channelId", channel); - - channel = channelService.getChannelById("test://channel/id"); - assertNull("Should return null if unknown channelId", channel); - - Channel createdChannel = createChannel(); - - channel = channelService.getChannelById(createdChannel.getId()); - assertNotNull("Should return created channel!", channel); - assertEquals(createdChannel.getId(), channel.getId()); - assertEquals(channelName, channel.getName()); - assertEquals(createdChannel.getChannelType().getId(), channel.getChannelType().getId()); - } - - private boolean checkContainsChannel(List channels, final String... ids) - { - ArrayList remainingIds = new ArrayList(Arrays.asList(ids)); - for (Channel channel : channels) - { - remainingIds.remove(channel.getId()); - if (remainingIds.isEmpty()) - { - return true; - } - } - return false; - } - - private Channel createChannel() - { - return testHelper.createChannel(channelTypeId, channelName); - } - - @Before - @Override - public void onSetUp() throws Exception - { - super.onSetUp(); - this.channelService = (ChannelService) getApplicationContext().getBean("ChannelService"); - testHelper.mockChannelType(channelTypeId); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java b/src/test/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java deleted file mode 100644 index 337dd7c6bc..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/ChannelServiceImplTest.java +++ /dev/null @@ -1,92 +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.publishing; - -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; - -import java.util.List; - -import javax.annotation.Resource; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.NodeService; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Nick Smith - * @since 4.0 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:test/alfresco/test-web-publishing-context.xml"}) -public class ChannelServiceImplTest -{ - @Resource - ChannelServiceImpl channelService; - - @Resource - NodeService nodeService; - - @Resource - ServiceRegistry serviceRegistry; - - @Resource - MockChannelType mockChannelType; - - @Test - public void testRegister() - { - List types = channelService.getChannelTypes(); - - // Check the mock channel type is registered through Spring. - assertTrue(types.contains(mockChannelType)); - channelService.getChannelType(MockChannelType.ID); - try - { - channelService.register(null); - fail("Exception expected when calling register(null)"); - } - catch(IllegalArgumentException e) - { - //NOOP - } - try - { - channelService.register(mockChannelType); - fail("Exception expected when trying to register the same ChannelType twice"); - } - catch(IllegalArgumentException e) - { - //NOOP - } - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/EnvironmentImplTest.java b/src/test/java/org/alfresco/repo/publishing/EnvironmentImplTest.java deleted file mode 100644 index b13bf9302e..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/EnvironmentImplTest.java +++ /dev/null @@ -1,94 +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.publishing; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class EnvironmentImplTest //extends AbstractPublishingIntegrationTest -{ -// private Channel channel1; -// private Channel channel2; -// -// @Resource(name="channelService") -// private ChannelService channelService; -// -// @Test -// public void testCheckPublishStatus() -// { -// NodeRef first = fileFolderService.create(docLib, "first", ContentModel.TYPE_CONTENT).getNodeRef(); -// NodeRef second = fileFolderService.create(docLib, "second", ContentModel.TYPE_CONTENT).getNodeRef(); -// -// Map results = environment.checkPublishStatus(channel1.getId(), first); -// assertEquals(1, results.size()); -// checkNodeStatus(first, Status.NOT_PUBLISHED, results); -// -// // Schedule first Node for publishing. -// Calendar schedule = Calendar.getInstance(); -// schedule.add(Calendar.YEAR, 1); -// MutablePublishingPackage pckg =queue.createPublishingPackage(); -// pckg.addNodesToPublish(first); -// queue.scheduleNewEvent(pckg, channel1.getId(), schedule, null, null); -// -// results = environment.checkPublishStatus(channel1.getId(), first, second); -// assertEquals(2, results.size()); -// checkNodeStatus(first, Status.ON_QUEUE, results); -// checkNodeStatus(second, Status.NOT_PUBLISHED, results); -// -// results = environment.checkPublishStatus(channel2.getId(), first, second); -// assertEquals(2, results.size()); -// checkNodeStatus(first, Status.NOT_PUBLISHED, results); -// checkNodeStatus(second, Status.NOT_PUBLISHED, results); -// } -// -// private void checkNodeStatus(NodeRef node, Status expStatus, Map results) -// { -// NodePublishStatus nodeStatus = results.get(node); -// assertEquals(node, nodeStatus.getNodeRef()); -// assertEquals(expStatus, nodeStatus.getStatus()); -// } -// -// /** -// * {@inheritDoc} -// */ -// @Override -// public void onSetUp() throws Exception -// { -// super.onSetUp(); -// channelService = (ChannelServiceImpl) getApplicationContext().getBean("channelService"); -// -// ChannelType channelType = mockChannelType(); -// if (channelService.getChannelType(channelType.getId()) == null) -// { -// channelService.register(channelType); -// } -// this.channel1 = channelService.createChannel(channelTypeId, GUID.generate(), null); -// this.channel2 = channelService.createChannel(channelTypeId, GUID.generate(), null); -// } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishEventActionTest.java b/src/test/java/org/alfresco/repo/publishing/PublishEventActionTest.java deleted file mode 100644 index 645346ce60..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishEventActionTest.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.publishing; - -import static org.alfresco.model.ContentModel.ASPECT_GEOGRAPHIC; -import static org.alfresco.model.ContentModel.ASPECT_TEMPORARY; -import static org.alfresco.model.ContentModel.PROP_CONTENT; -import static org.alfresco.model.ContentModel.PROP_LATITUDE; -import static org.alfresco.model.ContentModel.PROP_LONGITUDE; -import static org.alfresco.model.ContentModel.PROP_NAME; -import static org.alfresco.model.ContentModel.TYPE_CONTENT; -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_LAST_PUBLISHING_EVENT; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.service.cmr.publishing.NodeSnapshot; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingPackage; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Nick Smith - * @since 4.0 - */ -@Category(BaseSpringTestsCategory.class) -public class PublishEventActionTest extends AbstractPublishingIntegrationTest -{ - private static final String contentNodeName = "TheName"; - private static final String content = "The quick brown fox jumped over the lazy dog"; - - @Resource(name="publishingService") - private PublishingService publishingService; - - @Resource(name="contentService") - private ContentService contentService; - - @Autowired - private ChannelHelper channelHelper; - - @Autowired - private PublishEventAction action; - - private Channel channel; - private NodeRef channelNode; - private AbstractChannelType channelType; - - @Test - public void testPublishNodes() throws Exception - { - // Create content node with appropriate aspects added. - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - double lattitude = 0.25; - double longtitude = 0.75; - addGeographicAspect(source, lattitude, longtitude); - nodeService.addAspect(source, ASPECT_TEMPORARY, null); - - NodeRef publishEventNode = publishNode(source); - - // Check published node exists and is in correct place. - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertNotNull(publishedNode); - assertTrue(nodeService.exists(publishedNode)); - assertEquals(channelNode, nodeService.getPrimaryParent(publishedNode).getParentRef()); - - // Check published node type and aspects - assertEquals(TYPE_CONTENT, nodeService.getType(publishedNode)); - Set sourceAspects = nodeService.getAspects(source); - Set publishedAspects = nodeService.getAspects(publishedNode); - assertTrue(publishedAspects.containsAll(sourceAspects)); - assertTrue(publishedAspects.contains(ASPECT_GEOGRAPHIC)); - assertTrue(publishedAspects.contains(ASPECT_TEMPORARY)); - - // Check published node properties - Map publishedProps = nodeService.getProperties(publishedNode); - assertEquals(lattitude, publishedProps.get(PROP_LATITUDE)); - assertEquals(longtitude, publishedProps.get(PROP_LONGITUDE)); - assertEquals(contentNodeName, publishedProps.get(PROP_NAME)); - assertEquals(content, readContent(source)); - - // Check lastPublishingEvent association is created. - List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); - assertEquals(1, assocs.size()); - assertEquals(publishEventNode, assocs.get(0).getTargetRef()); - } - - public void testUpdatePublishedNode() throws Exception - { - // Create content node without aspects - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - NodeRef publishEventNode = publishNode(source); - - // Check published node exists - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertNotNull(publishedNode); - assertTrue(nodeService.exists(publishedNode)); - - // Verify properties set correctly. - Map publishedProps = nodeService.getProperties(publishedNode); - assertFalse(publishedProps.containsKey(PROP_LATITUDE)); - assertFalse(publishedProps.containsKey(PROP_LONGITUDE)); - assertEquals(contentNodeName, publishedProps.get(PROP_NAME)); - assertEquals(content, readContent(source)); - - Set aspects = nodeService.getAspects(source); - assertFalse(aspects.contains(ASPECT_GEOGRAPHIC)); - - // Check lastPublishingEvent association is created. - List assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); - assertEquals(1, assocs.size()); - assertEquals(publishEventNode, assocs.get(0).getTargetRef()); - - // Modify source node - double lattitude = 0.25; - double longtitude = 0.75; - addGeographicAspect(source, lattitude, longtitude); - - String newName = "NewName"; - nodeService.setProperty(source, PROP_NAME, newName); - String newContent = "The new content"; - testHelper.writeContent(source, newContent, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Update published node. - publishEventNode = publishNode(source); - NodeRef newPublishNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertEquals(publishedNode, newPublishNode); - - // Published node shoudl still exist. - assertNotNull(publishedNode); - assertTrue(nodeService.exists(publishedNode)); - - // Check aspects modified - aspects = nodeService.getAspects(publishedNode); - assertTrue(aspects.contains(ASPECT_GEOGRAPHIC)); - assertTrue(aspects.containsAll(nodeService.getAspects(source))); - - // Check properties modified - publishedProps = nodeService.getProperties(publishedNode); - assertEquals(lattitude, publishedProps.get(PROP_LATITUDE)); - assertEquals(longtitude, publishedProps.get(PROP_LONGITUDE)); - assertEquals(newName, publishedProps.get(PROP_NAME)); - assertEquals(newContent, readContent(source)); - - // Check lastPublishingEvent association has changed. - assocs = nodeService.getTargetAssocs(publishedNode, ASSOC_LAST_PUBLISHING_EVENT); - assertEquals(1, assocs.size()); - assertEquals(publishEventNode, assocs.get(0).getTargetRef()); - - // Remove aspect from source node. - nodeService.removeAspect(source, ASPECT_GEOGRAPHIC); - - // Update publish node - publishNode(source); - newPublishNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertEquals(publishedNode, newPublishNode); - - aspects = nodeService.getAspects(source); - assertFalse(aspects.contains(ASPECT_GEOGRAPHIC)); - - publishedProps = nodeService.getProperties(publishedNode); - assertFalse(publishedProps.containsKey(PROP_LATITUDE)); - assertFalse(publishedProps.containsKey(PROP_LONGITUDE)); - } - - public void testUnpublishNode() throws Exception - { - // Create content node and publish. - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - publishNode(source); - - // Check published node exists - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertNotNull(publishedNode); - assertTrue(nodeService.exists(publishedNode)); - - // Unpublish source node. - NodeRef eventNode = publishNode(source, null, false); - - // Check the published node no longer exists. - assertFalse(nodeService.exists(publishedNode)); - publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertNull(publishedNode); - - // Check can generate a valid snapshot for the unpublish entry. - PublishingEvent event = publishingService.getPublishingEvent(eventNode.toString()); - PublishingPackage packg = event.getPackage(); - - Set toUnpublish = packg.getNodesToUnpublish(); - assertEquals(1, toUnpublish.size()); - assertTrue(toUnpublish.contains(source)); - - PublishingPackageEntry entry = packg.getEntryMap().get(source); - assertEquals(false, entry.isPublish()); - - NodeSnapshot snapshot = entry.getSnapshot(); - assertEquals(source, snapshot.getNodeRef()); - assertEquals(ContentModel.TYPE_CONTENT, snapshot.getType()); - Serializable name = nodeService.getProperty(source, ContentModel.PROP_NAME); - assertEquals(name, snapshot.getProperties().get(ContentModel.PROP_NAME)); - - } - - @SuppressWarnings("unchecked") - @Test - public void testChannelTypePublishIsCalledOnPublish() throws Exception - { - // Create content node with appropriate aspects added. - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Enable publishing on ChannelType. - when(channelType.canPublish()).thenReturn(true); - - publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - - // Check publish was called - verify(channelType, times(1)).publish(eq(publishedNode), anyMap()); - } - - @SuppressWarnings("unchecked") - public void testChannelTypePublishIsCalledOnUpdate() throws Exception - { - // Create content node with appropriate aspects added. - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Publish source node but dont' call ChannelType.publish(). - publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - - // Check publish was not called. - verify(channelType, never()).publish(eq(publishedNode), anyMap()); - - // Enable publishing on ChannelType. - when(channelType.canPublish()).thenReturn(true); - - // Update publish node - publishNode(source); - - // Check publish was called on update - verify(channelType, times(1)).publish(eq(publishedNode), anyMap()); - - // Unpublish node. - publishNode(source, null, false); - - // Check unpublish was not called, since ChannelType doesn't support it. - verify(channelType, never()).unpublish(eq(publishedNode), anyMap()); - - // Enable unpublishing on ChannelType. - when(channelType.canUnpublish()).thenReturn(true); - - // Re-publish the node. - publishNode(source); - - // Get the newly published node. - publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - assertNotNull(publishedNode); - - // Unpublish the node - publishNode(source, null, false); - - // Check unpublish was called on update - verify(channelType, times(1)).unpublish(eq(publishedNode), anyMap()); - } - - @Test - @SuppressWarnings("unchecked") - public void testSupportedContentTypes() throws Exception - { - // Create content node with appropriate aspects added. - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Enable publishing on ChannelType. - when(channelType.canPublish()).thenReturn(true); - - // Set supported type to cm:folder - Set contentTypes = Collections.singleton(ContentModel.TYPE_FOLDER); - when(channelType.getSupportedContentTypes()).thenReturn(contentTypes); - - // Publish source node but don't call ChannelType.publish(). - publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - - verify(channelType, never()).publish(eq(publishedNode), anyMap()); - - // Change supported type to cm:content - contentTypes = Collections.singleton(ContentModel.TYPE_CONTENT); - when(channelType.getSupportedContentTypes()).thenReturn(contentTypes); - - // Publish source node - publishNode(source); - - verify(channelType, times(1)).publish(eq(publishedNode), anyMap()); - - // Change supported type to cm:cmobject - contentTypes = Collections.singleton(ContentModel.TYPE_CMOBJECT); - when(channelType.getSupportedContentTypes()).thenReturn(contentTypes); - - // Publish source node - publishNode(source); - - verify(channelType, times(2)).publish(eq(publishedNode), anyMap()); - } - - @Test - @SuppressWarnings("unchecked") - public void testSupportedMimeTypes() throws Exception - { - // Create content node with appropriate aspects added. - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Enable publishing on ChannelType. - when(channelType.canPublish()).thenReturn(true); - - // Set supported type to XML - Set mimeTypes = Collections.singleton(MimetypeMap.MIMETYPE_XML); - when(channelType.getSupportedMimeTypes()).thenReturn(mimeTypes); - - // Publish source node but don't call ChannelType.publish(). - publishNode(source); - NodeRef publishedNode = channelHelper.mapSourceToEnvironment(source, channelNode); - - verify(channelType, never()).publish(eq(publishedNode), anyMap()); - - // Change supported type to plain text. - mimeTypes = Collections.singleton(MimetypeMap.MIMETYPE_TEXT_PLAIN); - when(channelType.getSupportedMimeTypes()).thenReturn(mimeTypes); - - // Publish source node - publishNode(source); - - verify(channelType, times(1)).publish(eq(publishedNode), anyMap()); - } - - @SuppressWarnings("unchecked") - public void testStatusUpdate() throws Exception - { - NodeRef source = testHelper.createContentNode(contentNodeName, content, MimetypeMap.MIMETYPE_TEXT_PLAIN); - - // Create Status Update - String message = "Here is the message "; - - String url = "http://test/url"; - when(channelType.getNodeUrl(any(NodeRef.class))).thenReturn(url); - when(channelType.canPublishStatusUpdates()).thenReturn(true); - - publishNode(source, message); - - String expMessage = message + " " + url; - verify(channelType, times(1)).sendStatusUpdate(any(Channel.class), eq(expMessage)); - } - - private NodeRef publishNode(NodeRef source) - { - return publishNode(source, null); - } - - private NodeRef publishNode(NodeRef source, String message) - { - return publishNode(source, message, true); - } - - private NodeRef publishNode(NodeRef source, String message, boolean publish) - { - PublishingDetails details = publishingService.createPublishingDetails(); - details.setPublishChannelId(channel.getId()); - if (publish) - { - details.addNodesToPublish(source); - } - else - { - details.addNodesToUnpublish(source); - } - if (message != null) - { - details.setStatusMessage(message) - .setStatusNodeToLinkTo(source) - .addStatusUpdateChannels(channel.getId()); - } - String eventId = testHelper.scheduleEvent1Year(details); - - assertNotNull(eventId); - NodeRef eventNode = new NodeRef(eventId); - assertTrue(nodeService.exists(eventNode)); - Serializable eventStatus = nodeService.getProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS); - assertEquals(Status.SCHEDULED.name(), eventStatus); - - action.executeImpl(null, eventNode); - - // Check Status has changed to COMPLETE - eventStatus = nodeService.getProperty(eventNode, PublishingModel.PROP_PUBLISHING_EVENT_STATUS); - assertEquals(Status.COMPLETED.name(), eventStatus); - - return eventNode; - } - - private void addGeographicAspect(NodeRef source, double lattitude, double longtitude) - { - Map props = new HashMap(); - props.put(PROP_LATITUDE, lattitude); - props.put(PROP_LONGITUDE, longtitude); - serviceRegistry.getNodeService().addAspect(source, ASPECT_GEOGRAPHIC, props); - } - - private String readContent(NodeRef source) - { - ContentReader reader = contentService.getReader(source, PROP_CONTENT); - return reader.getContentString(); - } - - @Override - public void onSetUp() throws Exception - { - super.onSetUp(); - this.publishingService = (PublishingService) getApplicationContext().getBean("publishingService"); - this.contentService = (ContentService) getApplicationContext().getBean("ContentService"); - this.channelHelper = (ChannelHelper) getApplicationContext().getBean("channelHelper"); - this.action = (PublishEventAction) getApplicationContext().getBean("pub_publishEvent"); - - this.channelType = testHelper.mockChannelType(channelTypeId); - this.channel = testHelper.createChannel(channelTypeId); - this.channelNode = new NodeRef(channel.getId()); - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java b/src/test/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java deleted file mode 100644 index 3d865cac09..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishWebContentActivitiTest.java +++ /dev/null @@ -1,62 +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.publishing; - -import java.util.List; - -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.junit.experimental.categories.Category; - - -/** - * @author Nick Smith - * @author Frederik Heremans - * @since 4.0 - */ -@Category(OwnJVMTestsCategory.class) -public class PublishWebContentActivitiTest extends PublishWebContentProcessTest -{ - private static final String DEF_NAME = "activiti$publishWebContent"; - - @Override - protected String getWorkflowDefinitionName() - { - return DEF_NAME; - } - - /** - * Activiti has 2 paths: a timer-scope-path and the main execution-path - */ - protected void checkNode(String expNode) - { - List paths = workflowService.getWorkflowPaths(instanceId); - assertEquals(2, paths.size()); - WorkflowPath path = paths.get(0); - assertEquals(expNode, path.getNode().getName()); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java b/src/test/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java deleted file mode 100644 index 206c54e92c..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishWebContentProcessTest.java +++ /dev/null @@ -1,251 +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.publishing; - -import static org.alfresco.model.ContentModel.ASSOC_CONTAINS; -import static org.alfresco.model.ContentModel.PROP_NAME; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_STATUS; -import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_SCHEDULED_PUBLISH_DATE; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_EVENT; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.Serializable; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.action.executer.ActionExecuter; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.workflow.WorkflowModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.action.Action; -import org.alfresco.service.cmr.action.ActionDefinition; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.workflow.WorkflowDefinition; -import org.alfresco.service.cmr.workflow.WorkflowInstance; -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.cmr.workflow.WorkflowTask; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -/** - * @author Nick Smith - * @author Frederik Heremans - * - * @since 4.0 - */ -public abstract class PublishWebContentProcessTest extends BaseSpringTest -{ - protected ServiceRegistry serviceRegistry; - protected Repository repositoryHelper; - protected ActionExecuter publishEventAction; - - protected NodeService nodeService; - protected WorkflowService workflowService; - protected RetryingTransactionHelper transactionHelper; - protected NodeRef event; - protected String instanceId; - protected long threadId; - - /** - * Get definition to use - */ - protected abstract String getWorkflowDefinitionName(); - - @Test - public void testProcessTimers() throws Exception - { - final Calendar scheduledTime = Calendar.getInstance(); - scheduledTime.add(Calendar.SECOND, 5); - - startWorkflowAndCommit(scheduledTime); - - // Should be waiting for scheduled time. - checkNode("waitForScheduledTime"); - - // Wait for scheduled time to elapse. - Thread.sleep(10000); - - // Should have ended - checkEnded(instanceId); - - // Check the Publish Event Action was called - verify(publishEventAction).execute(any(Action.class), any(NodeRef.class)); - - assertFalse("The action should be run from a different Thread!", Thread.currentThread().getId()==threadId); - } - - public void testProcessNoSchedule() throws Exception - { - startWorkflowAndCommit(null); - - // Wait for async action to execute - Thread.sleep(500); - - // Should have ended - checkEnded(instanceId); - - // Check the Publish Event Action was called - verify(publishEventAction).execute(any(Action.class), any(NodeRef.class)); - - assertFalse("The action should be run from a different Thread!", Thread.currentThread().getId()==threadId); - } - - private void checkEnded(String instanceId2) - { - WorkflowInstance instance = workflowService.getWorkflowById(instanceId2); - if (instance.isActive()) - { - List paths = workflowService.getWorkflowPaths(instance.getId()); - String nodeName = paths.get(0).getNode().getName(); - fail("Workflow should have ended! At node: " +nodeName); - } - } - - private void startWorkflowAndCommit(final Calendar scheduledTime) - { - RetryingTransactionCallback startWorkflowCallback = new RetryingTransactionCallback() - { - public Void execute() throws Throwable - { - WorkflowPath path = startWorkflow(scheduledTime); - - // End the Start task. - WorkflowTask startTask = workflowService.getStartTask(path.getInstance().getId()); - workflowService.endTask(startTask.getId(), null); - return null; - } - }; - transactionHelper.doInTransaction(startWorkflowCallback); - } - - private WorkflowPath startWorkflow(Calendar scheduledTime) - { - WorkflowDefinition definition = workflowService.getDefinitionByName(getWorkflowDefinitionName()); - assertNotNull("The definition is null!", definition); - - NodeRef pckg = workflowService.createPackage(null); - - Map params = new HashMap(); - params.put(PROP_WF_PUBLISHING_EVENT, event); - params.put(PROP_WF_SCHEDULED_PUBLISH_DATE, scheduledTime); - params.put(WorkflowModel.ASSOC_PACKAGE, pckg); - - WorkflowPath path = workflowService.startWorkflow(definition.getId(), params); - assertNotNull(path); - this.instanceId = path.getInstance().getId(); - return path; - } - - protected void checkNode(String expNode) - { - List paths = workflowService.getWorkflowPaths(instanceId); - assertEquals(1, paths.size()); - WorkflowPath path = paths.get(0); - assertEquals(expNode, path.getNode().getName()); - } - - @Before - public void onSetUp() - { - serviceRegistry = (ServiceRegistry)getApplicationContext().getBean("ServiceRegistry"); - repositoryHelper = (Repository) getApplicationContext().getBean("repositoryHelper"); - publishEventAction = (ActionExecuter) getApplicationContext().getBean("pub_publishEvent"); - - reset(publishEventAction); - ActionDefinition actionDef = mock(ActionDefinition.class); - when(publishEventAction.getActionDefinition()).thenReturn(actionDef); - // Record thread action is run in. - Mockito.doAnswer(new Answer() - { - public Void answer(InvocationOnMock invocation) throws Throwable - { - threadId = Thread.currentThread().getId(); - return null; - } - }).when(publishEventAction).execute(any(Action.class), any(NodeRef.class)); - - this.workflowService = serviceRegistry.getWorkflowService(); - this.nodeService = serviceRegistry.getNodeService(); - this.transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); - AuthenticationUtil.setRunAsUser(AuthenticationUtil.getSystemUserName()); - NodeRef companyHome = repositoryHelper.getCompanyHome(); - String name = GUID.generate(); - Map props = new HashMap(); - props.put(PROP_NAME, name); - props.put(PROP_PUBLISHING_EVENT_STATUS, Status.SCHEDULED.name()); - - QName assocName = QName.createQNameWithValidLocalName(PublishingModel.NAMESPACE, name); - ChildAssociationRef eventAssoc = nodeService.createNode(companyHome, ASSOC_CONTAINS, assocName, TYPE_PUBLISHING_EVENT, props); - this.event = eventAssoc.getChildRef(); - } - - @Override - protected String[] getConfigLocations() - { - return new String[] - { - ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:test/alfresco/test-web-publishing--workflow-context.xml" - }; - } - - @After - public void onTearDown() - { - try - { - workflowService.cancelWorkflow(instanceId); - } - catch (Exception e) - { - // NOOP - } - nodeService.deleteNode(event); - AuthenticationUtil.clearCurrentSecurityContext(); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java b/src/test/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java deleted file mode 100644 index ef11e9a43a..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishingEventHelperTest.java +++ /dev/null @@ -1,223 +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.publishing; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static org.alfresco.repo.publishing.PublishingModel.ASSOC_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_COMMENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_PAYLOAD; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_STATUS; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_TIME; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_TIME_ZONE; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_PUBLISHING_EVENT; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Resource; - -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -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.cmr.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Nick Smith - * @since 4.0 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:test/alfresco/test-web-publishing-context.xml"}) -public class PublishingEventHelperTest -{ - @Resource(name="publishingEventHelper") - PublishingEventHelper helper; - - @Resource(name="NodeService") - NodeService nodeService; - - @Resource(name="ContentService") - ContentService contentService; - - @Resource(name="PermissionService") - PermissionService permissionService; - - @Test - public void testGetPublishingEventNode() throws Exception - { - NodeRef eventNode= helper.getPublishingEventNode(null); - assertNull("If id is null event shoudl be null!", eventNode); - - eventNode= helper.getPublishingEventNode("foo"); - assertNull("If id is invalid event shoudl be null!", eventNode); - - String nonExistantId = "foo://bar/nonExistantId"; - eventNode= helper.getPublishingEventNode(nonExistantId); - assertNull("If event node does not exist event shoudl be null!", eventNode); - - String nonPublishingEventId = "foo://bar/nonPublishingEventId"; - NodeRef nonPublishingEventNode = new NodeRef(nonPublishingEventId); - when(nodeService.exists(nonPublishingEventNode)).thenReturn(true); - - eventNode= helper.getPublishingEventNode(nonPublishingEventId); - assertNull("Event shoudl exist!", eventNode); - - String publishingEventId = "foo://bar/publishingEventId"; - NodeRef publishingEventNode = new NodeRef(publishingEventId); - when(nodeService.exists(publishingEventNode)).thenReturn(true); - when(nodeService.getType(publishingEventNode)).thenReturn(TYPE_PUBLISHING_EVENT); - - eventNode= helper.getPublishingEventNode(publishingEventId); - assertNotNull("Event shoudl exist!", eventNode); - } - - @Test - public void testGetPublishingEvent() throws Exception - { - // Mock up ContentReader to do nothing. Not testing payload deserialization. - ContentReader reader = mock(ContentReader.class); - InputStream inputStream = mock(InputStream.class); - when(reader.getContentInputStream()).thenReturn(inputStream); - when(contentService.getReader(any(NodeRef.class), any(QName.class))) - .thenReturn(reader); - NodeSnapshotSerializer serializer = mock(NodeSnapshotSerializer.class); - helper.setSerializer(serializer); - - PublishingEvent result = helper.getPublishingEvent((NodeRef)null); - assertNull(result); - - String comment = "The comment"; - Status status = Status.COMPLETED; - Date modified= new Date(); - Date created = new Date(modified.getTime()-3600000); - String creatorName = "The creator"; - String modifierName = "The modifier"; - Calendar schedule = Calendar.getInstance(); - schedule.add(Calendar.MONTH, 6); - Date scheduledTime = schedule.getTime(); - String scheduledTimeZone = schedule.getTimeZone().getID(); - - // Mock up node properties. - Map props = new HashMap(); - props.put(PROP_PUBLISHING_EVENT_COMMENT, comment); - props.put(PROP_PUBLISHING_EVENT_STATUS, status.name()); - props.put(PROP_PUBLISHING_EVENT_TIME, scheduledTime); - props.put(PROP_PUBLISHING_EVENT_TIME_ZONE, scheduledTimeZone); - props.put(ContentModel.PROP_CREATED, created); - props.put(ContentModel.PROP_CREATOR, creatorName); - props.put(ContentModel.PROP_MODIFIED, modified); - props.put(ContentModel.PROP_MODIFIER, modifierName); - - NodeRef eventNode = new NodeRef("foo://bar/eventNode"); - when(nodeService.getProperties(eventNode)).thenReturn(props); - - result = helper.getPublishingEvent(eventNode); - assertEquals(eventNode.toString(), result.getId()); - assertEquals(comment, result.getComment()); - assertEquals(status, result.getStatus()); - assertEquals(schedule, result.getScheduledTime()); - assertEquals(created, result.getCreatedTime()); - assertEquals(creatorName, result.getCreator()); - assertEquals(modified, result.getModifiedTime()); - assertEquals(modifierName, result.getModifier()); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - public void testCreateNode() throws Exception - { - when(permissionService.hasPermission(any(NodeRef.class), anyString())).thenReturn(AccessStatus.ALLOWED); - // Mock serializer since this behaviour is already tested in PublishingPackageSerializerTest. - ContentWriter writer = mock(ContentWriter.class); - when(contentService.getWriter(any(NodeRef.class), eq(PROP_PUBLISHING_EVENT_PAYLOAD), eq(true))) - .thenReturn(writer); - OutputStream outputStream = mock(OutputStream.class); - when(writer.getContentOutputStream()).thenReturn(outputStream); - NodeSnapshotSerializer serializer = mock(NodeSnapshotSerializer.class); - helper.setSerializer(serializer); - - NodeRef queue = new NodeRef("foo://bar/queue"); - NodeRef event = new NodeRef("foo://bar/event"); - - ChildAssociationRef childAssoc = new ChildAssociationRef(ASSOC_PUBLISHING_EVENT, queue, null, event); - when(nodeService.createNode(any(NodeRef.class), any(QName.class), any(QName.class), any(QName.class), anyMap())) - .thenReturn(childAssoc); - - String channelId = "test://channel/id"; - Calendar schedule = Calendar.getInstance(); - String comment = "The comment"; - - PublishingDetails details = new PublishingDetailsImpl() - .setSchedule(schedule) - .setPublishChannelId(channelId) - .setComment(comment); - - NodeRef result = helper.createNode(queue, details); - assertEquals(event, result); - - ArgumentCaptor argument = ArgumentCaptor.forClass(Map.class); - verify(nodeService) - .createNode(eq(queue), eq(ASSOC_PUBLISHING_EVENT), - any(QName.class), eq(TYPE_PUBLISHING_EVENT), - argument.capture()); - Map props = argument.getValue(); - - assertNotNull(props.get(ContentModel.PROP_NAME)); - assertEquals(channelId, props.get(PROP_PUBLISHING_EVENT_CHANNEL)); - assertEquals(comment, props.get(PROP_PUBLISHING_EVENT_COMMENT)); - assertEquals(schedule.getTime(), props.get(PROP_PUBLISHING_EVENT_TIME)); - assertEquals(schedule.getTimeZone().getID(), props.get(PROP_PUBLISHING_EVENT_TIME_ZONE)); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java b/src/test/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java deleted file mode 100644 index 0a637dd2d4..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishingIntegratedTest.java +++ /dev/null @@ -1,178 +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.publishing; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Calendar; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import junit.framework.Assert; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * @author Brian - * @since 4.0 - */ -@Category(OwnJVMTestsCategory.class) -public class PublishingIntegratedTest extends BaseSpringTest -{ - protected ServiceRegistry serviceRegistry; - protected RetryingTransactionHelper retryingTransactionHelper; - protected NodeService nodeService; - protected WorkflowService workflowService; - protected FileFolderService fileFolderService; - protected SiteService siteService; - private ChannelService channelService; - private PublishingService publishingService; - - protected AuthenticationComponent authenticationComponent; - private String siteId; - private AbstractChannelType mockedChannelType = mock(AbstractChannelType.class); - private String channelTypeName; - - @Test - public void testScheduleNewEvent() throws Exception - { - Channel channel = channelService.createChannel(channelTypeName, GUID.generate(), null); - - Set nodes = new HashSet(); - for (int i = 0; i < 4; ++i) - { - nodes.add(nodeService.createNode(channel.getNodeRef(), ContentModel.ASSOC_CONTAINS, QName.createQName( - NamespaceService.CONTENT_MODEL_1_0_URI, Integer.toString(i)), ContentModel.TYPE_CONTENT).getChildRef()); - } - - Calendar schedule = Calendar.getInstance(); - schedule.add(Calendar.HOUR, 1); - - PublishingDetails details = publishingService.createPublishingDetails() - .addNodesToPublish(nodes) - .setPublishChannelId(channel.getId()) - .setSchedule(schedule); - - String eventId = publishingService.scheduleNewEvent(details); - - PublishingEvent event = publishingService.getPublishingEvent(eventId); - - Assert.assertEquals(schedule, event.getScheduledTime()); - Assert.assertEquals(eventId, event.getId()); - Collection entries = event.getPackage().getEntries(); - Assert.assertEquals(4, entries.size()); - for (PublishingPackageEntry entry : entries) - { - Assert.assertTrue(entry.isPublish()); - Assert.assertTrue(nodes.remove(entry.getNodeRef())); - } - Assert.assertTrue(nodes.isEmpty()); - } - - @Test - public void testCancelScheduledEvent() - { - Channel channel = channelService.createChannel(channelTypeName, GUID.generate(), null); - - Set nodes = new HashSet(); - for (int i = 0; i < 4; ++i) - { - nodes.add(nodeService.createNode(channel.getNodeRef(), ContentModel.ASSOC_CONTAINS, QName.createQName( - NamespaceService.CONTENT_MODEL_1_0_URI, Integer.toString(i)), ContentModel.TYPE_CONTENT).getChildRef()); - } - Calendar schedule = Calendar.getInstance(); - schedule.add(Calendar.HOUR, 1); - - PublishingDetails details = publishingService.createPublishingDetails() - .addNodesToPublish(nodes) - .setPublishChannelId(channel.getId()) - .setSchedule(schedule); - String eventId = publishingService.scheduleNewEvent(details); - PublishingEvent event = publishingService.getPublishingEvent(eventId); - Assert.assertNotNull(event); - publishingService.cancelPublishingEvent(eventId); - event = publishingService.getPublishingEvent(eventId); - Assert.assertNull(event); - } - - /** - * @throws java.lang.Exception - */ - @Override - @Before - public void onSetUp() throws Exception - { - serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); - serviceRegistry.getAuthenticationService().authenticate("admin", "admin".toCharArray()); - - retryingTransactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); - fileFolderService = serviceRegistry.getFileFolderService(); - workflowService = serviceRegistry.getWorkflowService(); - nodeService = serviceRegistry.getNodeService(); - siteService = serviceRegistry.getSiteService(); - - channelService = (ChannelService) applicationContext.getBean("ChannelService"); - publishingService = (PublishingService) applicationContext.getBean("PublishingService"); - siteId = GUID.generate(); - siteService.createSite("test", siteId, "Test site created by ChannelServiceImplIntegratedTest", - "Test site created by PublishingIntegratedTest", SiteVisibility.PUBLIC); - - channelTypeName = "MockedChannelType"; - when(mockedChannelType.getId()).thenReturn(channelTypeName); - when(mockedChannelType.getChannelNodeType()).thenReturn(PublishingModel.TYPE_DELIVERY_CHANNEL); - - if (channelService.getChannelType(channelTypeName)== null) - { - channelService.register(mockedChannelType); - } - } -} \ No newline at end of file diff --git a/src/test/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java b/src/test/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java deleted file mode 100644 index 03c5ef1a26..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishingPackageSerializerTest.java +++ /dev/null @@ -1,146 +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.publishing; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.Serializable; -import java.util.ArrayList; -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 javax.annotation.Resource; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.transfer.manifest.TransferManifestNormalNode; -import org.alfresco.service.cmr.publishing.NodeSnapshot; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.GUID; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * @author Brian - * @author Nick Smith - * @since 4.0 - */ -@Category(OwnJVMTestsCategory.class) -public class PublishingPackageSerializerTest extends AbstractPublishingIntegrationTest -{ - @Resource(name="publishingPackageSerializer") - private StandardNodeSnapshotSerializer serializer; - - private TransferManifestNormalNode normalNode1; - - /** - * @throws java.lang.Exception - */ - @Before - @Override - public void onSetUp() throws Exception - { - super.onSetUp(); - serializer = (StandardNodeSnapshotSerializer) getApplicationContext().getBean("publishingPackageSerializer"); - normalNode1 = new TransferManifestNormalNode(); - normalNode1.setAccessControl(null); - - Set aspects = new HashSet(); - aspects.add(ContentModel.ASPECT_AUDITABLE); - aspects.add(ContentModel.ASPECT_TITLED); - normalNode1.setAspects(aspects); - - List childAssocs = new ArrayList(); - normalNode1.setChildAssocs(childAssocs); - - String guid = GUID.generate(); - NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, guid); - normalNode1.setNodeRef(nodeRef); - - ChildAssociationRef primaryParentAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, new NodeRef( - StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "MY_PARENT_NODEREF"), QName.createQName( - NamespaceService.CONTENT_MODEL_1_0_URI, "localname"), nodeRef, true, -1); - List parentAssocs = new ArrayList(); - parentAssocs.add(primaryParentAssoc); - normalNode1.setParentAssocs(parentAssocs); - - Path path = new Path(); - path.append(new Path.ChildAssocElement(primaryParentAssoc)); - normalNode1.setParentPath(path); - - normalNode1.setPrimaryParentAssoc(primaryParentAssoc); - - Map props = new HashMap(); - props.put(ContentModel.PROP_NAME, guid); - normalNode1.setProperties(props); - - List sourceAssocs = new ArrayList(); - sourceAssocs.add(new AssociationRef(nodeRef, ContentModel.ASSOC_ATTACHMENTS, nodeRef)); - sourceAssocs.add(new AssociationRef(nodeRef, ContentModel.ASSOC_REFERENCES, nodeRef)); - normalNode1.setSourceAssocs(sourceAssocs); - - List targetAssocs = new ArrayList(); - targetAssocs.add(new AssociationRef(nodeRef, ContentModel.ASSOC_ATTACHMENTS, nodeRef)); - targetAssocs.add(new AssociationRef(nodeRef, ContentModel.ASSOC_REFERENCES, nodeRef)); - normalNode1.setTargetAssocs(targetAssocs); - - normalNode1.setType(ContentModel.TYPE_CONTENT); - normalNode1.setAncestorType(ContentModel.TYPE_CONTENT); - normalNode1.setUuid(guid); - } - - @Test - public void testSerializer() throws Exception - { - NodeSnapshotTransferImpl transferSnapshot = new NodeSnapshotTransferImpl(normalNode1); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - serializer.serialize(Collections.singleton(transferSnapshot), os); - os.close(); - - byte[] output = os.toByteArray(); - - ByteArrayInputStream is = new ByteArrayInputStream(output); - List snapshots = serializer.deserialize(is); - assertEquals(1, snapshots.size()); - NodeSnapshot snapshot = snapshots.get(0); - assertEquals(normalNode1.getNodeRef(), snapshot.getNodeRef()); - assertEquals(normalNode1.getType(), snapshot.getType()); - assertEquals(normalNode1.getAspects(), snapshot.getAspects()); - assertEquals(normalNode1.getProperties(), snapshot.getProperties()); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java b/src/test/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java deleted file mode 100644 index c2acf4db9f..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishingQueueImplTest.java +++ /dev/null @@ -1,251 +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.publishing; - -import static org.alfresco.model.ContentModel.PROP_VERSION_LABEL; -import static org.alfresco.repo.publishing.PublishingModel.PROP_PUBLISHING_EVENT_WORKFLOW_ID; -import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_PUBLISHING_EVENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_WF_SCHEDULED_PUBLISH_DATE; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingPackage; -import org.alfresco.service.cmr.publishing.PublishingPackageEntry; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.publishing.StatusUpdate; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.workflow.WorkflowInstance; -import org.alfresco.service.cmr.workflow.WorkflowPath; -import org.alfresco.service.cmr.workflow.WorkflowService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.GUID; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * @author Nick Smith - * @since 4.0 - */ -@Category(OwnJVMTestsCategory.class) -public class PublishingQueueImplTest extends AbstractPublishingIntegrationTest -{ - private static final String channelId = "test://channel/node"; - private static final String comment = "The Comment"; - - private PublishingService publishingService; - private WorkflowService workflowService; - - @Test - public void testScheduleNewPublishingEvent() throws Exception - { - NodeRef firstNode = createContent("First"); - NodeRef secondNode = createContent("second"); - - assertNull(nodeService.getProperty(firstNode, PROP_VERSION_LABEL)); - assertNull(nodeService.getProperty(firstNode, PROP_VERSION_LABEL)); - - Calendar schedule = Calendar.getInstance(); - schedule.add(Calendar.HOUR, 2); - - PublishingDetails details = publishingService.createPublishingDetails() - .addNodesToPublish(firstNode, secondNode) - .setPublishChannelId(channelId) - .setSchedule(schedule) - .setComment(comment); - - String eventId = testHelper.scheduleEvent(details); - - //Check schedule triggered versioning. - Serializable version = nodeService.getProperty(firstNode, PROP_VERSION_LABEL); - assertNotNull(version); - - PublishingEvent event = publishingService.getPublishingEvent(eventId); - assertEquals(eventId, event.getId()); - assertEquals(comment, event.getComment()); - assertEquals(Status.SCHEDULED, event.getStatus()); - assertEquals(AuthenticationUtil.getAdminUserName(), event.getCreator()); - assertEquals(schedule, event.getScheduledTime()); - assertEquals(channelId, event.getChannelId()); - assertNull(event.getStatusUpdate()); - - PublishingPackage pckg = event.getPackage(); - ArrayList toPublish = new ArrayList(2); - ArrayList toUnpublish = new ArrayList(1); - for (PublishingPackageEntry entry : pckg.getEntries()) - { - if (entry.isPublish()) - { - assertNotNull(entry.getSnapshot()); - toPublish.add(entry.getNodeRef()); - } - else - { - toUnpublish.add(entry.getNodeRef()); - } - } - - assertEquals(2, toPublish.size()); - assertTrue(toPublish.contains(firstNode)); - assertTrue(toPublish.contains(secondNode)); - - assertEquals(0, toUnpublish.size()); - - // Check the correct version is recorded in the entry. - PublishingPackageEntry entry = pckg.getEntryMap().get(firstNode); - assertEquals(version, entry.getSnapshot().getVersion()); - - NodeRef eventNode = new NodeRef(eventId); - String wfId = (String) nodeService.getProperty(eventNode, PROP_PUBLISHING_EVENT_WORKFLOW_ID); - - WorkflowInstance instance = workflowService.getWorkflowById(wfId); - assertNotNull(instance); - List paths = workflowService.getWorkflowPaths(wfId); - assertEquals(2, paths.size()); - Map props = workflowService.getPathProperties(paths.get(0).getId()); - assertEquals(eventNode, props.get(PROP_WF_PUBLISHING_EVENT)); - assertEquals(schedule, props.get(PROP_WF_SCHEDULED_PUBLISH_DATE)); - } - - @Test - public void testScheduleNewPublishingEventWithStatusUpdate() throws Exception - { - NodeRef firstNode = createContent("First"); - NodeRef secondNode = createContent("Second"); - - List statusChannels = Arrays.asList("test://channel/Channel1", "test://channel/Channel2", "test://channel/Channel3" ); - String message = "The message"; - PublishingDetails details = publishingService.createPublishingDetails() - .setPublishChannelId(channelId) - .addNodesToPublish(firstNode, secondNode) - .setStatusMessage(message) - .setStatusNodeToLinkTo(secondNode) - .addStatusUpdateChannels(statusChannels); - - // Publish an event with the StatusUpdate - String eventId = testHelper.scheduleEvent1Year(details); - - PublishingEvent event = publishingService.getPublishingEvent(eventId); - StatusUpdate actualUpdate = event.getStatusUpdate(); - assertEquals(message, actualUpdate.getMessage()); - assertEquals(secondNode, actualUpdate.getNodeToLinkTo()); - Set names = actualUpdate.getChannelIds(); - assertEquals(3, names.size()); - assertTrue(names.containsAll(statusChannels)); - } - - @Test - public void testScheduleNewEventPermissions() throws Exception - { - // Create Channels as Admin - testHelper.mockChannelType(channelTypeId); - Channel publishChannel = testHelper.createChannel(channelTypeId); - Channel statusChannel = testHelper.createChannel(channelTypeId); - - NodeRef firstNode = createContent("First"); - NodeRef secondNode = createContent("Second"); - - // Create User1, add read permissions and set as current user. - String user1 = GUID.generate(); - personManager.createPerson(user1); - testHelper.setChannelPermission(user1, publishChannel.getId(), PermissionService.READ); - testHelper.setChannelPermission(user1, statusChannel.getId(), PermissionService.READ); - personManager.setUser(user1); - - // Publish an event - PublishingDetails details = publishingService.createPublishingDetails(); - details.addNodesToPublish(firstNode, secondNode); - details.setPublishChannelId(publishChannel.getId()); - try - { - testHelper.scheduleEvent1Year(details); - fail("shceduleNewEvent should have thrown an AccessDeniedException!"); - } - catch(AlfrescoRuntimeException e) - { - //NOOP - } - - // Set Add Child permission on publish channel. - testHelper.allowChannelAccess(user1, publishChannel.getId()); - - // Check publish works now. - String eventId = testHelper.scheduleEvent1Year(details); - assertNotNull(eventId); - - String message = "The message"; - details.setStatusMessage(message) - .setStatusNodeToLinkTo(secondNode) - .addStatusUpdateChannels(statusChannel.getId()); - try - { - eventId = testHelper.scheduleEvent1Year(details); - fail("shceduleNewEvent with status update should have thrown an AccessDeniedException!"); - } - catch(AlfrescoRuntimeException e) - { - //NOOP - } - - // Set Add Child permission on status channel. - testHelper.allowChannelAccess(user1, statusChannel.getId()); - - // Check publish works now. - eventId = testHelper.scheduleEvent1Year(details); - assertNotNull(eventId); - } - - private NodeRef createContent(String name) - { - return testHelper.createContentNode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public void onSetUp() throws Exception - { - super.onSetUp(); - this.workflowService = serviceRegistry.getWorkflowService(); - this.publishingService = (PublishingService) getApplicationContext().getBean("publishingService"); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java b/src/test/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java deleted file mode 100644 index 866614f20a..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishingRootObjectTest.java +++ /dev/null @@ -1,89 +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.publishing; - -import javax.annotation.Resource; - -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * @author Nick Smith - * @since 4.0 - */ -@Category(OwnJVMTestsCategory.class) -public class PublishingRootObjectTest extends AbstractPublishingIntegrationTest -{ - @Resource(name="publishingRootObject") - private PublishingRootObject rootObject; - - @Test - public void testGetEnvironment() throws Exception - { - Environment theEnvironment = rootObject.getEnvironment(); - assertNotNull(theEnvironment); - assertTrue(nodeService.exists(theEnvironment.getNodeRef())); - assertEquals(PublishingModel.TYPE_ENVIRONMENT, nodeService.getType(theEnvironment.getNodeRef())); - } - - @Test - public void testGetPublishingQueue() throws Exception - { - PublishingQueueImpl theQueue = rootObject.getPublishingQueue(); - assertNotNull(theQueue); - NodeRef queueNode = theQueue.getNodeRef(); - assertTrue(nodeService.exists(queueNode)); - assertEquals(PublishingModel.TYPE_PUBLISHING_QUEUE, nodeService.getType(queueNode)); - ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(queueNode); - assertEquals(PublishingModel.ASSOC_PUBLISHING_QUEUE, parentAssoc.getTypeQName()); - assertEquals(rootObject.getEnvironment().getNodeRef(), parentAssoc.getParentRef()); - } - - @Test - public void testGetChannelContainer() throws Exception - { - NodeRef channels = rootObject.getChannelContainer(); - assertNotNull(channels); - assertTrue(nodeService.exists(channels)); - assertEquals(ContentModel.TYPE_FOLDER, nodeService.getType(channels)); - ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(channels); - assertEquals(PublishingRootObject.CHANNELS_QNAME, parentAssoc.getQName()); - assertEquals(rootObject.getEnvironment().getNodeRef(), parentAssoc.getParentRef()); - } - - @Override - public void onSetUp() throws Exception - { - super.onSetUp(); - this.rootObject = (PublishingRootObject) getApplicationContext().getBean(PublishingRootObject.NAME); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/PublishingTestHelper.java b/src/test/java/org/alfresco/repo/publishing/PublishingTestHelper.java deleted file mode 100644 index f07c22f2b3..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/PublishingTestHelper.java +++ /dev/null @@ -1,312 +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.publishing; - -import static org.alfresco.model.ContentModel.TYPE_CONTENT; -import static org.alfresco.repo.publishing.PublishingModel.PROP_AUTHORISATION_COMPLETE; -import static org.alfresco.repo.publishing.PublishingModel.TYPE_DELIVERY_CHANNEL; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.Serializable; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.PublishingDetails; -import org.alfresco.service.cmr.publishing.PublishingEvent; -import org.alfresco.service.cmr.publishing.PublishingQueue; -import org.alfresco.service.cmr.publishing.PublishingService; -import org.alfresco.service.cmr.publishing.Status; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.publishing.channels.ChannelType; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.GUID; - -/** - * @author Nick Smith - * @since 4.0 - */ -public class PublishingTestHelper -{ - private final ChannelService channelService; - private final PublishingService publishingService; - private final SiteService siteService; - private final FileFolderService fileFolderService; - private final PermissionService permissionService; - - private final NodeRef docLib; - private final String siteId = GUID.generate(); - - private final List channels = new LinkedList(); - private final List events = new LinkedList(); - - public PublishingTestHelper(ChannelService channelService, - PublishingService publishingService, - SiteService siteService, - FileFolderService fileFolderService, - PermissionService permissionService) - { - this.channelService = channelService; - this.publishingService = publishingService; - this.siteService = siteService; - this.fileFolderService = fileFolderService; - this.permissionService = permissionService; - - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - siteService.createSite("test", siteId, - "Test site created by ChannelServiceImplIntegratedTest", - "Test site created by ChannelServiceImplIntegratedTest", - SiteVisibility.PUBLIC); - this.docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); - } - - - public void tearDown() throws Exception - { - AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); - try - { - cancelAllEvents(); - } - finally - { - try - { - deleteAllChannels(); - } - finally - { - deleteSite(); - } - } - } - - private void deleteSite() - { - try - { - siteService.deleteSite(siteId); - } - catch (Throwable t) - { - //NOOP - } - } - - private void deleteAllChannels() - { - for (Channel channel : channels) - { - try - { - channelService.deleteChannel(channel); - } - catch (Throwable t) - { - //NOOP - } - } - } - - private void cancelAllEvents() - { - for (String event : events) - { - try - { - publishingService.cancelPublishingEvent(event); - } - catch (Throwable t) - { - //NOOP - } - } - } - - public AbstractChannelType mockChannelType(String channelTypeId) - { - AbstractChannelType channelType = (AbstractChannelType) channelService.getChannelType(channelTypeId); - if (channelType != null) - { - reset(channelType); - when(channelType.getId()).thenReturn(channelTypeId); - when(channelType.getTitle()).thenReturn(channelTypeId); - } - else - { - channelType = mock(AbstractChannelType.class); - when(channelType.getId()).thenReturn(channelTypeId); - when(channelType.getTitle()).thenReturn(channelTypeId); - channelService.register(channelType); - } - when(channelType.getChannelNodeType()).thenReturn(TYPE_DELIVERY_CHANNEL); - return channelType; - } - - public Channel createChannel(String typeId) - { - String channelName = GUID.generate(); - return createChannel(typeId, channelName); - } - - public Channel createChannel(String typeId, String channelName) - { - return createChannel(typeId, channelName, true); - } - - public Channel createChannel(String typeId, String channelName, boolean isAuthorised) - { - Channel channel = channelService.createChannel(typeId, channelName, null); - channels.add(channel); - Map properties = Collections.singletonMap(PROP_AUTHORISATION_COMPLETE, (Serializable)isAuthorised); - channelService.updateChannel(channel, properties); - return channel; - } - - public void allowChannelAccess(String username, String channelId) - { - setChannelPermission(username, channelId, PermissionService.ADD_CHILDREN); - } - - public void setChannelPermission(final String username, String channelId, final String permission) - { - final NodeRef channel = new NodeRef(channelId); - AuthenticationUtil.runAs(new RunAsWork() - { - public Void doWork() throws Exception - { - permissionService.setPermission(channel, username, permission, true); - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - public String scheduleEvent1Year(PublishingDetails details) - { - Calendar schedule = Calendar.getInstance(); - schedule.add(Calendar.YEAR, 1); - details.setSchedule(schedule); - return scheduleEvent(details); - } - - public String scheduleEvent(PublishingDetails details) - { - String eventId = publishingService.scheduleNewEvent(details); - events.add(eventId); - return eventId; - } - - public void addEvent(String eventId) - { - events.add(eventId); - } - - public void addEvents(Collection eventIds) - { - events.addAll(eventIds); - } - - public NodeRef createContentNode(String name) - { - return fileFolderService.create(docLib, name, TYPE_CONTENT).getNodeRef(); - } - - public NodeRef createContentNode(String name, File theContent, String mimetype) - { - NodeRef source = createContentNode(name); - writeContent(source, theContent, mimetype); - return source; - } - - public NodeRef createContentNode(String name, String theContent, String mimetype) - { - NodeRef source = fileFolderService.create(docLib, name, TYPE_CONTENT).getNodeRef(); - writeContent(source, theContent, mimetype); - return source; - } - - public void writeContent(NodeRef source, String theContent, String mimetype) - { - ContentWriter writer = fileFolderService.getWriter(source); - writer.setEncoding("UTF-8"); - writer.putContent(theContent); - writer.setMimetype(mimetype); - } - - public void writeContent(NodeRef source, File theContent, String mimetype) - { - ContentWriter writer = fileFolderService.getWriter(source); - writer.setMimetype(mimetype); - writer.setEncoding("UTF-8"); - writer.putContent(theContent); - } - - - public PublishingEvent publishAndWait(final PublishingDetails details, RetryingTransactionHelper transactionHelper) throws InterruptedException - { - RetryingTransactionCallback startWorkflowCallback = new RetryingTransactionCallback() - { - public String execute() throws Throwable - { - return scheduleEvent(details); - } - }; - String eventId = transactionHelper.doInTransaction(startWorkflowCallback); - - int i = 0; - while (i < 100) - { - Thread.sleep(200); - PublishingEvent event = publishingService.getPublishingEvent(eventId); - Status status = event.getStatus(); - if (Status.IN_PROGRESS != status && Status.SCHEDULED != status) - { - return event; - } - i++; - } - throw new IllegalStateException("The publishing event did not complete after 20s!"); - } -} diff --git a/src/test/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java b/src/test/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java deleted file mode 100644 index 5ca9dc6c62..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/WebPublishingTestSuite.java +++ /dev/null @@ -1,50 +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.publishing; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * @author Nick Smith - * @since 4.0 - */ -@RunWith(Suite.class) -@Suite.SuiteClasses( { ChannelServiceImplTest.class, - PublishingEventHelperTest.class, - ChannelServiceImplIntegratedTest.class, - PublishingRootObjectTest.class, -// EnvironmentImplTest.class, - PublishingQueueImplTest.class, - PublishingPackageSerializerTest.class, -// PublishEventActionTest.class, - PublishingIntegratedTest.class - }) -public class WebPublishingTestSuite -{ - //NOOP -} diff --git a/src/test/java/org/alfresco/repo/publishing/flickr/FlickrTest.java b/src/test/java/org/alfresco/repo/publishing/flickr/FlickrTest.java deleted file mode 100644 index 3e5ab2263b..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/flickr/FlickrTest.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.publishing.flickr; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.node.archive.NodeArchiveService; -import org.alfresco.repo.publishing.Environment; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.repo.publishing.PublishingQueueImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -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.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; -import org.junit.Assert; -import org.junit.experimental.categories.Category; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -/** - * @author Brian - * @since 4.0 - */ -@Category(BaseSpringTestsCategory.class) -public class FlickrTest extends BaseSpringTest -{ - protected ServiceRegistry serviceRegistry; - protected SiteService siteService; - protected FileFolderService fileFolderService; - protected NodeService nodeService; - protected String siteId; - protected PublishingQueueImpl queue; - protected Environment environment; - protected NodeRef docLib; - protected NodeArchiveService nodeArchiveService; - - private ChannelService channelService; - - private RetryingTransactionHelper transactionHelper; - - public void onSetUp() throws Exception - { - serviceRegistry = (ServiceRegistry) getApplicationContext().getBean("ServiceRegistry"); - channelService = (ChannelService) getApplicationContext().getBean("channelService"); - nodeArchiveService = (NodeArchiveService) getApplicationContext().getBean("nodeArchiveService"); - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - siteService = serviceRegistry.getSiteService(); - fileFolderService = serviceRegistry.getFileFolderService(); - nodeService = serviceRegistry.getNodeService(); - transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); - - siteId = GUID.generate(); - siteService.createSite("test", siteId, "Site created by publishing test", "Site created by publishing test", - SiteVisibility.PUBLIC); - docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); - } - - public void onTearDown() - { - SiteInfo siteInfo = siteService.getSite(siteId); - if (siteInfo != null) - { - siteService.deleteSite(siteId); - nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteInfo.getNodeRef())); - } - } - - public void testBlank() - { - } - - //Note that this test isn't normally run, as it requires a valid Flickr OAuth token. - //To run it, remove the initial 'x' from the method name and set the appropriate values where the - //text "YOUR_OAUTH_TOKEN_VALUE" and "YOUR_OAUTH_TOKEN_SECRET" appear. Note that these can be quite tricky to obtain... - public void xtestFlickrPublishAndUnpublishActions() throws Exception - { - final String channelName = "FlickrTestChannel_" + GUID.generate(); - final FlickrChannelType channelType = (FlickrChannelType) channelService.getChannelType(FlickrChannelType.ID); - final NodeRef contentNode = transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - Map props = new HashMap(); - props.put(PublishingModel.PROP_OAUTH1_TOKEN_VALUE, "YOUR_OAUTH_TOKEN_VALUE"); - props.put(PublishingModel.PROP_OAUTH1_TOKEN_SECRET, "YOUR_OAUTH_TOKEN_SECRET"); - props.put(PublishingModel.PROP_AUTHORISATION_COMPLETE, Boolean.TRUE); - - Channel channel = channelService.createChannel(FlickrChannelType.ID, channelName, props); - //This looks a little odd, but a new channel always has its "authorisation complete" flag - //forced off initially. This will force it on for this channel... - channelService.updateChannel(channel, props); - - NodeRef channelNode = channel.getNodeRef(); - Resource file = new ClassPathResource("test/alfresco/TestImageFile.png"); - Map contentProps = new HashMap(); - contentProps.put(ContentModel.PROP_NAME, "Test Image"); - NodeRef contentNode = nodeService.createNode(channelNode, ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testImage"), - ContentModel.TYPE_CONTENT, contentProps).getChildRef(); - ContentService contentService = serviceRegistry.getContentService(); - ContentWriter writer = contentService.getWriter(contentNode, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_IMAGE_PNG); - writer.putContent(file.getFile()); - return contentNode; - } - }); - transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - Channel channel = channelService.getChannelByName(channelName); - channelType.publish(contentNode, channel.getProperties()); - - Map props = nodeService.getProperties(contentNode); - Assert.assertTrue(nodeService.hasAspect(contentNode, FlickrPublishingModel.ASPECT_ASSET)); - Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_ID)); - Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_URL)); - - System.out.println("Asset id: " + props.get(PublishingModel.PROP_ASSET_ID)); - System.out.println("Asset URL: " + props.get(PublishingModel.PROP_ASSET_URL)); - - channelType.unpublish(contentNode, channel.getProperties()); - - props = nodeService.getProperties(contentNode); - Assert.assertFalse(nodeService.hasAspect(contentNode, FlickrPublishingModel.ASPECT_ASSET)); - Assert.assertFalse(nodeService.hasAspect(contentNode, PublishingModel.ASPECT_ASSET)); - Assert.assertNull(props.get(PublishingModel.PROP_ASSET_ID)); - Assert.assertNull(props.get(PublishingModel.PROP_ASSET_URL)); - return null; - } - }); - - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/slideshare/SlideShareTest.java b/src/test/java/org/alfresco/repo/publishing/slideshare/SlideShareTest.java deleted file mode 100644 index 34ceb954c5..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/slideshare/SlideShareTest.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.publishing.slideshare; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.node.archive.NodeArchiveService; -import org.alfresco.repo.publishing.Environment; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.repo.publishing.PublishingQueueImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.repository.ContentIOException; -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.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; -import org.junit.Assert; -import org.junit.experimental.categories.Category; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -/** - * - * @author Brian - * @since 4.0 - */ -@Category(BaseSpringTestsCategory.class) -public class SlideShareTest extends BaseSpringTest -{ - protected ServiceRegistry serviceRegistry; - protected SiteService siteService; - protected FileFolderService fileFolderService; - protected NodeService nodeService; - protected String siteId; - protected PublishingQueueImpl queue; - protected Environment environment; - protected NodeRef docLib; - protected Map testFiles = new TreeMap(); - protected Map testNodeMap = new HashMap(); - protected NodeArchiveService nodeArchiveService; - - private ChannelService channelService; - - private RetryingTransactionHelper transactionHelper; - - public void onSetUp() throws Exception - { - serviceRegistry = (ServiceRegistry) getApplicationContext().getBean("ServiceRegistry"); - channelService = (ChannelService) getApplicationContext().getBean("channelService"); - nodeArchiveService = (NodeArchiveService) getApplicationContext().getBean("nodeArchiveService"); - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - siteService = serviceRegistry.getSiteService(); - fileFolderService = serviceRegistry.getFileFolderService(); - nodeService = serviceRegistry.getNodeService(); - transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); - - siteId = GUID.generate(); - siteService.createSite("test", siteId, "Site created by publishing test", "Site created by publishing test", - SiteVisibility.PUBLIC); - docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); - - testFiles.put("test/alfresco/TestPresentation.pptx", MimetypeMap.MIMETYPE_OPENXML_PRESENTATION); - testFiles.put("test/alfresco/TestPresentation2.ppt", MimetypeMap.MIMETYPE_PPT); - testFiles.put("test/alfresco/TestPresentation3.odp", MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION); - testFiles.put("test/alfresco/TestPresentation4.pdf", MimetypeMap.MIMETYPE_PDF); - } - - public void onTearDown() - { - SiteInfo siteInfo = siteService.getSite(siteId); - if (siteInfo != null) - { - siteService.deleteSite(siteId); - nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteInfo.getNodeRef())); - } - } - - public void testBlank() - { - - } - - // Note that this test isn't normally run, as it requires valid YouTube - // credentials. - // To run it, remove the initial 'x' from the method name and set the - // appropriate YouTube credentials where the - // text "YOUR_USER_NAME" and "YOUR_PASSWORD" appear. - public void xtestSlideSharePublishAndUnpublishActions() throws Exception - { - final SlideShareChannelType channelType = (SlideShareChannelType)channelService.getChannelType(SlideShareChannelType.ID); - final String channelName = GUID.generate(); - final List nodes = transactionHelper.doInTransaction(new RetryingTransactionCallback>() - { - public List execute() throws Throwable - { - List createdTestNodes = new ArrayList(); - Map props = new HashMap(); - // props.put(PublishingModel.PROP_CHANNEL_USERNAME, - // "YOUR_USER_NAME"); - // props.put(PublishingModel.PROP_CHANNEL_PASSWORD, - // "YOUR_PASSWORD"); - props.put(PublishingModel.PROP_CHANNEL_USERNAME, "YOUR_USER_NAME"); - props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "YOUR_PASSWORD"); - Channel channel = channelService.createChannel(SlideShareChannelType.ID, channelName, props); - - NodeRef channelNode = channel.getNodeRef(); - - for (Map.Entry testFileInfoEntry : testFiles.entrySet()) - { - NodeRef nodeRef = createTestNode(channelNode, testFileInfoEntry.getKey(), testFileInfoEntry - .getValue()); - createdTestNodes.add(nodeRef); - testNodeMap.put(nodeRef, testFileInfoEntry.getKey()); - } - return createdTestNodes; - } - - private NodeRef createTestNode(NodeRef parent, String fileLocation, String mimeType) - throws ContentIOException, IOException - { - Resource file = new ClassPathResource(fileLocation); - Map props = new HashMap(); - props.put(ContentModel.PROP_NAME, "Presentation " + GUID.generate()); - NodeRef node = nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, GUID.generate()), - ContentModel.TYPE_CONTENT, props).getChildRef(); - ContentService contentService = serviceRegistry.getContentService(); - ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true); - writer.setMimetype(mimeType); - writer.putContent(file.getFile()); - return node; - } - }); - - transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - Map channelProperties = channelService.getChannelByName(channelName).getProperties(); - for (NodeRef node : nodes) - { - channelType.publish(node, channelProperties); - Map props = nodeService.getProperties(node); - Assert.assertTrue(nodeService.hasAspect(node, SlideSharePublishingModel.ASPECT_ASSET)); - Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_ID)); - Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_URL)); - - System.out.println("Published test file: " + testNodeMap.get(node)); - System.out.println("SlideShare id: " + props.get(PublishingModel.PROP_ASSET_ID)); - System.out.println("SlideShare URL: " + props.get(PublishingModel.PROP_ASSET_URL)); - } - - for (NodeRef node : nodes) - { - Map props = nodeService.getProperties(node); - channelType.unpublish(node, channelProperties); - props = nodeService.getProperties(node); - Assert.assertFalse(nodeService.hasAspect(node, SlideSharePublishingModel.ASPECT_ASSET)); - Assert.assertNull(props.get(PublishingModel.PROP_ASSET_ID)); - Assert.assertNull(props.get(PublishingModel.PROP_ASSET_URL)); - - System.out.println("Unpublished test file: " + testNodeMap.get(node)); - } - return null; - } - }); - - transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - for (NodeRef node : nodes) - { - nodeService.deleteNode(node); - } - return null; - } - }); - - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/test/SiteType.java b/src/test/java/org/alfresco/repo/publishing/test/SiteType.java deleted file mode 100644 index 6420d73eb5..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/test/SiteType.java +++ /dev/null @@ -1,98 +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.publishing.test; - -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * - * @author Brian Remmington - */ -public class SiteType -{ - /** Log */ - private final static Log log = LogFactory.getLog(SiteType.class); - - private PolicyComponent policyComponent; - private ChannelService channelService; - - /** - * This is the list of collections that will be created automatically for - * any new section. - */ - /** - * Set the policy component - * - * @param policyComponent - * policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - public void setChannelService(ChannelService channelService) - { - this.channelService = channelService; - } - - /** - * Init method. Binds model behaviours to policies. - */ - public void init() - { - // Register the association behaviours - policyComponent.bindClassBehaviour(NodeServicePolicies.OnCreateNodePolicy.QNAME, SiteModel.TYPE_SITE, - new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT)); - } - - /** - * On create node behaviour - * - * @param childAssocRef - * child association reference - */ - public void onCreateNode(ChildAssociationRef childAssocRef) - { - if (log.isDebugEnabled()) - { - log.debug("onCreateNode " + childAssocRef); - } - String siteId = childAssocRef.getQName().getLocalName(); - channelService.createChannel("TestChannelType1", "Test Channel One", null); - channelService.createChannel("TestChannelType2", "Test Channel Two", null); - channelService.createChannel("TestChannelType3", "Test Channel Three", null); - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/test/TestChannelType1.java b/src/test/java/org/alfresco/repo/publishing/test/TestChannelType1.java deleted file mode 100644 index 25786a4d41..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/test/TestChannelType1.java +++ /dev/null @@ -1,120 +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.publishing.test; - -import java.io.Serializable; -import java.util.Map; -import java.util.Set; - -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -public class TestChannelType1 extends AbstractChannelType -{ - - @Override - public boolean canPublish() - { - return true; - } - - @Override - public boolean canPublishStatusUpdates() - { - return false; - } - - @Override - public boolean canUnpublish() - { - return false; - } - - @Override - public QName getChannelNodeType() - { - return PublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return "TestChannelType1"; - } - - @Override - public int getMaximumStatusLength() - { - return 0; - } - - @Override - public String getNodeUrl(NodeRef node) - { - return node.getId(); - } - - @Override - public Set getSupportedContentTypes() - { - return null; - } - - @Override - public Set getSupportedMimeTypes() - { - return null; - } - - @Override - public void publish(NodeRef nodeToPublish, Map properties) - { - //Deliberately blank - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map properties) - { - //Deliberately blank - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - //Deliberately blank - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - return null; - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/test/TestChannelType2.java b/src/test/java/org/alfresco/repo/publishing/test/TestChannelType2.java deleted file mode 100644 index cab9e18a98..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/test/TestChannelType2.java +++ /dev/null @@ -1,120 +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.publishing.test; - -import java.io.Serializable; -import java.util.Map; -import java.util.Set; - -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -public class TestChannelType2 extends AbstractChannelType -{ - - @Override - public boolean canPublish() - { - return true; - } - - @Override - public boolean canPublishStatusUpdates() - { - return true; - } - - @Override - public boolean canUnpublish() - { - return false; - } - - @Override - public QName getChannelNodeType() - { - return PublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return "TestChannelType2"; - } - - @Override - public int getMaximumStatusLength() - { - return 140; - } - - @Override - public String getNodeUrl(NodeRef node) - { - return node.getId(); - } - - @Override - public Set getSupportedContentTypes() - { - return null; - } - - @Override - public Set getSupportedMimeTypes() - { - return null; - } - - @Override - public void publish(NodeRef nodeToPublish, Map properties) - { - //Deliberately blank - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map properties) - { - //Deliberately blank - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - //Deliberately blank - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - return null; - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/test/TestChannelType3.java b/src/test/java/org/alfresco/repo/publishing/test/TestChannelType3.java deleted file mode 100644 index 3474f8732d..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/test/TestChannelType3.java +++ /dev/null @@ -1,120 +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.publishing.test; - -import java.io.Serializable; -import java.util.Map; -import java.util.Set; - -import org.alfresco.repo.publishing.AbstractChannelType; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; - -public class TestChannelType3 extends AbstractChannelType -{ - - @Override - public boolean canPublish() - { - return false; - } - - @Override - public boolean canPublishStatusUpdates() - { - return true; - } - - @Override - public boolean canUnpublish() - { - return false; - } - - @Override - public QName getChannelNodeType() - { - return PublishingModel.TYPE_DELIVERY_CHANNEL; - } - - @Override - public String getId() - { - return "TestChannelType3"; - } - - @Override - public int getMaximumStatusLength() - { - return 200; - } - - @Override - public String getNodeUrl(NodeRef node) - { - return node.getId(); - } - - @Override - public Set getSupportedContentTypes() - { - return null; - } - - @Override - public Set getSupportedMimeTypes() - { - return null; - } - - @Override - public void publish(NodeRef nodeToPublish, Map properties) - { - //Deliberately blank - } - - @Override - public void unpublish(NodeRef nodeToUnpublish, Map properties) - { - //Deliberately blank - } - - @Override - public void sendStatusUpdate(Channel channel, String status) - { - //Deliberately blank - } - - @Override - public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl) - { - return null; - } - -} diff --git a/src/test/java/org/alfresco/repo/publishing/youtube/YouTubeTest.java b/src/test/java/org/alfresco/repo/publishing/youtube/YouTubeTest.java deleted file mode 100644 index 2ace292f52..0000000000 --- a/src/test/java/org/alfresco/repo/publishing/youtube/YouTubeTest.java +++ /dev/null @@ -1,180 +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.publishing.youtube; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.node.archive.NodeArchiveService; -import org.alfresco.repo.publishing.Environment; -import org.alfresco.repo.publishing.PublishingModel; -import org.alfresco.repo.publishing.PublishingQueueImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.publishing.channels.Channel; -import org.alfresco.service.cmr.publishing.channels.ChannelService; -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.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; -import org.junit.Assert; -import org.junit.experimental.categories.Category; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -/** - * - * @author Brian - * @since 4.0 - */ -@Category(BaseSpringTestsCategory.class) -public class YouTubeTest extends BaseSpringTest -{ - protected ServiceRegistry serviceRegistry; - protected SiteService siteService; - protected FileFolderService fileFolderService; - protected NodeService nodeService; - protected String siteId; - protected PublishingQueueImpl queue; - protected Environment environment; - protected NodeRef docLib; - protected NodeArchiveService nodeArchiveService; - - private ChannelService channelService; - - private RetryingTransactionHelper transactionHelper; - - public void onSetUp() throws Exception - { - serviceRegistry = (ServiceRegistry) getApplicationContext().getBean("ServiceRegistry"); - channelService = (ChannelService) getApplicationContext().getBean("channelService"); - nodeArchiveService = (NodeArchiveService) getApplicationContext().getBean("nodeArchiveService"); - AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - siteService = serviceRegistry.getSiteService(); - fileFolderService = serviceRegistry.getFileFolderService(); - nodeService = serviceRegistry.getNodeService(); - transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); - - siteId = GUID.generate(); - siteService.createSite("test", siteId, "Site created by publishing test", "Site created by publishing test", - SiteVisibility.PUBLIC); - docLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); - } - - public void onTearDown() - { - SiteInfo siteInfo = siteService.getSite(siteId); - if (siteInfo != null) - { - siteService.deleteSite(siteId); - nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteInfo.getNodeRef())); - } - } - - public void testBlank() - { - - } - - //Note that this test isn't normally run, as it requires valid YouTube credentials. - //To run it, remove the initial 'x' from the method name and set the appropriate YouTube credentials where the - //text "YOUR_USER_NAME" and "YOUR_PASSWORD" appear. - public void xtestYouTubePublishAndUnpublishActions() throws Exception - { - final String channelName = GUID.generate(); - final YouTubeChannelType channelType = (YouTubeChannelType) channelService.getChannelType(YouTubeChannelType.ID); - - final NodeRef vidNode = transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - Map props = new HashMap(); - props.put(PublishingModel.PROP_CHANNEL_USERNAME, "YOUR_USER_NAME"); - props.put(PublishingModel.PROP_CHANNEL_PASSWORD, "YOUR_PASSWORD"); - Channel channel = channelService.createChannel(YouTubeChannelType.ID, channelName, props); - - NodeRef channelNode = channel.getNodeRef(); - Resource videoFile = new ClassPathResource("test/alfresco/TestVideoFile.MP4"); - Map vidProps = new HashMap(); - vidProps.put(ContentModel.PROP_NAME, "Test Video"); - NodeRef vidNode = nodeService.createNode(channelNode, ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testVideo"), - ContentModel.TYPE_CONTENT, vidProps).getChildRef(); - ContentService contentService = serviceRegistry.getContentService(); - ContentWriter writer = contentService.getWriter(vidNode, ContentModel.PROP_CONTENT, true); - writer.setMimetype("video/mpg"); - writer.putContent(videoFile.getFile()); - return vidNode; - } - }); - - transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - channelType.publish(vidNode, channelService.getChannelByName(channelName).getProperties()); - Map props = nodeService.getProperties(vidNode); - Assert.assertTrue(nodeService.hasAspect(vidNode, YouTubePublishingModel.ASPECT_ASSET)); - Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_ID)); - Assert.assertNotNull(props.get(PublishingModel.PROP_ASSET_URL)); - - System.out.println("YouTube video: " + props.get(PublishingModel.PROP_ASSET_ID)); - - channelType.unpublish(vidNode, channelService.getChannelByName(channelName).getProperties()); - props = nodeService.getProperties(vidNode); - Assert.assertFalse(nodeService.hasAspect(vidNode, YouTubePublishingModel.ASPECT_ASSET)); - Assert.assertNull(props.get(PublishingModel.PROP_ASSET_ID)); - Assert.assertNull(props.get(PublishingModel.PROP_ASSET_URL)); - return null; - } - }); - - transactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - nodeService.deleteNode(vidNode); - return null; - } - }); - - } - -} diff --git a/src/test/resources/org/alfresco/repo/publishing/test/publishing-test-context.xml b/src/test/resources/org/alfresco/repo/publishing/test/publishing-test-context.xml deleted file mode 100644 index 4129e9e837..0000000000 --- a/src/test/resources/org/alfresco/repo/publishing/test/publishing-test-context.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/test/resources/test/alfresco/test-web-publishing--workflow-context.xml b/src/test/resources/test/alfresco/test-web-publishing--workflow-context.xml deleted file mode 100644 index 763df59851..0000000000 --- a/src/test/resources/test/alfresco/test-web-publishing--workflow-context.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/test/resources/test/alfresco/test-web-publishing-context.xml b/src/test/resources/test/alfresco/test-web-publishing-context.xml deleted file mode 100644 index 22cc9de35c..0000000000 --- a/src/test/resources/test/alfresco/test-web-publishing-context.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - true - - - - classpath:alfresco/repository.properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -