diff --git a/pom.xml b/pom.xml index 5fa9a3e..ee9211d 100644 --- a/pom.xml +++ b/pom.xml @@ -43,10 +43,11 @@ 8 lines,vars,source - acs62 + acs7 5.7.2 5.2.14.RELEASE + 3.4.7 @@ -89,6 +90,31 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + add-jaxrs-src + add-source + + + src/main/cxf + + + + + add-test-src + add-test-source + + + src/test/cxf + + + + + maven-surefire-plugin 3.0.0-M5 diff --git a/src/main/cxf/com/inteligr8/alfresco/acs/AcsClientCxfConfiguration.java b/src/main/cxf/com/inteligr8/alfresco/acs/AcsClientCxfConfiguration.java new file mode 100644 index 0000000..0d03eac --- /dev/null +++ b/src/main/cxf/com/inteligr8/alfresco/acs/AcsClientCxfConfiguration.java @@ -0,0 +1,46 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.acs; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import com.inteligr8.rs.ClientCxfConfiguration; + +/** + * This class provides a POJO & Spring-based implementation of the + * ClientCxfConfiguration interface. You can use it outside of the Spring + * context, but you will need the spring-context and spring-beans libraries in + * your non-Spring application. + * + * @author brian@inteligr8.com + */ +@Configuration +@ComponentScan +public class AcsClientCxfConfiguration extends AcsClientConfiguration implements ClientCxfConfiguration { + + @Value("${content.service.cxf.defaultBusEnabled:true}") + private boolean defaultBusEnabled; + + public boolean isDefaultBusEnabled() { + return this.defaultBusEnabled; + } + + public void setDefaultBusEnabled(boolean defaultBusEnabled) { + this.defaultBusEnabled = defaultBusEnabled; + } + +} diff --git a/src/main/cxf/com/inteligr8/alfresco/acs/AcsClientCxfImpl.java b/src/main/cxf/com/inteligr8/alfresco/acs/AcsClientCxfImpl.java new file mode 100644 index 0000000..0f53421 --- /dev/null +++ b/src/main/cxf/com/inteligr8/alfresco/acs/AcsClientCxfImpl.java @@ -0,0 +1,43 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.acs; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import com.inteligr8.rs.ClientCxfImpl; + +/** + * This class provides a POJO & Spring-based implementation of the Apache + * CXF client. You can use it outside of the Spring context, but you will need + * the spring-context and spring-beans libraries in your non-Spring + * application. + * + * @author brian@inteligr8.com + */ +@Component("acs.client.cxf") +@Lazy +public class AcsClientCxfImpl extends ClientCxfImpl { + + /** + * This constructor is for Spring or POJO use + */ + @Autowired + public AcsClientCxfImpl(AcsClientCxfConfiguration config) { + super(config); + } + +} diff --git a/src/main/cxf/com/inteligr8/alfresco/acs/AcsPublicRestApiCxfImpl.java b/src/main/cxf/com/inteligr8/alfresco/acs/AcsPublicRestApiCxfImpl.java new file mode 100644 index 0000000..1e3132c --- /dev/null +++ b/src/main/cxf/com/inteligr8/alfresco/acs/AcsPublicRestApiCxfImpl.java @@ -0,0 +1,39 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.acs; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +/** + * This class provides the Apache CXF client to the JAX-RS API for the ACS + * Public ReST API. + * + * @author brian@inteligr8.com + */ +@Component("acs.api.cxf") +@Lazy +public class AcsPublicRestApiCxfImpl extends AcsPublicRestApiImpl implements AcsPublicRestCxfApi { + + /** + * This constructor is for Spring or POJO use + */ + @Autowired + public AcsPublicRestApiCxfImpl(AcsClientCxfImpl client) { + super(client); + } + +} diff --git a/src/test/cxf/META-INF/services/javax.ws.rs.client.ClientBuilder b/src/test/cxf/META-INF/services/javax.ws.rs.client.ClientBuilder new file mode 100644 index 0000000..018e11f --- /dev/null +++ b/src/test/cxf/META-INF/services/javax.ws.rs.client.ClientBuilder @@ -0,0 +1 @@ +org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl \ No newline at end of file diff --git a/src/test/cxf/com/inteligr8/alfresco/acs/ConnectionCxfClientIT.java b/src/test/cxf/com/inteligr8/alfresco/acs/ConnectionCxfClientIT.java new file mode 100644 index 0000000..4947600 --- /dev/null +++ b/src/test/cxf/com/inteligr8/alfresco/acs/ConnectionCxfClientIT.java @@ -0,0 +1,42 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.acs; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +import com.inteligr8.rs.ClientConfiguration; + +@TestPropertySource(locations = {"/local.properties"}) +@SpringJUnitConfig(classes = {AcsClientCxfConfiguration.class, AcsPublicRestApiCxfImpl.class, AcsClientCxfImpl.class}) +public class ConnectionCxfClientIT extends ConnectionClientIT { + + @Autowired + @Qualifier("acs.api.cxf") + private AcsPublicRestApiImpl api; + + @Override + public AcsPublicRestApi getApi() { + return this.api; + } + + @Override + public ClientConfiguration getConfiguration() { + return this.api.getClient().getConfig(); + } + +} diff --git a/src/test/cxf/com/inteligr8/alfresco/acs/CxfUploadIT.java b/src/test/cxf/com/inteligr8/alfresco/acs/CxfUploadIT.java new file mode 100644 index 0000000..b9f6ffd --- /dev/null +++ b/src/test/cxf/com/inteligr8/alfresco/acs/CxfUploadIT.java @@ -0,0 +1,71 @@ +/* + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +package com.inteligr8.alfresco.acs; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Collections; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIf; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +import com.inteligr8.alfresco.acs.model.Node; +import com.inteligr8.alfresco.acs.model.NodeBodyCreate; +import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartCxf; +import com.inteligr8.rs.ClientConfiguration; + +@TestPropertySource(locations = {"/local.properties"}) +@SpringJUnitConfig(classes = {AcsClientCxfConfiguration.class, AcsPublicRestApiCxfImpl.class, AcsClientCxfImpl.class}) +public class CxfUploadIT extends UploadIT { + + @Autowired + @Qualifier("acs.api.cxf") + private AcsPublicRestApiCxfImpl api; + + @Override + public AcsPublicRestApi getApi() { + return this.api; + } + + @Override + public ClientConfiguration getConfiguration() { + return this.api.getClient().getConfig(); + } + + @Test + @EnabledIf("hostExists") + public void uploadFile() throws IOException { + String folderNodeId = this.getSharedFolder(); + + NodeBodyCreate nodeBody = new NodeBodyCreate().nodeType("trx:transferReport").name("test-name1.txt") + .properties(Collections.singletonMap("cm:author", "Brian")); + + ByteArrayInputStream istream = new ByteArrayInputStream("This is a test".getBytes()); + NodeBodyCreateMultipartCxf body = NodeBodyCreateMultipartCxf.from(nodeBody, "test-name2.txt", istream, true, null, null); + + Node newNode = this.api.getNodesExtApi().createNode(folderNodeId, body).getEntry(); + Assertions.assertNotNull(newNode); + Assertions.assertNotNull(newNode.getId()); + Assertions.assertEquals(folderNodeId, newNode.getParentId()); + Assertions.assertEquals(nodeBody.getNodeType(), newNode.getNodeType()); + Assertions.assertTrue(newNode.getName().startsWith("test-name1")); + } + +}