├── docs └── images │ ├── alfresco.png │ └── simple_integration_diagram.png ├── alfresco-acs-java-rest-api ├── alfresco-acs-java-rest-api-lib │ ├── alfresco-event-gateway-api-client │ │ ├── .swagger-codegen │ │ │ └── VERSION │ │ ├── docs │ │ │ ├── Filter.md │ │ │ └── Subscription.md │ │ ├── .swagger-codegen-ignore │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ ├── org │ │ │ │ └── alfresco │ │ │ │ │ └── gateway │ │ │ │ │ └── handler │ │ │ │ │ └── SubscriptionsApiClient.java │ │ │ │ └── io │ │ │ │ └── swagger │ │ │ │ └── configuration │ │ │ │ ├── ClientConfiguration.java │ │ │ │ └── ApiKeyRequestInterceptor.java │ │ └── pom.xml │ ├── src │ │ └── main │ │ │ └── resources │ │ │ ├── templates │ │ │ ├── project │ │ │ │ ├── build.properties │ │ │ │ └── plugins.sbt │ │ │ ├── beanValidationQueryParams.mustache │ │ │ ├── application.properties │ │ │ ├── beanValidationPathParams.mustache │ │ │ ├── generatedAnnotation.mustache │ │ │ ├── optionalDataType.mustache │ │ │ ├── exampleReturnTypes.mustache │ │ │ ├── returnTypes.mustache │ │ │ ├── implicitHeader.mustache │ │ │ ├── apiException.mustache │ │ │ ├── beanValidation.mustache │ │ │ ├── notFoundException.mustache │ │ │ ├── application.mustache │ │ │ ├── bodyParams.mustache │ │ │ ├── libraries │ │ │ │ └── spring-cloud │ │ │ │ │ ├── apiClient.mustache │ │ │ │ │ ├── formParams.mustache │ │ │ │ │ ├── clientConfiguration.mustache │ │ │ │ │ ├── apiKeyRequestInterceptor.mustache │ │ │ │ │ ├── jacksonConfiguration.mustache │ │ │ │ │ └── pom.mustache │ │ │ ├── xmlAnnotation.mustache │ │ │ ├── headerParams.mustache │ │ │ ├── pathParams.mustache │ │ │ ├── typeInfoAnnotation.mustache │ │ │ ├── queryParams.mustache │ │ │ ├── formParams.mustache │ │ │ ├── apiOriginFilter.mustache │ │ │ ├── model.mustache │ │ │ ├── beanValidationCore.mustache │ │ │ ├── apiResponseMessage.mustache │ │ │ ├── enumOuterClass.mustache │ │ │ ├── enumClass.mustache │ │ │ ├── api_doc.mustache │ │ │ ├── swaggerDocumentationConfig.mustache │ │ │ └── apiDelegate.mustache │ │ │ └── sources │ │ │ └── alfresco-core-rest-api │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── core │ │ │ └── handler │ │ │ └── ContentApiClient.java │ ├── generated │ │ ├── alfresco-auth-rest-api │ │ │ └── pom.xml │ │ ├── alfresco-core-rest-api │ │ │ └── pom.xml │ │ ├── alfresco-model-rest-api │ │ │ └── pom.xml │ │ ├── alfresco-search-rest-api │ │ │ └── pom.xml │ │ ├── alfresco-discovery-rest-api │ │ │ └── pom.xml │ │ ├── alfresco-search-sql-rest-api │ │ │ └── pom.xml │ │ ├── alfresco-governance-core-rest-api │ │ │ └── pom.xml │ │ └── alfresco-governance-classification-rest-api │ │ │ └── pom.xml │ └── README.md ├── alfresco-acs-java-rest-api-spring-boot-starter │ ├── src │ │ └── test │ │ │ ├── resources │ │ │ └── application-test.properties │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── rest │ │ │ └── sdk │ │ │ ├── AcsTestApplication.java │ │ │ └── ApplicationTest.java │ └── pom.xml ├── alfresco-acs-java-rest-api-spring-boot │ └── src │ │ └── main │ │ ├── resources │ │ ├── META-INF │ │ │ └── spring │ │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ └── alfresco-java-rest-api-default.properties │ │ └── java │ │ └── org │ │ └── alfresco │ │ └── rest │ │ └── sdk │ │ └── config │ │ ├── AlfrescoRestApiProperties.java │ │ └── AlfrescoRestApiAutoConfiguration.java └── pom.xml ├── srcclr.yml ├── alfresco-java-event-api ├── alfresco-java-event-api-spring-boot │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring │ │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── event │ │ │ └── sdk │ │ │ └── autoconfigure │ │ │ └── AlfrescoEventsProperties.java │ └── pom.xml ├── alfresco-java-event-api-spring-boot-starter │ └── pom.xml ├── alfresco-java-event-api-handling │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── event │ │ │ └── sdk │ │ │ └── handling │ │ │ ├── handler │ │ │ ├── NodeEventHandler.java │ │ │ ├── PermissionEventHandler.java │ │ │ ├── ChildAssocEventHandler.java │ │ │ ├── PeerAssocEventHandler.java │ │ │ ├── OnNodeCreatedEventHandler.java │ │ │ ├── OnNodeDeletedEventHandler.java │ │ │ ├── OnNodeUpdatedEventHandler.java │ │ │ ├── OnPermissionUpdatedEventHandler.java │ │ │ ├── OnChildAssocCreatedEventHandler.java │ │ │ ├── OnChildAssocDeletedEventHandler.java │ │ │ ├── OnPeerAssocCreatedEventHandler.java │ │ │ └── OnPeerAssocDeletedEventHandler.java │ │ │ ├── EventHandlingException.java │ │ │ ├── EventHandlingExecutor.java │ │ │ └── filter │ │ │ ├── PropertyValueFilter.java │ │ │ ├── IsFileFilter.java │ │ │ ├── IsFolderFilter.java │ │ │ ├── NodeAspectFilter.java │ │ │ ├── NodeTypeFilter.java │ │ │ ├── AssocTypeFilter.java │ │ │ ├── AspectRemovedFilter.java │ │ │ ├── PropertyAddedFilter.java │ │ │ ├── PropertyRemovedFilter.java │ │ │ ├── NodeMovedFilter.java │ │ │ └── MimeTypeFilter.java │ └── pom.xml ├── alfresco-java-event-api-integration │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── event │ │ │ └── sdk │ │ │ └── integration │ │ │ ├── EventChannels.java │ │ │ ├── transformer │ │ │ └── EventGenericTransformer.java │ │ │ └── filter │ │ │ └── IntegrationEventFilter.java │ └── pom.xml └── pom.xml ├── samples ├── event-api-handlers │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── sdk │ │ │ └── sample │ │ │ └── event │ │ │ ├── handler │ │ │ ├── FolderDeletedHandler.java │ │ │ ├── ContentUpdatedHandler.java │ │ │ ├── HtmlContentCreatedHandler.java │ │ │ ├── ContentTypeNodeCreatedHandler.java │ │ │ ├── MultipleEventTypeHandler.java │ │ │ ├── TitleModifiedHandler.java │ │ │ └── NodeMovedHandler.java │ │ │ └── EventsHandlersSampleApplication.java │ ├── Dockerfile │ ├── run.sh │ ├── pom.xml │ ├── run.bat │ └── README.md ├── event-api-spring-integration │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── application.properties │ ├── Dockerfile │ ├── run.sh │ ├── run.bat │ ├── pom.xml │ └── README.md ├── extension-template │ ├── Dockerfile │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── sdk │ │ │ └── sample │ │ │ └── ExtensionTemplateApplication.java │ ├── run.sh │ ├── run.bat │ ├── pom.xml │ └── README.md └── pom.xml ├── .pre-commit-config.yaml ├── .editorconfig ├── integration-tests ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── core │ │ │ └── TestApplication.java │ └── test │ │ └── java │ │ ├── org │ │ └── alfresco │ │ │ ├── AbstractContentBasedIntegrationTest.java │ │ │ ├── AbstractFolderBasedIntegrationTest.java │ │ │ ├── core │ │ │ ├── PreferencesApiServiceIntegrationTests.java │ │ │ ├── VersionsApiServiceIntegrationTest.java │ │ │ ├── TrashcanApiServiceIntegrationTest.java │ │ │ └── QueriesApiServiceIntegrationTest.java │ │ │ ├── AbstractNodeBasedIntegrationTest.java │ │ │ └── AbstractSiteBasedIntegrationTest.java │ │ └── util │ │ ├── Constants.java │ │ └── TestUtils.java └── pom.xml ├── scripts └── ci │ ├── init.sh │ ├── verify_release_tag.sh │ └── maven_release.sh ├── .github └── dependabot.yml ├── alfresco-java-rest-api-common ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── alfresco │ │ │ └── rest │ │ │ └── sdk │ │ │ └── feign │ │ │ ├── DelegatedAuthenticationProvider.java │ │ │ ├── config │ │ │ ├── EnableAuthConfiguration.java │ │ │ ├── DelegatedAuthenticationConfiguration.java │ │ │ └── BasicAuthConfiguration.java │ │ │ └── DelegatedAuthenticationRequestInterceptor.java │ └── test │ │ └── java │ │ └── org │ │ └── alfresco │ │ └── rest │ │ └── sdk │ │ └── feign │ │ └── DelegatedAuthenticationRequestInterceptorTest.java └── pom.xml ├── .ci.settings.xml └── .gitignore /docs/images/alfresco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alfresco/alfresco-java-sdk/HEAD/docs/images/alfresco.png -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/.swagger-codegen/VERSION: -------------------------------------------------------------------------------- 1 | 3.0.27 -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.12.0 2 | -------------------------------------------------------------------------------- /docs/images/simple_integration_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alfresco/alfresco-java-sdk/HEAD/docs/images/simple_integration_diagram.png -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/beanValidationQueryParams.mustache: -------------------------------------------------------------------------------- 1 | {{#required}}@NotNull {{/required}}{{>beanValidationCore}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/application.properties: -------------------------------------------------------------------------------- 1 | springfox.documentation.swagger.v2.path=/api-docs 2 | #server.port=8090 3 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/beanValidationPathParams.mustache: -------------------------------------------------------------------------------- 1 | {{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} -------------------------------------------------------------------------------- /srcclr.yml: -------------------------------------------------------------------------------- 1 | # To avoid the provided dependencies we set the scope to runtime. See: https://docs.veracode.com/r/c_sc_scan_directives 2 | # runtime: to restrict the scan to compile and runtime dependencies. 3 | scope: runtime -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot-starter/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=alfresco-acs-java-sdk-test 2 | 3 | content.service.url=http://localhost:8080 4 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.alfresco.rest.sdk.config.AlfrescoRestApiAutoConfiguration 2 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.alfresco.event.sdk.autoconfigure.AlfrescoEventsAutoConfiguration 2 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.activemq.brokerUrl=tcp://activemq:61616 2 | spring.jms.cache.enabled=false 3 | alfresco.events.enableSpringIntegration=false 4 | alfresco.events.enableHandlers=true -------------------------------------------------------------------------------- /samples/event-api-handlers/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amazoncorretto:17-alpine3.18@sha256:6a3dc573328ced158ae25ffde792accbe8b1ff2e7b505c72d2d5e7b9bfa9ac26 2 | 3 | ARG JAR_FILE=target/*.jar 4 | COPY ${JAR_FILE} app.jar 5 | ENTRYPOINT ["java","-jar","/app.jar"] 6 | -------------------------------------------------------------------------------- /samples/event-api-spring-integration/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.activemq.brokerUrl=tcp://activemq:61616 2 | spring.jms.cache.enabled=false 3 | alfresco.events.enableSpringIntegration=true 4 | alfresco.events.enableHandlers=false -------------------------------------------------------------------------------- /samples/extension-template/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amazoncorretto:17-alpine3.18@sha256:6a3dc573328ced158ae25ffde792accbe8b1ff2e7b505c72d2d5e7b9bfa9ac26 2 | 3 | ARG JAR_FILE=target/*.jar 4 | COPY ${JAR_FILE} app.jar 5 | ENTRYPOINT ["java","-jar","/app.jar"] 6 | -------------------------------------------------------------------------------- /samples/event-api-spring-integration/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amazoncorretto:17-alpine3.18@sha256:6a3dc573328ced158ae25ffde792accbe8b1ff2e7b505c72d2d5e7b9bfa9ac26 2 | 3 | ARG JAR_FILE=target/*.jar 4 | COPY ${JAR_FILE} app.jar 5 | ENTRYPOINT ["java","-jar","/app.jar"] 6 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/generatedAnnotation.mustache: -------------------------------------------------------------------------------- 1 | {{^hideGenerationTimestamp}} 2 | @javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") 3 | {{/hideGenerationTimestamp}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/optionalDataType.mustache: -------------------------------------------------------------------------------- 1 | {{#useOptional}}{{#required}}{{{dataType}}}{{/required}}{{^required}}Optional<{{{dataType}}}>{{/required}}{{/useOptional}}{{^useOptional}}{{{dataType}}}{{/useOptional}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/exampleReturnTypes.mustache: -------------------------------------------------------------------------------- 1 | {{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/returnTypes.mustache: -------------------------------------------------------------------------------- 1 | {{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/implicitHeader.mustache: -------------------------------------------------------------------------------- 1 | {{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required=true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{#hasMore}},{{/hasMore}}{{/isHeaderParam}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/docs/Filter.md: -------------------------------------------------------------------------------- 1 | # Filter 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **id** | **String** | | [optional] 7 | **type** | **String** | | 8 | **config** | **Map<String, String>** | | [optional] 9 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/apiException.mustache: -------------------------------------------------------------------------------- 1 | package {{apiPackage}}; 2 | 3 | {{>generatedAnnotation}} 4 | public class ApiException extends Exception{ 5 | private int code; 6 | public ApiException (int code, String msg) { 7 | super(msg); 8 | this.code = code; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/beanValidation.mustache: -------------------------------------------------------------------------------- 1 | {{#required}} 2 | @NotNull 3 | {{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}} 4 | @Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}} 5 | @Valid{{/isPrimitiveType}}{{/isNotContainer}} 6 | {{>beanValidationCore}} 7 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/Alfresco/alfresco-build-tools 3 | rev: v1.0.0 4 | hooks: 5 | - id: travis-yml-lint 6 | - repo: https://github.com/pre-commit/pre-commit-hooks 7 | rev: v3.4.0 8 | hooks: 9 | - id: check-yaml 10 | args: [--allow-multiple-documents] 11 | - id: check-json 12 | - id: check-xml 13 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/notFoundException.mustache: -------------------------------------------------------------------------------- 1 | package {{apiPackage}}; 2 | 3 | {{>generatedAnnotation}} 4 | public class NotFoundException extends ApiException { 5 | private int code; 6 | public NotFoundException (int code, String msg) { 7 | super(code, msg); 8 | this.code = code; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/application.mustache: -------------------------------------------------------------------------------- 1 | springfox.documentation.swagger.v2.path=/api-docs 2 | server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} 3 | server.port={{serverPort}} 4 | spring.jackson.date-format={{basePackage}}.RFC3339DateFormat 5 | spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | indent_style = space 10 | indent_size = 2 11 | 12 | [*.java] 13 | indent_size = 4 14 | 15 | [*.md] 16 | max_line_length = off 17 | trim_trailing_whitespace = false 18 | 19 | [Makefile] 20 | indent_style = tab 21 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/bodyParams.mustache: -------------------------------------------------------------------------------- 1 | {{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/libraries/spring-cloud/apiClient.mustache: -------------------------------------------------------------------------------- 1 | package {{package}}; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import {{configPackage}}.ClientConfiguration; 5 | 6 | {{=<% %>=}} 7 | @FeignClient(name = "alfresco<%classname%>", url = "${<%title%>.url:<%hostWithoutBasePath%>}", configuration = ClientConfiguration.class) 8 | <%={{ }}=%> 9 | public interface {{classname}}Client extends {{classname}} { 10 | } 11 | -------------------------------------------------------------------------------- /samples/extension-template/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.activemq.brokerUrl=tcp://localhost:61616 2 | spring.jms.cache.enabled=false 3 | alfresco.events.enableSpringIntegration=false 4 | alfresco.events.enableHandlers=true 5 | 6 | content.service.security.basicAuth.username=admin 7 | content.service.security.basicAuth.password=admin 8 | 9 | content.service.url=http://localhost:8080 10 | content.service.path=/alfresco/api/-default-/public/alfresco/versions/1 11 | 12 | local.storage.folder=/tmp 13 | -------------------------------------------------------------------------------- /integration-tests/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #spring.activemq.brokerUrl=tcp://localhost:61616 2 | #spring.jms.cache.enabled=false 3 | #alfresco.events.enableSpringIntegration=false 4 | #alfresco.events.enableHandlers=true 5 | 6 | content.service.security.basicAuth.username=admin 7 | content.service.security.basicAuth.password=admin 8 | 9 | content.service.url=http://localhost:8080 10 | content.service.path=/alfresco/api/-default-/public/alfresco/versions/1 11 | 12 | logging.level.org.apache.http=TRACE 13 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/xmlAnnotation.mustache: -------------------------------------------------------------------------------- 1 | {{#withXml}} 2 | {{#jackson}} 3 | @JacksonXmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}") 4 | {{/jackson}} 5 | @XmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}") 6 | @XmlAccessorType(XmlAccessType.FIELD){{/withXml}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/headerParams.mustache: -------------------------------------------------------------------------------- 1 | {{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot/src/main/resources/alfresco-java-rest-api-default.properties: -------------------------------------------------------------------------------- 1 | content.service.path=/alfresco/api/-default-/public/alfresco/versions/1 2 | search.service.path=/alfresco/api/-default-/public/search/versions/1 3 | search-sql.service.path=/alfresco/api/-default-/public/search/versions/1 4 | governance.service.path=/alfresco/api/-default-/public/gs/versions/1 5 | authentication.service.path=/alfresco/api/-default-/public/authentication/versions/1 6 | discovery.service.path=/alfresco/api 7 | 8 | feign.httpclient.enabled=true 9 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/pathParams.mustache: -------------------------------------------------------------------------------- 1 | {{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/typeInfoAnnotation.mustache: -------------------------------------------------------------------------------- 1 | {{#jackson}} 2 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator}}", visible = true ) 3 | @JsonSubTypes({ 4 | {{#children}} 5 | @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), 6 | {{/children}} 7 | }){{/jackson}} 8 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.4") 2 | 3 | libraryDependencies <+= sbtVersion(v => v match { 4 | case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8" 5 | case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10" 6 | case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11" 7 | case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1" 8 | case x if (x.startsWith("0.12")) => "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1" 9 | }) -------------------------------------------------------------------------------- /scripts/ci/init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "=========================== Starting Init Script ===========================" 3 | PS4="\[\e[35m\]+ \[\e[m\]" 4 | set -vex 5 | pushd "$(dirname "${BASH_SOURCE[0]}")/../../" 6 | 7 | # Maven Setup 8 | find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf 9 | 10 | # Docker Logins 11 | echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin 12 | echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io 13 | 14 | popd 15 | set +vex 16 | echo "=========================== Finishing Init Script ==========================" 17 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/libraries/spring-cloud/formParams.mustache: -------------------------------------------------------------------------------- 1 | {{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestParam("{{baseName}}") MultipartFile {{paramName}}{{/isFile}}{{/isFormParam}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/queryParams.mustache: -------------------------------------------------------------------------------- 1 | {{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}} -------------------------------------------------------------------------------- /scripts/ci/verify_release_tag.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "=========================== Starting Verify Release Tag Script ===========================" 3 | PS4="\[\e[35m\]+ \[\e[m\]" 4 | set -vex 5 | pushd "$(dirname "${BASH_SOURCE[0]}")/../../" 6 | 7 | # 8 | # Check that the version to be released does not already have a git tag. 9 | # 10 | 11 | POM_VERSION=$(mvn -B -q help:evaluate -Dexpression=project.version -DforceStdout) 12 | printf "POM version: %s\n" "${POM_VERSION}" 13 | 14 | TAG="${POM_VERSION%-SNAPSHOT}" 15 | 16 | if git rev-parse "${TAG}^{tag}" &>/dev/null ; then 17 | echo "The next tag \"${TAG}\" already exists in the git project" 18 | exit 1 19 | fi 20 | 21 | popd 22 | set +vex 23 | echo "=========================== Finishing Verify Release Tag Script ==========================" 24 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/formParams.mustache: -------------------------------------------------------------------------------- 1 | {{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/docs/Subscription.md: -------------------------------------------------------------------------------- 1 | # Subscription 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **createdDate** | **Long** | | [optional] 7 | **modifiedDate** | **Long** | | [optional] 8 | **id** | **String** | | [optional] 9 | **status** | [**StatusEnum**](#StatusEnum) | | [optional] 10 | **type** | **String** | | 11 | **user** | **String** | | [optional] 12 | **config** | **Map<String, String>** | | [optional] 13 | **filters** | [**List<Filter>**](Filter.md) | | [optional] 14 | 15 | 16 | ## Enum: StatusEnum 17 | Name | Value 18 | ---- | ----- 19 | ACTIVE | "ACTIVE" 20 | INACTIVE | "INACTIVE" 21 | -------------------------------------------------------------------------------- /scripts/ci/maven_release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "=========================== Starting Release Script ===========================" 4 | PS4="\[\e[35m\]+ \[\e[m\]" 5 | set -vex 6 | pushd "$(dirname "${BASH_SOURCE[0]}")/../../" 7 | 8 | # Github Actions CI runner work on DETACHED HEAD, so we need to checkout the release branch 9 | git checkout -B "${BRANCH_NAME}" 10 | 11 | git pull 12 | 13 | # Run the release plugin - with "[skip ci]" in the release commit message 14 | mvn -B \ 15 | "-Darguments=-DskipTests -DbuildNumber=$GITHUB_RUN_NUMBER" \ 16 | release:clean release:prepare release:perform \ 17 | -DscmCommentPrefix="[maven-release-plugin][skip ci] " \ 18 | -Dusername="${GIT_USERNAME}" \ 19 | -Dpassword="${GIT_PASSWORD}" 20 | 21 | popd 22 | set +vex 23 | echo "=========================== Finishing Release Script ==========================" 24 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | 7.2.1-SNAPSHOT 8 | alfresco-java-sdk 9 | 10 | 11 | alfresco-acs-java-rest-api 12 | pom 13 | Alfresco Java Rest API :: Parent 14 | 15 | 16 | alfresco-acs-java-rest-api-lib 17 | alfresco-acs-java-rest-api-spring-boot 18 | alfresco-acs-java-rest-api-spring-boot-starter 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-event-api 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-java-event-api-spring-boot-starter 12 | Alfresco Java Event API :: Spring Boot Starter 13 | 14 | 15 | 16 | org.alfresco 17 | alfresco-java-event-api-spring-boot 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "maven" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | - package-ecosystem: "docker" 13 | directory: "/" 14 | schedule: 15 | interval: "daily" 16 | ignore: 17 | - dependency-name: "amazoncorretto" 18 | versions: [">17"] 19 | - package-ecosystem: "github-actions" 20 | directory: "/" 21 | schedule: 22 | interval: "daily" 23 | groups: 24 | github-actions: 25 | patterns: 26 | - "*" 27 | update-types: 28 | - "minor" 29 | - "patch" 30 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/NodeEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | /** 19 | * {@link EventHandler} interface that groups all the event handlers related to node events. 20 | */ 21 | public interface NodeEventHandler extends EventHandler { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot/src/main/java/org/alfresco/rest/sdk/config/AlfrescoRestApiProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.config; 17 | 18 | import org.springframework.boot.context.properties.ConfigurationProperties; 19 | 20 | @ConfigurationProperties(prefix = "alfresco.rest.api") 21 | public class AlfrescoRestApiProperties { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/PermissionEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | /** 19 | * {@link EventHandler} interface that groups all the event handlers related to permission events. 20 | */ 21 | public interface PermissionEventHandler extends EventHandler { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/apiOriginFilter.mustache: -------------------------------------------------------------------------------- 1 | package {{apiPackage}}; 2 | 3 | import java.io.IOException; 4 | 5 | import jakarta.servlet.*; 6 | import jakarta.servlet.http.HttpServletResponse; 7 | 8 | {{>generatedAnnotation}} 9 | public class ApiOriginFilter implements javax.servlet.Filter { 10 | @Override 11 | public void doFilter(ServletRequest request, ServletResponse response, 12 | FilterChain chain) throws IOException, ServletException { 13 | HttpServletResponse res = (HttpServletResponse) response; 14 | res.addHeader("Access-Control-Allow-Origin", "*"); 15 | res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); 16 | res.addHeader("Access-Control-Allow-Headers", "Content-Type"); 17 | chain.doFilter(request, response); 18 | } 19 | 20 | @Override 21 | public void destroy() { 22 | } 23 | 24 | @Override 25 | public void init(FilterConfig filterConfig) throws ServletException { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/model.mustache: -------------------------------------------------------------------------------- 1 | package {{package}}; 2 | 3 | import java.util.Objects; 4 | {{#imports}}import {{import}}; 5 | {{/imports}} 6 | {{#serializableModel}} 7 | import java.io.Serializable; 8 | {{/serializableModel}} 9 | {{#useBeanValidation}} 10 | import org.springframework.validation.annotation.Validated; 11 | import jakarta.validation.Valid; 12 | import jakarta.validation.constraints.*; 13 | {{/useBeanValidation}} 14 | {{#jackson}} 15 | {{#withXml}} 16 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; 17 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; 18 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; 19 | {{/withXml}} 20 | {{/jackson}} 21 | {{#withXml}} 22 | import jakarta.xml.bind.annotation.*; 23 | {{/withXml}} 24 | 25 | {{#models}} 26 | {{#model}} 27 | {{#isEnum}} 28 | {{>enumOuterClass}} 29 | {{/isEnum}} 30 | {{^isEnum}} 31 | {{>pojo}} 32 | {{/isEnum}} 33 | {{/model}} 34 | {{/models}} 35 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/libraries/spring-cloud/clientConfiguration.mustache: -------------------------------------------------------------------------------- 1 | package {{configPackage}}; 2 | 3 | import org.alfresco.rest.sdk.feign.config.BasicAuthConfiguration; 4 | import org.alfresco.rest.sdk.feign.config.DelegatedAuthenticationConfiguration; 5 | import org.alfresco.rest.sdk.feign.config.OAuth2Configuration; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Import; 8 | 9 | /** 10 | * Feign client Spring configuration that provides support for different authentication methods. Currently, supported methods are: 11 | * 17 | */ 18 | @Configuration 19 | @Import({BasicAuthConfiguration.class, OAuth2Configuration.class, DelegatedAuthenticationConfiguration.class}) 20 | public class ClientConfiguration { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/ChildAssocEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | /** 19 | * {@link EventHandler} interface that groups all the event handlers related to parent-child association events. 20 | */ 21 | public interface ChildAssocEventHandler extends EventHandler { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/PeerAssocEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | /** 19 | * {@link EventHandler} interface that groups all the event handlers related to peer to peer association events. 20 | */ 21 | public interface PeerAssocEventHandler extends EventHandler { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/libraries/spring-cloud/apiKeyRequestInterceptor.mustache: -------------------------------------------------------------------------------- 1 | package {{configPackage}}; 2 | 3 | import feign.RequestInterceptor; 4 | import feign.RequestTemplate; 5 | import feign.Util; 6 | 7 | 8 | public class ApiKeyRequestInterceptor implements RequestInterceptor { 9 | private final String location; 10 | private final String name; 11 | private String value; 12 | 13 | public ApiKeyRequestInterceptor(String location, String name, String value) { 14 | Util.checkNotNull(location, "location", new Object[0]); 15 | Util.checkNotNull(name, "name", new Object[0]); 16 | Util.checkNotNull(value, "value", new Object[0]); 17 | this.location = location; 18 | this.name = name; 19 | this.value = value; 20 | } 21 | 22 | @Override 23 | public void apply(RequestTemplate requestTemplate) { 24 | if(location.equals("header")) { 25 | requestTemplate.header(name, value); 26 | } else if(location.equals("query")) { 27 | requestTemplate.query(name, value); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/libraries/spring-cloud/jacksonConfiguration.mustache: -------------------------------------------------------------------------------- 1 | package {{configPackage}}; 2 | 3 | import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.threeten.bp.Instant; 8 | import org.threeten.bp.OffsetDateTime; 9 | import org.threeten.bp.ZonedDateTime; 10 | 11 | @Configuration 12 | public class JacksonConfiguration { 13 | 14 | @Bean 15 | @ConditionalOnMissingBean(ThreeTenModule.class) 16 | ThreeTenModule threeTenModule() { 17 | ThreeTenModule module = new ThreeTenModule(); 18 | module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); 19 | module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); 20 | module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); 21 | return module; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/extension-template/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "${M2_HOME}" ]; then 4 | export MVN_EXEC="mvn" 5 | else 6 | export MVN_EXEC="${M2_HOME}/bin/mvn" 7 | fi 8 | 9 | start() { 10 | docker compose up --build -d 11 | } 12 | 13 | down() { 14 | docker compose down 15 | } 16 | 17 | build() { 18 | docker rmi extension-template:development 19 | $MVN_EXEC clean package 20 | } 21 | 22 | tail() { 23 | docker compose logs -f 24 | } 25 | 26 | start_sample() { 27 | docker compose up --build -d extension-template 28 | } 29 | 30 | stop_sample() { 31 | docker compose kill eextension-template 32 | yes | docker compose rm -f extension-template 33 | } 34 | 35 | case "$1" in 36 | build_start) 37 | down 38 | build 39 | start 40 | tail 41 | ;; 42 | reload_sample) 43 | stop_sample 44 | build 45 | start_sample 46 | tail 47 | ;; 48 | start) 49 | start 50 | tail 51 | ;; 52 | stop) 53 | down 54 | ;; 55 | tail) 56 | tail 57 | ;; 58 | *) 59 | echo "Usage: $0 {build_start|reload_sample|start|stop|tail}" 60 | esac 61 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/AbstractContentBasedIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco; 17 | 18 | import util.Constants.NodeTypes; 19 | 20 | /** 21 | * Test scenario that creates a content node before the execution. 22 | */ 23 | public abstract class AbstractContentBasedIntegrationTest extends AbstractNodeBasedIntegrationTest { 24 | 25 | protected String getTestNodeType() { 26 | return NodeTypes.FILE; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/AbstractFolderBasedIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco; 17 | 18 | import util.Constants.NodeTypes; 19 | 20 | /** 21 | * Test scenario that creates a folder node before the execution. 22 | */ 23 | public abstract class AbstractFolderBasedIntegrationTest extends AbstractNodeBasedIntegrationTest { 24 | 25 | protected String getTestNodeType() { 26 | return NodeTypes.FOLDER; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /samples/event-api-spring-integration/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "${M2_HOME}" ]; then 4 | export MVN_EXEC="mvn" 5 | else 6 | export MVN_EXEC="${M2_HOME}/bin/mvn" 7 | fi 8 | 9 | start() { 10 | docker compose up --build -d 11 | } 12 | 13 | down() { 14 | docker compose down 15 | } 16 | 17 | build() { 18 | docker rmi event-api-si-sample:development 19 | $MVN_EXEC clean package 20 | } 21 | 22 | tail() { 23 | docker compose logs -f 24 | } 25 | 26 | start_sample() { 27 | docker compose up --build -d event-api-si-sample 28 | } 29 | 30 | stop_sample() { 31 | docker compose kill event-api-si-sample 32 | yes | docker compose rm -f event-api-si-sample 33 | } 34 | 35 | case "$1" in 36 | build_start) 37 | down 38 | build 39 | start 40 | tail 41 | ;; 42 | reload_sample) 43 | stop_sample 44 | build 45 | start_sample 46 | tail 47 | ;; 48 | start) 49 | start 50 | tail 51 | ;; 52 | stop) 53 | down 54 | ;; 55 | tail) 56 | tail 57 | ;; 58 | *) 59 | echo "Usage: $0 {build_start|reload_sample|start|stop|tail}" 60 | esac -------------------------------------------------------------------------------- /samples/event-api-handlers/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "${M2_HOME}" ]; then 4 | export MVN_EXEC="mvn" 5 | else 6 | export MVN_EXEC="${M2_HOME}/bin/mvn" 7 | fi 8 | 9 | start() { 10 | docker compose up --build -d 11 | } 12 | 13 | down() { 14 | docker compose down 15 | } 16 | 17 | build() { 18 | docker rmi event-api-handlers-sample:development 19 | $MVN_EXEC clean package 20 | } 21 | 22 | tail() { 23 | docker compose logs -f 24 | } 25 | 26 | start_sample() { 27 | docker compose up --build -d event-api-handlers-sample 28 | } 29 | 30 | stop_sample() { 31 | docker compose kill event-api-handlers-sample 32 | yes | docker compose rm -f event-api-handlers-sample 33 | } 34 | 35 | case "$1" in 36 | build_start) 37 | down 38 | build 39 | start 40 | tail 41 | ;; 42 | reload_sample) 43 | stop_sample 44 | build 45 | start_sample 46 | tail 47 | ;; 48 | start) 49 | start 50 | tail 51 | ;; 52 | stop) 53 | down 54 | ;; 55 | tail) 56 | tail 57 | ;; 58 | *) 59 | echo "Usage: $0 {build_start|reload_sample|start|stop|tail}" 60 | esac -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-acs-java-rest-api 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-acs-java-rest-api-spring-boot-starter 12 | Alfresco Java Rest API :: Spring Boot Starter 13 | 14 | 15 | 16 | org.alfresco 17 | alfresco-acs-java-rest-api-spring-boot 18 | ${project.version} 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-test 24 | test 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot-starter/src/test/java/org/alfresco/rest/sdk/AcsTestApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | 21 | @SpringBootApplication 22 | public class AcsTestApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(AcsTestApplication.class, args); 26 | } 27 | 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot-starter/src/test/java/org/alfresco/rest/sdk/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk; 17 | 18 | import org.junit.jupiter.api.Test; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | import org.springframework.test.context.TestPropertySource; 21 | 22 | @SpringBootTest 23 | @TestPropertySource("classpath:application-test.properties") 24 | class ApplicationTest { 25 | 26 | @Test 27 | void contextLoads() { 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/sources/alfresco-core-rest-api/src/main/java/org/alfresco/core/handler/ContentApiClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.core.handler; 17 | 18 | import io.swagger.configuration.ClientConfiguration; 19 | import org.springframework.cloud.openfeign.FeignClient; 20 | 21 | @FeignClient(name = "alfrescoContentApi", url = "${content.service.url}", path = "${content.service.path}", configuration = ClientConfiguration.class) 22 | public interface ContentApiClient extends ContentApi { 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/.swagger-codegen-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /integration-tests/src/main/java/org/alfresco/core/TestApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.core; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.context.annotation.PropertySource; 21 | 22 | @PropertySource("classpath:application.properties") 23 | @SpringBootApplication 24 | public class TestApplication { 25 | 26 | public static void main(final String[] args) { 27 | SpringApplication.run(TestApplication.class, args); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/src/main/java/org/alfresco/gateway/handler/SubscriptionsApiClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.gateway.handler; 17 | 18 | import org.springframework.cloud.openfeign.FeignClient; 19 | import io.swagger.configuration.ClientConfiguration; 20 | 21 | @FeignClient(name = "alfrescoSubscriptionsApi", url = "${event.gateway.service.url}", path = "${event.gateway.service.path}", configuration = ClientConfiguration.class) 22 | public interface SubscriptionsApiClient extends SubscriptionsApi { 23 | } 24 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnNodeCreatedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for node creation handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnNodeCreatedEventHandler extends NodeEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.NODE_CREATED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnNodeDeletedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for node deletion handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnNodeDeletedEventHandler extends NodeEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.NODE_DELETED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnNodeUpdatedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for node update handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnNodeUpdatedEventHandler extends NodeEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.NODE_UPDATED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnPermissionUpdatedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for permission update handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnPermissionUpdatedEventHandler extends PermissionEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.PERMISSION_UPDATED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnChildAssocCreatedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for parent-child association creation handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnChildAssocCreatedEventHandler extends ChildAssocEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.CHILD_ASSOC_CREATED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnChildAssocDeletedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for parent-child association deletion handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnChildAssocDeletedEventHandler extends ChildAssocEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.CHILD_ASSOC_DELETED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnPeerAssocCreatedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for peer to peer association creation handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnPeerAssocCreatedEventHandler extends PeerAssocEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.PEER_ASSOC_CREATED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/OnPeerAssocDeletedEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.handler; 17 | 18 | import org.alfresco.repo.event.v1.model.EventType; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * {@link EventHandler} for peer to peer association deletion handling. 24 | */ 25 | @FunctionalInterface 26 | public interface OnPeerAssocDeletedEventHandler extends PeerAssocEventHandler { 27 | 28 | default Set getHandledEventTypes() { 29 | return Set.of(EventType.PEER_ASSOC_DELETED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/src/main/java/org/alfresco/rest/sdk/feign/DelegatedAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.feign; 17 | 18 | import feign.RequestTemplate; 19 | 20 | /** 21 | * Interface to be implemented to allow a delegated authentication in the SDK feign clients. 22 | */ 23 | @FunctionalInterface 24 | public interface DelegatedAuthenticationProvider { 25 | 26 | /** 27 | * Set the authentication details in the request template. 28 | * 29 | * @param template {@link RequestTemplate} to set the authentication details 30 | */ 31 | void setAuthentication(RequestTemplate template); 32 | } 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/util/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package util; 17 | 18 | /** 19 | * Test constants utility class. 20 | */ 21 | public class Constants { 22 | 23 | public static class NodeTypes { 24 | 25 | public static String FOLDER = "cm:folder"; 26 | public static String FILE = "cm:content"; 27 | } 28 | 29 | public static class PersonIds { 30 | 31 | public static String CURRENT_USER = "-me-"; 32 | public static String EXISTING_TEST_USER = "abeecher"; 33 | } 34 | 35 | public static class SiteIds { 36 | 37 | public static String EXISTING_TEST_SITE = "swsdp"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/src/main/java/org/alfresco/rest/sdk/feign/config/EnableAuthConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.feign.config; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | import org.springframework.context.annotation.Import; 23 | 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Target({ElementType.TYPE}) 26 | @Import({BasicAuthConfiguration.class, OAuth2Configuration.class, DelegatedAuthenticationConfiguration.class}) 27 | public @interface EnableAuthConfiguration { 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /samples/event-api-handlers/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-sdk-samples 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | event-api-handlers 12 | Alfresco Java Event API :: Sample Handlers App 13 | Sample application to demonstrate Java Event API client handlers approach 14 | 15 | 16 | 17 | org.alfresco 18 | alfresco-java-event-api-spring-boot-starter 19 | ${project.version} 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.apache.maven.plugins 27 | maven-compiler-plugin 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/EventHandlingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling; 17 | 18 | /** 19 | * {@link RuntimeException} that reflects a problem handling an event. 20 | */ 21 | public class EventHandlingException extends RuntimeException { 22 | 23 | /** 24 | * Construct a new event handling exception with the specified message and cause. 25 | * 26 | * @param message given message to add to the exception 27 | * @param cause given {@link Throwable} that caused this exception 28 | */ 29 | public EventHandlingException(final String message, final Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/extension-template/run.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | IF [%M2_HOME%]==[] ( 4 | SET MVN_EXEC=mvn 5 | ) 6 | 7 | IF NOT [%M2_HOME%]==[] ( 8 | SET MVN_EXEC=%M2_HOME%\bin\mvn 9 | ) 10 | 11 | IF [%1]==[] ( 12 | echo "Usage: %0 {build_start|reload_sample|start|stop|tail}" 13 | GOTO END 14 | ) 15 | 16 | IF %1==build_start ( 17 | CALL :down 18 | CALL :build 19 | CALL :start 20 | CALL :tail 21 | GOTO END 22 | ) 23 | IF %1==reload_sample ( 24 | CALL :stop_sample 25 | CALL :build 26 | CALL :start_sample 27 | CALL :tail 28 | GOTO END 29 | ) 30 | IF %1==start ( 31 | CALL :start 32 | CALL :tail 33 | GOTO END 34 | ) 35 | IF %1==stop ( 36 | CALL :down 37 | GOTO END 38 | ) 39 | IF %1==tail ( 40 | CALL :tail 41 | GOTO END 42 | ) 43 | 44 | echo "Usage: %0 {build_start|reload_sample|start|stop|tail}" 45 | :END 46 | EXIT /B %ERRORLEVEL% 47 | 48 | :down 49 | docker compose down 50 | EXIT /B 0 51 | :build 52 | docker rmi extension-template:development 53 | call %MVN_EXEC% clean package 54 | EXIT /B 0 55 | :start 56 | docker compose up --build -d 57 | EXIT /B 0 58 | :tail 59 | docker compose logs -f 60 | EXIT /B 0 61 | :stop_sample 62 | docker compose kill extension-template 63 | docker compose rm -f extension-template 64 | EXIT /B 0 65 | :start_sample 66 | docker compose up --build -d extension-template 67 | EXIT /B 0 68 | -------------------------------------------------------------------------------- /samples/extension-template/src/main/java/org/alfresco/sdk/sample/ExtensionTemplateApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; 22 | 23 | @SpringBootApplication 24 | @EnableAutoConfiguration(exclude={SecurityAutoConfiguration.class}) 25 | public class ExtensionTemplateApplication { 26 | 27 | public static void main(final String[] args) { 28 | SpringApplication.run(ExtensionTemplateApplication.class, args); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /samples/event-api-spring-integration/run.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | IF [%M2_HOME%]==[] ( 4 | SET MVN_EXEC=mvn 5 | ) 6 | 7 | IF NOT [%M2_HOME%]==[] ( 8 | SET MVN_EXEC=%M2_HOME%\bin\mvn 9 | ) 10 | 11 | IF [%1]==[] ( 12 | echo "Usage: %0 {build_start|reload_sample|start|stop|tail}" 13 | GOTO END 14 | ) 15 | 16 | IF %1==build_start ( 17 | CALL :down 18 | CALL :build 19 | CALL :start 20 | CALL :tail 21 | GOTO END 22 | ) 23 | IF %1==reload_sample ( 24 | CALL :stop_sample 25 | CALL :build 26 | CALL :start_sample 27 | CALL :tail 28 | GOTO END 29 | ) 30 | IF %1==start ( 31 | CALL :start 32 | CALL :tail 33 | GOTO END 34 | ) 35 | IF %1==stop ( 36 | CALL :down 37 | GOTO END 38 | ) 39 | IF %1==tail ( 40 | CALL :tail 41 | GOTO END 42 | ) 43 | 44 | echo "Usage: %0 {build_start|reload_sample|start|stop|tail}" 45 | :END 46 | EXIT /B %ERRORLEVEL% 47 | 48 | :down 49 | docker compose down 50 | EXIT /B 0 51 | :build 52 | docker rmi event-api-si-sample:development 53 | call %MVN_EXEC% clean package 54 | EXIT /B 0 55 | :start 56 | docker compose up --build -d 57 | EXIT /B 0 58 | :tail 59 | docker compose logs -f 60 | EXIT /B 0 61 | :stop_sample 62 | docker compose kill event-api-si-sample 63 | docker compose rm -f event-api-si-sample 64 | EXIT /B 0 65 | :start_sample 66 | docker compose up --build -d event-api-si-sample 67 | EXIT /B 0 -------------------------------------------------------------------------------- /.ci.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | alfresco-private 7 | ${env.MAVEN_USERNAME} 8 | ${env.MAVEN_PASSWORD} 9 | 10 | 11 | alfresco-public 12 | ${env.MAVEN_USERNAME} 13 | ${env.MAVEN_PASSWORD} 14 | 15 | 16 | alfresco-public-snapshots 17 | ${env.MAVEN_USERNAME} 18 | ${env.MAVEN_PASSWORD} 19 | 20 | 21 | alfresco-internal-releases 22 | ${MAVEN_USERNAME} 23 | ${MAVEN_PASSWORD} 24 | 25 | 26 | alfresco-enterprise-snapshots 27 | ${MAVEN_USERNAME} 28 | ${MAVEN_PASSWORD} 29 | 30 | 31 | alfresco-enterprise-releases 32 | ${MAVEN_USERNAME} 33 | ${MAVEN_PASSWORD} 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /samples/event-api-spring-integration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-sdk-samples 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | event-api-spring-integration 12 | Alfresco Java Event API :: Sample Spring Integration App 13 | Sample application to demonstrate Java Event API Spring Integration client approach 14 | 15 | 16 | 17 | org.alfresco 18 | alfresco-java-event-api-spring-boot-starter 19 | ${project.version} 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.apache.maven.plugins 27 | maven-compiler-plugin 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-integration/src/main/java/org/alfresco/event/sdk/integration/EventChannels.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.integration; 17 | 18 | /** 19 | * Channels provided by the Alfresco Java event API. 20 | */ 21 | public class EventChannels { 22 | 23 | private static final String PREFIX = "alfresco.events."; 24 | private static final String SUFFIX = ".channel"; 25 | 26 | public static final String SPRING_INTEGRATION = PREFIX + "si" + SUFFIX; 27 | public static final String HANDLERS = PREFIX + "handlers" + SUFFIX; 28 | public static final String MAIN = PREFIX + "main" + SUFFIX; 29 | public static final String ERROR = PREFIX + "error" + SUFFIX; 30 | 31 | private EventChannels() { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/event-api-handlers/run.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | IF [%M2_HOME%]==[] ( 4 | SET MVN_EXEC=mvn 5 | ) 6 | 7 | IF NOT [%M2_HOME%]==[] ( 8 | SET MVN_EXEC=%M2_HOME%\bin\mvn 9 | ) 10 | 11 | IF [%1]==[] ( 12 | echo "Usage: %0 {build_start|reload_sample|start|stop|tail}" 13 | GOTO END 14 | ) 15 | 16 | IF %1==build_start ( 17 | CALL :down 18 | CALL :build 19 | CALL :start 20 | CALL :tail 21 | GOTO END 22 | ) 23 | IF %1==reload_sample ( 24 | CALL :stop_sample 25 | CALL :build 26 | CALL :start_sample 27 | CALL :tail 28 | GOTO END 29 | ) 30 | IF %1==start ( 31 | CALL :start 32 | CALL :tail 33 | GOTO END 34 | ) 35 | IF %1==stop ( 36 | CALL :down 37 | GOTO END 38 | ) 39 | IF %1==tail ( 40 | CALL :tail 41 | GOTO END 42 | ) 43 | 44 | echo "Usage: %0 {build_start|reload_sample|start|stop|tail}" 45 | :END 46 | EXIT /B %ERRORLEVEL% 47 | 48 | :down 49 | docker compose down 50 | EXIT /B 0 51 | :build 52 | docker rmi event-api-handlers-sample:development 53 | call %MVN_EXEC% clean package 54 | EXIT /B 0 55 | :start 56 | docker compose up --build -d 57 | EXIT /B 0 58 | :tail 59 | docker compose logs -f 60 | EXIT /B 0 61 | :stop_sample 62 | docker compose kill event-api-handlers-sample 63 | docker compose rm -f event-api-handlers-sample 64 | EXIT /B 0 65 | :start_sample 66 | docker compose up --build -d event-api-handlers-sample 67 | EXIT /B 0 -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-event-api 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-java-event-api-handling 12 | Alfresco Java Event API :: Event Handling 13 | 14 | 15 | 16 | org.alfresco 17 | acs-event-model 18 | 19 | 20 | org.slf4j 21 | slf4j-api 22 | 23 | 24 | 25 | junit 26 | junit 27 | test 28 | 29 | 30 | org.assertj 31 | assertj-core 32 | test 33 | 34 | 35 | org.mockito 36 | mockito-core 37 | test 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/util/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package util; 17 | 18 | import org.apache.commons.lang3.RandomStringUtils; 19 | 20 | /** 21 | * Utility class for testing. 22 | */ 23 | public class TestUtils { 24 | 25 | public static String getRandomSiteName() { 26 | return "java-sdk-test-site-" + RandomStringUtils.randomNumeric(8); 27 | } 28 | 29 | public static String getRandomGroupName() { 30 | return "java-sdk-test-group-" + RandomStringUtils.randomNumeric(8); 31 | } 32 | 33 | public static String getRandomTagName() { 34 | return "java-sdk-test-tag-" + RandomStringUtils.randomNumeric(8); 35 | } 36 | 37 | public static String getRandomNodeName() { 38 | return "java-sdk-test-node-" + RandomStringUtils.randomNumeric(8); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/EventHandlingExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling; 17 | 18 | import org.alfresco.repo.event.v1.model.DataAttributes; 19 | import org.alfresco.repo.event.v1.model.RepoEvent; 20 | import org.alfresco.repo.event.v1.model.Resource; 21 | 22 | /** 23 | * Definition of the operations related to the execution of the handling of the repository events. 24 | */ 25 | @FunctionalInterface 26 | public interface EventHandlingExecutor { 27 | 28 | /** 29 | * Execute the event handlers that correspond to a specific {@link RepoEvent}. 30 | * 31 | * @param repoEvent given {@link RepoEvent} to be handled 32 | */ 33 | void executeEventHandlers(final RepoEvent> repoEvent); 34 | } 35 | -------------------------------------------------------------------------------- /integration-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | alfresco-java-sdk 7 | org.alfresco 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | integration-tests 12 | Alfresco Java SDK :: Integration Tests 13 | 14 | 15 | 16 | org.alfresco 17 | alfresco-acs-java-rest-api-spring-boot-starter 18 | ${project.version} 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-test 23 | test 24 | 25 | 26 | org.apache.commons 27 | commons-lang3 28 | test 29 | 30 | 31 | org.awaitility 32 | awaitility 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /samples/extension-template/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-sdk-samples 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | extension-template 12 | Alfresco Java SDK :: Extension Template 13 | Sample application to demonstrate Java Event API and REST API working together 14 | 15 | 16 | 17 | org.alfresco 18 | alfresco-java-event-api-spring-boot-starter 19 | ${project.version} 20 | 21 | 22 | org.alfresco 23 | alfresco-acs-java-rest-api-spring-boot-starter 24 | ${project.version} 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-compiler-plugin 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-maven-plugin 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/beanValidationCore.mustache: -------------------------------------------------------------------------------- 1 | {{#pattern}}@Pattern(regexp="{{{pattern}}}"{{#vendorExtensions.x-pattern-message}}, message="{{vendorExtensions.x-pattern-message}}"{{/vendorExtensions.x-pattern-message}}) {{/pattern}}{{! 2 | minLength && maxLength set 3 | }}{{#minLength}}{{#maxLength}}@Size(min={{minLength}},max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! 4 | minLength set, maxLength not 5 | }}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{! 6 | minLength not set, maxLength set 7 | }}{{^minLength}}{{#maxLength}}@Size(max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! 8 | @Size: minItems && maxItems set 9 | }}{{#minItems}}{{#maxItems}}@Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! 10 | @Size: minItems set, maxItems not 11 | }}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{! 12 | @Size: minItems not set && maxItems set 13 | }}{{^minItems}}{{#maxItems}}@Size(max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! 14 | check for integer or long / all others=decimal type with @Decimal* 15 | isInteger set 16 | }}{{#isInteger}}{{#minimum}}@Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}) {{/maximum}}{{/isInteger}}{{! 17 | isLong set 18 | }}{{#isLong}}{{#minimum}}@Min({{minimum}}L){{/minimum}}{{#maximum}} @Max({{maximum}}L) {{/maximum}}{{/isLong}}{{! 19 | Not Integer, not Long => we have a decimal value! 20 | }}{{^isInteger}}{{^isLong}}{{#minimum}}@DecimalMin("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}") {{/maximum}}{{/isLong}}{{/isInteger}} -------------------------------------------------------------------------------- /alfresco-java-event-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-sdk 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-java-event-api 12 | pom 13 | Alfresco Java Event API :: Parent 14 | 15 | 16 | 17 | 18 | org.alfresco 19 | alfresco-java-event-api-handling 20 | ${project.version} 21 | 22 | 23 | org.alfresco 24 | alfresco-java-event-api-integration 25 | ${project.version} 26 | 27 | 28 | org.alfresco 29 | alfresco-java-event-api-spring-boot 30 | ${project.version} 31 | 32 | 33 | 34 | 35 | 36 | alfresco-java-event-api-handling 37 | alfresco-java-event-api-integration 38 | alfresco-java-event-api-spring-boot 39 | alfresco-java-event-api-spring-boot-starter 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/PropertyValueFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import org.alfresco.repo.event.v1.model.DataAttributes; 19 | import org.alfresco.repo.event.v1.model.RepoEvent; 20 | import org.alfresco.repo.event.v1.model.Resource; 21 | 22 | import java.io.Serializable; 23 | 24 | /** 25 | * Abstract {@link EventFilter} class that has the common functionality that checks if an event represents a node with a specific property with a specific 26 | * value. 27 | */ 28 | public abstract class PropertyValueFilter extends AbstractEventFilter { 29 | 30 | protected String propertyName; 31 | protected Serializable propertyValue; 32 | 33 | @Override 34 | public boolean test(final RepoEvent> event) { 35 | return isNodeEvent(event) && checkPropertyValue(event); 36 | } 37 | 38 | protected abstract boolean checkPropertyValue(final RepoEvent> event); 39 | } 40 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | 9 | alfresco-event-gateway-api-client 10 | alfresco-event-gateway-api 11 | 7.2.1-SNAPSHOT 12 | 13 | 14 | io.swagger 15 | swagger-annotations 16 | 17 | 18 | org.springframework.cloud 19 | spring-cloud-starter-openfeign 20 | 21 | 22 | org.alfresco 23 | alfresco-java-rest-api-common 24 | 25 | 26 | com.fasterxml.jackson.datatype 27 | jackson-datatype-jsr310 28 | 29 | 30 | jakarta.validation 31 | jakarta.validation-api 32 | provided 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-test 37 | test 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/src/main/java/io/swagger/configuration/ClientConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.swagger.configuration; 17 | 18 | import org.alfresco.rest.sdk.feign.config.BasicAuthConfiguration; 19 | import org.alfresco.rest.sdk.feign.config.DelegatedAuthenticationConfiguration; 20 | import org.alfresco.rest.sdk.feign.config.OAuth2Configuration; 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.context.annotation.Import; 23 | 24 | /** 25 | * Feign client Spring configuration that provides support for different authentication methods. Currently, supported methods are: 26 | *
    27 | *
  • Basic Authentication
  • 28 | *
  • OAuth2 - Client credentials flow
  • 29 | *
  • OAuth2 - Password flow
  • 30 | *
  • Delegated (external) authentication
  • 31 | *
32 | */ 33 | @Configuration 34 | @Import({BasicAuthConfiguration.class, OAuth2Configuration.class, DelegatedAuthenticationConfiguration.class}) 35 | public class ClientConfiguration { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot/src/main/java/org/alfresco/rest/sdk/config/AlfrescoRestApiAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.config; 17 | 18 | import org.springframework.boot.autoconfigure.AutoConfiguration; 19 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 20 | import org.springframework.cloud.openfeign.EnableFeignClients; 21 | import org.springframework.context.annotation.PropertySource; 22 | 23 | @AutoConfiguration 24 | @EnableFeignClients(basePackages = { 25 | "org.alfresco.authentication.handler", 26 | "org.alfresco.core.handler", 27 | "org.alfresco.discovery.handler", 28 | "org.alfresco.governance.core.handler", 29 | "org.alfresco.governance.classification.handler", 30 | "org.alfresco.model.handler", 31 | "org.alfresco.search.handler", 32 | "org.alfresco.search.sql.handler" 33 | }) 34 | @PropertySource("classpath:alfresco-java-rest-api-default.properties") 35 | @EnableConfigurationProperties(AlfrescoRestApiProperties.class) 36 | public class AlfrescoRestApiAutoConfiguration { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/core/PreferencesApiServiceIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.core; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.alfresco.core.handler.PreferencesApiClient; 21 | import org.alfresco.core.model.PreferencePaging; 22 | import org.junit.jupiter.api.Test; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.boot.test.context.SpringBootTest; 25 | import org.springframework.http.ResponseEntity; 26 | import util.Constants.PersonIds; 27 | 28 | /** 29 | * Integration tests for {@link PreferencesApiClient}. 30 | */ 31 | @SpringBootTest 32 | public class PreferencesApiServiceIntegrationTests { 33 | 34 | @Autowired 35 | private PreferencesApiClient preferencesApiClient; 36 | 37 | @Test 38 | void should_listPreferences() { 39 | ResponseEntity listPreferencesResponse = preferencesApiClient.listPreferences(PersonIds.CURRENT_USER, null, null, null); 40 | 41 | assertThat(listPreferencesResponse.getBody().getList()).isNotNull(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-auth-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-auth-rest-api 11 | alfresco-auth-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-core-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-core-rest-api 11 | alfresco-core-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-sdk 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-java-rest-api-common 12 | Alfresco Java REST API :: Common functionality 13 | 14 | 15 | 16 | org.springframework.cloud 17 | spring-cloud-starter-openfeign 18 | 19 | 20 | org.springframework.security 21 | spring-security-oauth2-client 22 | 23 | 24 | org.springframework.security 25 | spring-security-config 26 | 27 | 28 | junit 29 | junit 30 | test 31 | 32 | 33 | org.assertj 34 | assertj-core 35 | test 36 | 37 | 38 | org.mockito 39 | mockito-core 40 | test 41 | 42 | 43 | com.nimbusds 44 | nimbus-jose-jwt 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-model-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-model-rest-api 11 | alfresco-model-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-search-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-search-rest-api 11 | alfresco-search-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/alfresco-event-gateway-api-client/src/main/java/io/swagger/configuration/ApiKeyRequestInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.swagger.configuration; 17 | 18 | import feign.RequestInterceptor; 19 | import feign.RequestTemplate; 20 | import feign.Util; 21 | 22 | 23 | public class ApiKeyRequestInterceptor implements RequestInterceptor { 24 | private final String location; 25 | private final String name; 26 | private String value; 27 | 28 | public ApiKeyRequestInterceptor(String location, String name, String value) { 29 | Util.checkNotNull(location, "location", new Object[0]); 30 | Util.checkNotNull(name, "name", new Object[0]); 31 | Util.checkNotNull(value, "value", new Object[0]); 32 | this.location = location; 33 | this.name = name; 34 | this.value = value; 35 | } 36 | 37 | @Override 38 | public void apply(RequestTemplate requestTemplate) { 39 | if(location.equals("header")) { 40 | requestTemplate.header(name, value); 41 | } else if(location.equals("query")) { 42 | requestTemplate.query(name, value); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-discovery-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-discovery-rest-api 11 | alfresco-discovery-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-search-sql-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-search-sql-rest-api 11 | alfresco-search-sql-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-governance-core-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-governance-core-rest-api 11 | alfresco-governance-core-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-governance-classification-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.alfresco 6 | alfresco-acs-java-rest-api-lib 7 | 7.2.1-SNAPSHOT 8 | ../.. 9 | 10 | alfresco-governance-classification-rest-api 11 | alfresco-governance-classification-rest-api 12 | 7.2.1-SNAPSHOT 13 | 14 | 15 | io.swagger 16 | swagger-annotations 17 | 18 | 19 | org.springframework.cloud 20 | spring-cloud-starter-openfeign 21 | 22 | 23 | org.alfresco 24 | alfresco-java-rest-api-common 25 | 26 | 27 | com.fasterxml.jackson.datatype 28 | jackson-datatype-jsr310 29 | 30 | 31 | jakarta.validation 32 | jakarta.validation-api 33 | provided 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-test 38 | test 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/apiResponseMessage.mustache: -------------------------------------------------------------------------------- 1 | package {{apiPackage}}; 2 | 3 | import jakarta.xml.bind.annotation.XmlTransient; 4 | 5 | {{>generatedAnnotation}} 6 | @javax.xml.bind.annotation.XmlRootElement 7 | public class ApiResponseMessage { 8 | public static final int ERROR = 1; 9 | public static final int WARNING = 2; 10 | public static final int INFO = 3; 11 | public static final int OK = 4; 12 | public static final int TOO_BUSY = 5; 13 | 14 | int code; 15 | String type; 16 | String message; 17 | 18 | public ApiResponseMessage(){} 19 | 20 | public ApiResponseMessage(int code, String message){ 21 | this.code = code; 22 | switch(code){ 23 | case ERROR: 24 | setType("error"); 25 | break; 26 | case WARNING: 27 | setType("warning"); 28 | break; 29 | case INFO: 30 | setType("info"); 31 | break; 32 | case OK: 33 | setType("ok"); 34 | break; 35 | case TOO_BUSY: 36 | setType("too busy"); 37 | break; 38 | default: 39 | setType("unknown"); 40 | break; 41 | } 42 | this.message = message; 43 | } 44 | 45 | @XmlTransient 46 | public int getCode() { 47 | return code; 48 | } 49 | 50 | public void setCode(int code) { 51 | this.code = code; 52 | } 53 | 54 | public String getType() { 55 | return type; 56 | } 57 | 58 | public void setType(String type) { 59 | this.type = type; 60 | } 61 | 62 | public String getMessage() { 63 | return message; 64 | } 65 | 66 | public void setMessage(String message) { 67 | this.message = message; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/enumOuterClass.mustache: -------------------------------------------------------------------------------- 1 | {{#jackson}} 2 | import com.fasterxml.jackson.annotation.JsonCreator; 3 | {{/jackson}} 4 | 5 | /** 6 | * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} 7 | */ 8 | public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { 9 | {{#gson}} 10 | {{#allowableValues}}{{#enumVars}} 11 | @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) 12 | {{{name}}}({{{value}}}){{^-last}}, 13 | {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} 14 | {{/gson}} 15 | {{^gson}} 16 | {{#allowableValues}}{{#enumVars}} 17 | {{{name}}}({{{value}}}){{^-last}}, 18 | {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} 19 | {{/gson}} 20 | 21 | private {{{dataType}}} value; 22 | 23 | {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { 24 | this.value = value; 25 | } 26 | 27 | @Override 28 | @JsonValue 29 | public String toString() { 30 | return String.valueOf(value); 31 | } 32 | 33 | @JsonCreator 34 | public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { 35 | for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { 36 | if (String.valueOf(b.value).equals(text)) { 37 | return b; 38 | } 39 | } 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-integration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-event-api 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-java-event-api-integration 12 | Alfresco Java Event API :: Spring Integration 13 | 14 | 15 | 16 | org.springframework.integration 17 | spring-integration-core 18 | 19 | 20 | 21 | com.fasterxml.jackson.core 22 | jackson-databind 23 | 24 | 25 | 26 | org.slf4j 27 | slf4j-api 28 | 29 | 30 | 31 | org.alfresco 32 | acs-event-model 33 | 34 | 35 | 36 | org.alfresco 37 | alfresco-java-event-api-handling 38 | 39 | 40 | 41 | junit 42 | junit 43 | test 44 | 45 | 46 | org.assertj 47 | assertj-core 48 | test 49 | 50 | 51 | org.mockito 52 | mockito-core 53 | test 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/IsFileFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import org.alfresco.repo.event.v1.model.DataAttributes; 19 | import org.alfresco.repo.event.v1.model.NodeResource; 20 | import org.alfresco.repo.event.v1.model.RepoEvent; 21 | import org.alfresco.repo.event.v1.model.Resource; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | /** 26 | * {@link EventFilter} that checks if an event corresponds to a node of type file in the repository. 27 | */ 28 | public class IsFileFilter extends AbstractEventFilter { 29 | 30 | private static final Logger LOGGER = LoggerFactory.getLogger(IsFileFilter.class); 31 | 32 | private IsFileFilter() { 33 | } 34 | 35 | /** 36 | * Obtain a {@link IsFileFilter}. 37 | * 38 | * @return created {@link IsFileFilter} 39 | */ 40 | public static IsFileFilter get() { 41 | return new IsFileFilter(); 42 | } 43 | 44 | @Override 45 | public boolean test(final RepoEvent> event) { 46 | LOGGER.debug("Checking if event {} is a file event", event); 47 | return isNodeEvent(event) && ((NodeResource) event.getData().getResource()).isFile(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/README.md: -------------------------------------------------------------------------------- 1 | # Alfresco ACS Java REST API 2 | 3 | ## What is Out-of-Process? 4 | 5 | [Alfresco SDK 4.x](https://github.com/Alfresco/alfresco-sdk) was conceived for creating JAR and AMP 6 | modules that run in the same JVM as Alfresco Repository or Share. This is still the default 7 | extension approach for certain use cases (e.g. Content modelling). 8 | 9 | Alfresco Java SDK 5.0.0 is not a continuation of 4.x. Instead, it is an additional SDK that allows 10 | developers to create out-of-process extensions. These applications run separately, consuming public 11 | APIs exposed by Alfresco Repository. 12 | 13 |

14 | alfresco 15 |

16 | 17 | Existing projects with business logic that could be lifted out and implemented as an external 18 | service can use Alfresco Java SDK 5.0 and start using the public REST API to interact with the 19 | Repository. Any business logic executed as a result of an action in the Repository, such as document 20 | or folder uploaded, updated, deleted, can be reimplemented as an external out-process extension 21 | utilizing the new Event API. 22 | 23 | ## Build 24 | 25 | Run the following command: 26 | 27 | ```console 28 | mvn clean install 29 | ``` 30 | 31 | You can set versions for API definitions using Maven properties, and exporting them, for example: 32 | ```console 33 | MAVEN_CLI_OPTS="${MAVEN_CLI_OPTS} -Dacs.version=23.4.0" 34 | MAVEN_CLI_OPTS="${MAVEN_CLI_OPTS} -Dags.version=23.4.0.55" 35 | ``` 36 | 37 | In the `generate-sources` phase the script `patch.sh` is executed. This script finds and replaces in the generated code configurations with the correct names and cleans unnecessary files. 38 | 39 | TODO: include alfresco-event-gateway-api generation into the automated script generation once `swagger-codegen` plugin is updated to `3.0.x`. See: https://alfresco.atlassian.net/browse/REPO-5667 40 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/src/main/java/org/alfresco/rest/sdk/feign/config/DelegatedAuthenticationConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.feign.config; 17 | 18 | import org.alfresco.rest.sdk.feign.DelegatedAuthenticationProvider; 19 | import org.alfresco.rest.sdk.feign.DelegatedAuthenticationRequestInterceptor; 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | /** 25 | * Configuration for external delegated authentication mechanism. This must be provided by the integrator of the SDK in the form of a bean that implements the 26 | * interface {@link DelegatedAuthenticationRequestInterceptor}. This authentication method is enabled via the property 27 | * content.service.security.delegated. 28 | */ 29 | @Configuration 30 | @ConditionalOnProperty("content.service.security.delegated") 31 | public class DelegatedAuthenticationConfiguration { 32 | 33 | @Bean 34 | public DelegatedAuthenticationRequestInterceptor delegatedAuthenticationRequestInterceptor(DelegatedAuthenticationProvider 35 | delegatedAuthenticationProvider) { 36 | return new DelegatedAuthenticationRequestInterceptor(delegatedAuthenticationProvider); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/IsFolderFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import org.alfresco.repo.event.v1.model.DataAttributes; 19 | import org.alfresco.repo.event.v1.model.NodeResource; 20 | import org.alfresco.repo.event.v1.model.RepoEvent; 21 | import org.alfresco.repo.event.v1.model.Resource; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | /** 26 | * {@link EventFilter} that checks if an event corresponds to a node of type folder in the repository. 27 | */ 28 | public class IsFolderFilter extends AbstractEventFilter { 29 | 30 | private static final Logger LOGGER = LoggerFactory.getLogger(IsFolderFilter.class); 31 | 32 | private IsFolderFilter() { 33 | } 34 | 35 | /** 36 | * Obtain a {@link IsFolderFilter}. 37 | * 38 | * @return created {@link IsFolderFilter} 39 | */ 40 | public static IsFolderFilter get() { 41 | return new IsFolderFilter(); 42 | } 43 | 44 | @Override 45 | public boolean test(final RepoEvent> event) { 46 | LOGGER.debug("Checking if event {} is a folder event", event); 47 | return isNodeEvent(event) && ((NodeResource) event.getData().getResource()).isFolder(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/enumClass.mustache: -------------------------------------------------------------------------------- 1 | /** 2 | * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} 3 | */ 4 | public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { 5 | {{#gson}} 6 | {{#allowableValues}} 7 | {{#enumVars}} 8 | @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) 9 | {{{name}}}({{{value}}}){{^-last}}, 10 | {{/-last}}{{#-last}};{{/-last}} 11 | {{/enumVars}} 12 | {{/allowableValues}} 13 | {{/gson}} 14 | {{^gson}} 15 | {{#allowableValues}} 16 | {{#enumVars}} 17 | {{{name}}}({{{value}}}){{^-last}}, 18 | {{/-last}}{{#-last}};{{/-last}} 19 | {{/enumVars}} 20 | {{/allowableValues}} 21 | {{/gson}} 22 | 23 | private {{{datatype}}} value; 24 | 25 | {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { 26 | this.value = value; 27 | } 28 | 29 | @Override 30 | @JsonValue 31 | public String toString() { 32 | return String.valueOf(value); 33 | } 34 | 35 | @JsonCreator 36 | public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { 37 | for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { 38 | if (String.valueOf(b.value).equals(text)) { 39 | return b; 40 | } 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/src/test/java/org/alfresco/rest/sdk/feign/DelegatedAuthenticationRequestInterceptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.feign; 17 | 18 | import static org.mockito.Mockito.verify; 19 | 20 | import feign.RequestTemplate; 21 | import org.junit.Before; 22 | import org.junit.Test; 23 | import org.mockito.Mock; 24 | import org.mockito.MockitoAnnotations; 25 | 26 | /** 27 | * Unit tests for {@link DelegatedAuthenticationRequestInterceptor}. 28 | */ 29 | public class DelegatedAuthenticationRequestInterceptorTest { 30 | 31 | @Mock 32 | private DelegatedAuthenticationProvider mockDelegatedAuthenticationProvider; 33 | 34 | private DelegatedAuthenticationRequestInterceptor delegatedAuthenticationRequestInterceptor; 35 | 36 | @Before 37 | public void setup() { 38 | MockitoAnnotations.openMocks(this); 39 | delegatedAuthenticationRequestInterceptor = new DelegatedAuthenticationRequestInterceptor(mockDelegatedAuthenticationProvider); 40 | } 41 | 42 | @Test 43 | public void should_invokeDelegatedAuthenticationProvider_when_interceptorIsApplied() { 44 | RequestTemplate requestTemplate = new RequestTemplate(); 45 | 46 | delegatedAuthenticationRequestInterceptor.apply(requestTemplate); 47 | 48 | verify(mockDelegatedAuthenticationProvider).setAuthentication(requestTemplate); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/FolderDeletedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.filter.EventFilter; 19 | import org.alfresco.event.sdk.handling.filter.IsFolderFilter; 20 | import org.alfresco.event.sdk.handling.handler.OnNodeDeletedEventHandler; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.NodeResource; 23 | import org.alfresco.repo.event.v1.model.RepoEvent; 24 | import org.alfresco.repo.event.v1.model.Resource; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Sample event handler to demonstrate reacting to the deletion of a folder node in the repository. 31 | */ 32 | @Component 33 | public class FolderDeletedHandler implements OnNodeDeletedEventHandler { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(FolderDeletedHandler.class); 36 | 37 | @Override 38 | public void handleEvent(final RepoEvent> repoEvent) { 39 | LOGGER.info("The folder named {} has been deleted!", ((NodeResource) repoEvent.getData().getResource()).getName()); 40 | } 41 | 42 | @Override 43 | public EventFilter getEventFilter() { 44 | return IsFolderFilter.get(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/ContentUpdatedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.filter.ContentChangedFilter; 19 | import org.alfresco.event.sdk.handling.filter.EventFilter; 20 | import org.alfresco.event.sdk.handling.handler.OnNodeUpdatedEventHandler; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.NodeResource; 23 | import org.alfresco.repo.event.v1.model.RepoEvent; 24 | import org.alfresco.repo.event.v1.model.Resource; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Sample event handler to demonstrate reacting to the update of a content in the repository. 31 | */ 32 | @Component 33 | public class ContentUpdatedHandler implements OnNodeUpdatedEventHandler { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(ContentUpdatedHandler.class); 36 | 37 | @Override 38 | public void handleEvent(final RepoEvent> repoEvent) { 39 | LOGGER.info("The content of the node {} has been updated!", ((NodeResource) repoEvent.getData().getResource()).getName()); 40 | } 41 | 42 | @Override 43 | public EventFilter getEventFilter() { 44 | return ContentChangedFilter.get(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/src/main/java/org/alfresco/rest/sdk/feign/config/BasicAuthConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.feign.config; 17 | 18 | import feign.auth.BasicAuthRequestInterceptor; 19 | import org.springframework.beans.factory.annotation.Value; 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | /** 25 | * Configuration for basic authentication. It configures a {@link BasicAuthRequestInterceptor} that uses the credentials configured in the properties 26 | * content.service.security.basicAuth.username and content.service.security.basicAuth.password. 27 | */ 28 | @Configuration 29 | @ConditionalOnProperty("content.service.security.basicAuth.username") 30 | public class BasicAuthConfiguration { 31 | 32 | @Value("${content.service.security.basicAuth.username:#{null}}") 33 | private String basicAuthUsername; 34 | @Value("${content.service.security.basicAuth.password:#{null}}") 35 | private String basicAuthPassword; 36 | 37 | @Bean 38 | @ConditionalOnProperty("content.service.security.basicAuth.username") 39 | public BasicAuthRequestInterceptor basicAuthRequestInterceptor() { 40 | return new BasicAuthRequestInterceptor(this.basicAuthUsername, this.basicAuthPassword); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/HtmlContentCreatedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.filter.EventFilter; 19 | import org.alfresco.event.sdk.handling.filter.MimeTypeFilter; 20 | import org.alfresco.event.sdk.handling.handler.OnNodeCreatedEventHandler; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.NodeResource; 23 | import org.alfresco.repo.event.v1.model.RepoEvent; 24 | import org.alfresco.repo.event.v1.model.Resource; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Sample event handler to demonstrate reacting to the creation of an HTML content in the repository. 31 | */ 32 | @Component 33 | public class HtmlContentCreatedHandler implements OnNodeCreatedEventHandler { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(HtmlContentCreatedHandler.class); 36 | 37 | @Override 38 | public void handleEvent(final RepoEvent> repoEvent) { 39 | LOGGER.info("An HTML content named {} has been created!", ((NodeResource) repoEvent.getData().getResource()).getName()); 40 | } 41 | 42 | @Override 43 | public EventFilter getEventFilter() { 44 | return MimeTypeFilter.of("text/html"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /samples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.5.7 9 | 10 | 11 | 12 | org.alfresco 13 | alfresco-java-sdk-samples 14 | 7.2.1-SNAPSHOT 15 | pom 16 | Alfresco :: Java SDK :: Samples 17 | Sample application of the Java SDK 18 | 19 | 20 | 3.20.0 21 | 22 | 23 | 24 | 25 | alfresco-enterprise-releases 26 | https://artifacts.alfresco.com/nexus/content/repositories/enterprise-releases 27 | 28 | 29 | alfresco-enterprise-snapshots 30 | https://artifacts.alfresco.com/nexus/content/repositories/enterprise-snapshots 31 | 32 | 33 | 34 | 35 | 39 | 40 | org.apache.commons 41 | commons-lang3 42 | ${org.apache.common-lang-3.version} 43 | 44 | 45 | 46 | 47 | extension-template 48 | event-api-handlers 49 | event-api-spring-integration 50 | 51 | 52 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/ContentTypeNodeCreatedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.filter.EventFilter; 19 | import org.alfresco.event.sdk.handling.filter.NodeTypeFilter; 20 | import org.alfresco.event.sdk.handling.handler.OnNodeCreatedEventHandler; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.NodeResource; 23 | import org.alfresco.repo.event.v1.model.RepoEvent; 24 | import org.alfresco.repo.event.v1.model.Resource; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Sample event handler to demonstrate reacting to the creation of a cm:content node in the repository. 31 | */ 32 | @Component 33 | public class ContentTypeNodeCreatedHandler implements OnNodeCreatedEventHandler { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(ContentTypeNodeCreatedHandler.class); 36 | 37 | @Override 38 | public void handleEvent(final RepoEvent> repoEvent) { 39 | LOGGER.info("A new node named {} of type cm:content has been created!", ((NodeResource) repoEvent.getData().getResource()).getName()); 40 | } 41 | 42 | @Override 43 | public EventFilter getEventFilter() { 44 | return NodeTypeFilter.of("cm:content"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /alfresco-java-rest-api-common/src/main/java/org/alfresco/rest/sdk/feign/DelegatedAuthenticationRequestInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.rest.sdk.feign; 17 | 18 | import feign.RequestInterceptor; 19 | import feign.RequestTemplate; 20 | import java.util.Objects; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | /** 25 | * Feign {@link RequestInterceptor} that delegates the authentication in an external class implementing {@link DelegatedAuthenticationProvider}. 26 | */ 27 | public class DelegatedAuthenticationRequestInterceptor implements RequestInterceptor { 28 | 29 | private static final Logger LOGGER = LoggerFactory.getLogger(DelegatedAuthenticationRequestInterceptor.class); 30 | 31 | private final DelegatedAuthenticationProvider delegatedAuthenticationProvider; 32 | 33 | /** 34 | * Constructor. 35 | * 36 | * @param delegatedAuthenticationProvider given {@link DelegatedAuthenticationProvider} 37 | */ 38 | public DelegatedAuthenticationRequestInterceptor(final DelegatedAuthenticationProvider delegatedAuthenticationProvider) { 39 | this.delegatedAuthenticationProvider = Objects.requireNonNull(delegatedAuthenticationProvider); 40 | } 41 | 42 | @Override 43 | public void apply(RequestTemplate requestTemplate) { 44 | LOGGER.debug("Delegating authentication setup to the provider {}", delegatedAuthenticationProvider); 45 | delegatedAuthenticationProvider.setAuthentication(requestTemplate); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/MultipleEventTypeHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.handler.OnNodeCreatedEventHandler; 19 | import org.alfresco.event.sdk.handling.handler.OnNodeUpdatedEventHandler; 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.EventType; 22 | import org.alfresco.repo.event.v1.model.RepoEvent; 23 | import org.alfresco.repo.event.v1.model.Resource; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | import org.springframework.stereotype.Component; 27 | 28 | import java.util.Set; 29 | 30 | /** 31 | * Sample event handler to demonstrate reacting to more than one event type. You only need to provide your own implementation of the method 32 | * getHandledEventTypes. 33 | */ 34 | @Component 35 | public class MultipleEventTypeHandler implements OnNodeCreatedEventHandler, OnNodeUpdatedEventHandler { 36 | 37 | private static final Logger LOGGER = LoggerFactory.getLogger(MultipleEventTypeHandler.class); 38 | 39 | @Override 40 | public void handleEvent(final RepoEvent> event) { 41 | LOGGER.info("Multiple event handler detecting an event of type {}", event.getType()); 42 | } 43 | 44 | @Override public Set getHandledEventTypes() { 45 | return Set.of(EventType.NODE_CREATED, EventType.NODE_UPDATED); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/core/VersionsApiServiceIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.core; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.alfresco.AbstractContentBasedIntegrationTest; 21 | import org.alfresco.core.handler.VersionsApiClient; 22 | import org.alfresco.core.model.VersionEntry; 23 | import org.alfresco.core.model.VersionPaging; 24 | import org.junit.jupiter.api.Test; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.boot.test.context.SpringBootTest; 27 | import org.springframework.http.ResponseEntity; 28 | 29 | /** 30 | * Integration tests for {@link VersionsApiClient}. 31 | */ 32 | @SpringBootTest 33 | public class VersionsApiServiceIntegrationTest extends AbstractContentBasedIntegrationTest { 34 | 35 | @Autowired 36 | private VersionsApiClient versionsApiClient; 37 | 38 | @Test 39 | void should_listVersionsAndGetVersion() { 40 | ResponseEntity listVersionsResponse = versionsApiClient.listVersionHistory(testNode.getId(), null, null, null, null); 41 | ResponseEntity getVersionResponse = versionsApiClient 42 | .getVersion(testNode.getId(), listVersionsResponse.getBody().getList().getEntries().get(0).getEntry().getId()); 43 | 44 | assertThat(listVersionsResponse.getBody().getList().getEntries()).isNotEmpty(); 45 | assertThat(getVersionResponse.getBody().getEntry().getId()).isNotNull(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/core/TrashcanApiServiceIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.core; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.alfresco.AbstractFolderBasedIntegrationTest; 21 | import org.alfresco.core.handler.TrashcanApiClient; 22 | import org.alfresco.core.model.DeletedNodeEntry; 23 | import org.alfresco.core.model.DeletedNodesPaging; 24 | import org.junit.jupiter.api.Test; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.boot.test.context.SpringBootTest; 27 | import org.springframework.http.ResponseEntity; 28 | 29 | /** 30 | * Integration tests for {@link TrashcanApiClient}. 31 | */ 32 | @SpringBootTest 33 | public class TrashcanApiServiceIntegrationTest extends AbstractFolderBasedIntegrationTest { 34 | 35 | @Autowired 36 | private TrashcanApiClient trashcanApiClient; 37 | 38 | @Test 39 | void should_getDeletedNodeAndListDeletedNodes() { 40 | nodesApiClient.deleteNode(testNode.getId(), null); 41 | ResponseEntity getDeletedNodeResponse = trashcanApiClient.getDeletedNode(testNode.getId(), null); 42 | ResponseEntity listDeletedNodesResponse = trashcanApiClient.listDeletedNodes(null, null, null); 43 | 44 | assertThat(getDeletedNodeResponse.getBody().getEntry().getId()).isEqualTo(testNode.getId()); 45 | assertThat(listDeletedNodesResponse.getBody().getList().getEntries()).isNotEmpty(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-spring-boot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.alfresco 7 | alfresco-java-event-api 8 | 7.2.1-SNAPSHOT 9 | 10 | 11 | alfresco-java-event-api-spring-boot 12 | Alfresco Java Event API :: Spring Boot AutoConfiguration 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-autoconfigure 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-configuration-processor 28 | true 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-integration 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-activemq 39 | 40 | 41 | 42 | org.springframework.integration 43 | spring-integration-jms 44 | 45 | 46 | 47 | org.alfresco 48 | alfresco-java-event-api-integration 49 | 50 | 51 | 52 | org.alfresco 53 | alfresco-java-event-api-handling 54 | 55 | 56 | 57 | org.alfresco 58 | acs-event-model 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/NodeAspectFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.Objects; 19 | 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.RepoEvent; 22 | import org.alfresco.repo.event.v1.model.Resource; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * {@link EventFilter} that checks if an event is related to a node with an specific aspect. 28 | */ 29 | public class NodeAspectFilter extends AbstractEventFilter { 30 | 31 | private static final Logger LOGGER = LoggerFactory.getLogger(NodeAspectFilter.class); 32 | 33 | private final String acceptedAspect; 34 | 35 | private NodeAspectFilter(final String acceptedAspect) { 36 | this.acceptedAspect = Objects.requireNonNull(acceptedAspect); 37 | } 38 | 39 | /** 40 | * Create a {@link NodeAspectFilter} for a specific aspect. 41 | * 42 | * @param acceptedAspect given aspect name to be accepted by the filter 43 | * @return created {@link NodeAspectFilter} 44 | */ 45 | public static NodeAspectFilter of(final String acceptedAspect) { 46 | return new NodeAspectFilter(acceptedAspect); 47 | } 48 | 49 | @Override 50 | public boolean test(final RepoEvent> event) { 51 | LOGGER.debug("Checking filter for aspect {} and event {}", acceptedAspect, event); 52 | return isNodeEvent(event) && hasAspectAfter(event, acceptedAspect); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/api_doc.mustache: -------------------------------------------------------------------------------- 1 | # {{classname}}{{#description}} 2 | {{description}}{{/description}} 3 | 4 | All URIs are relative to *{{basePath}}* 5 | 6 | Method | HTTP request | Description 7 | ------------- | ------------- | ------------- 8 | {{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} 9 | {{/operation}}{{/operations}} 10 | 11 | {{#operations}} 12 | {{#operation}} 13 | 14 | # **{{operationId}}** 15 | > {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) 16 | 17 | {{summary}}{{#notes}} 18 | 19 | {{notes}}{{/notes}} 20 | 21 | ### Parameters 22 | {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} 23 | Name | Type | Description | Notes 24 | ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} 25 | {{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} 26 | {{/allParams}} 27 | 28 | ### Return type 29 | 30 | {{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} 31 | 32 | ### Authorization 33 | 34 | {{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} 35 | 36 | ### HTTP request headers 37 | 38 | - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} 39 | - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} 40 | 41 | {{/operation}} 42 | {{/operations}} 43 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/AbstractNodeBasedIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco; 17 | 18 | import org.alfresco.core.handler.NodesApiClient; 19 | import org.alfresco.core.model.Node; 20 | import org.alfresco.core.model.NodeBodyCreate; 21 | import org.alfresco.core.model.NodeEntry; 22 | import org.junit.jupiter.api.BeforeEach; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.http.ResponseEntity; 25 | import util.TestUtils; 26 | 27 | /** 28 | * Test scenario that creates a node before the execution. The node type must be determined by the children classes. The node is not deleted after the test 29 | * because it relies on the deletion of the whole site in {@link AbstractSiteBasedIntegrationTest}. 30 | */ 31 | public abstract class AbstractNodeBasedIntegrationTest extends AbstractSiteBasedIntegrationTest { 32 | 33 | @Autowired 34 | protected NodesApiClient nodesApiClient; 35 | 36 | protected Node testNode; 37 | 38 | @BeforeEach 39 | public void setup() { 40 | super.setup(); 41 | createTestNode(); 42 | } 43 | 44 | private void createTestNode() { 45 | NodeBodyCreate nodeBody = new NodeBodyCreate(); 46 | String nodeName = TestUtils.getRandomNodeName(); 47 | nodeBody.setName(nodeName); 48 | nodeBody.setNodeType(getTestNodeType()); 49 | ResponseEntity createNodeResponse = nodesApiClient.createNode(testSiteDocumentLibraryId, nodeBody, null, null, true, null, null); 50 | testNode = createNodeResponse.getBody().getEntry(); 51 | } 52 | 53 | protected abstract String getTestNodeType(); 54 | } 55 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/EventsHandlersSampleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event; 17 | 18 | import org.alfresco.event.sdk.handling.handler.OnNodeCreatedEventHandler; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.boot.SpringApplication; 22 | import org.springframework.boot.autoconfigure.SpringBootApplication; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.core.annotation.Order; 25 | 26 | @SpringBootApplication 27 | public class EventsHandlersSampleApplication { 28 | 29 | private static final Logger LOGGER = LoggerFactory.getLogger(EventsHandlersSampleApplication.class); 30 | 31 | public static void main(final String[] args) { 32 | SpringApplication.run(EventsHandlersSampleApplication.class, args); 33 | } 34 | 35 | /** 36 | * This event handler definition illustrates how you can use Spring's {@link Order} annotation to sort the execution of event handlers. 37 | */ 38 | @Bean 39 | @Order(10) 40 | public OnNodeCreatedEventHandler firstCustomNodeCreatedEventHandler() { 41 | return repoEvent -> LOGGER.info("First Event handler triggered on node created - Event: {}", repoEvent); 42 | } 43 | 44 | /** 45 | * This event handler definition illustrates how you can use Spring's {@link Order} annotation to sort the execution of event handlers. 46 | */ 47 | @Bean 48 | @Order(20) 49 | public OnNodeCreatedEventHandler secondCustomNodeCreatedEventHandler() { 50 | return repoEvent -> LOGGER.info("Second Event handler triggered on node created - Event: {}", repoEvent); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/NodeTypeFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.Objects; 19 | 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.NodeResource; 22 | import org.alfresco.repo.event.v1.model.RepoEvent; 23 | import org.alfresco.repo.event.v1.model.Resource; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | /** 28 | * {@link EventFilter} that checks if an event is related to a node with an specific type. 29 | */ 30 | public class NodeTypeFilter extends AbstractEventFilter { 31 | 32 | private static final Logger LOGGER = LoggerFactory.getLogger(NodeTypeFilter.class); 33 | 34 | private final String acceptedNodeType; 35 | 36 | private NodeTypeFilter(final String acceptedNodeType) { 37 | this.acceptedNodeType = Objects.requireNonNull(acceptedNodeType); 38 | } 39 | 40 | /** 41 | * Obtain a {@link NodeTypeFilter} for a specific type. 42 | * 43 | * @param acceptedNodeType given type name to be accepted by the filter. 44 | * @return created {@link NodeTypeFilter} 45 | */ 46 | public static NodeTypeFilter of(final String acceptedNodeType) { 47 | return new NodeTypeFilter(acceptedNodeType); 48 | } 49 | 50 | @Override 51 | public boolean test(final RepoEvent> event) { 52 | LOGGER.debug("Checking filter for node type {} and event {}", acceptedNodeType, event); 53 | return isNodeEvent(event) && acceptedNodeType.equals(((NodeResource) event.getData().getResource()).getNodeType()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /samples/event-api-spring-integration/README.md: -------------------------------------------------------------------------------- 1 | # Alfresco Java Event API - Spring Integration Sample Application 2 | 3 | Sample application to demonstrate the pure Spring Integration approach to use the Alfresco Java Event API. 4 | 5 | It is a Spring Boot application that makes use of the [Alfresco Java Event API Spring Boot Starter](../../alfresco-java-event-api/README.md#spring-boot-custom-starter) 6 | to define sample Spring Integration flows that log information about specific handled events. 7 | 8 | ## Usage 9 | 10 | ### Pre-Requisites 11 | 12 | To properly build and run the project in a local environment it is required to have installed some tools. 13 | 14 | * Java 17: 15 | ```bash 16 | $ java -version 17 | 18 | openjdk version "17.0.4" 2022-07-19 LTS 19 | OpenJDK Runtime Environment (build 17.0.4+8-LTS) 20 | OpenJDK 64-Bit Server VM (build 17.0.4+8-LTS, mixed mode, sharing) 21 | 22 | ``` 23 | 24 | * [Maven](https://maven.apache.org/install.html) version 3.3 or higher: 25 | ```bash 26 | $ mvn -version 27 | 28 | Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00) 29 | ``` 30 | 31 | * [Docker](https://docs.docker.com/install/) version 1.12 or higher: 32 | ```bash 33 | $ docker -v 34 | 35 | Docker version 20.10.2, build 2291f61 36 | ``` 37 | 38 | * [Docker compose](https://docs.docker.com/compose/install/): 39 | ```bash 40 | $ docker compose version 41 | 42 | Docker Compose version v2.28.1-desktop.1 43 | ``` 44 | 45 | ### Build and run 46 | 47 | This sample project local development environment is based on Docker, so a ```run.sh/run.bat``` utility script has been included in order to build, run or stop 48 | easily. This script will require execution permissions, so add it if it hasn't. 49 | 50 | ```bash 51 | $ chmod +x run.sh 52 | ``` 53 | 54 | See [```run.sh```](run.sh) or [```run.bat```](run.bat) if you would like to know how each function exactly works. 55 | 56 | #### How To Run 57 | 58 | Build all and run: 59 | 60 | ```bash 61 | $ ./run.sh build_start 62 | ``` 63 | 64 | Only start the environment (without building it): 65 | 66 | ```bash 67 | $ ./run.sh build_start 68 | ``` 69 | 70 | #### How To Stop 71 | 72 | Stop all the containers of the environment: 73 | 74 | ```bash 75 | $ ./run.sh stop 76 | ``` 77 | 78 | #### How To Reload the Sample App 79 | 80 | If you want to rebuild and redeploy *only* the sample app: 81 | 82 | ```bash 83 | $ ./run.sh reload_sample 84 | ``` 85 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/swaggerDocumentationConfig.mustache: -------------------------------------------------------------------------------- 1 | package {{configPackage}}; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.service.Contact; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | {{#useOptional}} 13 | import java.util.Optional; 14 | {{/useOptional}} 15 | 16 | {{>generatedAnnotation}} 17 | @Configuration 18 | public class SwaggerDocumentationConfig { 19 | 20 | ApiInfo apiInfo() { 21 | return new ApiInfoBuilder() 22 | .title("{{appName}}") 23 | .description("{{{appDescription}}}") 24 | .license("{{licenseInfo}}") 25 | .licenseUrl("{{licenseUrl}}") 26 | .termsOfServiceUrl("{{infoUrl}}") 27 | .version("{{appVersion}}") 28 | .contact(new Contact("","", "{{infoEmail}}")) 29 | .build(); 30 | } 31 | 32 | @Bean 33 | public Docket customImplementation(){ 34 | return new Docket(DocumentationType.SWAGGER_2) 35 | .select() 36 | .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) 37 | .build() 38 | {{#java8}} 39 | .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) 40 | .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) 41 | {{/java8}} 42 | {{#joda}} 43 | .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) 44 | .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) 45 | {{/joda}} 46 | {{#threetenbp}} 47 | .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class) 48 | .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class) 49 | {{/threetenbp}} 50 | {{#useOptional}} 51 | .genericModelSubstitutes(Optional.class) 52 | {{/useOptional}} 53 | .apiInfo(apiInfo()); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/AssocTypeFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.Objects; 19 | 20 | import org.alfresco.repo.event.v1.model.AbstractAssociationResource; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.RepoEvent; 23 | import org.alfresco.repo.event.v1.model.Resource; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | /** 28 | * {@link EventFilter} that checks if an event corresponds to a specific association type. This doesn't distinguish if the event is representing peer or child 29 | * associations. 30 | */ 31 | public class AssocTypeFilter extends AbstractEventFilter { 32 | 33 | private static final Logger LOGGER = LoggerFactory.getLogger(AssocTypeFilter.class); 34 | 35 | private final String acceptedAssocType; 36 | 37 | private AssocTypeFilter(final String acceptedAssocType) { 38 | this.acceptedAssocType = Objects.requireNonNull(acceptedAssocType); 39 | } 40 | 41 | /** 42 | * Obtain a {@link AssocTypeFilter} for a specific association type. 43 | * 44 | * @param acceptedAssocType given association type to be filtered 45 | * @return created {@link AssocTypeFilter} 46 | */ 47 | public static AssocTypeFilter of(final String acceptedAssocType) { 48 | return new AssocTypeFilter(acceptedAssocType); 49 | } 50 | 51 | @Override 52 | public boolean test(final RepoEvent> event) { 53 | LOGGER.debug("Checking filter for assoc type {} and event {}", acceptedAssocType, event); 54 | return isAssocEvent(event) && acceptedAssocType.equals(((AbstractAssociationResource) event.getData().getResource()).getAssocType()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/AspectRemovedFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.Objects; 19 | 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.RepoEvent; 22 | import org.alfresco.repo.event.v1.model.Resource; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * {@link EventFilter} that checks if an event represents the removal of an aspect from a node in the repository. 28 | */ 29 | public class AspectRemovedFilter extends AbstractEventFilter { 30 | 31 | private static final Logger LOGGER = LoggerFactory.getLogger(AspectRemovedFilter.class); 32 | 33 | private final String removedAspect; 34 | 35 | private AspectRemovedFilter(final String removedAspect) { 36 | this.removedAspect = Objects.requireNonNull(removedAspect); 37 | } 38 | 39 | /** 40 | * Create a {@link AspectRemovedFilter} for a specific aspect. 41 | * 42 | * @param removedAspect given aspect name to be accepted by the filter 43 | * @return created {@link AspectRemovedFilter} 44 | */ 45 | public static AspectRemovedFilter of(final String removedAspect) { 46 | return new AspectRemovedFilter(removedAspect); 47 | } 48 | 49 | @Override 50 | public boolean test(final RepoEvent> event) { 51 | LOGGER.debug("Checking filter for the removal of the aspect {} and event {}", removedAspect, event); 52 | return isNodeEvent(event) && checkAspectRemoved(event); 53 | } 54 | 55 | private boolean checkAspectRemoved(final RepoEvent> event) { 56 | return hasAspectBefore(event, removedAspect) && !hasAspectAfter(event, removedAspect); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/PropertyAddedFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.Objects; 19 | 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.RepoEvent; 22 | import org.alfresco.repo.event.v1.model.Resource; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * {@link EventFilter} that checks if an event corresponds to the addition of a specific property to a node in the repository. 28 | */ 29 | public class PropertyAddedFilter extends AbstractEventFilter { 30 | 31 | private static final Logger LOGGER = LoggerFactory.getLogger(PropertyAddedFilter.class); 32 | 33 | private final String addedProperty; 34 | 35 | private PropertyAddedFilter(final String addedProperty) { 36 | this.addedProperty = Objects.requireNonNull(addedProperty); 37 | } 38 | 39 | /** 40 | * Obtain a {@link PropertyAddedFilter} for a specific property. 41 | * 42 | * @param addedProperty given property name to be accepted by the filter 43 | * @return created {@link PropertyAddedFilter} 44 | */ 45 | public static PropertyAddedFilter of(final String addedProperty) { 46 | return new PropertyAddedFilter(addedProperty); 47 | } 48 | 49 | @Override 50 | public boolean test(final RepoEvent> event) { 51 | LOGGER.debug("Checking filter for property {} added and event {}", addedProperty, event); 52 | return isNodeEvent(event) && checkPropertyAdded(event); 53 | } 54 | 55 | private boolean checkPropertyAdded(final RepoEvent> event) { 56 | return !hasPropertyBefore(event, addedProperty) && hasPropertyAfter(event, addedProperty); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /samples/event-api-handlers/README.md: -------------------------------------------------------------------------------- 1 | # Alfresco Java Event API - Plain Event Handlers Sample Application 2 | 3 | Sample application to demonstrate the Java plain handlers approach to use the Alfresco Java Event API. 4 | 5 | It is a Spring Boot application that makes use of the [Alfresco Java Event API Spring Boot Starter](../../alfresco-java-event-api/README.md#spring-boot-custom-starter) 6 | to define sample [```EventHandler```](../../alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/EventHandler.java)'s 7 | that log information about the handled events. 8 | 9 | ## Usage 10 | 11 | ### Pre-Requisites 12 | 13 | To properly build and run the project in a local environment it is required to have installed some tools. 14 | 15 | * Java 17: 16 | ```bash 17 | $ java -version 18 | 19 | openjdk version "17.0.4" 2022-07-19 LTS 20 | OpenJDK Runtime Environment (build 17.0.4+8-LTS) 21 | OpenJDK 64-Bit Server VM (build 17.0.4+8-LTS, mixed mode, sharing) 22 | 23 | ``` 24 | 25 | * [Maven](https://maven.apache.org/install.html) version 3.3 or higher: 26 | ```bash 27 | $ mvn -version 28 | 29 | Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00) 30 | ``` 31 | 32 | * [Docker](https://docs.docker.com/install/) version 1.12 or higher: 33 | ```bash 34 | $ docker -v 35 | 36 | Docker version 20.10.2, build 2291f61 37 | ``` 38 | 39 | * [Docker compose](https://docs.docker.com/compose/install/): 40 | ```bash 41 | $ docker compose version 42 | 43 | Docker Compose version v2.28.1-desktop.1 44 | ``` 45 | 46 | ### Build and run 47 | 48 | This sample project local development environment is based on Docker, so a ```run.sh/run.bat``` utility script has been included in order to build, run or stop 49 | easily. This script will require execution permissions, so add it if it hasn't. 50 | 51 | ```bash 52 | $ chmod +x run.sh 53 | ``` 54 | 55 | See [```run.sh```](run.sh) or [```run.bat```](run.bat) if you would like to know how each function exactly works. 56 | 57 | #### How To Run 58 | 59 | Build all and run: 60 | 61 | ```bash 62 | $ ./run.sh build_start 63 | ``` 64 | 65 | Only start the environment (without building it): 66 | 67 | ```bash 68 | $ ./run.sh build_start 69 | ``` 70 | 71 | #### How To Stop 72 | 73 | Stop all the containers of the environment: 74 | 75 | ```bash 76 | $ ./run.sh stop 77 | ``` 78 | 79 | #### How To Reload the Sample App 80 | 81 | If you want to rebuild and redeploy *only* the sample app: 82 | 83 | ```bash 84 | $ ./run.sh reload_sample 85 | ``` 86 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/libraries/spring-cloud/pom.mustache: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | @project.groupId@ 7 | @project.artifactId@ 8 | @project.version@ 9 | ../.. 10 | 11 | {{artifactId}} 12 | {{artifactId}} 13 | @project.version@ 14 | 15 | 16 | io.swagger 17 | swagger-annotations 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-openfeign 22 | 23 | 24 | org.alfresco 25 | alfresco-java-rest-api-common 26 | 27 | {{#withXml}} 28 | 29 | com.fasterxml.jackson.dataformat 30 | jackson-dataformat-xml 31 | 32 | {{/withXml}} 33 | {{#java8}} 34 | 35 | com.fasterxml.jackson.datatype 36 | jackson-datatype-jsr310 37 | 38 | {{/java8}} 39 | {{#joda}} 40 | 41 | com.fasterxml.jackson.datatype 42 | jackson-datatype-joda 43 | 44 | {{/joda}} 45 | {{#threetenbp}} 46 | 47 | com.github.joschi.jackson 48 | jackson-datatype-threetenbp 49 | 2.6.4 50 | 51 | {{/threetenbp}} 52 | {{#useBeanValidation}} 53 | 54 | jakarta.validation 55 | jakarta.validation-api 56 | provided 57 | 58 | {{/useBeanValidation}} 59 | 60 | org.springframework.boot 61 | spring-boot-starter-test 62 | test 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/PropertyRemovedFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.Objects; 19 | 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.RepoEvent; 22 | import org.alfresco.repo.event.v1.model.Resource; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * {@link EventFilter} that checks if an event corresponds to the removal of a specific property to a node in the repository. 28 | */ 29 | public class PropertyRemovedFilter extends AbstractEventFilter { 30 | 31 | private static final Logger LOGGER = LoggerFactory.getLogger(PropertyRemovedFilter.class); 32 | 33 | private final String removedProperty; 34 | 35 | private PropertyRemovedFilter(final String removedProperty) { 36 | this.removedProperty = Objects.requireNonNull(removedProperty); 37 | } 38 | 39 | /** 40 | * Obtain a {@link PropertyRemovedFilter} for a specific property. 41 | * 42 | * @param removedProperty given property name to be accepted by the filter 43 | * @return created {@link PropertyRemovedFilter} 44 | */ 45 | public static PropertyRemovedFilter of(final String removedProperty) { 46 | return new PropertyRemovedFilter(removedProperty); 47 | } 48 | 49 | @Override 50 | public boolean test(final RepoEvent> event) { 51 | LOGGER.debug("Checking filter for property {} removed and event {}", removedProperty, event); 52 | return isNodeEvent(event) && checkPropertyRemoved(event); 53 | } 54 | 55 | private boolean checkPropertyRemoved(final RepoEvent> event) { 56 | return hasPropertyBefore(event, removedProperty) && !hasPropertyAfter(event, removedProperty); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/NodeMovedFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import java.util.List; 19 | 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.NodeResource; 22 | import org.alfresco.repo.event.v1.model.RepoEvent; 23 | import org.alfresco.repo.event.v1.model.Resource; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | /** 28 | * {@link EventFilter} that checks if an event represents the movement of a node in the hierarchy in the repository. 29 | */ 30 | public class NodeMovedFilter extends AbstractEventFilter { 31 | 32 | private static final Logger LOGGER = LoggerFactory.getLogger(NodeMovedFilter.class); 33 | 34 | private NodeMovedFilter() { 35 | } 36 | 37 | /** 38 | * Obtain a {@link NodeMovedFilter}. 39 | * 40 | * @return created {@link NodeMovedFilter} 41 | */ 42 | public static NodeMovedFilter get() { 43 | return new NodeMovedFilter(); 44 | } 45 | 46 | @Override 47 | public boolean test(final RepoEvent> event) { 48 | LOGGER.debug("Checking if event {} reflects a node moved", event); 49 | return isNodeEvent(event) && checkNodeMoved(event); 50 | } 51 | 52 | private boolean checkNodeMoved(final RepoEvent> event) { 53 | return hasResourceBefore(event) && checkPrimaryHierarchy(event); 54 | } 55 | 56 | private boolean checkPrimaryHierarchy(final RepoEvent> event) { 57 | final NodeResource nodeResourceBefore = (NodeResource) event.getData().getResourceBefore(); 58 | final List primaryHierarchy = nodeResourceBefore.getPrimaryHierarchy(); 59 | return primaryHierarchy != null && !primaryHierarchy.isEmpty(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-integration/src/main/java/org/alfresco/event/sdk/integration/transformer/EventGenericTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.integration.transformer; 17 | 18 | import com.fasterxml.jackson.core.JsonProcessingException; 19 | import com.fasterxml.jackson.core.type.TypeReference; 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | import org.alfresco.event.sdk.handling.EventHandlingException; 22 | import org.alfresco.repo.event.databind.ObjectMapperFactory; 23 | import org.alfresco.repo.event.v1.model.DataAttributes; 24 | import org.alfresco.repo.event.v1.model.RepoEvent; 25 | import org.alfresco.repo.event.v1.model.Resource; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import org.springframework.integration.core.GenericTransformer; 30 | 31 | /** 32 | * {@link GenericTransformer} implementation that transforms a repository event in JSON format (following the Repo Event JSON schema) into a {@link RepoEvent} 33 | * object. 34 | */ 35 | public class EventGenericTransformer implements GenericTransformer>> { 36 | 37 | private static final Logger LOGGER = LoggerFactory.getLogger(EventGenericTransformer.class); 38 | 39 | private final ObjectMapper objectMapper = new ObjectMapperFactory().createObjectMapper(); 40 | 41 | @Override 42 | public RepoEvent> transform(final String eventJSON) { 43 | LOGGER.debug("Transforming JSON event {}", eventJSON); 44 | try { 45 | return objectMapper.readValue(eventJSON, new TypeReference<>() { 46 | }); 47 | } catch (final JsonProcessingException excp) { 48 | LOGGER.error("An error occurred transforming the JSON event {}", eventJSON); 49 | throw new EventHandlingException("An error occurred transforming the JSON event", excp); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-integration/src/main/java/org/alfresco/event/sdk/integration/filter/IntegrationEventFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.integration.filter; 17 | 18 | import java.util.Objects; 19 | import org.alfresco.event.sdk.handling.filter.EventFilter; 20 | import org.alfresco.repo.event.v1.model.DataAttributes; 21 | import org.alfresco.repo.event.v1.model.RepoEvent; 22 | import org.alfresco.repo.event.v1.model.Resource; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | import org.springframework.integration.core.MessageSelector; 26 | import org.springframework.messaging.Message; 27 | 28 | /** 29 | * {@link MessageSelector} implementation that is simply a wrapper of a {@link EventFilter}. This way any {@link EventFilter} can be used in a Spring 30 | * Integration context. 31 | */ 32 | public class IntegrationEventFilter implements MessageSelector { 33 | 34 | private static final Logger LOGGER = LoggerFactory.getLogger(IntegrationEventFilter.class); 35 | 36 | private final EventFilter eventFilter; 37 | 38 | private IntegrationEventFilter(final EventFilter eventFilter) { 39 | this.eventFilter = Objects.requireNonNull(eventFilter); 40 | } 41 | 42 | /** 43 | * Obtain a {@link IntegrationEventFilter} that filters following the conditions of a {@link EventFilter}. 44 | * 45 | * @param eventFilter given {@link EventFilter} to be applied 46 | * @return created {@link IntegrationEventFilter} 47 | */ 48 | public static IntegrationEventFilter of(final EventFilter eventFilter) { 49 | return new IntegrationEventFilter(eventFilter); 50 | } 51 | 52 | @Override 53 | public boolean accept(final Message source) { 54 | LOGGER.debug("Checking event filter {} for message {}", eventFilter, source); 55 | return eventFilter.test((RepoEvent>) source.getPayload()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-spring-boot/src/main/java/org/alfresco/event/sdk/autoconfigure/AlfrescoEventsProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.autoconfigure; 17 | 18 | import org.springframework.boot.context.properties.ConfigurationProperties; 19 | 20 | /** 21 | * Define the properties that allow the configuration of the Alfresco Java Events API SDK for Spring Boot. 22 | */ 23 | @ConfigurationProperties(prefix = "alfresco.events") 24 | public class AlfrescoEventsProperties { 25 | 26 | /** 27 | * Name of the topic where the events are published by ACS. This corresponds to be property "repo.event2.topic.endpoint" in ACS. 28 | *

29 | * Default value: alfresco.repo.event2 30 | */ 31 | private String topicName = "alfresco.repo.event2"; 32 | 33 | /** 34 | * Enable the Spring Integration way of handling messages from the events API. 35 | *

36 | * Default value: true 37 | */ 38 | private boolean enableSpringIntegration = true; 39 | 40 | /** 41 | * Enable the plain Java handlers to listen to the events produced by the API. 42 | *

43 | * Default value: true 44 | */ 45 | private boolean enableHandlers = true; 46 | 47 | public String getTopicName() { 48 | return topicName; 49 | } 50 | 51 | public void setTopicName(final String topicName) { 52 | this.topicName = topicName; 53 | } 54 | 55 | public boolean isEnableSpringIntegration() { 56 | return enableSpringIntegration; 57 | } 58 | 59 | public void setEnableSpringIntegration(final boolean enableSpringIntegration) { 60 | this.enableSpringIntegration = enableSpringIntegration; 61 | } 62 | 63 | public boolean isEnableHandlers() { 64 | return enableHandlers; 65 | } 66 | 67 | public void setEnableHandlers(final boolean enableHandlers) { 68 | this.enableHandlers = enableHandlers; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/src/main/resources/templates/apiDelegate.mustache: -------------------------------------------------------------------------------- 1 | package {{package}}; 2 | 3 | {{#imports}}import {{import}}; 4 | {{/imports}} 5 | import io.swagger.annotations.*; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import java.util.List; 10 | {{#async}} 11 | import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; 12 | {{/async}} 13 | 14 | {{#operations}} 15 | /** 16 | * A delegate to be called by the {@link {{classname}}Controller}}. 17 | * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. 18 | */ 19 | {{>generatedAnnotation}} 20 | public interface {{classname}}Delegate { 21 | {{#operation}} 22 | /** 23 | * @see {{classname}}#{{operationId}} 24 | */ 25 | {{#defaultInterfaces}}default {{/defaultInterfaces}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, 26 | {{/hasMore}}{{/allParams}}){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}} { 27 | if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { 28 | {{#examples}} 29 | if (getAcceptHeader().get().contains("{{{contentType}}}")) { 30 | try { 31 | return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; 32 | } catch (IOException e) { 33 | log.error("Couldn't serialize response for content type {{{contentType}}}", e); 34 | return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; 35 | } 36 | } 37 | {{/examples}} 38 | } else { 39 | log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); 40 | } 41 | return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; 42 | }{{/defaultInterfaces}} 43 | 44 | {{/operation}} 45 | } 46 | {{/operations}} 47 | -------------------------------------------------------------------------------- /alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/filter/MimeTypeFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.event.sdk.handling.filter; 17 | 18 | import org.alfresco.repo.event.v1.model.DataAttributes; 19 | import org.alfresco.repo.event.v1.model.NodeResource; 20 | import org.alfresco.repo.event.v1.model.RepoEvent; 21 | import org.alfresco.repo.event.v1.model.Resource; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | import java.util.Arrays; 26 | import java.util.HashSet; 27 | import java.util.Objects; 28 | import java.util.Set; 29 | 30 | /** 31 | * {@link EventFilter} that checks if an events makes reference to a content with a specific mime-type within a set of them. 32 | */ 33 | public class MimeTypeFilter extends AbstractEventFilter { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(MimeTypeFilter.class); 36 | 37 | private final Set acceptedMimeTypes; 38 | 39 | private MimeTypeFilter(final Set acceptedMimeTypes) { 40 | this.acceptedMimeTypes = acceptedMimeTypes; 41 | } 42 | 43 | /** 44 | * Obtain a {@link MimeTypeFilter} for a specific mime-type. 45 | * 46 | * @param acceptedMimeTypes given list of mime-type's that must be accepted by the filter 47 | * @return created {@link MimeTypeFilter} 48 | */ 49 | public static MimeTypeFilter of(final String... acceptedMimeTypes) { 50 | Objects.requireNonNull(acceptedMimeTypes); 51 | return new MimeTypeFilter(new HashSet<>(Arrays.asList(acceptedMimeTypes))); 52 | } 53 | 54 | @Override 55 | public boolean test(final RepoEvent> event) { 56 | LOGGER.debug("Checking filter for MimeTypes {} and event {}", acceptedMimeTypes, event); 57 | return isContentEvent(event) && acceptedMimeTypes.contains(((NodeResource)event.getData().getResource()).getContent().getMimeType()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/TitleModifiedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.filter.EventFilter; 19 | import org.alfresco.event.sdk.handling.filter.PropertyChangedFilter; 20 | import org.alfresco.event.sdk.handling.handler.OnNodeUpdatedEventHandler; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.NodeResource; 23 | import org.alfresco.repo.event.v1.model.RepoEvent; 24 | import org.alfresco.repo.event.v1.model.Resource; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Sample event handler to demonstrate reacting to the update of the title of a node in the repository. 31 | */ 32 | @Component 33 | public class TitleModifiedHandler implements OnNodeUpdatedEventHandler { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(TitleModifiedHandler.class); 36 | private static final String CM_TITLE = "cm:title"; 37 | 38 | @Override 39 | public void handleEvent(final RepoEvent> repoEvent) { 40 | final NodeResource nodeResource = (NodeResource) repoEvent.getData().getResource(); 41 | final NodeResource beforeNodeResource = (NodeResource) repoEvent.getData().getResourceBefore(); 42 | final String name = nodeResource.getName(); 43 | final String previousTitle = (String) beforeNodeResource.getProperties().getOrDefault(CM_TITLE, ""); 44 | final String currentTitle = (String) nodeResource.getProperties().getOrDefault(CM_TITLE, ""); 45 | 46 | LOGGER.info("The title of the node {} has changed from '{}' to '{}'!", name, previousTitle, currentTitle); 47 | } 48 | 49 | @Override 50 | public EventFilter getEventFilter() { 51 | return PropertyChangedFilter.of(CM_TITLE); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/core/QueriesApiServiceIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.core; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | import org.alfresco.AbstractSiteBasedIntegrationTest; 21 | import org.alfresco.core.handler.QueriesApiClient; 22 | import org.alfresco.core.handler.SitesApiClient; 23 | import org.alfresco.core.model.PersonPaging; 24 | import org.alfresco.core.model.SitePaging; 25 | import org.junit.jupiter.api.Test; 26 | import org.springframework.beans.factory.annotation.Autowired; 27 | import org.springframework.boot.test.context.SpringBootTest; 28 | import org.springframework.http.ResponseEntity; 29 | import util.Constants.PersonIds; 30 | import util.Constants.SiteIds; 31 | 32 | /** 33 | * Integration tests for {@link QueriesApiClient}. 34 | */ 35 | @SpringBootTest 36 | public class QueriesApiServiceIntegrationTest extends AbstractSiteBasedIntegrationTest { 37 | 38 | @Autowired 39 | private QueriesApiClient queriesApiClient; 40 | 41 | @Autowired 42 | private SitesApiClient sitesApiClient; 43 | 44 | @Test 45 | void should_findPeople() { 46 | ResponseEntity findPeopleResponse = queriesApiClient.findPeople(PersonIds.EXISTING_TEST_USER, null, null, null, null); 47 | 48 | assertThat(findPeopleResponse.getBody().getList().getEntries()).isNotEmpty(); 49 | assertThat(findPeopleResponse.getBody().getList().getEntries().get(0).getEntry().getId()).isEqualTo(PersonIds.EXISTING_TEST_USER); 50 | } 51 | 52 | @Test 53 | void should_findSites() { 54 | ResponseEntity findSitesResponse = queriesApiClient.findSites(SiteIds.EXISTING_TEST_SITE, null, null, null, null); 55 | 56 | assertThat(findSitesResponse.getBody().getList().getEntries()).isNotEmpty(); 57 | assertThat(findSitesResponse.getBody().getList().getEntries().get(0).getEntry().getId()).isEqualTo(SiteIds.EXISTING_TEST_SITE); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /integration-tests/src/test/java/org/alfresco/AbstractSiteBasedIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco; 17 | 18 | import org.alfresco.core.handler.SitesApiClient; 19 | import org.alfresco.core.model.Site; 20 | import org.alfresco.core.model.SiteBodyCreate; 21 | import org.alfresco.core.model.SiteContainerEntry; 22 | import org.alfresco.core.model.SiteEntry; 23 | import org.junit.jupiter.api.AfterEach; 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.http.ResponseEntity; 27 | import util.TestUtils; 28 | 29 | /** 30 | * Test scenario that creates a site before the execution and deletes it once the test is done. 31 | */ 32 | public abstract class AbstractSiteBasedIntegrationTest { 33 | 34 | @Autowired 35 | protected SitesApiClient sitesApiClient; 36 | 37 | protected Site testSite; 38 | protected String testSiteDocumentLibraryId; 39 | 40 | @BeforeEach 41 | public void setup() { 42 | createTestSite(); 43 | getDocumentLibraryId(); 44 | } 45 | 46 | @AfterEach 47 | public void tearDown() { 48 | deleteTestSite(); 49 | } 50 | 51 | private void createTestSite() { 52 | SiteBodyCreate siteBodyCreate = new SiteBodyCreate(); 53 | siteBodyCreate.setTitle(TestUtils.getRandomSiteName()); 54 | ResponseEntity createSiteResponse = sitesApiClient.createSite(siteBodyCreate, null, null, null); 55 | testSite = createSiteResponse.getBody().getEntry(); 56 | } 57 | 58 | private void getDocumentLibraryId() { 59 | ResponseEntity getSiteContainerResponse = sitesApiClient.getSiteContainer(testSite.getTitle(), "documentLibrary", null); 60 | testSiteDocumentLibraryId = getSiteContainerResponse.getBody().getEntry().getId(); 61 | } 62 | 63 | private void deleteTestSite() { 64 | sitesApiClient.deleteSite(testSite.getId(), true); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | ### STS ### 26 | .apt_generated 27 | .classpath 28 | .factorypath 29 | .project 30 | .settings 31 | .springBeans 32 | .sts4-cache 33 | 34 | ### IntelliJ IDEA ### 35 | target/ 36 | .idea 37 | *.iws 38 | *.iml 39 | *.ipr 40 | 41 | ### NetBeans ### 42 | /nbproject/private/ 43 | /nbbuild/ 44 | /dist/ 45 | /nbdist/ 46 | /.nb-gradle/ 47 | build/ 48 | !**/src/main/**/build/ 49 | !**/src/test/**/build/ 50 | 51 | ### VS Code ### 52 | .vscode/ 53 | 54 | ### mac OS ### 55 | .DS_Store 56 | 57 | ### generated sources (keep just the pom files to avoid build issues) ### 58 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-auth-rest-api/* 59 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-auth-rest-api/pom.xml 60 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-core-rest-api/* 61 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-core-rest-api/pom.xml 62 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-discovery-rest-api/* 63 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-discovery-rest-api/pom.xml 64 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-governance-classification-rest-api/* 65 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-governance-classification-rest-api/pom.xml 66 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-governance-core-rest-api/* 67 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-governance-core-rest-api/pom.xml 68 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-model-rest-api/* 69 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-model-rest-api/pom.xml 70 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-search-rest-api/* 71 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-search-rest-api/pom.xml 72 | alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-search-sql-rest-api/* 73 | !/alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-lib/generated/alfresco-search-sql-rest-api/pom.xml 74 | 75 | *.versionsBackup 76 | -------------------------------------------------------------------------------- /samples/event-api-handlers/src/main/java/org/alfresco/sdk/sample/event/handler/NodeMovedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2021 Alfresco Software, Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.alfresco.sdk.sample.event.handler; 17 | 18 | import org.alfresco.event.sdk.handling.filter.EventFilter; 19 | import org.alfresco.event.sdk.handling.filter.NodeMovedFilter; 20 | import org.alfresco.event.sdk.handling.handler.OnNodeUpdatedEventHandler; 21 | import org.alfresco.repo.event.v1.model.DataAttributes; 22 | import org.alfresco.repo.event.v1.model.NodeResource; 23 | import org.alfresco.repo.event.v1.model.RepoEvent; 24 | import org.alfresco.repo.event.v1.model.Resource; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Sample event handler to demonstrate reacting to the movement of a node in the repository. 31 | */ 32 | @Component 33 | public class NodeMovedHandler implements OnNodeUpdatedEventHandler { 34 | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(NodeMovedHandler.class); 36 | private static final String COMMA = ","; 37 | 38 | @Override 39 | public void handleEvent(final RepoEvent> repoEvent) { 40 | final NodeResource nodeResource = (NodeResource) repoEvent.getData().getResource(); 41 | final NodeResource beforeNodeResource = (NodeResource) repoEvent.getData().getResourceBefore(); 42 | final String name = nodeResource.getName(); 43 | final String currentPrimaryHierarchy = String.join(COMMA, nodeResource.getPrimaryHierarchy()); 44 | final String previousPrimaryHierarchy = String.join(COMMA, beforeNodeResource.getPrimaryHierarchy()); 45 | 46 | LOGGER.info("The node {} has been moved from the hierarchy path [{}] to the new hierarchy path [{}] in the repository!", name, previousPrimaryHierarchy, 47 | currentPrimaryHierarchy); 48 | } 49 | 50 | @Override 51 | public EventFilter getEventFilter() { 52 | return NodeMovedFilter.get(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /samples/extension-template/README.md: -------------------------------------------------------------------------------- 1 | # Alfresco Java SDK - Extension Template 2 | 3 | Sample application to demonstrate both event handling and REST API usage within a sample extension. 4 | 5 | It is a Spring Boot application that makes use of: 6 | * [Alfresco Java Event API Spring Boot Starter](../../alfresco-java-event-api/README.md#spring-boot-custom-starter) 7 | to define a sample [```EventHandler```](../../alfresco-java-event-api/alfresco-java-event-api-handling/src/main/java/org/alfresco/event/sdk/handling/handler/EventHandler.java) 8 | * [Alfresco Java ACS REST API Spring Boot Starter](../../alfresco-acs-java-rest-api/alfresco-acs-java-rest-api-spring-boot-starter) 9 | to consume Alfresco Repository Core API and Alfresco Repository Model API. 10 | 11 | ## Usage 12 | 13 | ### Pre-Requisites 14 | 15 | To properly build and run the project in a local environment it is required to have installed some tools. 16 | 17 | * Java 17: 18 | ```bash 19 | $ java -version 20 | 21 | openjdk version "17.0.4" 2022-07-19 LTS 22 | OpenJDK Runtime Environment (build 17.0.4+8-LTS) 23 | OpenJDK 64-Bit Server VM (build 17.0.4+8-LTS, mixed mode, sharing) 24 | ``` 25 | 26 | * [Maven](https://maven.apache.org/install.html) version 3.3 or higher: 27 | ```bash 28 | $ mvn -version 29 | 30 | Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00) 31 | ``` 32 | 33 | * [Docker](https://docs.docker.com/install/) version 1.12 or higher: 34 | ```bash 35 | $ docker -v 36 | 37 | Docker version 20.10.2, build 2291f61 38 | ``` 39 | 40 | * [Docker compose](https://docs.docker.com/compose/install/): 41 | ```bash 42 | $ docker compose version 43 | 44 | Docker Compose version v2.28.1-desktop.1 45 | ``` 46 | 47 | ### Build and run 48 | 49 | This sample project local development environment is based on Docker, so a ```run.sh/run.bat``` utility script has been included in order to build, run or stop 50 | easily. This script will require execution permissions, so add it if it hasn't. 51 | 52 | ```bash 53 | $ chmod +x run.sh 54 | ``` 55 | 56 | See [```run.sh```](run.sh) or [```run.bat```](run.bat) if you would like to know how each function exactly works. 57 | 58 | #### How To Run 59 | 60 | Build all and run: 61 | 62 | ```bash 63 | $ ./run.sh build_start 64 | ``` 65 | 66 | Only start the environment (without building it): 67 | 68 | ```bash 69 | $ ./run.sh build_start 70 | ``` 71 | 72 | #### How To Stop 73 | 74 | Stop all the containers of the environment: 75 | 76 | ```bash 77 | $ ./run.sh stop 78 | ``` 79 | 80 | #### How To Reload the Sample App 81 | 82 | If you want to rebuild and redeploy *only* the sample app: 83 | 84 | ```bash 85 | $ ./run.sh reload_sample 86 | ``` 87 | --------------------------------------------------------------------------------